summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2007-05-03 17:09:47 (EDT)
committer pelder2007-05-03 17:09:47 (EDT)
commiteaf2dfdcc17f52013d02eaddf511c236e4ef2a23 (patch)
treea0704135c3d95585478ab76c8488d5b19144be87
parentadce6f8dbdb63b6325e925f0440176a9c9eeb10d (diff)
downloadorg.eclipse.jet-eaf2dfdcc17f52013d02eaddf511c236e4ef2a23.zip
org.eclipse.jet-eaf2dfdcc17f52013d02eaddf511c236e4ef2a23.tar.gz
org.eclipse.jet-eaf2dfdcc17f52013d02eaddf511c236e4ef2a23.tar.bz2
Regenerate JET templates
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java119
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/DummyMain.java22
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java92
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2TransformGenerator.java187
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/TagDataDeclGenerator.java57
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteJavaExpressionTemplate.java20
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteTextElementTemplate.java20
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLEndGenerator.java44
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLStartGenerator.java83
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v1/JET1JavaGenerator.java122
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v2/JET2JavaGeneratorNew.java303
11 files changed, 597 insertions, 472 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
index a2cd96b..ee55276 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
@@ -9,80 +9,83 @@ import org.eclipse.jet.JET2Template;
public class CodeGenTemplateLoader 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 CodeGenTemplateLoader() {
- super();
- }
+ public CodeGenTemplateLoader() {
+ 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(10);
- addTemplate("templates/writeJavaExpression.jet", "org.eclipse.jet.internal.compiler.templates.WriteJavaExpressionTemplate" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/xmlStart.jet", "org.eclipse.jet.internal.compiler.templates.XMLStartGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/main.jet", "org.eclipse.jet.internal.compiler.templates.DummyMain" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/jet2transform.jet", "org.eclipse.jet.internal.compiler.templates.JET2TransformGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/xmlEnd.jet", "org.eclipse.jet.internal.compiler.templates.XMLEndGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/v1/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.v1.JET1JavaGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/v2/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.v2.JET2JavaGeneratorNew" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/tagDataDeclarations.jet", "org.eclipse.jet.internal.compiler.templates.TagDataDeclGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/writeTextElement.jet", "org.eclipse.jet.internal.compiler.templates.WriteTextElementTemplate" ); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ this.pathToFactoryMap = new HashMap(10);
+ addTemplate("templates/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/jet2transform.jet", "org.eclipse.jet.internal.compiler.templates.JET2TransformGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/main.jet", "org.eclipse.jet.internal.compiler.templates.DummyMain" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/tagDataDeclarations.jet", "org.eclipse.jet.internal.compiler.templates.TagDataDeclGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/v1/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.v1.JET1JavaGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/v2/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.v2.JET2JavaGeneratorNew" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/writeJavaExpression.jet", "org.eclipse.jet.internal.compiler.templates.WriteJavaExpressionTemplate" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/writeTextElement.jet", "org.eclipse.jet.internal.compiler.templates.WriteTextElementTemplate" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/xmlEnd.jet", "org.eclipse.jet.internal.compiler.templates.XMLEndGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ addTemplate("templates/xmlStart.jet", "org.eclipse.jet.internal.compiler.templates.XMLStartGenerator" ); //$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/src/org/eclipse/jet/internal/compiler/templates/DummyMain.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/DummyMain.java
index aff1fbe..35cfec5 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/DummyMain.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/DummyMain.java
@@ -9,19 +9,14 @@ import org.eclipse.jet.taglib.TagInfo;
public class DummyMain implements JET2Template {
private static final String _jetns_c = "org.eclipse.jet.controlTags"; //$NON-NLS-1$
- public DummyMain() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "This transform in not intended to be run."; //$NON-NLS-1$
- private static final String TEXT_2 = NL;
+ public DummyMain() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
+
private static final class _TAGS {
- private static final TagInfo c_log_2_1 = new TagInfo("c:log", //$NON-NLS-1$
+ static final TagInfo c_log_2_1 = new TagInfo("c:log", //$NON-NLS-1$
2, 1,
new String[] {
},
@@ -29,7 +24,8 @@ public class DummyMain implements JET2Template {
} );
}
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
RuntimeTagElement _jettag_c_log_2_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "log", "c:log", _TAGS.c_log_2_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_c_log_2_1.setRuntimeParent(null);
_jettag_c_log_2_1.setTagInfo(_TAGS.c_log_2_1);
@@ -37,11 +33,11 @@ public class DummyMain implements JET2Template {
JET2Writer _jettag_c_log_2_1_saved_out = out;
while (_jettag_c_log_2_1.okToProcessBody()) {
out = out.newNestedContentWriter();
- out.write(_TEXT.TEXT_1);
+ out.write("This transform in not intended to be run."); //$NON-NLS-1$
_jettag_c_log_2_1.handleBodyContent(out);
}
out = _jettag_c_log_2_1_saved_out;
_jettag_c_log_2_1.doEnd();
- out.write(_TEXT.TEXT_2);
+ out.write(NL);
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java
index be48209..4131ba7 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java
@@ -16,7 +16,7 @@ import java.util.Iterator;
public class JET2JavaGenerator implements JET2Template {
private static final String _jetns_c = "org.eclipse.jet.controlTags"; //$NON-NLS-1$
-
+
private XMLElement[] getAllXMLTags(JET2CompilationUnit cu) {
final List result = new ArrayList();
cu.accept(new DefaultJET2ASTVisitor() {
@@ -41,32 +41,14 @@ public class JET2JavaGenerator implements JET2Template {
return (JET2Declaration[])result.toArray(new JET2Declaration[result.size()]);
}
- public JET2JavaGenerator() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "package "; //$NON-NLS-1$
- private static final String TEXT_2 = ";" + NL + NL + "import org.eclipse.jet.JET2Context;" + NL + "import org.eclipse.jet.JET2Template;" + NL + "import org.eclipse.jet.JET2Writer;" + NL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String TEXT_3 = "import org.eclipse.jet.taglib.RuntimeTagElement;" + NL + "import org.eclipse.jet.taglib.TagInfo;" + NL; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_4 = "import "; //$NON-NLS-1$
- private static final String TEXT_5 = ";" + NL; //$NON-NLS-1$
- private static final String TEXT_6 = NL + "public class "; //$NON-NLS-1$
- private static final String TEXT_7 = " implements JET2Template {" + NL; //$NON-NLS-1$
- private static final String TEXT_8 = " public static final String _jetns_"; //$NON-NLS-1$
- 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 = NL;
- private static final String TEXT_13 = NL + "\tpublic "; //$NON-NLS-1$
- private static final String TEXT_14 = "() {" + NL + "\t\tsuper();" + NL + "\t}" + NL + NL + "\tpublic void generate(final JET2Context context, JET2Writer out) {" + NL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String TEXT_15 = NL + "\t}" + NL + NL + "}" + NL; //$NON-NLS-1$ //$NON-NLS-2$
+ public JET2JavaGenerator() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
+
private static final class _TAGS {
- private static final TagInfo c_include_80_4 = new TagInfo("c:include", //$NON-NLS-1$
+ static final TagInfo c_include_80_4 = new TagInfo("c:include", //$NON-NLS-1$
80, 4,
new String[] {
"template", //$NON-NLS-1$
@@ -76,7 +58,8 @@ public class JET2JavaGenerator implements JET2Template {
} );
}
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
JET2CompilationUnit cu = (JET2CompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
@@ -88,38 +71,62 @@ public class JET2JavaGenerator implements JET2Template {
MethodBodyCreator generatedBody = new MethodBodyCreator(TransformContextExtender.getInstance(context).getLoader());
cu.accept(generatedBody);
- out.write(_TEXT.TEXT_1);
+ out.write("package "); //$NON-NLS-1$
out.write( cu.getOutputJavaPackage() );
- out.write(_TEXT.TEXT_2);
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Context;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Template;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Writer;"); //$NON-NLS-1$
+ out.write(NL);
if( allXMLElements.length > 0) {
- out.write(_TEXT.TEXT_3);
+ out.write("import org.eclipse.jet.taglib.RuntimeTagElement;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.taglib.TagInfo;"); //$NON-NLS-1$
+ out.write(NL);
}
for(Iterator i=cu.getImports().iterator();i.hasNext();) {
String importName = (String)i.next();
- out.write(_TEXT.TEXT_4);
+ out.write("import "); //$NON-NLS-1$
out.write(importName);
- out.write(_TEXT.TEXT_5);
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_6);
+ out.write(NL);
+ out.write("public class "); //$NON-NLS-1$
out.write( cu.getOutputJavaClassName() );
- out.write(_TEXT.TEXT_7);
+ out.write(" implements JET2Template {"); //$NON-NLS-1$
+ out.write(NL);
if( allXMLElements.length > 0) {
for(int i = 0; i < tlRefs.length; i++ ) {
- out.write(_TEXT.TEXT_8);
+ out.write(" public static final String _jetns_"); //$NON-NLS-1$
out.write( tlRefs[i].getPrefix() );
- out.write(_TEXT.TEXT_9);
+ out.write(" = \""); //$NON-NLS-1$
out.write( tlRefs[i].getTagLibraryId() );
- out.write(_TEXT.TEXT_10);
+ out.write("\"; //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
}
}
for(int i = 0; i < allMemberDeclarations.length; i++) {
- out.write(_TEXT.TEXT_11);
+ out.write(NL);
out.write( allMemberDeclarations[i].getJavaContent() );
- out.write(_TEXT.TEXT_12);
+ out.write(NL);
}
- out.write(_TEXT.TEXT_13);
+ out.write(NL);
+ out.write("\tpublic "); //$NON-NLS-1$
out.write( cu.getOutputJavaClassName() );
- out.write(_TEXT.TEXT_14);
+ out.write("() {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("\t\tsuper();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("\t}"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write("\tpublic void generate(final JET2Context context, JET2Writer out) {"); //$NON-NLS-1$
+ out.write(NL);
for(int i = 0; i < allXMLElements.length; i++) {
context.setVariable("element", allXMLElements[i]); //$NON-NLS-1$
@@ -130,6 +137,11 @@ public class JET2JavaGenerator implements JET2Template {
_jettag_c_include_80_4.doEnd();
}
out.write( generatedBody.getBuffer() );
- out.write(_TEXT.TEXT_15);
+ out.write(NL);
+ out.write("\t}"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write("}"); //$NON-NLS-1$
+ out.write(NL);
}
}
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 e79ff98..9abaa71 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
@@ -12,39 +12,154 @@ import org.eclipse.jet.internal.compiler.LoaderGenerationParameters;
public class JET2TransformGenerator implements JET2Template {
- public JET2TransformGenerator() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- 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 + " 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 = " 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 = " }" + 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$
+ public JET2TransformGenerator() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
LoaderGenerationParameters parms = (LoaderGenerationParameters)context.getVariable("args"); //$NON-NLS-1$
Map templateMap = (Map) parms.getTemplateMap();;
- out.write(_TEXT.TEXT_1);
+ out.write("package "); //$NON-NLS-1$
out.write( parms.getPackageName() );
- out.write(_TEXT.TEXT_2);
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write("import java.util.HashMap;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import java.util.Map;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2TemplateLoader;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2TemplateLoaderExtension;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Template;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write("public class "); //$NON-NLS-1$
out.write( parms.getClassName() );
- out.write(_TEXT.TEXT_3);
+ out.write(" implements JET2TemplateLoader, JET2TemplateLoaderExtension {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" private static final class TemplateFactoryMethod {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" private final String templatePath;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" private final String templateClass;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" public TemplateFactoryMethod(String templatePath, String templateClass) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" this.templatePath = templatePath;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" this.templateClass = templateClass;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" public String getTemplateClass() {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" return this.templateClass;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" public String getTemplatePath() {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" return this.templatePath;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" public JET2Template newTemplate() {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" JET2Template template = null;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" try {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" template = (JET2Template) Class.forName(this.templateClass).newInstance();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" } catch (InstantiationException e) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" // ignore"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" } catch (IllegalAccessException e) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" // ignore"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" } catch (ClassNotFoundException e) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" // ignore"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" return template;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" private Map pathToFactoryMap = null;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" private JET2TemplateLoader delegate = null;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" public "); //$NON-NLS-1$
out.write( parms.getClassName() );
- out.write(_TEXT.TEXT_4);
+ out.write("() {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" super();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" public JET2Template getTemplate(String templatePath) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" if(this.pathToFactoryMap == null) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" initPathToFactoryMap();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" TemplateFactoryMethod factory = (TemplateFactoryMethod)this.pathToFactoryMap.get(templatePath);"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" return factory == null ? this.delegate == null ? null : this.delegate.getTemplate(templatePath) : factory.newTemplate();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" private void addTemplate(String templatePath, String templateClass) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" this.pathToFactoryMap.put(templatePath,"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" new TemplateFactoryMethod(templatePath, templateClass));"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" private void initPathToFactoryMap() {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" this.pathToFactoryMap = new HashMap("); //$NON-NLS-1$
out.write( templateMap.size() );
- out.write(_TEXT.TEXT_5);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
List templatePaths = new ArrayList(templateMap.keySet());
Collections.sort(templatePaths);
@@ -52,12 +167,32 @@ Map templateMap = (Map) parms.getTemplateMap();;
String key = (String)i.next();
String value = (String)templateMap.get(key);
- out.write(_TEXT.TEXT_6);
+ out.write(" addTemplate(\""); //$NON-NLS-1$
out.write( key );
- out.write(_TEXT.TEXT_7);
+ out.write("\", \""); //$NON-NLS-1$
out.write( value );
- out.write(_TEXT.TEXT_8);
+ out.write("\" ); //$NON-NLS-1$ //$NON-NLS-2$"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_9);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" public void setDelegateLoader(JET2TemplateLoader loader) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" this.delegate = loader;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" public JET2TemplateLoader getDelegateLoader() {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" return this.delegate;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("}"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/TagDataDeclGenerator.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/TagDataDeclGenerator.java
index a76f6b5..d9f3583 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/TagDataDeclGenerator.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/TagDataDeclGenerator.java
@@ -11,28 +11,14 @@ import org.eclipse.jet.internal.compiler.MethodBodyCreator;
public class TagDataDeclGenerator implements JET2Template {
- public TagDataDeclGenerator() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = " final TagInfo "; //$NON-NLS-1$
- private static final String TEXT_2 = " = new TagInfo(\""; //$NON-NLS-1$
- private static final String TEXT_3 = "\", //$NON-NLS-1$" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_4 = ", "; //$NON-NLS-1$
- private static final String TEXT_5 = "," + NL + " new String[] {" + NL; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_6 = " \""; //$NON-NLS-1$
- private static final String TEXT_7 = "\", //$NON-NLS-1$" + NL; //$NON-NLS-1$
- private static final String TEXT_8 = " }," + NL + " new String[] {" + NL; //$NON-NLS-1$ //$NON-NLS-2$
- 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; //$NON-NLS-1$
+ public TagDataDeclGenerator() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
XMLElement element;
try {
@@ -44,28 +30,39 @@ public class TagDataDeclGenerator implements JET2Template {
String varName = MethodBodyCreator.tagInfoVariableName(element);
- out.write(_TEXT.TEXT_1);
+ out.write(" final TagInfo "); //$NON-NLS-1$
out.write( varName );
- out.write(_TEXT.TEXT_2);
+ out.write(" = new TagInfo(\""); //$NON-NLS-1$
out.write(element.getName());
- out.write(_TEXT.TEXT_3);
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( element.getLine() );
- out.write(_TEXT.TEXT_4);
+ out.write(", "); //$NON-NLS-1$
out.write( element.getColumn() );
- out.write(_TEXT.TEXT_5);
+ out.write(","); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" new String[] {"); //$NON-NLS-1$
+ out.write(NL);
for (Iterator i = element.getAttributes().keySet().iterator(); i.hasNext();) {
String attrName = (String) i.next();
- out.write(_TEXT.TEXT_6);
+ out.write(" \""); //$NON-NLS-1$
out.write( attrName );
- out.write(_TEXT.TEXT_7);
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_8);
+ out.write(" },"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" new String[] {"); //$NON-NLS-1$
+ out.write(NL);
for (Iterator i = element.getAttributes().values().iterator(); i.hasNext();) {
String attrValue = (String) i.next();
- out.write(_TEXT.TEXT_9);
+ out.write(" \""); //$NON-NLS-1$
out.write( JavaUtil.escapeJavaString(attrValue.toCharArray()) );
- out.write(_TEXT.TEXT_10);
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_11);
+ out.write(" } );"); //$NON-NLS-1$
+ out.write(NL);
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteJavaExpressionTemplate.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteJavaExpressionTemplate.java
index 9d0afdd..03f4d2a 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteJavaExpressionTemplate.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteJavaExpressionTemplate.java
@@ -7,26 +7,22 @@ import org.eclipse.jet.compiler.JET2Expression;
public class WriteJavaExpressionTemplate implements JET2Template {
- public WriteJavaExpressionTemplate() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "out.write("; //$NON-NLS-1$
- private static final String TEXT_2 = ");" + NL; //$NON-NLS-1$
+ public WriteJavaExpressionTemplate() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
final String indent = (String)context.getVariable("indent"); //$NON-NLS-1$
final JET2Expression expr = (JET2Expression)context.getVariable("element"); //$NON-NLS-1$
out.write( indent );
- out.write(_TEXT.TEXT_1);
+ out.write("out.write("); //$NON-NLS-1$
out.write( expr.getJavaContent() );
- out.write(_TEXT.TEXT_2);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteTextElementTemplate.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteTextElementTemplate.java
index cdbe7e1..8f38a90 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteTextElementTemplate.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteTextElementTemplate.java
@@ -8,28 +8,24 @@ import org.eclipse.jet.internal.JavaUtil;
public class WriteTextElementTemplate implements JET2Template {
- public WriteTextElementTemplate() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "out.write( "; //$NON-NLS-1$
- private static final String TEXT_2 = " ); //$NON-NLS-1$" + NL; //$NON-NLS-1$
+ public WriteTextElementTemplate() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
final String indent = (String)context.getVariable("indent"); //$NON-NLS-1$
final TextElement text = (TextElement)context.getVariable("element"); //$NON-NLS-1$
if(text.getText().length > 0) {
out.write( indent );
- out.write(_TEXT.TEXT_1);
+ out.write("out.write( "); //$NON-NLS-1$
out.write( JavaUtil.asJavaQuotedString(text.getText()) );
- out.write(_TEXT.TEXT_2);
+ out.write(" ); //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
}
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLEndGenerator.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLEndGenerator.java
index 4d26546..72f8151 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLEndGenerator.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLEndGenerator.java
@@ -10,23 +10,14 @@ import org.eclipse.jet.internal.compiler.GenXMLElement;
public class XMLEndGenerator implements JET2Template {
private static final String _jetns_c = "org.eclipse.jet.controlTags"; //$NON-NLS-1$
- public XMLEndGenerator() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = " "; //$NON-NLS-1$
- private static final String TEXT_2 = ".handleBodyContent(out);" + NL; //$NON-NLS-1$
- private static final String TEXT_3 = "}" + NL; //$NON-NLS-1$
- private static final String TEXT_4 = "out = "; //$NON-NLS-1$
- private static final String TEXT_5 = "_saved_out;" + NL; //$NON-NLS-1$
- private static final String TEXT_6 = ".doEnd();" + NL; //$NON-NLS-1$
+ public XMLEndGenerator() {
+ 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_7_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_7_1 = new TagInfo("c:get", //$NON-NLS-1$
7, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -34,7 +25,7 @@ public class XMLEndGenerator implements JET2Template {
new String[] {
"$indent", //$NON-NLS-1$
} );
- private static final TagInfo c_get_8_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_8_1 = new TagInfo("c:get", //$NON-NLS-1$
8, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -42,7 +33,7 @@ public class XMLEndGenerator implements JET2Template {
new String[] {
"$indent", //$NON-NLS-1$
} );
- private static final TagInfo c_get_10_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_10_1 = new TagInfo("c:get", //$NON-NLS-1$
10, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -50,7 +41,7 @@ public class XMLEndGenerator implements JET2Template {
new String[] {
"$indent", //$NON-NLS-1$
} );
- private static final TagInfo c_get_13_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_13_1 = new TagInfo("c:get", //$NON-NLS-1$
13, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -60,7 +51,8 @@ public class XMLEndGenerator implements JET2Template {
} );
}
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
GenXMLElement element = (GenXMLElement) context.getVariable("element"); //$NON-NLS-1$
@@ -70,24 +62,27 @@ public class XMLEndGenerator implements JET2Template {
_jettag_c_get_7_1.setTagInfo(_TAGS.c_get_7_1);
_jettag_c_get_7_1.doStart(context, out);
_jettag_c_get_7_1.doEnd();
- out.write(_TEXT.TEXT_1);
+ out.write(" "); //$NON-NLS-1$
out.write( element.getTagVariable() );
- out.write(_TEXT.TEXT_2);
+ out.write(".handleBodyContent(out);"); //$NON-NLS-1$
+ out.write(NL);
RuntimeTagElement _jettag_c_get_8_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_8_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_c_get_8_1.setRuntimeParent(null);
_jettag_c_get_8_1.setTagInfo(_TAGS.c_get_8_1);
_jettag_c_get_8_1.doStart(context, out);
_jettag_c_get_8_1.doEnd();
- out.write(_TEXT.TEXT_3);
+ out.write("}"); //$NON-NLS-1$
+ out.write(NL);
if(element.requiresNewWriter()) {
RuntimeTagElement _jettag_c_get_10_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_10_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_c_get_10_1.setRuntimeParent(null);
_jettag_c_get_10_1.setTagInfo(_TAGS.c_get_10_1);
_jettag_c_get_10_1.doStart(context, out);
_jettag_c_get_10_1.doEnd();
- out.write(_TEXT.TEXT_4);
+ out.write("out = "); //$NON-NLS-1$
out.write( element.getTagVariable() );
- out.write(_TEXT.TEXT_5);
+ out.write("_saved_out;"); //$NON-NLS-1$
+ out.write(NL);
}
}
RuntimeTagElement _jettag_c_get_13_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_13_1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -96,6 +91,7 @@ public class XMLEndGenerator implements JET2Template {
_jettag_c_get_13_1.doStart(context, out);
_jettag_c_get_13_1.doEnd();
out.write( element.getTagVariable() );
- out.write(_TEXT.TEXT_6);
+ out.write(".doEnd();"); //$NON-NLS-1$
+ out.write(NL);
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLStartGenerator.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLStartGenerator.java
index a327f96..f7b821d 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLStartGenerator.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLStartGenerator.java
@@ -10,33 +10,14 @@ import org.eclipse.jet.internal.compiler.GenXMLElement;
public class XMLStartGenerator implements JET2Template {
private static final String _jetns_c = "org.eclipse.jet.controlTags"; //$NON-NLS-1$
- public XMLStartGenerator() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "RuntimeTagElement "; //$NON-NLS-1$
- private static final String TEXT_2 = " = context.getTagFactory().createRuntimeTag(_jetns_"; //$NON-NLS-1$
- private static final String TEXT_3 = ", \""; //$NON-NLS-1$
- private static final String TEXT_4 = "\", \""; //$NON-NLS-1$
- private static final String TEXT_5 = "\", "; //$NON-NLS-1$
- private static final String TEXT_6 = "); //$NON-NLS-1$ //$NON-NLS-2$" + NL; //$NON-NLS-1$
- private static final String TEXT_7 = ".setRuntimeParent("; //$NON-NLS-1$
- private static final String TEXT_8 = ");" + NL; //$NON-NLS-1$
- private static final String TEXT_9 = ".setTagInfo("; //$NON-NLS-1$
- private static final String TEXT_10 = ");" + NL; //$NON-NLS-1$
- private static final String TEXT_11 = ".doStart(context, out);" + NL; //$NON-NLS-1$
- private static final String TEXT_12 = "JET2Writer "; //$NON-NLS-1$
- private static final String TEXT_13 = "_saved_out = out;" + NL; //$NON-NLS-1$
- private static final String TEXT_14 = "while ("; //$NON-NLS-1$
- private static final String TEXT_15 = ".okToProcessBody()) {" + NL; //$NON-NLS-1$
- private static final String TEXT_16 = " out = out.newNestedContentWriter();" + NL; //$NON-NLS-1$
+ public XMLStartGenerator() {
+ 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_6_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_6_1 = new TagInfo("c:get", //$NON-NLS-1$
6, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -44,7 +25,7 @@ public class XMLStartGenerator implements JET2Template {
new String[] {
"$indent", //$NON-NLS-1$
} );
- private static final TagInfo c_get_7_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_7_1 = new TagInfo("c:get", //$NON-NLS-1$
7, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -52,7 +33,7 @@ public class XMLStartGenerator implements JET2Template {
new String[] {
"$indent", //$NON-NLS-1$
} );
- private static final TagInfo c_get_8_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_8_1 = new TagInfo("c:get", //$NON-NLS-1$
8, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -60,7 +41,7 @@ public class XMLStartGenerator implements JET2Template {
new String[] {
"$indent", //$NON-NLS-1$
} );
- private static final TagInfo c_get_9_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_9_1 = new TagInfo("c:get", //$NON-NLS-1$
9, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -68,7 +49,7 @@ public class XMLStartGenerator implements JET2Template {
new String[] {
"$indent", //$NON-NLS-1$
} );
- private static final TagInfo c_get_12_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_12_1 = new TagInfo("c:get", //$NON-NLS-1$
12, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -76,7 +57,7 @@ public class XMLStartGenerator implements JET2Template {
new String[] {
"$indent", //$NON-NLS-1$
} );
- private static final TagInfo c_get_14_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_14_1 = new TagInfo("c:get", //$NON-NLS-1$
14, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -84,7 +65,7 @@ public class XMLStartGenerator implements JET2Template {
new String[] {
"$indent", //$NON-NLS-1$
} );
- private static final TagInfo c_get_16_1 = new TagInfo("c:get", //$NON-NLS-1$
+ static final TagInfo c_get_16_1 = new TagInfo("c:get", //$NON-NLS-1$
16, 1,
new String[] {
"select", //$NON-NLS-1$
@@ -94,7 +75,8 @@ public class XMLStartGenerator implements JET2Template {
} );
}
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
GenXMLElement element = (GenXMLElement) context.getVariable("element"); //$NON-NLS-1$
@@ -103,42 +85,46 @@ public class XMLStartGenerator implements JET2Template {
_jettag_c_get_6_1.setTagInfo(_TAGS.c_get_6_1);
_jettag_c_get_6_1.doStart(context, out);
_jettag_c_get_6_1.doEnd();
- out.write(_TEXT.TEXT_1);
+ out.write("RuntimeTagElement "); //$NON-NLS-1$
out.write( element.getTagVariable() );
- out.write(_TEXT.TEXT_2);
+ out.write(" = context.getTagFactory().createRuntimeTag(_jetns_"); //$NON-NLS-1$
out.write( element.getNSPrefix() );
- out.write(_TEXT.TEXT_3);
+ out.write(", \""); //$NON-NLS-1$
out.write( element.getTagNCName() );
- out.write(_TEXT.TEXT_4);
+ out.write("\", \""); //$NON-NLS-1$
out.write( element.getName() );
- out.write(_TEXT.TEXT_5);
+ out.write("\", "); //$NON-NLS-1$
out.write( element.getTagInfoVariable() );
- out.write(_TEXT.TEXT_6);
+ out.write("); //$NON-NLS-1$ //$NON-NLS-2$"); //$NON-NLS-1$
+ out.write(NL);
RuntimeTagElement _jettag_c_get_7_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_7_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_c_get_7_1.setRuntimeParent(null);
_jettag_c_get_7_1.setTagInfo(_TAGS.c_get_7_1);
_jettag_c_get_7_1.doStart(context, out);
_jettag_c_get_7_1.doEnd();
out.write( element.getTagVariable() );
- out.write(_TEXT.TEXT_7);
+ out.write(".setRuntimeParent("); //$NON-NLS-1$
out.write( element.getParentTagVariable() );
- out.write(_TEXT.TEXT_8);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
RuntimeTagElement _jettag_c_get_8_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_8_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_c_get_8_1.setRuntimeParent(null);
_jettag_c_get_8_1.setTagInfo(_TAGS.c_get_8_1);
_jettag_c_get_8_1.doStart(context, out);
_jettag_c_get_8_1.doEnd();
out.write( element.getTagVariable() );
- out.write(_TEXT.TEXT_9);
+ out.write(".setTagInfo("); //$NON-NLS-1$
out.write( element.getTagInfoVariable() );
- out.write(_TEXT.TEXT_10);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
RuntimeTagElement _jettag_c_get_9_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_9_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_c_get_9_1.setRuntimeParent(null);
_jettag_c_get_9_1.setTagInfo(_TAGS.c_get_9_1);
_jettag_c_get_9_1.doStart(context, out);
_jettag_c_get_9_1.doEnd();
out.write( element.getTagVariable() );
- out.write(_TEXT.TEXT_11);
+ out.write(".doStart(context, out);"); //$NON-NLS-1$
+ out.write(NL);
if(element.hasBody()) {
if(element.requiresNewWriter()) {
RuntimeTagElement _jettag_c_get_12_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_12_1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -146,25 +132,28 @@ public class XMLStartGenerator implements JET2Template {
_jettag_c_get_12_1.setTagInfo(_TAGS.c_get_12_1);
_jettag_c_get_12_1.doStart(context, out);
_jettag_c_get_12_1.doEnd();
- out.write(_TEXT.TEXT_12);
+ out.write("JET2Writer "); //$NON-NLS-1$
out.write( element.getTagVariable() );
- out.write(_TEXT.TEXT_13);
+ out.write("_saved_out = out;"); //$NON-NLS-1$
+ out.write(NL);
}
RuntimeTagElement _jettag_c_get_14_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_14_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_c_get_14_1.setRuntimeParent(null);
_jettag_c_get_14_1.setTagInfo(_TAGS.c_get_14_1);
_jettag_c_get_14_1.doStart(context, out);
_jettag_c_get_14_1.doEnd();
- out.write(_TEXT.TEXT_14);
+ out.write("while ("); //$NON-NLS-1$
out.write( element.getTagVariable() );
- out.write(_TEXT.TEXT_15);
+ out.write(".okToProcessBody()) {"); //$NON-NLS-1$
+ out.write(NL);
if(element.requiresNewWriter()) {
RuntimeTagElement _jettag_c_get_16_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _TAGS.c_get_16_1); //$NON-NLS-1$ //$NON-NLS-2$
_jettag_c_get_16_1.setRuntimeParent(null);
_jettag_c_get_16_1.setTagInfo(_TAGS.c_get_16_1);
_jettag_c_get_16_1.doStart(context, out);
_jettag_c_get_16_1.doEnd();
- out.write(_TEXT.TEXT_16);
+ out.write(" out = out.newNestedContentWriter();"); //$NON-NLS-1$
+ out.write(NL);
}
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v1/JET1JavaGenerator.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v1/JET1JavaGenerator.java
index 2467796..22330f0 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v1/JET1JavaGenerator.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v1/JET1JavaGenerator.java
@@ -10,121 +10,131 @@ import org.eclipse.jet.internal.JavaUtil;
public class JET1JavaGenerator implements JET2Template {
- public JET1JavaGenerator() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "package "; //$NON-NLS-1$
- private static final String TEXT_2 = ";" + NL + NL; //$NON-NLS-1$
- private static final String TEXT_3 = "import "; //$NON-NLS-1$
- private static final String TEXT_4 = ";" + NL; //$NON-NLS-1$
- private static final String TEXT_5 = NL + "public class "; //$NON-NLS-1$
- private static final String TEXT_6 = NL + "{" + NL; //$NON-NLS-1$
- private static final String TEXT_7 = "\t"; //$NON-NLS-1$
- private static final String TEXT_8 = NL;
- private static final String TEXT_9 = " protected static String nl;" + NL + " public static synchronized "; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_10 = " create(String lineSeparator)" + NL + " {" + NL + " nl = lineSeparator;" + NL + " "; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String TEXT_11 = " result = new "; //$NON-NLS-1$
- private static final String TEXT_12 = "();" + NL + " nl = null;" + NL + " return result;" + NL + " }" + NL + NL + " protected final String NL = nl == null ? (System.getProperties().getProperty(\"line.separator\")) : nl; //$NON-NLS-1$" + NL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- private static final String TEXT_13 = " protected final String TEXT_"; //$NON-NLS-1$
- private static final String TEXT_14 = " = "; //$NON-NLS-1$
- private static final String TEXT_15 = ";"; //$NON-NLS-1$
- private static final String TEXT_16 = NL;
- private static final String TEXT_17 = NL + " public String generate(Object argument)" + NL + " {" + NL + " final StringBuffer stringBuffer = new StringBuffer();" + NL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String TEXT_18 = " stringBuffer.append(TEXT_"; //$NON-NLS-1$
- private static final String TEXT_19 = ");" + NL; //$NON-NLS-1$
- private static final String TEXT_20 = " "; //$NON-NLS-1$
- private static final String TEXT_21 = NL;
- private static final String TEXT_22 = " stringBuffer.append("; //$NON-NLS-1$
- private static final String TEXT_23 = ");" + NL; //$NON-NLS-1$
- private static final String TEXT_24 = " return stringBuffer.toString();" + NL + " }" + NL + "}" + NL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ public JET1JavaGenerator() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
- out.write(_TEXT.TEXT_1);
+ out.write("package "); //$NON-NLS-1$
out.write( cu.getOutputJavaPackage() );
- out.write(_TEXT.TEXT_2);
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
for(Iterator i=cu.getImports().iterator();i.hasNext();) {
String importName = (String)i.next();
- out.write(_TEXT.TEXT_3);
+ out.write("import "); //$NON-NLS-1$
out.write(importName);
- out.write(_TEXT.TEXT_4);
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_5);
+ out.write(NL);
+ out.write("public class "); //$NON-NLS-1$
out.write( cu.getOutputJavaClassName() );
- out.write(_TEXT.TEXT_6);
+ out.write(NL);
+ out.write("{"); //$NON-NLS-1$
+ out.write(NL);
cu.accept(new SafeJETASTVisitor(context,out) {
public boolean visit(JavaDeclaration decl) {
- out.write(_TEXT.TEXT_7);
+ out.write("\t"); //$NON-NLS-1$
out.write( decl.getJavaContent() );
- out.write(_TEXT.TEXT_8);
+ out.write(NL);
return true;
}
});
- out.write(_TEXT.TEXT_9);
+ out.write(" protected static String nl;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" public static synchronized "); //$NON-NLS-1$
out.write( cu.getOutputJavaClassName() );
- out.write(_TEXT.TEXT_10);
+ out.write(" create(String lineSeparator)"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" nl = lineSeparator;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( cu.getOutputJavaClassName() );
- out.write(_TEXT.TEXT_11);
+ out.write(" result = new "); //$NON-NLS-1$
out.write( cu.getOutputJavaClassName() );
- out.write(_TEXT.TEXT_12);
+ out.write("();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" nl = null;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" return result;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" protected final String NL = nl == null ? (System.getProperties().getProperty(\"line.separator\")) : nl; //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
cu.accept(new SafeJETASTVisitor(context,out) {
private int textCount = 0;
public boolean visit(TextElement text) {
textCount++;
- out.write(_TEXT.TEXT_13);
+ out.write(" protected final String TEXT_"); //$NON-NLS-1$
out.write(textCount);
- out.write(_TEXT.TEXT_14);
+ out.write(" = "); //$NON-NLS-1$
out.write(JavaUtil.asJavaQuoteStringWithNLRemoved(text.getText()));
- out.write(_TEXT.TEXT_15);
+ out.write(";"); //$NON-NLS-1$
out.write(JavaUtil.nlsCommentsForJavaQuoteStringWithNLRemoved(text.getText()));
- out.write(_TEXT.TEXT_16);
+ out.write(NL);
return true;
}
});
- out.write(_TEXT.TEXT_17);
+ out.write(NL);
+ out.write(" public String generate(Object argument)"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" final StringBuffer stringBuffer = new StringBuffer();"); //$NON-NLS-1$
+ out.write(NL);
cu.accept(new SafeJETASTVisitor(context,out) {
private int textCount = 0;
public boolean visit(TextElement text) {
textCount++;
- out.write(_TEXT.TEXT_18);
+ out.write(" stringBuffer.append(TEXT_"); //$NON-NLS-1$
out.write(textCount);
- out.write(_TEXT.TEXT_19);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
return true;
}
public boolean visit(JavaScriptlet scriptlet) {
- out.write(_TEXT.TEXT_20);
+ out.write(" "); //$NON-NLS-1$
out.write( scriptlet.getJavaContent() );
- out.write(_TEXT.TEXT_21);
+ out.write(NL);
return true;
}
public boolean visit(JavaExpression expr) {
- out.write(_TEXT.TEXT_22);
+ out.write(" stringBuffer.append("); //$NON-NLS-1$
out.write( expr.getJavaContent() );
- out.write(_TEXT.TEXT_23);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
return true;
}
});
- out.write(_TEXT.TEXT_24);
+ out.write(" return stringBuffer.toString();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("}"); //$NON-NLS-1$
+ out.write(NL);
}
}
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 717897d..deeeb02 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
@@ -12,90 +12,14 @@ import org.eclipse.jet.internal.JavaUtil;
public class JET2JavaGeneratorNew implements JET2Template {
- public JET2JavaGeneratorNew() {
- super();
- }
-
- private static final String NL = System.getProperties().getProperty("line.separator");
-
- private static final class _TEXT {
- private static final String TEXT_1 = "package "; //$NON-NLS-1$
- private static final String TEXT_2 = ";" + NL + NL + "import org.eclipse.jet.JET2Context;" + NL + "import org.eclipse.jet.JET2Template;" + NL + "import org.eclipse.jet.JET2Writer;" + NL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- private static final String TEXT_3 = "import org.eclipse.jet.taglib.RuntimeTagElement;" + NL + "import org.eclipse.jet.taglib.TagInfo;" + NL; //$NON-NLS-1$ //$NON-NLS-2$
- private static final String TEXT_4 = "import "; //$NON-NLS-1$
- private static final String TEXT_5 = ";" + NL; //$NON-NLS-1$
- private static final String TEXT_6 = NL + "public class "; //$NON-NLS-1$
- private static final String TEXT_7 = " implements JET2Template {" + NL; //$NON-NLS-1$
- private static final String TEXT_8 = " private static final String _jetns_"; //$NON-NLS-1$
- 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 = " "; //$NON-NLS-1$
- private static final String TEXT_13 = NL;
- 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 = ".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 = ".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 JET2JavaGeneratorNew() {
+ super();
}
+ private static final String NL = System.getProperties().getProperty("line.separator"); //$NON-NLS-1$
- public void generate(final JET2Context context, JET2Writer out) {
+ public void generate(final JET2Context context, final JET2Writer __out) {
+ JET2Writer out = __out;
JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
TagUsageVisitor tuv = new TagUsageVisitor();
@@ -103,46 +27,72 @@ public class JET2JavaGeneratorNew implements JET2Template {
TagLibraryReference[] tlrefs = tuv.getUsedTagLibraryReferences(cu);
final String nlConstantName = "NL"; //$NON-NLS-1$
- out.write(_TEXT.TEXT_1);
+ out.write("package "); //$NON-NLS-1$
out.write( cu.getOutputJavaPackage() );
- out.write(_TEXT.TEXT_2);
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Context;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Template;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.JET2Writer;"); //$NON-NLS-1$
+ out.write(NL);
if(tuv.hasTags()) {
- out.write(_TEXT.TEXT_3);
+ out.write("import org.eclipse.jet.taglib.RuntimeTagElement;"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("import org.eclipse.jet.taglib.TagInfo;"); //$NON-NLS-1$
+ out.write(NL);
}
for(Iterator i=cu.getImports().iterator();i.hasNext();) {
- out.write(_TEXT.TEXT_4);
+ out.write("import "); //$NON-NLS-1$
out.write( (String)i.next() );
- out.write(_TEXT.TEXT_5);
+ out.write(";"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_6);
+ out.write(NL);
+ out.write("public class "); //$NON-NLS-1$
out.write( cu.getOutputJavaClassName() );
- out.write(_TEXT.TEXT_7);
+ out.write(" implements JET2Template {"); //$NON-NLS-1$
+ out.write(NL);
for(int i = 0; i < tlrefs.length; i++ ) {
- out.write(_TEXT.TEXT_8);
+ out.write(" private static final String _jetns_"); //$NON-NLS-1$
out.write( tlrefs[i].getPrefix() );
- out.write(_TEXT.TEXT_9);
+ out.write(" = \""); //$NON-NLS-1$
out.write( tlrefs[i].getTagLibraryId() );
- out.write(_TEXT.TEXT_10);
+ out.write("\"; //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_11);
+ out.write(NL);
cu.accept(new V2CodeGenVisitor(context,out) {
public boolean visit(JavaDeclaration decl) {
- out.write(_TEXT.TEXT_12);
+ out.write(" "); //$NON-NLS-1$
out.write( decl.getJavaContent() );
- out.write(_TEXT.TEXT_13);
+ out.write(NL);
return true;
}
});
- out.write(_TEXT.TEXT_14);
+ out.write(" public "); //$NON-NLS-1$
out.write( cu.getOutputJavaClassName() );
- out.write(_TEXT.TEXT_15);
+ out.write("() {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" super();"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(NL);
+ out.write(" private static final String "); //$NON-NLS-1$
out.write(nlConstantName);
- out.write(_TEXT.TEXT_16);
+ out.write(" = System.getProperties().getProperty(\"line.separator\"); //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
if(tuv.hasTags()) {
- out.write(_TEXT.TEXT_17);
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" private static final class _TAGS {"); //$NON-NLS-1$
+ out.write(NL);
cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
public boolean visit(XMLBodyElement e) {
doElementVisit(e);
@@ -154,46 +104,63 @@ public class JET2JavaGeneratorNew implements JET2Template {
}
public void doElementVisit(XMLElement e) {
- out.write(_TEXT.TEXT_18);
+ out.write(" static final TagInfo "); //$NON-NLS-1$
out.write( tagInfoVar(e) );
- out.write(_TEXT.TEXT_19);
+ out.write(" = new TagInfo(\""); //$NON-NLS-1$
out.write(e.getName());
- out.write(_TEXT.TEXT_20);
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( e.getLine() );
- out.write(_TEXT.TEXT_21);
+ out.write(", "); //$NON-NLS-1$
out.write( e.getColumn() );
- out.write(_TEXT.TEXT_22);
+ out.write(","); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" new String[] {"); //$NON-NLS-1$
+ out.write(NL);
for (Iterator i = e.getAttributes().keySet().iterator(); i.hasNext();) {
- out.write(_TEXT.TEXT_23);
+ out.write(" \""); //$NON-NLS-1$
out.write( (String) i.next() );
- out.write(_TEXT.TEXT_24);
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_25);
+ out.write(" },"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" new String[] {"); //$NON-NLS-1$
+ out.write(NL);
for (Iterator i = e.getAttributes().values().iterator(); i.hasNext();) {
String attrValue = (String) i.next();
- out.write(_TEXT.TEXT_26);
+ out.write(" \""); //$NON-NLS-1$
out.write( JavaUtil.escapeJavaString(attrValue.toCharArray()) );
- out.write(_TEXT.TEXT_27);
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_28);
+ out.write(" } );"); //$NON-NLS-1$
+ out.write(NL);
}
});
- out.write(_TEXT.TEXT_29);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_30);
+ out.write(NL);
+ out.write(" public void generate(final JET2Context context, final JET2Writer __out) {"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" JET2Writer out = __out;"); //$NON-NLS-1$
+ out.write(NL);
cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
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_31);
+ out.write(" out.write("); //$NON-NLS-1$
out.write(strings[i]);
- out.write(_TEXT.TEXT_32);
+ out.write("); "); //$NON-NLS-1$
if(strings[i].startsWith("\"")) { //$NON-NLS-1$
- out.write(_TEXT.TEXT_33);
+ out.write(" //$NON-NLS-1$"); //$NON-NLS-1$
}
- out.write(_TEXT.TEXT_34);
+ out.write(" "); //$NON-NLS-1$
+ out.write(NL);
}
}
@@ -201,53 +168,64 @@ public class JET2JavaGeneratorNew implements JET2Template {
}
public boolean visit(JavaScriptlet scriptlet) {
- out.write(_TEXT.TEXT_35);
+ out.write(" "); //$NON-NLS-1$
out.write( scriptlet.getJavaContent() );
- out.write(_TEXT.TEXT_36);
+ out.write(NL);
return true;
}
public boolean visit(JavaExpression expr) {
- out.write(_TEXT.TEXT_37);
+ out.write(" out.write("); //$NON-NLS-1$
out.write( expr.getJavaContent() );
- out.write(_TEXT.TEXT_38);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
return true;
}
public boolean visit(XMLBodyElement e) {
- out.write(_TEXT.TEXT_39);
+ out.write(" RuntimeTagElement "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_40);
+ out.write(" = context.getTagFactory().createRuntimeTag(_jetns_"); //$NON-NLS-1$
out.write( e.getNSPrefix() );
- out.write(_TEXT.TEXT_41);
+ out.write(", \""); //$NON-NLS-1$
out.write( e.getTagNCName() );
- out.write(_TEXT.TEXT_42);
+ out.write("\", \""); //$NON-NLS-1$
out.write( e.getName() );
- out.write(_TEXT.TEXT_43);
+ out.write("\", _TAGS."); //$NON-NLS-1$
out.write( tagInfoVar(e) );
- out.write(_TEXT.TEXT_44);
+ out.write("); //$NON-NLS-1$ //$NON-NLS-2$"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_45);
+ out.write(".setRuntimeParent("); //$NON-NLS-1$
out.write( parentTagVar(e) );
- out.write(_TEXT.TEXT_46);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_47);
+ out.write(".setTagInfo(_TAGS."); //$NON-NLS-1$
out.write( tagInfoVar(e) );
- out.write(_TEXT.TEXT_48);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_49);
+ out.write(".doStart(context, out);"); //$NON-NLS-1$
+ out.write(NL);
if(requiresOwnWriter(e)) {
- out.write(_TEXT.TEXT_50);
+ out.write(" JET2Writer "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_51);
+ out.write("_saved_out = out;"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_52);
+ out.write(" while ("); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_53);
+ out.write(".okToProcessBody()) {"); //$NON-NLS-1$
+ out.write(NL);
if(requiresOwnWriter(e)) {
- out.write(_TEXT.TEXT_54);
+ out.write(" out = out.newNestedContentWriter();"); //$NON-NLS-1$
+ out.write(NL);
}
in();
@@ -256,50 +234,67 @@ public class JET2JavaGeneratorNew implements JET2Template {
public void endVisit(XMLBodyElement e) {
out();
- out.write(_TEXT.TEXT_55);
+ out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_56);
+ out.write(".handleBodyContent(out);"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
if(requiresOwnWriter(e)) {
- out.write(_TEXT.TEXT_57);
+ out.write(" out = "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_58);
+ out.write("_saved_out;"); //$NON-NLS-1$
+ out.write(NL);
}
- out.write(_TEXT.TEXT_59);
+ out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_60);
+ out.write(".doEnd();"); //$NON-NLS-1$
+ out.write(NL);
}
public boolean visit(XMLEmptyElement e) {
- out.write(_TEXT.TEXT_61);
+ out.write(" RuntimeTagElement "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_62);
+ out.write(" = context.getTagFactory().createRuntimeTag(_jetns_"); //$NON-NLS-1$
out.write( e.getNSPrefix() );
- out.write(_TEXT.TEXT_63);
+ out.write(", \""); //$NON-NLS-1$
out.write( e.getTagNCName() );
- out.write(_TEXT.TEXT_64);
+ out.write("\", \""); //$NON-NLS-1$
out.write( e.getName() );
- out.write(_TEXT.TEXT_65);
+ out.write("\", _TAGS."); //$NON-NLS-1$
out.write( tagInfoVar(e) );
- out.write(_TEXT.TEXT_66);
+ out.write("); //$NON-NLS-1$ //$NON-NLS-2$"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_67);
+ out.write(".setRuntimeParent("); //$NON-NLS-1$
out.write( parentTagVar(e) );
- out.write(_TEXT.TEXT_68);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_69);
+ out.write(".setTagInfo(_TAGS."); //$NON-NLS-1$
out.write( tagInfoVar(e) );
- out.write(_TEXT.TEXT_70);
+ out.write(");"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_71);
+ out.write(".doStart(context, out);"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
- out.write(_TEXT.TEXT_72);
+ out.write(".doEnd();"); //$NON-NLS-1$
+ out.write(NL);
return true;
}
});
- out.write(_TEXT.TEXT_73);
+ out.write(" }"); //$NON-NLS-1$
+ out.write(NL);
+ out.write("}"); //$NON-NLS-1$
+ out.write(NL);
}
}