ANTLR V4 plugin in intellij provides an option to test the Parser rules in your grammar using the 'Test Rule' option available in the right click window. However this option is greyed out for Lexer rules. How can I test Lexer rules using this plugin ?
If you hold down the Ctrl key and hover over your input in the source view of the preview panel, you can get a pop-up preview of the token under the pointer. You can pull up the Intellij Plugin read.me on github and search for "ctrl key" for an example. You’ll still need to select a parse rule to debug to get this output.
It's useful but a bit tedious to hover over everything to get the full picture.
You may find it more useful to use the grun alias with the -tokens option or the grun <GrammarName> tokens alternative (using tokens instead of a start rule will just run the lexer and dump the tokenStream to sysout). It's not part of the plugin but is generally a very useful way to validate your lexer rules from the command line (even the terminal tab in IntelliJ). You'll need to run the antlr command to generate your source, and compile the java sources to run the grun alias.
(The Quick start on the ANTLR home page shows you how to set up the grun alias.
Related
as mentioned quiet similar in the header, may someone tell me, how can I create an own custom-relative-unit-path for the lazarus IDE (version: 2.0.6) .
The IDE has alreaday some internal $(RelativePaths) but I would like to create my own ones and setting them up in the "other unit paths" and finally use them of course ^^
i wanna do somewhere like: "$(MyCustomPath) = C:\Lazarus(someotherpathhere..)"
and put $(MyCustompath) in the "other unit" line and have it work ^^
Below what I would like to see :-)
Best regards
Shpendicus
enter image description here
I think the way to do this may be to use Lazarus IDE macros.
See https://wiki.freepascal.org/IDE_Macros_in_paths_and_filenames for full documentation.
In the section IDE Macros it says
IDE macros: they can be used in almost all IDE fields, e.g. search paths, custom options, file names, run parameters. They are replaced with their value before calling external tools like the compiler or the debugger. They are case insensitive.
and the IDE macro format section includes a few examples of ones which are already defined.
Creating macros is explained here: https://wiki.freepascal.org/Macros_and_Conditionals
To set a macro up for the current project, do the following:
Go to Project | Project Options | Compiler Options | Additions and Overrides
On the righthand side, click Add and select IDE Macro from the drop-down menu
This will open an IDE Macro line in the editor below. In it, replace
MacroName by MyCustomPath and Value by whatever you like. I used D:\Lazarus2\MA
Close the Project Options pop-up
Next, in the directory that MyCustomPath points to, create a unit e.g. Test.Pas that includes a compile stopper like an ! I used
unit Test
interface
!
implementation
end.
Add Test.Pas to the project's Uses list and attempt to compile. The compiler should complain that it can't find Test.Pas.
Next, open Project | Project Options | Compiler Options | Paths and in the Other unit files box at the top insert $(MyCustomPath)
Close Project Options and compile - now the compilation should proceed until it encounters the compile-stopping ! in Test.Pas
How to run a highlighted code only in IntelliJ IDEA? Sometimes you don't need to run the whole file and wants to just run the some numbers of code. Are there any such choices in IntelliJ IDEA?
It's possible to evaluate arbitrary expressions (Run | Evaluate Expression):
To evaluate a code fragment, click the Code Fragment Mode button and fill in the Code Fragment text box.
You can also use the Scratches feature.
Since version 15 Java scratches are runnable.
I have my Qt Creator 3.1.1 setup to indent with 4 spaces on Tab, but for some reason tab key doesn't work when I edit CMakeLists.txt. This only happens when I open it with CMake Editor, it works when I use Plain Text Editor. Is this a bug or I need to configure it somehow to make Tab key work?
I had exactly the same problem.
This issue occured because I have enabled auto-indent. The value in the "Preferences->Text Editor->Behavior" tab "Typing->Tab key performs auto-indent" was set to something else to "Never".
So to fix this issue you you need to set "Tab key performs auto-indent" to "Never".
Additionally to the answer above, inside 'Options' window and 'Behavior' pane, have a look at 'Tab Policy' section as well as 'Cleanups upon Saving' - and check if it is really what you expect.
For me the settings there were not what I have expected and it was triggering issues, eg. in a Makefile, first command of a task looks like line continuation for Qt Creator so, upon saving, it was "cleaning" (= breaking) the indentation by replacing it with 4 spaces, that was incoherent with overall indentation in the script. Et voilà - error, make didn't work correctly!
As always, it is a very nice tool but one needs to know how to use it...
I've recently switched over to intellij for scala development.
I'm having trouble finding the following shortcut:
In eclipse, I could type a method call e.g.
method("hello", 1)
and press <command>1 to have eclipse popup a suggestion to let me create a method stub.
Is there such a shortcut in intellij?
Use Alt+Enter (Show Intention Actions in Settings | Keymap).
Verified, works fine in IDEA 11.0.1 with the current Scala plug-in:
Activate Type aware highlighting (See the [T] symbol in the image) and
Set Highlighting level to Inspections
Then it is possible to use alt + enter (similar to Ctrl+1 in Eclipse) to show menu, which has create method option.
Why isn't it enabled by default?
The feature is in beta (or maybe in alpha) and sometimes may report "false errors" in regular code. Usually, such "errors" "found" only in a truly complex code, and, normally, everything works just fine.
Scala plugin doesn't rely on compiler to analyze code. We're implementing our own model of the language, and sometimes it's challenging, especially when it comes to Scala's type system and type inference (to size up the problem, you may try to formally "infer" a type of "foo".map(_ + 1) expression by hand).
I'm trying to migrate from Eclipse to IDEA. In Eclipse, when I hit the TAB key while typing in function parameters and in other contextual situations it will forward the cursor to the next place I can type (next parameter, end of the line for semi-colon, etc.). I use it constantly. Is there a way to get similar functionality in IDEA?
There is not direct equivalent to this action. See completion features page for the advanced features.
Regarding the semicolon insertion see Webstorm/Intellij put ";" always at the end of line.
See also Things possible in Eclipse that aren’t possible in IntelliJ?.