Recognizing Velocity user directives
Is it possible to have IDEA 8 recognize Velocity user directives?
Under the default setup, idea doesn't recognize user configured block directives. Since the start of these directives is not recognized as the start of a block, the PSI sees a bunch of extra "#end"s and fills my right gutter with crimson hate.
Does anyone have a suggestion on how to make the IDEA velocity language parser see my user defined directives as block starts?
B
Please sign in to leave a comment.
Hi brett,
Do you mean user defined macros?
Provide please some code examples.
thnx
Although user macros are not recognized either, that doesn't seem to be messing with the PSI.
I am referring here to user defined directives.
In Velocity.properties:
userdirective=com.myco.velocity.BlockSetDirective,com.myco.velocity.CatchDirective,com.myco.velocity.SQLResultSetDirective
velocimacro.library=WEB-INF/VM_global_library.vm,com/myco/app/form/FormMacros.vm,com/myco/component/ComponentLib.vm
It is a minor annoyance that library macros are not recognized (maybe a setup issue?).
However I get lots of errors when using a block userdirective
#if($someBoolean)
## catch is defined as a user directive in velocity.properties
## by the class com.myco.velocity.CatchDirective
#catch($errorVar)
Some dangerous chunk of code
that might throw an exception
#end ## Ideas parser ignores the #catch, and thinks this #end closes the #if block
#end ## and sees this #end as an unmatched block closing and marks gutter in red.
~~~~
I imagine that this support might required some complex modifications to the velocity PSI, so I am really hoping for some kind of work around.
B
brett,
Velocity user directives are not supported at the moment. Unfortunately, I don't see any reasonable work around for unmatched "red" #ends
But we can support user directives in some minor IDEA release, in 8.2.x for example.
Do anyone think this might be salvagable using any of these options:
B
It appears this is still affecting IntelliJ 9.0 (93.13), I don't suppose it is scheduled for a fix?
I tried adding the following lines to no avail....
#* @velocityproperties path="/WEB-INF/velocity.properties" *#
#* @vtlmacrolibrary path="/WEB-INF/velocity.properties" *#
I still miss this feature.
Here's my vote for "Recognizing Velocity user directives" ;-)
+1
+1 from me as well
Hmm ... just need to export those user directives as macros and then all is good - you can then define them in velocity_implicit.vm:
Hi Torben!
I think that your suggestion is only working with a small subset of directives.
Just think: "Why do we need directives and not always use macros always ... ?"
Your suggestion does not work for directives like that:
#ifnotnull($variableToTest)
doSomeThing
#else
doSomeThingElse
#end
Regards
Edy