History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEA-13853
Type: Bug Bug
Status: Open Open
Assignee: Alexey Kudravtsev
Reporter: Jason Winnebeck
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
IDEA: Feedback

Regression: Version control tags break file templates

Created: 24 Jul 07 16:47   Updated: 25 Jul 07 16:26
Component/s: Editor. Code Completion

Environment:
IDEA Win XP
JDK 1.6.0 running IDEA

Build: 7,087
Severity: Medium


 Description  « Hide
While testing the fix for IDEADEV-19267 in the new EAP, I noticed that another part of my template does not expand, and that is the version control keyword (like those used in RCS, CVS, VSS, and SVN) does not expand, because it seems that IDEA is treating it as a variable. Below is the template and generated file:
template
package ${PACKAGE_NAME};
#parse("File Header.java")
public class ${NAME} {
	/** Stores the version of source the class was compiled from. */
	public static final String revision = "$Revision: $";

}
File Header.java
/**
 * ${NAME}
 *
 * @author Jason Winnebeck
 */
test.java
/**
 * test
 *
 * @author Jason Winnebeck
 */
public class test {
	/**
	 * Stores the version of source the class was compiled from.
	 */
	public static final String revision = ": $";
}

As we can see: "$Revision: $" gets translated incorrectly. I tried to "escape" the $ by using double $$ and by using \$, neither of which worked for me.



 All   Comments   Work Log   Change History      Sort Order:
Alexey Kudravtsev - 25 Jul 07 14:43
You should prepend $var with \ (backslash) to avoid expanding Velocity variables. LIke this:

public static final String revision = "\$Revision: $";


Jason Winnebeck - 25 Jul 07 16:26
OK I did \$ and it did work. The reason why I thought I "tried" \$ before is because the syntax highlighting for it does not work. It highlights \ as an "illegal character" and the $Revision part is still bolded and colored as if it was going to be variable-replaced so I assumed that IDEA was still parsing my template as a variable there. I would probably still consider the syntax highlighting issue a usability bug because the user isn't given any indication that the \$ escaping works and the documentation below doesn't mention escaping, so users would probably try different techniques until they saw the coloring change back to a string.

I guess the templating engine changed between IDEA 6 and 7 as our team has used this template for a long time. It would probably be a good idea to document it because others may experience "breaking" changes as well.