velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Hall <ioeth.troco...@gmail.com>
Subject Re: Lexical error when using Velocity to generate Java comments
Date Thu, 04 Nov 2010 13:44:12 GMT
Right now we're using Velocity 1.6.4, but the:

#set($h = '#")

...DataObject${h}copyFrom(...

method worked great.  Thanks for the help!

--Matt

On Wed, Nov 3, 2010 at 1:06 PM, Nathan Bubna <nbubna@gmail.com> wrote:

> The #[[ unparsed, but included in output ]]# feature is also in 1.7-beta1.
>
> On Wed, Nov 3, 2010 at 8:52 AM, Claude Brisson <claude@renegat.net> wrote:
> > The upcoming release (2.0) of Velocity will introduce a way to have
> inlined
> > unparsed content:
> >
> >  #[[ ...unparsed content.. ]]#
> >
> > Meanwhile, there are several tricks that do work, like:
> >
> > #set($h = '#")
> >
> > ...DataObject${h}copyFrom(...
> >
> >
> >
> >  Claude
> >
> > On 03/11/2010 16:25, Matthew Hall wrote:
> >>
> >> I'm using Velocity to do some Java code generation, and I recently added
> >> Javadoc comments to the macro so that the generated Java code will be
> >> documented.  I'm having a problem getting Velocity to give me the output
> I
> >> want in my generated code, though.
> >>
> >> Here's an example of a Javadoc comment I added to my Velocity macro:
> >>
> >>    /**
> >>
> >>  * @see
> >>
> >>
> com.intervolve.prometheus.core.dataobj.DataObject#copyFrom(com.intervolve.prometheus.core.dataobj.DataObject)
> >>
> >>  */
> >>
> >> When I run the macro containing this comment, I get the following error:
> >>
> >> org.apache.velocity.exception.ParseErrorException: Lexical error:
> >> org.apache.velocity.runtime.parser.TokenMgrError: Lexical error at line
> >> 170,
> >> column 80.  Encountered: "i" (105), after : "."
> >> at org.apache.velocity.Template.process(Template.java:141)
> >> at
> >>
> >>
> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:446)
> >> at
> >>
> >>
> org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:354)
> >> at
> >>
> >>
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1400)
> >> at
> >>
> >>
> org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1380)
> >> at
> >>
> >>
> org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:401)
> >> at org.apache.velocity.texen.Generator.getTemplate(Generator.java:310)
> >> at org.apache.velocity.texen.Generator.parse(Generator.java:383)
> >> at org.apache.velocity.texen.Generator.parse(Generator.java:353)
> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >> at
> >>
> >>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >> at
> >>
> >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> at java.lang.reflect.Method.invoke(Method.java:597)
> >> at
> >>
> >>
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
> >> at
> >>
> >>
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
> >> at
> >>
> >>
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
> >> at
> >>
> >>
> org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
> >> at
> >>
> >>
> org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:342)
> >> at
> >>
> org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
> >> at
> org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:366)
> >> at
> >>
> >>
> org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
> >> at
> >>
> >>
> org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
> >> at org.apache.velocity.Template.merge(Template.java:328)
> >> at org.apache.velocity.Template.merge(Template.java:235)
> >> at org.apache.velocity.texen.Generator.parse(Generator.java:445)
> >> at org.apache.velocity.texen.ant.TexenTask.execute(TexenTask.java:584)
> >> at
> >>
> >>
> com.intervolve.prometheus.build.ant.OMGenerationTask.execute(OMGenerationTask.java:35)
> >> at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> >> at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
> >> at
> >>
> >>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >> at java.lang.reflect.Method.invoke(Method.java:597)
> >> at
> >>
> >>
> org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
> >> at org.apache.tools.ant.Task.perform(Task.java:348)
> >> at org.apache.tools.ant.Target.execute(Target.java:357)
> >> at org.apache.tools.ant.Target.performTasks(Target.java:385)
> >> at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
> >> at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
> >> at
> >>
> >>
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
> >> at
> >>
> >>
> org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
> >> at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
> >> at
> >>
> >>
> org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423)
> >> at
> >>
> >>
> org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137)
> >>
> >> I believe that this error is happening because Velocity thinks that
> >> "#copyFrom(com." is a directive, so I add the escape character in front
> of
> >> the #, like this:
> >>
> >>    /**
> >>
> >>  * @see
> >>
> >>
> com.intervolve.prometheus.core.dataobj.DataObject\#copyFrom(com.intervolve.prometheus.core.dataobj.DataObject)
> >>
> >>  */
> >>
> >> This resolves the error, and my Velocity macro is now able to run,
> >> however,
> >> the escape character is present in the generated code file as well.
>  This
> >> causes Javadoc to not be able to interpret the @see tag and correctly
> link
> >> to the specified method.  What can I do to resolve this, so that the
> >> escape
> >> character that is preventing the error does not appear in my generated
> >> code
> >> file?  Thanks in advance!
> >>
> >> --Matt
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message