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

9 comments
Comment actions Permalink

Hi brett,

Do you mean user defined macros?
Provide please some code examples.

thnx

0
Comment actions Permalink

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

0
Comment actions Permalink

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.

0
Comment actions Permalink

Do anyone think this might be salvagable using any of these options:

  1. Create a custom plugin to modify velocity language definitions.
  2. Somehow register my user directives as Block start tokens with the velocity PSI (if,foreach,macro,custom1,custom2,...)
  3. Redefine *.vm with my own language definition


B

0
Comment actions Permalink

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" *#

0
Comment actions Permalink

I still miss this feature.

Here's my vote for "Recognizing Velocity user directives" ;-)

+1

1
Comment actions Permalink

+1 from me as well

0
Comment actions Permalink

Hmm ... just need to export those user directives as macros and then all is good - you can then define them in velocity_implicit.vm:

#* @implicitly included *#

#* @vtlmacrolibrary path="com/gwtplatform/processors/tools/macros.vm" *#
#* @vtlmacrolibrary path="com/gwtplatform/dispatch/rest/processors/macros.vm" *#
#* @velocityproperties path=com/gwtplatform/dispatch/rest/processors/velocity.properties *#

#* @vtlvariable name="impl" type="com.gwtplatform.processors.tools.domain.Type" *#
#* @vtlvariable name="processor" type="com.gwtplatform.processors.tools.domain.Type" *#
0
Comment actions Permalink

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

0

Please sign in to leave a comment.