summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2007-05-01 20:11:30 (EDT)
committer pelder2007-05-01 20:11:30 (EDT)
commit0207798868de8a3925deeb32cfb42e2257c37100 (patch)
tree89d169d2a9583d771486f2c1b5bfbc5a9eb73780
parente6aa3f0b4400a2f9c9421a29987a7510da6cc565 (diff)
downloadorg.eclipse.jet-0207798868de8a3925deeb32cfb42e2257c37100.zip
org.eclipse.jet-0207798868de8a3925deeb32cfb42e2257c37100.tar.gz
org.eclipse.jet-0207798868de8a3925deeb32cfb42e2257c37100.tar.bz2
[184701] Make _TAGS members package visible. Move Text calculations in line, but avoid String concatenation. Other minor changes to eliminate as many compiler warnings as possible.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/JavaUtil.java39
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/V2CodeGenVisitor.java12
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2TransformGenerator.java23
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v2/JET2JavaGeneratorNew.java278
-rw-r--r--plugins/org.eclipse.jet/templates/jet2transform.jet112
-rw-r--r--plugins/org.eclipse.jet/templates/v2/jet2java.jet65
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet.expected.java43
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.loader.expected.java103
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.nopredefs.expected.java20
-rw-r--r--tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.predefs.expected.java24
10 files changed, 379 insertions, 340 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/JavaUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/JavaUtil.java
index 71d2114..15a7181 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/JavaUtil.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/JavaUtil.java
@@ -15,6 +15,8 @@
*******************************************************************************/
package org.eclipse.jet.internal;
+import java.util.ArrayList;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -140,6 +142,43 @@ public class JavaUtil
* @param text
* @return
*/
+ public static String[] asJavaQuotedStrings(char[] text, String nlConstantName)
+ {
+
+ String rawString = new String(text);
+ Matcher m = Pattern.compile(NL_PATTERN, Pattern.MULTILINE).matcher(rawString);
+ int nextStringStart = 0;
+ boolean nlFound = m.find();
+ if (nlFound)
+ {
+ final List constants = new ArrayList();
+
+ for (; nlFound; nlFound = m.find())
+ {
+ if (m.start() > nextStringStart)
+ {
+ constants.add(asJavaQuotedString(rawString.substring(nextStringStart, m.start()).toCharArray()));
+ }
+ constants.add(nlConstantName != null ? nlConstantName : asJavaQuotedString(m.group().toCharArray()));
+ nextStringStart = m.end();
+ }
+ if (nextStringStart < rawString.length())
+ {
+ constants.add(asJavaQuotedString(rawString.substring(nextStringStart).toCharArray()));
+ }
+ return (String[])constants.toArray(new String [constants.size()]);
+ }
+ else
+ {
+ return new String []{ asJavaQuotedString(text) };
+ }
+ }
+
+ /**
+ * Return a Java String expression with + NL + in place of new line data
+ * @param text
+ * @return
+ */
public static String nlsCommentsForJavaQuoteStringWithNLRemoved(char[] text)
{
String rawString = new String(text);
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/V2CodeGenVisitor.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/V2CodeGenVisitor.java
index f64f5b8..722f546 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/V2CodeGenVisitor.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/V2CodeGenVisitor.java
@@ -12,7 +12,7 @@
*
* </copyright>
*
- * $Id: V2CodeGenVisitor.java,v 1.1 2007/04/04 14:59:32 pelder Exp $
+ * $Id: V2CodeGenVisitor.java,v 1.2 2007/05/02 00:11:29 pelder Exp $
*/
package org.eclipse.jet.internal.compiler;
@@ -113,6 +113,16 @@ public class V2CodeGenVisitor extends SafeJETASTVisitor
return JavaUtil.asJavaQuoteStringWithNLRemoved(text.getText());
}
+ /**
+ * Return the text element as an array of Java text constants.
+ * @param text the text element
+ * @param nlConstantName the name of the constant to use for NL characters
+ * @return an array properly formatted Java quoted strings (including quotes) and NL constants
+ */
+ public String[] textConstants(TextElement text, String nlConstantName) {
+ return JavaUtil.asJavaQuotedStrings(text.getText(), nlConstantName);
+ }
+
public String nlsComment(TextElement text) {
return JavaUtil.nlsCommentsForJavaQuoteStringWithNLRemoved(text.getText());
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2TransformGenerator.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2TransformGenerator.java
index d6829f8..e79ff98 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2TransformGenerator.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2TransformGenerator.java
@@ -3,7 +3,10 @@ package org.eclipse.jet.internal.compiler.templates;
import org.eclipse.jet.JET2Context;
import org.eclipse.jet.JET2Template;
import org.eclipse.jet.JET2Writer;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.jet.internal.compiler.LoaderGenerationParameters;
@@ -18,13 +21,13 @@ public class JET2TransformGenerator implements JET2Template {
private static final class _TEXT {
private static final String TEXT_1 = "package "; //$NON-NLS-1$
private static final String TEXT_2 = ";" + NL + NL + "import java.util.HashMap;" + NL + "import java.util.Map;" + NL + NL + "import org.eclipse.jet.JET2TemplateLoader;" + NL + "import org.eclipse.jet.JET2TemplateLoaderExtension;" + NL + "import org.eclipse.jet.JET2Template;" + NL + NL + "public class "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- private static final String TEXT_3 = " implements JET2TemplateLoader, JET2TemplateLoaderExtension {" + NL + NL + "\tprivate static final class TemplateFactoryMethod {" + NL + NL + "\t\tprivate final String templatePath;" + NL + "\t\tprivate final String templateClass;" + NL + NL + "\t\tpublic TemplateFactoryMethod(String templatePath, String templateClass) {" + NL + "\t\t\tthis.templatePath = templatePath;" + NL + "\t\t\tthis.templateClass = templateClass;" + NL + "\t\t\t" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\tpublic String getTemplateClass() {" + NL + "\t\t\treturn templateClass;" + NL + "\t\t}" + NL + NL + "\t\tpublic String getTemplatePath() {" + NL + "\t\t\treturn templatePath;" + NL + "\t\t}" + NL + NL + "\t\tpublic JET2Template newTemplate() {" + NL + "\t\t\tJET2Template template = null;" + NL + "\t\t\ttry {" + NL + "\t\t\t\ttemplate = (JET2Template) Class.forName(templateClass).newInstance();" + NL + "\t\t\t} catch (InstantiationException e) {" + NL + "\t\t\t} catch (IllegalAccessException e) {" + NL + "\t\t\t} catch (ClassNotFoundException e) {" + NL + "\t\t\t}" + NL + "\t\t\treturn template;" + NL + "\t\t}" + NL + "\t\t" + NL + "\t\t" + NL + "\t}" + NL + NL + "\tprivate Map pathToFactoryMap = null;" + NL + "\t" + NL + "\tprivate JET2TemplateLoader delegate = null;" + NL + NL + "\tpublic "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ //$NON-NLS-28$ //$NON-NLS-29$ //$NON-NLS-30$ //$NON-NLS-31$ //$NON-NLS-32$ //$NON-NLS-33$
- private static final String TEXT_4 = "() {" + NL + "\t\tsuper();" + NL + "\t}" + NL + NL + "\tpublic JET2Template getTemplate(String templatePath) {" + NL + "\t if(pathToFactoryMap == null) {" + NL + " \t initPathToFactoryMap();" + NL + " }" + NL + " TemplateFactoryMethod factory = (TemplateFactoryMethod)pathToFactoryMap.get(templatePath);" + NL + "\t\treturn factory == null ? delegate == null ? null : delegate.getTemplate(templatePath) : factory.newTemplate();" + NL + "\t}" + NL + NL + "\tprivate void addTemplate(String templatePath, String templateClass) {" + NL + "\t\tpathToFactoryMap.put(templatePath, //$NON-NLS-1$" + NL + "\t\t new TemplateFactoryMethod(templatePath, templateClass));" + NL + "\t}" + NL + "\t" + NL + " private void initPathToFactoryMap() {" + NL + "\t pathToFactoryMap = new HashMap("; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$
+ private static final String TEXT_3 = " implements JET2TemplateLoader, JET2TemplateLoaderExtension {" + NL + NL + " private static final class TemplateFactoryMethod {" + NL + NL + " private final String templatePath;" + NL + " private final String templateClass;" + NL + NL + " public TemplateFactoryMethod(String templatePath, String templateClass) {" + NL + " this.templatePath = templatePath;" + NL + " this.templateClass = templateClass;" + NL + " " + NL + " }" + NL + " " + NL + " public String getTemplateClass() {" + NL + " return this.templateClass;" + NL + " }" + NL + NL + " public String getTemplatePath() {" + NL + " return this.templatePath;" + NL + " }" + NL + NL + " public JET2Template newTemplate() {" + NL + " JET2Template template = null;" + NL + " try {" + NL + " template = (JET2Template) Class.forName(this.templateClass).newInstance();" + NL + " } catch (InstantiationException e) {" + NL + " // ignore" + NL + " } catch (IllegalAccessException e) {" + NL + " // ignore" + NL + " } catch (ClassNotFoundException e) {" + NL + " // ignore" + NL + " }" + NL + " return template;" + NL + " }" + NL + " " + NL + " " + NL + " }" + NL + NL + " private Map pathToFactoryMap = null;" + NL + " " + NL + " private JET2TemplateLoader delegate = null;" + NL + NL + " public "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$ //$NON-NLS-25$ //$NON-NLS-26$ //$NON-NLS-27$ //$NON-NLS-28$ //$NON-NLS-29$ //$NON-NLS-30$ //$NON-NLS-31$ //$NON-NLS-32$ //$NON-NLS-33$ //$NON-NLS-34$ //$NON-NLS-35$ //$NON-NLS-36$
+ private static final String TEXT_4 = "() {" + NL + " super();" + NL + " }" + NL + NL + " public JET2Template getTemplate(String templatePath) {" + NL + " if(this.pathToFactoryMap == null) {" + NL + " initPathToFactoryMap();" + NL + " }" + NL + " TemplateFactoryMethod factory = (TemplateFactoryMethod)this.pathToFactoryMap.get(templatePath);" + NL + " return factory == null ? this.delegate == null ? null : this.delegate.getTemplate(templatePath) : factory.newTemplate();" + NL + " }" + NL + NL + " private void addTemplate(String templatePath, String templateClass) {" + NL + " this.pathToFactoryMap.put(templatePath," + NL + " new TemplateFactoryMethod(templatePath, templateClass));" + NL + " }" + NL + " " + NL + " private void initPathToFactoryMap() {" + NL + " this.pathToFactoryMap = new HashMap("; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$
private static final String TEXT_5 = ");" + NL; //$NON-NLS-1$
- private static final String TEXT_6 = "\t\t addTemplate(\""; //$NON-NLS-1$
+ private static final String TEXT_6 = " addTemplate(\""; //$NON-NLS-1$
private static final String TEXT_7 = "\", \""; //$NON-NLS-1$
private static final String TEXT_8 = "\" ); //$NON-NLS-1$ //$NON-NLS-2$" + NL; //$NON-NLS-1$
- private static final String TEXT_9 = "\t}" + NL + NL + " public void setDelegateLoader(JET2TemplateLoader loader) {" + NL + " this.delegate = loader;" + NL + " }" + NL + " " + NL + " public JET2TemplateLoader getDelegateLoader() {" + NL + " return delegate;" + NL + " }" + NL + "}" + NL + NL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ private static final String TEXT_9 = " }" + NL + NL + " public void setDelegateLoader(JET2TemplateLoader loader) {" + NL + " this.delegate = loader;" + NL + " }" + NL + " " + NL + " public JET2TemplateLoader getDelegateLoader() {" + NL + " return this.delegate;" + NL + " }" + NL + "}" + NL + NL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
}
@@ -42,13 +45,17 @@ Map templateMap = (Map) parms.getTemplateMap();;
out.write(_TEXT.TEXT_4);
out.write( templateMap.size() );
out.write(_TEXT.TEXT_5);
- for(Iterator i = templateMap.entrySet().iterator(); i.hasNext();){
- Map.Entry entry = (Map.Entry)i.next();
+
+ List templatePaths = new ArrayList(templateMap.keySet());
+ Collections.sort(templatePaths);
+ for(Iterator i = templatePaths.iterator(); i.hasNext();){
+ String key = (String)i.next();
+ String value = (String)templateMap.get(key);
out.write(_TEXT.TEXT_6);
- out.write( entry.getKey() );
+ out.write( key );
out.write(_TEXT.TEXT_7);
- out.write( entry.getValue() );
+ out.write( value );
out.write(_TEXT.TEXT_8);
}
out.write(_TEXT.TEXT_9);
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v2/JET2JavaGeneratorNew.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v2/JET2JavaGeneratorNew.java
index 648d75f..717897d 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v2/JET2JavaGeneratorNew.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v2/JET2JavaGeneratorNew.java
@@ -30,79 +30,78 @@ public class JET2JavaGeneratorNew implements JET2Template {
private static final String TEXT_9 = " = \""; //$NON-NLS-1$
private static final String TEXT_10 = "\"; //$NON-NLS-1$" + NL; //$NON-NLS-1$
private static final String TEXT_11 = NL;
- private static final String TEXT_12 = "\t"; //$NON-NLS-1$
+ private static final String TEXT_12 = " "; //$NON-NLS-1$
private static final String TEXT_13 = NL;
- private static final String TEXT_14 = "\tpublic "; //$NON-NLS-1$
- private static final String TEXT_15 = "() {" + NL + "\t\tsuper();" + NL + "\t}" + NL + NL + " private static final String NL = System.getProperties().getProperty(\"line.separator\");" + NL + " " + NL + " private static final class _TEXT {" + NL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- private static final String TEXT_16 = " private static final String "; //$NON-NLS-1$
- private static final String TEXT_17 = " = "; //$NON-NLS-1$
- private static final String TEXT_18 = ";"; //$NON-NLS-1$
- private static final String TEXT_19 = NL;
- private static final String TEXT_20 = " }" + NL + NL; //$NON-NLS-1$
- private static final String TEXT_21 = " private static final class _TAGS {" + NL; //$NON-NLS-1$
- private static final String TEXT_22 = " private static final TagInfo "; //$NON-NLS-1$
- private static final String TEXT_23 = " = new TagInfo(\""; //$NON-NLS-1$
- private static final String TEXT_24 = "\", //$NON-NLS-1$" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_25 = ", "; //$NON-NLS-1$
- private static final String TEXT_26 = "," + NL + " new String[] {" + NL; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_27 = " \""; //$NON-NLS-1$
- private static final String TEXT_28 = "\", //$NON-NLS-1$" + NL; //$NON-NLS-1$
- private static final String TEXT_29 = " }," + NL + " new String[] {" + NL; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_30 = " \""; //$NON-NLS-1$
- private static final String TEXT_31 = "\", //$NON-NLS-1$" + NL; //$NON-NLS-1$
- private static final String TEXT_32 = " } );" + NL; //$NON-NLS-1$
- private static final String TEXT_33 = " }" + NL; //$NON-NLS-1$
- private static final String TEXT_34 = NL + "\tpublic void generate(final JET2Context context, JET2Writer out) {" + NL; //$NON-NLS-1$
- private static final String TEXT_35 = " out.write(_TEXT."; //$NON-NLS-1$
- private static final String TEXT_36 = ");" + NL; //$NON-NLS-1$
- private static final String TEXT_37 = " "; //$NON-NLS-1$
- private static final String TEXT_38 = NL;
- private static final String TEXT_39 = " out.write("; //$NON-NLS-1$
- private static final String TEXT_40 = ");" + NL; //$NON-NLS-1$
- private static final String TEXT_41 = " RuntimeTagElement "; //$NON-NLS-1$
- private static final String TEXT_42 = " = context.getTagFactory().createRuntimeTag(_jetns_"; //$NON-NLS-1$
- private static final String TEXT_43 = ", \""; //$NON-NLS-1$
- private static final String TEXT_44 = "\", \""; //$NON-NLS-1$
- private static final String TEXT_45 = "\", _TAGS."; //$NON-NLS-1$
- private static final String TEXT_46 = "); //$NON-NLS-1$ //$NON-NLS-2$" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_47 = ".setRuntimeParent("; //$NON-NLS-1$
+ private static final String TEXT_14 = " public "; //$NON-NLS-1$
+ private static final String TEXT_15 = "() {" + NL + " super();" + NL + " }" + NL + NL + " private static final String "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String TEXT_16 = " = System.getProperties().getProperty(\"line.separator\"); //$NON-NLS-1$" + NL; //$NON-NLS-1$
+ private static final String TEXT_17 = " " + NL + " private static final class _TAGS {" + NL; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_18 = " static final TagInfo "; //$NON-NLS-1$
+ private static final String TEXT_19 = " = new TagInfo(\""; //$NON-NLS-1$
+ private static final String TEXT_20 = "\", //$NON-NLS-1$" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_21 = ", "; //$NON-NLS-1$
+ private static final String TEXT_22 = "," + NL + " new String[] {" + NL; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_23 = " \""; //$NON-NLS-1$
+ private static final String TEXT_24 = "\", //$NON-NLS-1$" + NL; //$NON-NLS-1$
+ private static final String TEXT_25 = " }," + NL + " new String[] {" + NL; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_26 = " \""; //$NON-NLS-1$
+ private static final String TEXT_27 = "\", //$NON-NLS-1$" + NL; //$NON-NLS-1$
+ private static final String TEXT_28 = " } );" + NL; //$NON-NLS-1$
+ private static final String TEXT_29 = " }" + NL; //$NON-NLS-1$
+ private static final String TEXT_30 = NL + " public void generate(final JET2Context context, final JET2Writer __out) {" + NL + " JET2Writer out = __out;" + NL; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_31 = " out.write("; //$NON-NLS-1$
+ private static final String TEXT_32 = "); "; //$NON-NLS-1$
+ private static final String TEXT_33 = " //$NON-NLS-1$"; //$NON-NLS-1$
+ private static final String TEXT_34 = " " + NL; //$NON-NLS-1$
+ private static final String TEXT_35 = " "; //$NON-NLS-1$
+ private static final String TEXT_36 = NL;
+ private static final String TEXT_37 = " out.write("; //$NON-NLS-1$
+ private static final String TEXT_38 = ");" + NL; //$NON-NLS-1$
+ private static final String TEXT_39 = " RuntimeTagElement "; //$NON-NLS-1$
+ private static final String TEXT_40 = " = context.getTagFactory().createRuntimeTag(_jetns_"; //$NON-NLS-1$
+ private static final String TEXT_41 = ", \""; //$NON-NLS-1$
+ private static final String TEXT_42 = "\", \""; //$NON-NLS-1$
+ private static final String TEXT_43 = "\", _TAGS."; //$NON-NLS-1$
+ private static final String TEXT_44 = "); //$NON-NLS-1$ //$NON-NLS-2$" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_45 = ".setRuntimeParent("; //$NON-NLS-1$
+ private static final String TEXT_46 = ");" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_47 = ".setTagInfo(_TAGS."; //$NON-NLS-1$
private static final String TEXT_48 = ");" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_49 = ".setTagInfo(_TAGS."; //$NON-NLS-1$
- private static final String TEXT_50 = ");" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_51 = ".doStart(context, out);" + NL; //$NON-NLS-1$
- private static final String TEXT_52 = " JET2Writer "; //$NON-NLS-1$
- private static final String TEXT_53 = "_saved_out = out;" + NL; //$NON-NLS-1$
- private static final String TEXT_54 = " while ("; //$NON-NLS-1$
- private static final String TEXT_55 = ".okToProcessBody()) {" + NL; //$NON-NLS-1$
- private static final String TEXT_56 = " out = out.newNestedContentWriter();" + NL; //$NON-NLS-1$
- private static final String TEXT_57 = " "; //$NON-NLS-1$
- private static final String TEXT_58 = ".handleBodyContent(out);" + NL + " }" + NL; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_59 = " out = "; //$NON-NLS-1$
- private static final String TEXT_60 = "_saved_out;" + NL; //$NON-NLS-1$
- private static final String TEXT_61 = " "; //$NON-NLS-1$
- private static final String TEXT_62 = ".doEnd();" + NL; //$NON-NLS-1$
- private static final String TEXT_63 = " RuntimeTagElement "; //$NON-NLS-1$
- private static final String TEXT_64 = " = context.getTagFactory().createRuntimeTag(_jetns_"; //$NON-NLS-1$
- private static final String TEXT_65 = ", \""; //$NON-NLS-1$
- private static final String TEXT_66 = "\", \""; //$NON-NLS-1$
- private static final String TEXT_67 = "\", _TAGS."; //$NON-NLS-1$
- private static final String TEXT_68 = "); //$NON-NLS-1$ //$NON-NLS-2$" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_69 = ".setRuntimeParent("; //$NON-NLS-1$
+ private static final String TEXT_49 = ".doStart(context, out);" + NL; //$NON-NLS-1$
+ private static final String TEXT_50 = " JET2Writer "; //$NON-NLS-1$
+ private static final String TEXT_51 = "_saved_out = out;" + NL; //$NON-NLS-1$
+ private static final String TEXT_52 = " while ("; //$NON-NLS-1$
+ private static final String TEXT_53 = ".okToProcessBody()) {" + NL; //$NON-NLS-1$
+ private static final String TEXT_54 = " out = out.newNestedContentWriter();" + NL; //$NON-NLS-1$
+ private static final String TEXT_55 = " "; //$NON-NLS-1$
+ private static final String TEXT_56 = ".handleBodyContent(out);" + NL + " }" + NL; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_57 = " out = "; //$NON-NLS-1$
+ private static final String TEXT_58 = "_saved_out;" + NL; //$NON-NLS-1$
+ private static final String TEXT_59 = " "; //$NON-NLS-1$
+ private static final String TEXT_60 = ".doEnd();" + NL; //$NON-NLS-1$
+ private static final String TEXT_61 = " RuntimeTagElement "; //$NON-NLS-1$
+ private static final String TEXT_62 = " = context.getTagFactory().createRuntimeTag(_jetns_"; //$NON-NLS-1$
+ private static final String TEXT_63 = ", \""; //$NON-NLS-1$
+ private static final String TEXT_64 = "\", \""; //$NON-NLS-1$
+ private static final String TEXT_65 = "\", _TAGS."; //$NON-NLS-1$
+ private static final String TEXT_66 = "); //$NON-NLS-1$ //$NON-NLS-2$" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_67 = ".setRuntimeParent("; //$NON-NLS-1$
+ private static final String TEXT_68 = ");" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_69 = ".setTagInfo(_TAGS."; //$NON-NLS-1$
private static final String TEXT_70 = ");" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_71 = ".setTagInfo(_TAGS."; //$NON-NLS-1$
- private static final String TEXT_72 = ");" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_73 = ".doStart(context, out);" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_74 = ".doEnd();" + NL; //$NON-NLS-1$
- private static final String TEXT_75 = " }" + NL + "}" + NL; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_71 = ".doStart(context, out);" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ private static final String TEXT_72 = ".doEnd();" + NL; //$NON-NLS-1$
+ private static final String TEXT_73 = " }" + NL + "}" + NL; //$NON-NLS-1$ //$NON-NLS-2$
}
public void generate(final JET2Context context, JET2Writer out) {
- JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
- TagUsageVisitor tuv = new TagUsageVisitor();
- cu.accept(tuv);
- TagLibraryReference[] tlrefs = tuv.getUsedTagLibraryReferences(cu);
+ JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
+ TagUsageVisitor tuv = new TagUsageVisitor();
+ cu.accept(tuv);
+ TagLibraryReference[] tlrefs = tuv.getUsedTagLibraryReferences(cu);
+ final String nlConstantName = "NL"; //$NON-NLS-1$
out.write(_TEXT.TEXT_1);
out.write( cu.getOutputJavaPackage() );
@@ -133,34 +132,17 @@ public class JET2JavaGeneratorNew implements JET2Template {
out.write( decl.getJavaContent() );
out.write(_TEXT.TEXT_13);
- return true;
+ return true;
}
});
out.write(_TEXT.TEXT_14);
out.write( cu.getOutputJavaClassName() );
out.write(_TEXT.TEXT_15);
- cu.accept(new V2CodeGenVisitor(context,out) {
- private int textCount = 0;
- public boolean visit(TextElement text) {
- if(text.getText().length > 0) {
-
+ out.write(nlConstantName);
out.write(_TEXT.TEXT_16);
- out.write( textVar(++textCount) );
- out.write(_TEXT.TEXT_17);
- out.write(textExpr(text));
- out.write(_TEXT.TEXT_18);
- out.write(nlsComment(text));
- out.write(_TEXT.TEXT_19);
-
- }
- return true;
- }
- });
-
- out.write(_TEXT.TEXT_20);
if(tuv.hasTags()) {
- out.write(_TEXT.TEXT_21);
+ out.write(_TEXT.TEXT_17);
cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
public boolean visit(XMLBodyElement e) {
doElementVisit(e);
@@ -172,146 +154,152 @@ public class JET2JavaGeneratorNew implements JET2Template {
}
public void doElementVisit(XMLElement e) {
- out.write(_TEXT.TEXT_22);
+ out.write(_TEXT.TEXT_18);
out.write( tagInfoVar(e) );
- out.write(_TEXT.TEXT_23);
+ out.write(_TEXT.TEXT_19);
out.write(e.getName());
- out.write(_TEXT.TEXT_24);
+ out.write(_TEXT.TEXT_20);
out.write( e.getLine() );
- out.write(_TEXT.TEXT_25);
+ out.write(_TEXT.TEXT_21);
out.write( e.getColumn() );
- out.write(_TEXT.TEXT_26);
- for (Iterator i = e.getAttributes().keySet().iterator(); i.hasNext();) {
- out.write(_TEXT.TEXT_27);
+ out.write(_TEXT.TEXT_22);
+ for (Iterator i = e.getAttributes().keySet().iterator(); i.hasNext();) {
+ out.write(_TEXT.TEXT_23);
out.write( (String) i.next() );
- out.write(_TEXT.TEXT_28);
+ out.write(_TEXT.TEXT_24);
}
- out.write(_TEXT.TEXT_29);
- for (Iterator i = e.getAttributes().values().iterator(); i.hasNext();) {
+ out.write(_TEXT.TEXT_25);
+ for (Iterator i = e.getAttributes().values().iterator(); i.hasNext();) {
String attrValue = (String) i.next();
- out.write(_TEXT.TEXT_30);
+ out.write(_TEXT.TEXT_26);
out.write( JavaUtil.escapeJavaString(attrValue.toCharArray()) );
- out.write(_TEXT.TEXT_31);
+ out.write(_TEXT.TEXT_27);
}
- out.write(_TEXT.TEXT_32);
+ out.write(_TEXT.TEXT_28);
}
});
- out.write(_TEXT.TEXT_33);
+ out.write(_TEXT.TEXT_29);
}
- out.write(_TEXT.TEXT_34);
+ out.write(_TEXT.TEXT_30);
cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
- private int textCount = 0;
- public boolean visit(TextElement text) {
- if(text.getText().length > 0) {
+ public boolean visit(TextElement text) {
+ if(text.getText().length > 0) {
+ String[] strings = textConstants(text, nlConstantName);
+ for(int i = 0; i < strings.length; i++) {
- out.write(_TEXT.TEXT_35);
- out.write(textVar(++textCount));
- out.write(_TEXT.TEXT_36);
+ out.write(_TEXT.TEXT_31);
+ out.write(strings[i]);
+ out.write(_TEXT.TEXT_32);
+ if(strings[i].startsWith("\"")) { //$NON-NLS-1$
+ out.write(_TEXT.TEXT_33);
+ }
+ out.write(_TEXT.TEXT_34);
- }
- return true;
+ }
+ }
+ return true;
}
public boolean visit(JavaScriptlet scriptlet) {
- out.write(_TEXT.TEXT_37);
+ out.write(_TEXT.TEXT_35);
out.write( scriptlet.getJavaContent() );
- out.write(_TEXT.TEXT_38);
+ out.write(_TEXT.TEXT_36);
- return true;
+ return true;
}
public boolean visit(JavaExpression expr) {
- out.write(_TEXT.TEXT_39);
+ out.write(_TEXT.TEXT_37);
out.write( expr.getJavaContent() );
- out.write(_TEXT.TEXT_40);
+ out.write(_TEXT.TEXT_38);
- return true;
+ return true;
}
public boolean visit(XMLBodyElement e) {
- out.write(_TEXT.TEXT_41);
+ out.write(_TEXT.TEXT_39);
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_42);
+ out.write(_TEXT.TEXT_40);
out.write( e.getNSPrefix() );
- out.write(_TEXT.TEXT_43);
+ out.write(_TEXT.TEXT_41);
out.write( e.getTagNCName() );
- out.write(_TEXT.TEXT_44);
+ out.write(_TEXT.TEXT_42);
out.write( e.getName() );
- out.write(_TEXT.TEXT_45);
+ out.write(_TEXT.TEXT_43);
out.write( tagInfoVar(e) );
+ out.write(_TEXT.TEXT_44);
+ out.write( tagVar(e) );
+ out.write(_TEXT.TEXT_45);
+ out.write( parentTagVar(e) );
out.write(_TEXT.TEXT_46);
out.write( tagVar(e) );
out.write(_TEXT.TEXT_47);
- out.write( parentTagVar(e) );
+ out.write( tagInfoVar(e) );
out.write(_TEXT.TEXT_48);
out.write( tagVar(e) );
out.write(_TEXT.TEXT_49);
- out.write( tagInfoVar(e) );
+ if(requiresOwnWriter(e)) {
out.write(_TEXT.TEXT_50);
out.write( tagVar(e) );
out.write(_TEXT.TEXT_51);
- if(requiresOwnWriter(e)) {
+ }
out.write(_TEXT.TEXT_52);
out.write( tagVar(e) );
out.write(_TEXT.TEXT_53);
- }
- out.write(_TEXT.TEXT_54);
- out.write( tagVar(e) );
- out.write(_TEXT.TEXT_55);
if(requiresOwnWriter(e)) {
- out.write(_TEXT.TEXT_56);
+ out.write(_TEXT.TEXT_54);
}
- in();
+ in();
return true;
}
public void endVisit(XMLBodyElement e) {
out();
+ out.write(_TEXT.TEXT_55);
+ out.write( tagVar(e) );
+ out.write(_TEXT.TEXT_56);
+ if(requiresOwnWriter(e)) {
out.write(_TEXT.TEXT_57);
out.write( tagVar(e) );
out.write(_TEXT.TEXT_58);
- if(requiresOwnWriter(e)) {
+ }
out.write(_TEXT.TEXT_59);
out.write( tagVar(e) );
out.write(_TEXT.TEXT_60);
- }
- out.write(_TEXT.TEXT_61);
- out.write( tagVar(e) );
- out.write(_TEXT.TEXT_62);
}
public boolean visit(XMLEmptyElement e) {
- out.write(_TEXT.TEXT_63);
+ out.write(_TEXT.TEXT_61);
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_64);
+ out.write(_TEXT.TEXT_62);
out.write( e.getNSPrefix() );
- out.write(_TEXT.TEXT_65);
+ out.write(_TEXT.TEXT_63);
out.write( e.getTagNCName() );
- out.write(_TEXT.TEXT_66);
+ out.write(_TEXT.TEXT_64);
out.write( e.getName() );
- out.write(_TEXT.TEXT_67);
+ out.write(_TEXT.TEXT_65);
out.write( tagInfoVar(e) );
+ out.write(_TEXT.TEXT_66);
+ out.write( tagVar(e) );
+ out.write(_TEXT.TEXT_67);
+ out.write( parentTagVar(e) );
out.write(_TEXT.TEXT_68);
out.write( tagVar(e) );
out.write(_TEXT.TEXT_69);
- out.write( parentTagVar(e) );
+ out.write( tagInfoVar(e) );
out.write(_TEXT.TEXT_70);
out.write( tagVar(e) );
out.write(_TEXT.TEXT_71);
- out.write( tagInfoVar(e) );
- out.write(_TEXT.TEXT_72);
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_73);
- out.write( tagVar(e) );
- out.write(_TEXT.TEXT_74);
+ out.write(_TEXT.TEXT_72);
return true;
}
});
- out.write(_TEXT.TEXT_75);
+ out.write(_TEXT.TEXT_73);
}
}
diff --git a/plugins/org.eclipse.jet/templates/jet2transform.jet b/plugins/org.eclipse.jet/templates/jet2transform.jet
index b52e10b..9bb5b35 100644
--- a/plugins/org.eclipse.jet/templates/jet2transform.jet
+++ b/plugins/org.eclipse.jet/templates/jet2transform.jet
@@ -1,7 +1,10 @@
<%@jet package="org.eclipse.jet.internal.compiler.templates"
class="JET2TransformGenerator"
%>
+<%@jet imports="java.util.ArrayList"%>
+<%@jet imports="java.util.Collections"%>
<%@jet imports="java.util.Iterator"%>
+<%@jet imports="java.util.List"%>
<%@jet imports="java.util.Map"%>
<%@jet imports="org.eclipse.jet.internal.compiler.LoaderGenerationParameters"%>
<%
@@ -19,75 +22,82 @@ import org.eclipse.jet.JET2Template;
public class <%= parms.getClassName() %> implements JET2TemplateLoader, JET2TemplateLoaderExtension {
- private static final class TemplateFactoryMethod {
+ private static final class TemplateFactoryMethod {
- private final String templatePath;
- private final String templateClass;
+ private final String templatePath;
+ private final String templateClass;
- public TemplateFactoryMethod(String templatePath, String templateClass) {
- this.templatePath = templatePath;
- this.templateClass = templateClass;
-
- }
-
- public String getTemplateClass() {
- return templateClass;
- }
+ public TemplateFactoryMethod(String templatePath, String templateClass) {
+ this.templatePath = templatePath;
+ this.templateClass = templateClass;
+
+ }
+
+ public String getTemplateClass() {
+ return this.templateClass;
+ }
- public String getTemplatePath() {
- return templatePath;
- }
+ public String getTemplatePath() {
+ return this.templatePath;
+ }
- public JET2Template newTemplate() {
- JET2Template template = null;
- try {
- template = (JET2Template) Class.forName(templateClass).newInstance();
- } catch (InstantiationException e) {
- } catch (IllegalAccessException e) {
- } catch (ClassNotFoundException e) {
- }
- return template;
- }
-
-
- }
+ public JET2Template newTemplate() {
+ JET2Template template = null;
+ try {
+ template = (JET2Template) Class.forName(this.templateClass).newInstance();
+ } catch (InstantiationException e) {
+ // ignore
+ } catch (IllegalAccessException e) {
+ // ignore
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ return template;
+ }
+
+
+ }
- private Map pathToFactoryMap = null;
-
- private JET2TemplateLoader delegate = null;
+ private Map pathToFactoryMap = null;
+
+ private JET2TemplateLoader delegate = null;
- public <%= parms.getClassName() %>() {
- super();
- }
+ public <%= parms.getClassName() %>() {
+ super();
+ }
- public JET2Template getTemplate(String templatePath) {
- if(pathToFactoryMap == null) {
- initPathToFactoryMap();
+ public JET2Template getTemplate(String templatePath) {
+ if(this.pathToFactoryMap == null) {
+ initPathToFactoryMap();
}
- TemplateFactoryMethod factory = (TemplateFactoryMethod)pathToFactoryMap.get(templatePath);
- return factory == null ? delegate == null ? null : delegate.getTemplate(templatePath) : factory.newTemplate();
- }
+ TemplateFactoryMethod factory = (TemplateFactoryMethod)this.pathToFactoryMap.get(templatePath);
+ return factory == null ? this.delegate == null ? null : this.delegate.getTemplate(templatePath) : factory.newTemplate();
+ }
- private void addTemplate(String templatePath, String templateClass) {
- pathToFactoryMap.put(templatePath, //$NON-NLS-1$
- new TemplateFactoryMethod(templatePath, templateClass));
- }
-
+ private void addTemplate(String templatePath, String templateClass) {
+ this.pathToFactoryMap.put(templatePath,
+ new TemplateFactoryMethod(templatePath, templateClass));
+ }
+
private void initPathToFactoryMap() {
- pathToFactoryMap = new HashMap(<%= templateMap.size() %>);
-<% for(Iterator i = templateMap.entrySet().iterator(); i.hasNext();){
- Map.Entry entry = (Map.Entry)i.next();
+ this.pathToFactoryMap = new HashMap(<%= templateMap.size() %>);
+<%
+ List templatePaths = new ArrayList(templateMap.keySet());
+ Collections.sort(templatePaths);
+ for(Iterator i = templatePaths.iterator(); i.hasNext();){
+ String key = (String)i.next();
+ String value = (String)templateMap.get(key);
%>
- addTemplate("<%= entry.getKey() %>", "<%= entry.getValue() %>" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("<%= key %>", "<%= value %>" ); //$NON-NLS-1$ //$NON-NLS-2$
<% } %>
- }
+ }
public void setDelegateLoader(JET2TemplateLoader loader) {
this.delegate = loader;
}
public JET2TemplateLoader getDelegateLoader() {
- return delegate;
+ return this.delegate;
}
}
diff --git a/plugins/org.eclipse.jet/templates/v2/jet2java.jet b/plugins/org.eclipse.jet/templates/v2/jet2java.jet
index e5fcbe4..1203b77 100644
--- a/plugins/org.eclipse.jet/templates/v2/jet2java.jet
+++ b/plugins/org.eclipse.jet/templates/v2/jet2java.jet
@@ -8,10 +8,11 @@
<%@jet imports="java.util.Iterator"%>
<%@jet imports="org.eclipse.jet.internal.JavaUtil"%>
<%
- JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
- TagUsageVisitor tuv = new TagUsageVisitor();
- cu.accept(tuv);
- TagLibraryReference[] tlrefs = tuv.getUsedTagLibraryReferences(cu);
+ JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
+ TagUsageVisitor tuv = new TagUsageVisitor();
+ cu.accept(tuv);
+ TagLibraryReference[] tlrefs = tuv.getUsedTagLibraryReferences(cu);
+ final String nlConstantName = "NL"; //$NON-NLS-1$
%>
package <%= cu.getOutputJavaPackage() %>;
@@ -34,34 +35,19 @@ public class <%= cu.getOutputJavaClassName() %> implements JET2Template {
<% cu.accept(new V2CodeGenVisitor(context,out) {
public boolean visit(JavaDeclaration decl) {
%>
- <%= decl.getJavaContent() %>
+ <%= decl.getJavaContent() %>
<%
- return true;
- }
- });
-%>
- public <%= cu.getOutputJavaClassName() %>() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
-<% cu.accept(new V2CodeGenVisitor(context,out) {
- private int textCount = 0;
- public boolean visit(TextElement text) {
- if(text.getText().length > 0) {
-%>
- private static final String <%= textVar(++textCount) %> = <%=textExpr(text)%>;<%=nlsComment(text)%>
-<%
- }
- return true;
+ return true;
}
});
%>
+ public <%= cu.getOutputJavaClassName() %>() {
+ super();
}
+ private static final String <%=nlConstantName%> = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
<% if(tuv.hasTags()) { %>
+
private static final class _TAGS {
<% cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
public boolean visit(XMLBodyElement e) {
@@ -74,15 +60,15 @@ public class <%= cu.getOutputJavaClassName() %> implements JET2Template {
}
public void doElementVisit(XMLElement e) {
%>
- private static final TagInfo <%= tagInfoVar(e) %> = new TagInfo("<%=e.getName()%>", //$NON-NLS-1$
+ static final TagInfo <%= tagInfoVar(e) %> = new TagInfo("<%=e.getName()%>", //$NON-NLS-1$
<%= e.getLine() %>, <%= e.getColumn() %>,
new String[] {
-<% for (Iterator i = e.getAttributes().keySet().iterator(); i.hasNext();) { %>
+<% for (Iterator i = e.getAttributes().keySet().iterator(); i.hasNext();) { %>
"<%= (String) i.next() %>", //$NON-NLS-1$
<% } %>
},
new String[] {
-<% for (Iterator i = e.getAttributes().values().iterator(); i.hasNext();) {
+<% for (Iterator i = e.getAttributes().values().iterator(); i.hasNext();) {
String attrValue = (String) i.next(); %>
"<%= JavaUtil.escapeJavaString(attrValue.toCharArray()) %>", //$NON-NLS-1$
<% } %>
@@ -92,28 +78,31 @@ public class <%= cu.getOutputJavaClassName() %> implements JET2Template {
}
<% } %>
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
<% cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
- private int textCount = 0;
- public boolean visit(TextElement text) {
- if(text.getText().length > 0) {
+ public boolean visit(TextElement text) {
+ if(text.getText().length > 0) {
+ String[] strings = textConstants(text, nlConstantName);
+ for(int i = 0; i < strings.length; i++) {
%>
- out.write(_TEXT.<%=textVar(++textCount)%>);
+ out.write(<%=strings[i]%>); <% if(strings[i].startsWith("\"")) { //$NON-NLS-1$ %> //$NON-NLS-1$<%}%>
<%
- }
- return true;
+ }
+ }
+ return true;
}
public boolean visit(JavaScriptlet scriptlet) {
%>
<%= scriptlet.getJavaContent() %>
<%
- return true;
+ return true;
}
public boolean visit(JavaExpression expr) {
%>
out.write(<%= expr.getJavaContent() %>);
<%
- return true;
+ return true;
}
public boolean visit(XMLBodyElement e) {
%>
@@ -129,7 +118,7 @@ public class <%= cu.getOutputJavaClassName() %> implements JET2Template {
out = out.newNestedContentWriter();
<% } %>
<%
- in();
+ in();
return true;
}
public void endVisit(XMLBodyElement e) {
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet.expected.java b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet.expected.java
index 92b9eeb..10083d8 100644
--- a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet.expected.java
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.input.jet.expected.java
@@ -9,22 +9,14 @@ import org.eclipse.jet.taglib.TagInfo;
public class _jet_simplev2input implements JET2Template {
private static final String _jetns_test = "org.eclipse.jet.tests.TestLibrary"; //$NON-NLS-1$
- public _jet_simplev2input() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\"" + NL + NL; //$NON-NLS-1$
- private static final String TEXT_2 = "some text"; //$NON-NLS-1$
- private static final String TEXT_3 = NL;
- private static final String TEXT_4 = "foo"; //$NON-NLS-1$
- private static final String TEXT_5 = NL;
+ public _jet_simplev2input() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
+
private static final class _TAGS {
- private static final TagInfo test_tokenize_4_1 = new TagInfo("test:tokenize", //$NON-NLS-1$
+ static final TagInfo test_tokenize_4_1 = new TagInfo("test:tokenize", //$NON-NLS-1$
4, 1,
new String[] {
"sep", //$NON-NLS-1$
@@ -36,13 +28,13 @@ public class _jet_simplev2input implements JET2Template {
"token", //$NON-NLS-1$
"a,b,c,d,e,f,g", //$NON-NLS-1$
} );
- private static final TagInfo test_other_5_1 = new TagInfo("test:other", //$NON-NLS-1$
+ static final TagInfo test_other_5_1 = new TagInfo("test:other", //$NON-NLS-1$
5, 1,
new String[] {
},
new String[] {
} );
- private static final TagInfo test_isAllUpper_6_1 = new TagInfo("test:isAllUpper", //$NON-NLS-1$
+ static final TagInfo test_isAllUpper_6_1 = new TagInfo("test:isAllUpper", //$NON-NLS-1$
6, 1,
new String[] {
"var", //$NON-NLS-1$
@@ -50,19 +42,19 @@ public class _jet_simplev2input implements JET2Template {
new String[] {
"token", //$NON-NLS-1$
} );
- private static final TagInfo test_upper_8_1 = new TagInfo("test:upper", //$NON-NLS-1$
+ static final TagInfo test_upper_8_1 = new TagInfo("test:upper", //$NON-NLS-1$
8, 1,
new String[] {
},
new String[] {
} );
- private static final TagInfo test_nl_8_29 = new TagInfo("test:nl", //$NON-NLS-1$
+ static final TagInfo test_nl_8_29 = new TagInfo("test:nl", //$NON-NLS-1$
8, 29,
new String[] {
},
new String[] {
} );
- private static final TagInfo test_other_9_1 = new TagInfo("test:other", //$NON-NLS-1$
+ static final TagInfo test_other_9_1 = new TagInfo("test:other", //$NON-NLS-1$
9, 1,
new String[] {
},
@@ -70,8 +62,11 @@ public class _jet_simplev2input implements JET2Template {
} );
}
- public void generate(final JET2Context context, JET2Writer out) {
- out.write(_TEXT.TEXT_1);
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
+ out.write("\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\""); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
RuntimeTagElement _jettag_test_tokenize_4_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "tokenize", "test:tokenize", _TAGS.test_tokenize_4_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_test_tokenize_4_1.setRuntimeParent(null);
_jettag_test_tokenize_4_1.setTagInfo(_TAGS.test_tokenize_4_1);
@@ -82,11 +77,11 @@ public class _jet_simplev2input implements JET2Template {
_jettag_test_other_5_1.setTagInfo(_TAGS.test_other_5_1);
_jettag_test_other_5_1.doStart(context, out);
while (_jettag_test_other_5_1.okToProcessBody()) {
- out.write(_TEXT.TEXT_2);
+ out.write("some text"); //$NON-NLS-1$
_jettag_test_other_5_1.handleBodyContent(out);
}
_jettag_test_other_5_1.doEnd();
- out.write(_TEXT.TEXT_3);
+ out.write(NL);
RuntimeTagElement _jettag_test_isAllUpper_6_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "isAllUpper", "test:isAllUpper", _TAGS.test_isAllUpper_6_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_test_isAllUpper_6_1.setRuntimeParent(_jettag_test_tokenize_4_1);
_jettag_test_isAllUpper_6_1.setTagInfo(_TAGS.test_isAllUpper_6_1);
@@ -102,7 +97,7 @@ public class _jet_simplev2input implements JET2Template {
JET2Writer _jettag_test_upper_8_1_saved_out = out;
while (_jettag_test_upper_8_1.okToProcessBody()) {
out = out.newNestedContentWriter();
- out.write(_TEXT.TEXT_4);
+ out.write("foo"); //$NON-NLS-1$
_jettag_test_upper_8_1.handleBodyContent(out);
}
out = _jettag_test_upper_8_1_saved_out;
@@ -112,7 +107,7 @@ public class _jet_simplev2input implements JET2Template {
_jettag_test_nl_8_29.setTagInfo(_TAGS.test_nl_8_29);
_jettag_test_nl_8_29.doStart(context, out);
_jettag_test_nl_8_29.doEnd();
- out.write(_TEXT.TEXT_5);
+ out.write(NL);
RuntimeTagElement _jettag_test_other_9_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _TAGS.test_other_9_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_test_other_9_1.setRuntimeParent(_jettag_test_tokenize_4_1);
_jettag_test_other_9_1.setTagInfo(_TAGS.test_other_9_1);
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.loader.expected.java b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.loader.expected.java
index c73aeff..7cb9a2a 100644
--- a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.loader.expected.java
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.loader.expected.java
@@ -9,72 +9,75 @@ import org.eclipse.jet.JET2Template;
public class TemplateLoaderClass implements JET2TemplateLoader, JET2TemplateLoaderExtension {
- private static final class TemplateFactoryMethod {
+ private static final class TemplateFactoryMethod {
- private final String templatePath;
- private final String templateClass;
+ private final String templatePath;
+ private final String templateClass;
- public TemplateFactoryMethod(String templatePath, String templateClass) {
- this.templatePath = templatePath;
- this.templateClass = templateClass;
-
- }
-
- public String getTemplateClass() {
- return templateClass;
- }
+ public TemplateFactoryMethod(String templatePath, String templateClass) {
+ this.templatePath = templatePath;
+ this.templateClass = templateClass;
+
+ }
+
+ public String getTemplateClass() {
+ return this.templateClass;
+ }
- public String getTemplatePath() {
- return templatePath;
- }
+ public String getTemplatePath() {
+ return this.templatePath;
+ }
- public JET2Template newTemplate() {
- JET2Template template = null;
- try {
- template = (JET2Template) Class.forName(templateClass).newInstance();
- } catch (InstantiationException e) {
- } catch (IllegalAccessException e) {
- } catch (ClassNotFoundException e) {
- }
- return template;
- }
-
-
- }
+ public JET2Template newTemplate() {
+ JET2Template template = null;
+ try {
+ template = (JET2Template) Class.forName(this.templateClass).newInstance();
+ } catch (InstantiationException e) {
+ // ignore
+ } catch (IllegalAccessException e) {
+ // ignore
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ return template;
+ }
+
+
+ }
- private Map pathToFactoryMap = null;
-
- private JET2TemplateLoader delegate = null;
+ private Map pathToFactoryMap = null;
+
+ private JET2TemplateLoader delegate = null;
- public TemplateLoaderClass() {
- super();
- }
+ public TemplateLoaderClass() {
+ super();
+ }
- public JET2Template getTemplate(String templatePath) {
- if(pathToFactoryMap == null) {
- initPathToFactoryMap();
+ public JET2Template getTemplate(String templatePath) {
+ if(this.pathToFactoryMap == null) {
+ initPathToFactoryMap();
}
- TemplateFactoryMethod factory = (TemplateFactoryMethod)pathToFactoryMap.get(templatePath);
- return factory == null ? delegate == null ? null : delegate.getTemplate(templatePath) : factory.newTemplate();
- }
+ TemplateFactoryMethod factory = (TemplateFactoryMethod)this.pathToFactoryMap.get(templatePath);
+ return factory == null ? this.delegate == null ? null : this.delegate.getTemplate(templatePath) : factory.newTemplate();
+ }
- private void addTemplate(String templatePath, String templateClass) {
- pathToFactoryMap.put(templatePath, //$NON-NLS-1$
- new TemplateFactoryMethod(templatePath, templateClass));
- }
-
+ private void addTemplate(String templatePath, String templateClass) {
+ this.pathToFactoryMap.put(templatePath,
+ new TemplateFactoryMethod(templatePath, templateClass));
+ }
+
private void initPathToFactoryMap() {
- pathToFactoryMap = new HashMap(2);
- addTemplate("simple.v2.input.jet", "org.eclipse.jet.compiled._jet_simplev2input" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("simple.v2.input2.jet", "org.eclipse.jet.compiled._jet_simplev2input2" ); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ this.pathToFactoryMap = new HashMap(2);
+ addTemplate("simple.v2.input.jet", "org.eclipse.jet.compiled._jet_simplev2input" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("simple.v2.input2.jet", "org.eclipse.jet.compiled._jet_simplev2input2" ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
public void setDelegateLoader(JET2TemplateLoader loader) {
this.delegate = loader;
}
public JET2TemplateLoader getDelegateLoader() {
- return delegate;
+ return this.delegate;
}
}
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.nopredefs.expected.java b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.nopredefs.expected.java
index 578bafa..3baccfb 100644
--- a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.nopredefs.expected.java
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.nopredefs.expected.java
@@ -6,18 +6,18 @@ import org.eclipse.jet.JET2Writer;
public class _jet_simplev2usePredefTagLibs implements JET2Template {
- public _jet_simplev2usePredefTagLibs() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "This template uses a predefined tag library:" + NL + NL + "<c:get select=\"$useMe/@attr\"/>" + NL; //$NON-NLS-1$ //$NON-NLS-2$
+ public _jet_simplev2usePredefTagLibs() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
- public void generate(final JET2Context context, JET2Writer out) {
- out.write(_TEXT.TEXT_1);
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
+ out.write("This template uses a predefined tag library:"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write("<c:get select=\"$useMe/@attr\"/>"); //$NON-NLS-1$
+ out.write(NL);
}
}
diff --git a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.predefs.expected.java b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.predefs.expected.java
index 2eeaaed..e57c391 100644
--- a/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.predefs.expected.java
+++ b/tests/org.eclipse.jet.tests/data/simplifiedCompiler/templates/simple.v2.usePredefTagLibs.jet.predefs.expected.java
@@ -9,19 +9,14 @@ import org.eclipse.jet.taglib.TagInfo;
public class _jet_simplev2usePredefTagLibs implements JET2Template {
private static final String _jetns_c = "org.eclipse.jet.controlTags"; //$NON-NLS-1$
- public _jet_simplev2usePredefTagLibs() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "This template uses a predefined tag library:" + NL + NL; //$NON-NLS-1$
- private static final String TEXT_2 = NL;
+ public _jet_simplev2usePredefTagLibs() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
+
private static final class _TAGS {
- private static final TagInfo c_get_3_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_3_1 = new TagInfo("c:get", //$NON-NLS-1$
3, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -31,13 +26,16 @@ public class _jet_simplev2usePredefTagLibs implements JET2Template {
} );
}
- public void generate(final JET2Context context, JET2Writer out) {
- out.write(_TEXT.TEXT_1);
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
+ out.write("This template uses a predefined tag library:"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
RuntimeTagElement _jettag_c_get_3_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_3_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_c_get_3_1.setRuntimeParent(null);
_jettag_c_get_3_1.setTagInfo(_TAGS.c_get_3_1);
_jettag_c_get_3_1.doStart(context, out);
_jettag_c_get_3_1.doEnd();
- out.write(_TEXT.TEXT_2);
+ out.write(NL);
}
}