How to format AspectJ *.aj files with eclipse - eclipse

Am I missing something or is it currently not possible to format AspectJ (*.aj) with eclipse built-in formatter?
I'm using eclipse kepler with AJDT-plugin and the formater doesn't do anything with those files. Currently I'm formatting manually.
Thanks in advance

You should be able to use the formatter. There are certain constructs that are not handled well or are just ignored. I can't quite recall, but I believe declare statements are ignored. So, it may be that your file does not contain any formattable code.
Also, check your error log to make sure there are no exceptions being thrown.

Related

gdb command in Eclipse expression view

I'm debugging some code with Eclipse CDT and GDB, and some strings are in UTF-8, so I use x/sh <buffer name> in the debugger console to display them.
Is there a way to put GDB command as expressions in the Expression view? I have a buffer called Work1, so I tried to add x/sh Work1 as an expression, but that didn't work.
When adding an expression, Eclipse uses the -var-create command to create a variable object. After reading the documentation I don't think it's possible to provide a custom format with var-set-format that fits what I need.
So my questions are:
Is there a way to directly use a GDB expression with Eclipse in a more automated way than the Debugging Console?
Is there a way to specify a more flexible display format with var-set-format?
Is any other way I can achieve this, like using the Memory View?
Thank you!

Use IntelijJ as default diff/merge tool in Eclipse

Has anyone maybe used Intelij as the default merge/diff tool in Eclipse?
I don't know what parameters should be used in the highlighted fields below.
EDIT:
See https://www.jetbrains.com/help/idea/2016.2/running-intellij-idea-as-a-diff-or-merge-command-line-tool.html about what kind of command-line parameters IntelliJ expects for the diff/merge: it seems like you have to add a diff argument first and then use the ${file1Path} and other placeholders separated with spaces, without using any comma nor and.

Change text in Eclipse at compile

I want to be able to write for example ((DATE)) in Eclipse and have it replaced with the current date when compiled. How to accomplish this?
The idea is to use dates in version numbers, so I could have the program output stuff like 1.0.2012.01.13
Edit: Language is Java and platform is Android
Can't be done unless you templatize your code using something like Velocity, which is going to be much more trouble than it's worth. Factor these strings out into .properties files and generate those, perhaps.

Xtext: grammar for language with significant/semantic whitespace

How can I use Xtext to parse languages with semantic whitespace? I'm trying to write a grammar for CoffeeScript and I can't find any good documentation on this.
Here's an example whitespace sensitive language in XText
AFAIK, you can't.
In case of parsing Python-like languages, you'd need the lexer to emit INDENT and DEDENT tokens. For that to happen, you'd need semantic predicates to be supported inside lexer rules (Xtext's terminal rules) that would first check if the current-position-in-line of the next character int the input equals 0 (the beginning of the line) and is a ' ' or '\t'.
But browsing through the documentation, I don't see this is supported by Xtext at the moment. Since Xtext 2.0, support has been added for semantic predicates in production rules (see: 6.2.8. Syntactic Predicates), but not in terminal rules.
The only way to do this with Xtext would be to let the lexer produce terminal spaces and line-breaks, but this would make an utter mess of your production rules.
If you want to parse such a language using Java (and a Java oriented parser generator) I'd recommend ANTLR, in which you can emit such INDENT and DEDENT tokens quite easily. But if you're keen on Eclipse integration, then I don't see how you'd be able to do this using Xtext, sorry.
Version 2.8 of Xtext comes with support for Whitespace-Aware Languages. This version ships with the "Home Automation Example" that you can use as a template.
For people interested in CoffeeScript, Adam Schmideg has an Eclipse plugin that uses XText.
For people interested in parsing Python-like DSL's in XText, Ralf Ebert's code for Todotext mentioned above is no longer available from Github but you can find it in the Eclipse test repository. See the original thread about this work and the Eclipse issue that was raised about it.
I have been playing with this code today and my conclusion is it no longer works in the current version of XText. When XText is used in Eclipse, I think it does "partial parsing". This is not compatible with the stateful lexer you need to process indentation sensative languages. So I suspect even if you patch the lexer, the Eclipse editor does not work. In the issue, it looks like Ralf proposed patches to address these issues, but looking into the XText source, these changes seem long gone? If I am wrong and someone can get it to work, I would be very interested?
There is a different implementation here but I cannot get that to work with the current version of XText either.
Instead I have switched to parboiled which does supports indentation based grammars out the box.

How to configure line wrapping for imports in eclipse

The eclipse and checkstyle guys of you will surely now this problem: After organizing imports in eclipse with CTRL-SHIFT-o, each import will be on a separate line, without line-wraps.
If you configured checkstyle to warn if you have lines greater than 80 characters, it will probably warn about your imports. Normally I insert newlines at appropriate positions in
the statement and everything is okay. But the next time someone uses the organize imports function of eclipse every import is on one line again.
The auto-linewrap of the eclipse formatter does not work with imports.
So I wonder if there is another way of telling eclipse to linewrap huge import statements?
Or is there a plugin to do this?
Why not defining an exception for the LineLength Checkstyle rule (with the ignorePattern property) ?
That way, any line beginning with import would not raise that warning.
If that is not possible, you will need to define a custom code formatter (see this SO answer)