summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-05-31 16:55:32 (EDT)
committer pelder2006-05-31 16:55:32 (EDT)
commit512c254e765c7e6ea93263898d473b4a82b53e7e (patch)
treedd4198068771236663003dda3fbcdc33d23d4997
parent8e43a38b22587e6d50d320e51976c3f66a1be0ac (diff)
downloadorg.eclipse.jet-512c254e765c7e6ea93263898d473b4a82b53e7e.zip
org.eclipse.jet-512c254e765c7e6ea93263898d473b4a82b53e7e.tar.gz
org.eclipse.jet-512c254e765c7e6ea93263898d473b4a82b53e7e.tar.bz2
[144779] Switch to JET2 for template engine used by compiler.
-rw-r--r--plugins/org.eclipse.jet/.project4
-rw-r--r--plugins/org.eclipse.jet/.settings/org.eclipse.jet.prefs6
-rw-r--r--plugins/org.eclipse.jet/plugin.xml13
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java45
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/MethodBodyCreator.java90
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/TemplateRunner.java59
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java88
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/DummyMain.java46
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2JavaGenerator.java201
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/JET2TransformGenerator.java100
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/TagDataDeclGenerator.java68
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteJavaExpressionTemplate.java41
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteTextElementTemplate.java45
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLEndGenerator.java118
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/XMLStartGenerator.java193
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/JET2TagException.java2
-rw-r--r--plugins/org.eclipse.jet/templates/jet2java.javajet94
-rw-r--r--plugins/org.eclipse.jet/templates/jet2java.jet81
-rw-r--r--plugins/org.eclipse.jet/templates/jet2transform.jet (renamed from plugins/org.eclipse.jet/templates/jet2transform.javajet)11
-rw-r--r--plugins/org.eclipse.jet/templates/main.jet2
-rw-r--r--plugins/org.eclipse.jet/templates/tagDataDeclarations.jet30
-rw-r--r--plugins/org.eclipse.jet/templates/writeJavaExpression.jet7
-rw-r--r--plugins/org.eclipse.jet/templates/writeTextElement.jet10
-rw-r--r--plugins/org.eclipse.jet/templates/xmlEnd.javajet15
-rw-r--r--plugins/org.eclipse.jet/templates/xmlEnd.jet13
-rw-r--r--plugins/org.eclipse.jet/templates/xmlStart.javajet21
-rw-r--r--plugins/org.eclipse.jet/templates/xmlStart.jet18
-rw-r--r--tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java176
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java8
29 files changed, 1068 insertions, 537 deletions
diff --git a/plugins/org.eclipse.jet/.project b/plugins/org.eclipse.jet/.project
index 0e19ddf..b90e790 100644
--- a/plugins/org.eclipse.jet/.project
+++ b/plugins/org.eclipse.jet/.project
@@ -6,7 +6,7 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.emf.codegen.JETBuilder</name>
+ <name>org.eclipse.jet.builder</name>
<arguments>
</arguments>
</buildCommand>
@@ -27,7 +27,7 @@
</buildCommand>
</buildSpec>
<natures>
- <nature>org.eclipse.emf.codegen.jet.IJETNature</nature>
+ <nature>org.eclipse.jet.jet2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
diff --git a/plugins/org.eclipse.jet/.settings/org.eclipse.jet.prefs b/plugins/org.eclipse.jet/.settings/org.eclipse.jet.prefs
new file mode 100644
index 0000000..979a879
--- /dev/null
+++ b/plugins/org.eclipse.jet/.settings/org.eclipse.jet.prefs
@@ -0,0 +1,6 @@
+#Tue May 30 19:15:29 EDT 2006
+eclipse.preferences.version=1
+org.eclipse.jet.compiledTemplatePackage=org.eclipse.jet.internal.compiler.templates
+org.eclipse.jet.compiledTemplateSrcDir=src
+org.eclipse.jet.projectPrefs=true
+org.eclipse.jet.setJavaDerived=false
diff --git a/plugins/org.eclipse.jet/plugin.xml b/plugins/org.eclipse.jet/plugin.xml
index 36c62b2..6080df5 100644
--- a/plugins/org.eclipse.jet/plugin.xml
+++ b/plugins/org.eclipse.jet/plugin.xml
@@ -1408,6 +1408,19 @@ if 'length' is specified, convert only the specified number of characters, other
library="jetant.jar"
name="jet.transform"/>
</extension>
+ <extension
+ point="org.eclipse.jet.transform">
+ <transform
+ startTemplate="org.eclipse.jet.transform1"
+ templateLoaderClass="org.eclipse.jet.internal.compiler.templates.CodeGenTemplateLoader">
+ <tagLibraries>
+ <importLibrary id="org.eclipse.jet.controlTags" usePrefix="c" autoImport="true"/>
+ <importLibrary id="org.eclipse.jet.javaTags" usePrefix="java" autoImport="true"/>
+ <importLibrary id="org.eclipse.jet.formatTags" usePrefix="f" autoImport="true"/>
+ <importLibrary id="org.eclipse.jet.workspaceTags" usePrefix="ws" autoImport="false"/>
+ </tagLibraries>
+ </transform>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java
index ac2a7b4..9420185 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/compiler/JET2Compiler.java
@@ -44,8 +44,7 @@ import org.eclipse.jet.internal.InternalJET2Platform;
import org.eclipse.jet.internal.JETActivatorWrapper;
import org.eclipse.jet.internal.compiler.JETCompilerState;
import org.eclipse.jet.internal.compiler.LoaderGenerationParameters;
-import org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator;
-import org.eclipse.jet.internal.compiler.templates.JET2TransformGenerator;
+import org.eclipse.jet.internal.compiler.TemplateRunner;
import org.eclipse.jet.internal.l10n.JET2Messages;
import org.eclipse.jet.internal.parser.ParseProblemSeverity;
import org.eclipse.jet.taglib.TagLibraryReference;
@@ -143,6 +142,8 @@ public class JET2Compiler
private Set sourceExtensions = null;
+ private final TemplateRunner templateRunner;
+
/**
* Create an instance of the JET compiler capable of incremental compilation from a saved state.
* @param project the project containing templates to be compiled.
@@ -176,6 +177,7 @@ public class JET2Compiler
{
templateLoaderPackage = templateLoaderClassName = null;
}
+ templateRunner = new TemplateRunner();
}
/**
* Create an instance
@@ -221,8 +223,11 @@ public class JET2Compiler
{
if(templateLoaderClassName == null) return;
- final LoaderGenerationParameters args = new LoaderGenerationParameters(templateLoaderPackage, templateLoaderClassName, compilerState.getTemplateMap());
- String src = new JET2TransformGenerator().generate(args);
+ final LoaderGenerationParameters args = new LoaderGenerationParameters(templateLoaderPackage,
+ templateLoaderClassName, compilerState.getTemplateMap());
+
+ String src = templateRunner.generate("templates/jet2transform.jet", //$NON-NLS-1$
+ Collections.singletonMap("args", args)); //$NON-NLS-1$
IPath targetPath = new Path(getSourceDirOption()).append(
templateLoaderPackage.replace('.', '/')).append(templateLoaderClassName).addFileExtension("java"); //$NON-NLS-1$
@@ -302,6 +307,8 @@ public class JET2Compiler
IFile file = (IFile)resource;
+ clean(resource.getProjectRelativePath().toString());
+
removeMarkers(resource);
JET2CompilationUnit cu = new JET2CompilationUnit(file);
@@ -424,8 +431,8 @@ public class JET2Compiler
-1);
}
- JET2JavaGenerator gen = new JET2JavaGenerator();
- String javaSrc = gen.generate(cu);
+ String javaSrc = templateRunner.generate("templates/jet2java.jet", //$NON-NLS-1$
+ Collections.singletonMap("cu", cu)); //$NON-NLS-1$
IFile targetFile = file.getProject().getFile(javaClassProjectPath(qualifiedClassName));
try
@@ -598,6 +605,7 @@ public class JET2Compiler
String javaClassName = (String)compilerState.getTemplateMap().get(resource.getProjectRelativePath().toString());
if (javaClassName != null)
{
+ ++noCompiles;
removeJavaClass(javaClassName, derivedOnly);
}
@@ -633,15 +641,7 @@ public class JET2Compiler
for (Iterator i = templatePathSet.iterator(); i.hasNext();)
{
String templatePath = (String)i.next();
- IFile templateResource = project.getFile(templatePath);
- try
- {
- removeDerivedResources(templateResource, true);
- }
- catch (CoreException e)
- {
- JETActivatorWrapper.INSTANCE.log(e);
- }
+ clean(templatePath);
}
if(templateLoaderClassName != null)
@@ -659,6 +659,21 @@ public class JET2Compiler
removeMarkers(project);
monitor.done();
}
+ /**
+ * @param templatePath
+ */
+ private void clean(String templatePath)
+ {
+ IFile templateResource = project.getFile(templatePath);
+ try
+ {
+ removeDerivedResources(templateResource, true);
+ }
+ catch (CoreException e)
+ {
+ JETActivatorWrapper.INSTANCE.log(e);
+ }
+ }
/**
* Returns the current compiler state
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/MethodBodyCreator.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/MethodBodyCreator.java
index 8aa72a9..98c9f4d 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/MethodBodyCreator.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/MethodBodyCreator.java
@@ -18,16 +18,21 @@
package org.eclipse.jet.internal.compiler;
+import org.eclipse.jet.BodyContentWriter;
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2TemplateLoader;
+import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.compiler.DefaultJET2ASTVisitor;
+import org.eclipse.jet.compiler.JET2CompilationUnit;
import org.eclipse.jet.compiler.JET2Expression;
import org.eclipse.jet.compiler.JET2Scriptlet;
import org.eclipse.jet.compiler.TextElement;
import org.eclipse.jet.compiler.XMLBodyElement;
import org.eclipse.jet.compiler.XMLElement;
import org.eclipse.jet.compiler.XMLEmptyElement;
-import org.eclipse.jet.internal.JavaUtil;
-import org.eclipse.jet.internal.compiler.templates.XMLEndGenerator;
-import org.eclipse.jet.internal.compiler.templates.XMLStartGenerator;
+import org.eclipse.jet.internal.compiler.templates.CodeGenTemplateLoader;
+import org.eclipse.jet.transform.TransformContextExtender;
/**
@@ -36,10 +41,6 @@ import org.eclipse.jet.internal.compiler.templates.XMLStartGenerator;
*/
public class MethodBodyCreator extends DefaultJET2ASTVisitor
{
- private static final String WRITE_STMT_OPENING = "out.write("; //$NON-NLS-1$
-
- private static final String WRITE_STMT_CLOSING = ");" + System.getProperty("line.separator"); //$NON-NLS-1$ //$NON-NLS-2$
-
private static final String NULL_KEYWORD = "null"; //$NON-NLS-1$
private static final String UNDERSCORE = "_"; //$NON-NLS-1$
@@ -48,14 +49,18 @@ public class MethodBodyCreator extends DefaultJET2ASTVisitor
private static final String TAG_PREFIX = "_jettag_"; //$NON-NLS-1$
- private XMLStartGenerator startGenerator = new XMLStartGenerator();
-
- private XMLEndGenerator endGenerator = new XMLEndGenerator();
-
private java.util.Stack varStack = new java.util.Stack();
- final StringBuffer buffer = new StringBuffer();
+ private final JET2TemplateLoader templateLoader;
+ private final JET2Context context;
+ private final JET2Writer out = new BodyContentWriter();
+ private String indent = " "; //$NON-NLS-1$
+ public MethodBodyCreator(JET2TemplateLoader templateLoader) {
+ this.templateLoader = templateLoader;
+ context = new JET2Context(null);
+ TransformContextExtender.getInstance(context);
+ }
/**
* Return the name of a unique variable to refer to the passed element.
* @param element
@@ -92,10 +97,10 @@ public class MethodBodyCreator extends DefaultJET2ASTVisitor
*/
public void visit(XMLBodyElement element)
{
- String tagVarName = tagVariableName(element);
- String parentTagVar = varStack.empty() ? NULL_KEYWORD : (String)varStack.peek();
- varStack.push(tagVarName);
- buffer.append(startGenerator.generate(new GenXMLElement(element, tagVarName, tagInfoVariableName(element), parentTagVar)));
+ GenXMLElement genElement = buildGenElement(element);
+ varStack.push(genElement.getTagVariable());
+ generate("templates/xmlStart.jet", indent, genElement); //$NON-NLS-1$
+ indent = indent + " "; //$NON-NLS-1$
}
/**
@@ -103,9 +108,10 @@ public class MethodBodyCreator extends DefaultJET2ASTVisitor
*/
public void endVisit(XMLBodyElement element)
{
- String tagVarName = (String)varStack.pop();
- String parentTagVar = varStack.empty() ? NULL_KEYWORD : (String)varStack.peek();
- buffer.append(endGenerator.generate(new GenXMLElement(element, tagVarName, tagInfoVariableName(element), parentTagVar)));
+ indent = indent.substring(0, indent.length() - 4);
+ GenXMLElement genElement = buildGenElement(element);
+ generate("templates/xmlEnd.jet", indent, genElement); //$NON-NLS-1$
+ varStack.pop();
}
/**
@@ -113,11 +119,21 @@ public class MethodBodyCreator extends DefaultJET2ASTVisitor
*/
public void visit(XMLEmptyElement element)
{
+ GenXMLElement genElement = buildGenElement(element);
+
+ generate("templates/xmlStart.jet", indent, genElement); //$NON-NLS-1$
+ generate("templates/xmlEnd.jet", indent, genElement); //$NON-NLS-1$
+ }
+
+ /**
+ * @param element
+ * @return
+ */
+ private GenXMLElement buildGenElement(XMLElement element)
+ {
String tagVarName = tagVariableName(element);
String parentTagVar = varStack.empty() ? NULL_KEYWORD : (String)varStack.peek();
- GenXMLElement genElement = new GenXMLElement(element, tagVarName, tagInfoVariableName(element), parentTagVar);
- buffer.append(startGenerator.generate(genElement));
- buffer.append(endGenerator.generate(genElement));
+ return new GenXMLElement(element, tagVarName, tagInfoVariableName(element), parentTagVar);
}
/**
@@ -125,9 +141,7 @@ public class MethodBodyCreator extends DefaultJET2ASTVisitor
*/
public void visit(JET2Expression expression)
{
- buffer.append(WRITE_STMT_OPENING);
- buffer.append(expression.getJavaContent());
- buffer.append(WRITE_STMT_CLOSING);
+ generate("templates/writeJavaExpression.jet", indent, expression); //$NON-NLS-1$
}
/**
@@ -135,7 +149,7 @@ public class MethodBodyCreator extends DefaultJET2ASTVisitor
*/
public void visit(JET2Scriptlet scriptlet)
{
- buffer.append(scriptlet.getJavaContent());
+ out.write(scriptlet.getJavaContent());
}
/**
@@ -143,18 +157,32 @@ public class MethodBodyCreator extends DefaultJET2ASTVisitor
*/
public void visit(TextElement text)
{
- buffer.append(WRITE_STMT_OPENING);
- buffer.append(JavaUtil.asJavaQuotedString(text.getText()));
- buffer.append(WRITE_STMT_CLOSING);
+ generate("templates/writeTextElement.jet", indent, text); //$NON-NLS-1$
}
+ public void visit(JET2CompilationUnit compilationUnit)
+ {
+
+ }
+
+ public void endVisit(JET2CompilationUnit compilationUnit)
+ {
+ super.endVisit(compilationUnit);
+ }
/**
* Return the underlying string buffer container the generated contents.
* @return the string buffer
*/
- public StringBuffer getBuffer()
+ public String getBuffer()
{
- return buffer;
+ return out.getDocument().get();
+ }
+
+ private void generate(String templatePath, String indent, Object element) {
+ context.setVariable("indent", indent); //$NON-NLS-1$
+ context.setVariable("element", element); //$NON-NLS-1$
+ JET2Template template = templateLoader.getTemplate(templatePath);
+ template.generate(context, out);
}
}
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/TemplateRunner.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/TemplateRunner.java
new file mode 100644
index 0000000..df59b31
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/TemplateRunner.java
@@ -0,0 +1,59 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+package org.eclipse.jet.internal.compiler;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.eclipse.jet.BodyContentWriter;
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2TemplateLoader;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.internal.compiler.templates.CodeGenTemplateLoader;
+import org.eclipse.jet.transform.TransformContextExtender;
+
+/**
+ * Run JET templates for code generator
+ */
+public class TemplateRunner
+{
+
+ private JET2TemplateLoader templateLoader = null;
+
+ public TemplateRunner() {
+ // TODO Use a the JET Bundle Loader to get this. This requires some careful
+ // work to make sure the corresponding JET bundle gets loaded and unloaded successfully.
+ // @see IJETBundleManager#connect(String, IProgressMonitor)
+ templateLoader = new CodeGenTemplateLoader();
+ }
+
+ public void generate(String templatePath, Map arguments, JET2Writer out) {
+ JET2Context context = new JET2Context(null);
+ TransformContextExtender.getInstance(context).setLoader(templateLoader);
+
+ context.setVariables(arguments != null ? arguments : Collections.EMPTY_MAP);
+ JET2Template template = templateLoader.getTemplate(templatePath);
+ template.generate(context, out);
+ }
+
+ public String generate(String templatePath, Map arguments) {
+ JET2Writer out = new BodyContentWriter();
+ generate(templatePath, arguments, out);
+ return out.getDocument().get();
+ }
+}
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
new file mode 100644
index 0000000..0ae6015
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
@@ -0,0 +1,88 @@
+package org.eclipse.jet.internal.compiler.templates;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jet.JET2TemplateLoader;
+import org.eclipse.jet.JET2TemplateLoaderExtension;
+import org.eclipse.jet.JET2Template;
+
+public class CodeGenTemplateLoader implements JET2TemplateLoader, JET2TemplateLoaderExtension {
+
+ private interface TemplateFactoryMethod {
+ public abstract JET2Template newTemplate();
+ }
+
+ private Map pathToFactoryMap = null;
+
+ private JET2TemplateLoader delegate = null;
+
+ public CodeGenTemplateLoader() {
+ super();
+ }
+
+ public JET2Template getTemplate(String templatePath) {
+ if(pathToFactoryMap == null) {
+ pathToFactoryMap = new HashMap(8);
+ pathToFactoryMap.put("templates/writeJavaExpression.jet",
+ new TemplateFactoryMethod() {
+ public JET2Template newTemplate() {
+ return new org.eclipse.jet.internal.compiler.templates.WriteJavaExpressionTemplate();
+ }
+ });
+ pathToFactoryMap.put("templates/jet2java.jet",
+ new TemplateFactoryMethod() {
+ public JET2Template newTemplate() {
+ return new org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator();
+ }
+ });
+ pathToFactoryMap.put("templates/xmlStart.jet",
+ new TemplateFactoryMethod() {
+ public JET2Template newTemplate() {
+ return new org.eclipse.jet.internal.compiler.templates.XMLStartGenerator();
+ }
+ });
+ pathToFactoryMap.put("templates/main.jet",
+ new TemplateFactoryMethod() {
+ public JET2Template newTemplate() {
+ return new org.eclipse.jet.internal.compiler.templates.DummyMain();
+ }
+ });
+ pathToFactoryMap.put("templates/jet2transform.jet",
+ new TemplateFactoryMethod() {
+ public JET2Template newTemplate() {
+ return new org.eclipse.jet.internal.compiler.templates.JET2TransformGenerator();
+ }
+ });
+ pathToFactoryMap.put("templates/xmlEnd.jet",
+ new TemplateFactoryMethod() {
+ public JET2Template newTemplate() {
+ return new org.eclipse.jet.internal.compiler.templates.XMLEndGenerator();
+ }
+ });
+ pathToFactoryMap.put("templates/tagDataDeclarations.jet",
+ new TemplateFactoryMethod() {
+ public JET2Template newTemplate() {
+ return new org.eclipse.jet.internal.compiler.templates.TagDataDeclGenerator();
+ }
+ });
+ pathToFactoryMap.put("templates/writeTextElement.jet",
+ new TemplateFactoryMethod() {
+ public JET2Template newTemplate() {
+ return new org.eclipse.jet.internal.compiler.templates.WriteTextElementTemplate();
+ }
+ });
+ }
+ TemplateFactoryMethod factory = (TemplateFactoryMethod)pathToFactoryMap.get(templatePath);
+ return factory == null ? delegate == null ? null : delegate.getTemplate(templatePath) : factory.newTemplate();
+ }
+
+ public void setDelegateLoader(JET2TemplateLoader loader) {
+ this.delegate = loader;
+ }
+
+ public JET2TemplateLoader getDelegateLoader() {
+ return 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
new file mode 100644
index 0000000..45bfa1d
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/DummyMain.java
@@ -0,0 +1,46 @@
+package org.eclipse.jet.internal.compiler.templates;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+
+public class DummyMain implements JET2Template {
+
+ public static final String _jetns_f = "org.eclipse.jet.formatTags";//$NON-NLS-1$
+public static final String _jetns_c = "org.eclipse.jet.controlTags";//$NON-NLS-1$
+public static final String _jetns_java = "org.eclipse.jet.javaTags";//$NON-NLS-1$
+
+
+
+
+ public DummyMain() {
+ super();
+ }
+
+ public void generate(JET2Context context, JET2Writer out) {
+
+ final TagInfo _jettd_c_log_2_1 = new TagInfo( "c:log", 2, 1, new String[] {}, new String[] {});
+
+
+ out.write("");
+ RuntimeTagElement _jettag_c_log_2_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "log", "c:log", _jettd_c_log_2_1);
+ _jettag_c_log_2_1.setRuntimeParent(null);
+ _jettag_c_log_2_1.setTagInfo(_jettd_c_log_2_1);
+ _jettag_c_log_2_1.doStart(context, out);
+ JET2Writer _jettag_c_log_2_1_saved_out = out;
+ while (_jettag_c_log_2_1.okToProcessBody()) {
+ out = out.newNestedContentWriter();
+
+out.write("This transform in not intended to be run.");
+ _jettag_c_log_2_1.handleBodyContent(out);
+ }
+ out = _jettag_c_log_2_1_saved_out;
+ _jettag_c_log_2_1.doEnd();
+out.write("\r\n");
+
+ }
+
+}
+ \ No newline at end of file
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 bb4556a..55e0fa7 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
@@ -1,121 +1,116 @@
package org.eclipse.jet.internal.compiler.templates;
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
import org.eclipse.jet.internal.compiler.*;
import org.eclipse.jet.compiler.*;
-import org.eclipse.jet.internal.JavaUtil;
+import org.eclipse.jet.transform.TransformContextExtender;
import org.eclipse.jet.taglib.TagLibraryReference;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Iterator;
-public class JET2JavaGenerator
-{
- protected static String nl;
- public static synchronized JET2JavaGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- JET2JavaGenerator result = new JET2JavaGenerator();
- nl = null;
- return result;
- }
+public class JET2JavaGenerator implements JET2Template {
+
+ public static final String _jetns_f = "org.eclipse.jet.formatTags";//$NON-NLS-1$
+public static final String _jetns_c = "org.eclipse.jet.controlTags";//$NON-NLS-1$
+public static final String _jetns_java = "org.eclipse.jet.javaTags";//$NON-NLS-1$
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "package ";
- protected final String TEXT_2 = ";" + NL + "" + NL + "import org.eclipse.jet.JET2Context;" + NL + "import org.eclipse.jet.JET2Template;" + NL + "import org.eclipse.jet.JET2Writer;" + NL + "import org.eclipse.jet.taglib.RuntimeTagElement;" + NL + "import org.eclipse.jet.taglib.TagInfo;";
- protected final String TEXT_3 = NL + "import ";
- protected final String TEXT_4 = ";";
- protected final String TEXT_5 = NL + NL + "public class ";
- protected final String TEXT_6 = " implements JET2Template {" + NL + "" + NL + "\t";
- protected final String TEXT_7 = NL + NL + "\t";
- protected final String TEXT_8 = NL + "\t" + NL + "\tpublic ";
- protected final String TEXT_9 = "() {" + NL + "\t\tsuper();" + NL + "\t}" + NL + "" + NL + "\tpublic void generate(JET2Context context, JET2Writer out) {" + NL + "\t\t" + NL + "\t\t";
- protected final String TEXT_10 = NL + NL + "\t\t";
- protected final String TEXT_11 = NL + "\t}" + NL + "" + NL + "}";
- protected final String TEXT_12 = NL + " ";
- public String generate(Object argument)
- {
- final StringBuffer stringBuffer = new StringBuffer();
-
- JET2CompilationUnit cu = (JET2CompilationUnit)argument;
-
- final StringBuffer declarations = new StringBuffer();
- cu.accept(new DefaultJET2ASTVisitor() {
- public void visit(JET2Declaration declaration) {
- declarations.append(declaration.getJavaContent());
- }
- });
- final StringBuffer tagNamespaceVariables = new StringBuffer();
- TagLibraryReference[] tlRefs = cu.getTagLibraryReferences();
- for(int i = 0; i < tlRefs.length; i++ ) {
- ;
- tagNamespaceVariables.append("public static final String _jetns_")
- .append(tlRefs[i].getPrefix())
- .append(" = \"")
- .append(tlRefs[i].getTagLibraryId())
- .append("\";")
- .append("//$NON-NLS-1$")
- .append(NL);
+ private XMLElement[] getAllXMLTags(JET2CompilationUnit cu) {
+ final List result = new ArrayList();
+ cu.accept(new DefaultJET2ASTVisitor() {
+ public void visit(XMLBodyElement element) {
+ result.add(element);
+ }
+ public void visit(XMLEmptyElement element) {
+ result.add(element);
+ }
+ });
+ return (XMLElement[])result.toArray(new XMLElement[result.size()]);
+ }
+
+ private JET2Declaration[] getAllJavaDeclarations(JET2CompilationUnit cu) {
+ final List result = new ArrayList();
+ cu.accept(new DefaultJET2ASTVisitor() {
+ public void visit(JET2Declaration declaration) {
+ result.add(declaration);
+ }
+ });
+ return (JET2Declaration[])result.toArray(new JET2Declaration[result.size()]);
+ }
+
+
+ public JET2JavaGenerator() {
+ super();
}
- final StringBuffer tagDataDeclarations = new StringBuffer();
- cu.accept(new DefaultJET2ASTVisitor() {
- private void writeDecl(XMLElement element) {
- tagDataDeclarations.append("final TagInfo ")
- .append(MethodBodyCreator.tagInfoVariableName(element))
- .append(" = new TagInfo( ")
- .append('"').append(element.getName()).append("\", ")
- .append(element.getLine()).append(", ")
- .append(element.getColumn()).append(", ")
- ;
- tagDataDeclarations.append(" new String[] {");
- for (Iterator i = element.getAttributes().keySet().iterator(); i.hasNext();) {
- String attrName = (String) i.next();
- tagDataDeclarations.append('"').append(attrName).append("\", ");
- }
- tagDataDeclarations.append("}, ");
- tagDataDeclarations.append(" new String[] {");
- for (Iterator i = element.getAttributes().values().iterator(); i.hasNext();) {
- String attrValue = (String) i.next();
- tagDataDeclarations.append(JavaUtil.asJavaQuotedString(attrValue.toCharArray())).append(", ");
- }
- tagDataDeclarations.append("});").append(NL);
- }
+ public void generate(JET2Context context, JET2Writer out) {
- public void visit(XMLBodyElement element) {
- writeDecl(element);
- }
+ final TagInfo _jettd_c_include_76_4 = new TagInfo( "c:include", 76, 4, new String[] {"template", }, new String[] {"templates/tagDataDeclarations.jet", });
+
+
+ out.write("");
+out.write("");
+out.write("");
+out.write("");
+out.write("");
+out.write("");
+out.write("");
+out.write("");
+out.write("");
+
+ JET2CompilationUnit cu = (JET2CompilationUnit)context.getVariable("cu");
+
+ final JET2Declaration[] allMemberDeclarations = getAllJavaDeclarations(cu);
+ final XMLElement[] allXMLElements = getAllXMLTags(cu);
- public void visit(XMLEmptyElement element) {
- writeDecl(element);
- }
- });
- MethodBodyCreator generatedBody = new MethodBodyCreator();
+ final StringBuffer tagNamespaceVariables = new StringBuffer();
+ final TagLibraryReference[] tlRefs = cu.getTagLibraryReferences();
+
+ MethodBodyCreator generatedBody = new MethodBodyCreator(TransformContextExtender.getInstance(context).getLoader());
cu.accept(generatedBody);
+out.write("package ");
+out.write( cu.getOutputJavaPackage() );
+out.write(";\r\n\r\nimport org.eclipse.jet.JET2Context;\r\nimport org.eclipse.jet.JET2Template;\r\nimport org.eclipse.jet.JET2Writer;\r\nimport org.eclipse.jet.taglib.RuntimeTagElement;\r\nimport org.eclipse.jet.taglib.TagInfo;\r\n");
+ for(Iterator i=cu.getImports().iterator();i.hasNext();) {
+ String importName = (String)i.next();out.write("import ");
+out.write(importName);
+out.write(";\r\n");
+ } out.write("\r\npublic class ");
+out.write( cu.getOutputJavaClassName() );
+out.write(" implements JET2Template {\r\n");
+ for(int i = 0; i < tlRefs.length; i++ ) { out.write(" public static final String _jetns_");
+out.write( tlRefs[i].getPrefix() );
+out.write(" = \"");
+out.write( tlRefs[i].getTagLibraryId() );
+out.write("\"; //$NON-NLS-1$\r\n");
+ } out.write("");
+ for(int i = 0; i < allMemberDeclarations.length; i++) { out.write("\r\n");
+out.write( allMemberDeclarations[i].getJavaContent() );
+out.write("\r\n");
+ } out.write("\r\n\tpublic ");
+out.write( cu.getOutputJavaClassName() );
+out.write("() {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic void generate(final JET2Context context, JET2Writer out) {\r\n");
+ for(int i = 0; i < allXMLElements.length; i++) {
+ context.setVariable("element", allXMLElements[i]); out.write("");
+ RuntimeTagElement _jettag_c_include_76_4 = context.getTagFactory().createRuntimeTag(_jetns_c, "include", "c:include", _jettd_c_include_76_4);
+ _jettag_c_include_76_4.setRuntimeParent(null);
+ _jettag_c_include_76_4.setTagInfo(_jettd_c_include_76_4);
+ _jettag_c_include_76_4.doStart(context, out);
+
+ _jettag_c_include_76_4.doEnd();
+out.write("");
+ } out.write("");
+out.write( generatedBody.getBuffer() );
+out.write("\r\n\t}\r\n\r\n}\r\n");
+
+ }
- stringBuffer.append(TEXT_1);
- stringBuffer.append( cu.getOutputJavaPackage() );
- stringBuffer.append(TEXT_2);
- for(Iterator i=cu.getImports().iterator();i.hasNext();) {
- String importName = (String)i.next();
- stringBuffer.append(TEXT_3);
- stringBuffer.append(importName);
- stringBuffer.append(TEXT_4);
- }
- stringBuffer.append(TEXT_5);
- stringBuffer.append( cu.getOutputJavaClassName() );
- stringBuffer.append(TEXT_6);
- stringBuffer.append( tagNamespaceVariables );
- stringBuffer.append(TEXT_7);
- stringBuffer.append( declarations );
- stringBuffer.append(TEXT_8);
- stringBuffer.append( cu.getOutputJavaClassName() );
- stringBuffer.append(TEXT_9);
- stringBuffer.append( tagDataDeclarations );
- stringBuffer.append(TEXT_10);
- stringBuffer.append( generatedBody.getBuffer() );
- stringBuffer.append(TEXT_11);
- stringBuffer.append(TEXT_12);
- return stringBuffer.toString();
- }
}
+ \ No newline at end of file
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 698d622..74612df 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
@@ -1,59 +1,59 @@
package org.eclipse.jet.internal.compiler.templates;
-import java.util.Map;
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
import java.util.Iterator;
+import java.util.Map;
+import org.eclipse.jet.BodyContentWriter;
import org.eclipse.jet.internal.compiler.LoaderGenerationParameters;
-public class JET2TransformGenerator
-{
- protected static String nl;
- public static synchronized JET2TransformGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- JET2TransformGenerator result = new JET2TransformGenerator();
- nl = null;
- return result;
- }
-
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "package ";
- protected 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 ";
- protected final String TEXT_3 = " implements JET2TemplateLoader, JET2TemplateLoaderExtension {" + NL + "" + NL + "\tprivate interface TemplateFactoryMethod {" + NL + "\t\tpublic abstract JET2Template newTemplate();" + NL + "\t}" + NL + "" + NL + "\tprivate Map pathToFactoryMap = null;" + NL + "\t" + NL + "\tprivate JET2TemplateLoader delegate = null;" + NL + "" + NL + "\tpublic ";
- protected final String TEXT_4 = "() {" + NL + "\t\tsuper();" + NL + "\t}" + NL + "" + NL + "\tpublic JET2Template getTemplate(String templatePath) {" + NL + "\t if(pathToFactoryMap == null) {" + NL + "\t pathToFactoryMap = new HashMap(";
- protected final String TEXT_5 = ");";
- protected final String TEXT_6 = NL + "\t\t pathToFactoryMap.put(\"";
- protected final String TEXT_7 = "\"," + NL + "\t\t new TemplateFactoryMethod() {" + NL + "\t\t public JET2Template newTemplate() {" + NL + " return new ";
- protected final String TEXT_8 = "();" + NL + "\t\t }" + NL + "\t\t });";
- protected final String TEXT_9 = 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 + " public void setDelegateLoader(JET2TemplateLoader loader) {" + NL + " this.delegate = loader;" + NL + " }" + NL + " " + NL + " public JET2TemplateLoader getDelegateLoader() {" + NL + " return delegate;" + NL + " }" + NL + "}" + NL;
- protected final String TEXT_10 = NL;
-
- public String generate(Object argument)
- {
- final StringBuffer stringBuffer = new StringBuffer();
-
-LoaderGenerationParameters parms = (LoaderGenerationParameters)argument;
-Map templateMap = (Map) parms.getTemplateMap();;
+public class JET2TransformGenerator implements JET2Template {
+
+ public static final String _jetns_f = "org.eclipse.jet.formatTags";//$NON-NLS-1$
+public static final String _jetns_c = "org.eclipse.jet.controlTags";//$NON-NLS-1$
+public static final String _jetns_java = "org.eclipse.jet.javaTags";//$NON-NLS-1$
+
- stringBuffer.append(TEXT_1);
- stringBuffer.append( parms.getPackageName() );
- stringBuffer.append(TEXT_2);
- stringBuffer.append( parms.getClassName() );
- stringBuffer.append(TEXT_3);
- stringBuffer.append( parms.getClassName() );
- stringBuffer.append(TEXT_4);
- stringBuffer.append( templateMap.size() );
- stringBuffer.append(TEXT_5);
- for(Iterator i = templateMap.entrySet().iterator(); i.hasNext();){
+
+
+ public JET2TransformGenerator() {
+ super();
+ }
+
+ public void generate(JET2Context context, JET2Writer out) {
+
+
+
+ out.write("");
+out.write("");
+out.write("");
+out.write("");
+out.write("");
+
+LoaderGenerationParameters parms = (LoaderGenerationParameters)context.getVariable("args");
+Map templateMap = (Map) parms.getTemplateMap();;
+out.write("package ");
+out.write( parms.getPackageName() );
+out.write(";\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\nimport org.eclipse.jet.JET2TemplateLoader;\r\nimport org.eclipse.jet.JET2TemplateLoaderExtension;\r\nimport org.eclipse.jet.JET2Template;\r\n\r\npublic class ");
+out.write( parms.getClassName() );
+out.write(" implements JET2TemplateLoader, JET2TemplateLoaderExtension {\r\n\r\n\tprivate interface TemplateFactoryMethod {\r\n\t\tpublic abstract JET2Template newTemplate();\r\n\t}\r\n\r\n\tprivate Map pathToFactoryMap = null;\r\n\t\r\n\tprivate JET2TemplateLoader delegate = null;\r\n\r\n\tpublic ");
+out.write( parms.getClassName() );
+out.write("() {\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic JET2Template getTemplate(String templatePath) {\r\n\t if(pathToFactoryMap == null) {\r\n\t pathToFactoryMap = new HashMap(");
+out.write( templateMap.size() );
+out.write(");\r\n");
+ for(Iterator i = templateMap.entrySet().iterator(); i.hasNext();){
Map.Entry entry = (Map.Entry)i.next();
+out.write("\t\t pathToFactoryMap.put(\"");
+out.write( entry.getKey() );
+out.write("\", //$NON-NLS-1$\r\n\t\t new TemplateFactoryMethod() {\r\n\t\t public JET2Template newTemplate() {\r\n return new ");
+out.write( entry.getValue() );
+out.write("();\r\n\t\t }\r\n\t\t });\r\n");
+ } out.write(" }\r\n TemplateFactoryMethod factory = (TemplateFactoryMethod)pathToFactoryMap.get(templatePath);\r\n\t\treturn factory == null ? delegate == null ? null : delegate.getTemplate(templatePath) : factory.newTemplate();\r\n\t}\r\n\r\n public void setDelegateLoader(JET2TemplateLoader loader) {\r\n this.delegate = loader;\r\n }\r\n \r\n public JET2TemplateLoader getDelegateLoader() {\r\n return delegate;\r\n }\r\n}\r\n\r\n");
+
+ }
- stringBuffer.append(TEXT_6);
- stringBuffer.append( entry.getKey() );
- stringBuffer.append(TEXT_7);
- stringBuffer.append( entry.getValue() );
- stringBuffer.append(TEXT_8);
- }
- stringBuffer.append(TEXT_9);
- stringBuffer.append(TEXT_10);
- return stringBuffer.toString();
- }
}
+ \ No newline at end of file
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
new file mode 100644
index 0000000..ea7b0cb
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/TagDataDeclGenerator.java
@@ -0,0 +1,68 @@
+package org.eclipse.jet.internal.compiler.templates;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+import java.util.Iterator;
+import org.eclipse.jet.taglib.JET2TagException;
+import org.eclipse.jet.compiler.XMLElement;
+import org.eclipse.jet.internal.compiler.MethodBodyCreator;
+
+public class TagDataDeclGenerator implements JET2Template {
+
+ public static final String _jetns_f = "org.eclipse.jet.formatTags";//$NON-NLS-1$
+public static final String _jetns_c = "org.eclipse.jet.controlTags";//$NON-NLS-1$
+public static final String _jetns_java = "org.eclipse.jet.javaTags";//$NON-NLS-1$
+
+
+
+
+ public TagDataDeclGenerator() {
+ super();
+ }
+
+ public void generate(JET2Context context, JET2Writer out) {
+
+
+
+ out.write("");
+out.write("");
+out.write("");
+out.write("");
+out.write("");
+
+ XMLElement element;
+ try {
+ element = (XMLElement)context.getVariable("element");
+ } catch( JET2TagException e) {
+ out.write(e.toString());
+ return;
+ }
+
+ String varName = MethodBodyCreator.tagInfoVariableName(element);
+out.write(" final TagInfo ");
+out.write( varName );
+out.write(" = new TagInfo(\"");
+out.write(element.getName());
+out.write("\", //$NON-NLS-1$\r\n ");
+out.write( element.getLine() );
+out.write(", ");
+out.write( element.getColumn() );
+out.write(",\r\n new String[] {\r\n");
+ for (Iterator i = element.getAttributes().keySet().iterator(); i.hasNext();) {
+ String attrName = (String) i.next(); out.write(" \"");
+out.write( attrName );
+out.write("\", //$NON-NLS-1$\r\n");
+ } out.write(" },\r\n new String[] {\r\n");
+ for (Iterator i = element.getAttributes().values().iterator(); i.hasNext();) {
+ String attrValue = (String) i.next(); out.write(" \"");
+out.write( attrValue );
+out.write("\", //$NON-NLS-1$\r\n");
+ } out.write(" } );\r\n");
+
+ }
+
+}
+ \ No newline at end of file
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
new file mode 100644
index 0000000..d136ff5
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteJavaExpressionTemplate.java
@@ -0,0 +1,41 @@
+package org.eclipse.jet.internal.compiler.templates;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+import org.eclipse.jet.compiler.JET2Expression;
+
+public class WriteJavaExpressionTemplate implements JET2Template {
+
+ public static final String _jetns_f = "org.eclipse.jet.formatTags";//$NON-NLS-1$
+public static final String _jetns_c = "org.eclipse.jet.controlTags";//$NON-NLS-1$
+public static final String _jetns_java = "org.eclipse.jet.javaTags";//$NON-NLS-1$
+
+
+
+
+ public WriteJavaExpressionTemplate() {
+ super();
+ }
+
+ public void generate(JET2Context context, JET2Writer out) {
+
+
+
+ out.write("");
+out.write("");
+
+final String indent = (String)context.getVariable("indent"); //$NON-NLS-1$
+final JET2Expression expr = (JET2Expression)context.getVariable("element"); //$NON-NLS-1$
+out.write("");
+out.write( indent );
+out.write("out.write(");
+out.write( expr.getJavaContent() );
+out.write(");\r\n");
+
+ }
+
+}
+ \ No newline at end of file
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
new file mode 100644
index 0000000..91830ac
--- /dev/null
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/WriteTextElementTemplate.java
@@ -0,0 +1,45 @@
+package org.eclipse.jet.internal.compiler.templates;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+import org.eclipse.jet.compiler.TextElement;
+import org.eclipse.jet.internal.JavaUtil;
+
+public class WriteTextElementTemplate implements JET2Template {
+
+ public static final String _jetns_f = "org.eclipse.jet.formatTags";//$NON-NLS-1$
+public static final String _jetns_c = "org.eclipse.jet.controlTags";//$NON-NLS-1$
+public static final String _jetns_java = "org.eclipse.jet.javaTags";//$NON-NLS-1$
+
+
+
+
+ public WriteTextElementTemplate() {
+ super();
+ }
+
+ public void generate(JET2Context context, JET2Writer out) {
+
+
+
+ out.write("");
+out.write("");
+out.write("");
+
+final String indent = (String)context.getVariable("indent"); //$NON-NLS-1$
+final TextElement text = (TextElement)context.getVariable("element"); //$NON-NLS-1$
+out.write("");
+ if(text.getText().length > 0) { out.write("");
+out.write( indent );
+out.write("out.write( ");
+out.write( JavaUtil.asJavaQuotedString(text.getText()) );
+out.write(" ); //$NON-NLS-1$\r\n");
+ } out.write("");
+
+ }
+
+}
+ \ No newline at end of file
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 104fb45..df831fa 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
@@ -1,47 +1,77 @@
package org.eclipse.jet.internal.compiler.templates;
-import org.eclipse.jet.internal.compiler.*;
-
-public class XMLEndGenerator
-{
- protected static String nl;
- public static synchronized XMLEndGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- XMLEndGenerator result = new XMLEndGenerator();
- nl = null;
- return result;
- }
-
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "\t\t\t";
- protected final String TEXT_2 = ".handleBodyContent(out);" + NL + "\t\t}";
- protected final String TEXT_3 = NL + "\t\tout = ";
- protected final String TEXT_4 = "_saved_out;";
- protected final String TEXT_5 = NL + "\t\t";
- protected final String TEXT_6 = ".doEnd();";
- protected final String TEXT_7 = NL;
-
- public String generate(Object argument)
- {
- final StringBuffer stringBuffer = new StringBuffer();
-
- GenXMLElement element = (GenXMLElement) argument;
-
- if(element.hasBody()) {
- stringBuffer.append(TEXT_1);
- stringBuffer.append( element.getTagVariable() );
- stringBuffer.append(TEXT_2);
- if(element.requiresNewWriter()) {
- stringBuffer.append(TEXT_3);
- stringBuffer.append( element.getTagVariable() );
- stringBuffer.append(TEXT_4);
- }
- }
- stringBuffer.append(TEXT_5);
- stringBuffer.append( element.getTagVariable() );
- stringBuffer.append(TEXT_6);
- stringBuffer.append(TEXT_7);
- return stringBuffer.toString();
- }
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+import org.eclipse.jet.internal.compiler.GenXMLElement;
+
+public class XMLEndGenerator implements JET2Template {
+
+ public static final String _jetns_f = "org.eclipse.jet.formatTags";//$NON-NLS-1$
+public static final String _jetns_c = "org.eclipse.jet.controlTags";//$NON-NLS-1$
+public static final String _jetns_java = "org.eclipse.jet.javaTags";//$NON-NLS-1$
+
+
+
+
+ public XMLEndGenerator() {
+ super();
+ }
+
+ public void generate(JET2Context context, JET2Writer out) {
+
+ final TagInfo _jettd_c_get_7_1 = new TagInfo( "c:get", 7, 1, new String[] {"select", }, new String[] {"$indent", });
+final TagInfo _jettd_c_get_8_1 = new TagInfo( "c:get", 8, 1, new String[] {"select", }, new String[] {"$indent", });
+final TagInfo _jettd_c_get_10_1 = new TagInfo( "c:get", 10, 1, new String[] {"select", }, new String[] {"$indent", });
+final TagInfo _jettd_c_get_13_1 = new TagInfo( "c:get", 13, 1, new String[] {"select", }, new String[] {"$indent", });
+
+
+ out.write("");
+out.write("");
+
+ GenXMLElement element = (GenXMLElement) context.getVariable("element"); //$NON-NLS-1$
+out.write("");
+ if(element.hasBody()) { out.write("");
+ RuntimeTagElement _jettag_c_get_7_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_7_1);
+ _jettag_c_get_7_1.setRuntimeParent(null);
+ _jettag_c_get_7_1.setTagInfo(_jettd_c_get_7_1);
+ _jettag_c_get_7_1.doStart(context, out);
+
+ _jettag_c_get_7_1.doEnd();
+out.write(" ");
+out.write( element.getTagVariable() );
+out.write(".handleBodyContent(out);\r\n");
+ RuntimeTagElement _jettag_c_get_8_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_8_1);
+ _jettag_c_get_8_1.setRuntimeParent(null);
+ _jettag_c_get_8_1.setTagInfo(_jettd_c_get_8_1);
+ _jettag_c_get_8_1.doStart(context, out);
+
+ _jettag_c_get_8_1.doEnd();
+out.write("}\r\n");
+ if(element.requiresNewWriter()) { out.write("");
+ RuntimeTagElement _jettag_c_get_10_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_10_1);
+ _jettag_c_get_10_1.setRuntimeParent(null);
+ _jettag_c_get_10_1.setTagInfo(_jettd_c_get_10_1);
+ _jettag_c_get_10_1.doStart(context, out);
+
+ _jettag_c_get_10_1.doEnd();
+out.write("out = ");
+out.write( element.getTagVariable() );
+out.write("_saved_out;\r\n");
+ } out.write("");
+ } out.write("");
+ RuntimeTagElement _jettag_c_get_13_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_13_1);
+ _jettag_c_get_13_1.setRuntimeParent(null);
+ _jettag_c_get_13_1.setTagInfo(_jettd_c_get_13_1);
+ _jettag_c_get_13_1.doStart(context, out);
+
+ _jettag_c_get_13_1.doEnd();
+out.write( element.getTagVariable() );
+out.write(".doEnd();\r\n");
+
+ }
+
}
+ \ No newline at end of file
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 aff5d09..a79dfe0 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
@@ -1,80 +1,119 @@
package org.eclipse.jet.internal.compiler.templates;
-import org.eclipse.jet.internal.compiler.*;
-
-public class XMLStartGenerator
-{
- protected static String nl;
- public static synchronized XMLStartGenerator create(String lineSeparator)
- {
- nl = lineSeparator;
- XMLStartGenerator result = new XMLStartGenerator();
- nl = null;
- return result;
- }
-
- protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
- protected final String TEXT_1 = "\t\tRuntimeTagElement ";
- protected final String TEXT_2 = " = context.getTagFactory().createRuntimeTag(_jetns_";
- protected final String TEXT_3 = ", \"";
- protected final String TEXT_4 = "\", \"";
- protected final String TEXT_5 = "\", ";
- protected final String TEXT_6 = ");" + NL + "\t\t";
- protected final String TEXT_7 = ".setRuntimeParent(";
- protected final String TEXT_8 = ");" + NL + "\t\t";
- protected final String TEXT_9 = ".setTagInfo(";
- protected final String TEXT_10 = ");" + NL + "\t\t";
- protected final String TEXT_11 = ".doStart(context, out);";
- protected final String TEXT_12 = NL + "\t\tJET2Writer ";
- protected final String TEXT_13 = "_saved_out = out;";
- protected final String TEXT_14 = NL + "\t\twhile (";
- protected final String TEXT_15 = ".okToProcessBody()) {";
- protected final String TEXT_16 = NL + "\t\t\tout = out.newNestedContentWriter();";
- protected final String TEXT_17 = NL + "\t\t";
- protected final String TEXT_18 = NL;
-
- public String generate(Object argument)
- {
- final StringBuffer stringBuffer = new StringBuffer();
-
- GenXMLElement element = (GenXMLElement) argument;
-
- stringBuffer.append(TEXT_1);
- stringBuffer.append( element.getTagVariable() );
- stringBuffer.append(TEXT_2);
- stringBuffer.append( element.getNSPrefix() );
- stringBuffer.append(TEXT_3);
- stringBuffer.append( element.getTagNCName() );
- stringBuffer.append(TEXT_4);
- stringBuffer.append( element.getName() );
- stringBuffer.append(TEXT_5);
- stringBuffer.append( element.getTagInfoVariable() );
- stringBuffer.append(TEXT_6);
- stringBuffer.append( element.getTagVariable() );
- stringBuffer.append(TEXT_7);
- stringBuffer.append( element.getParentTagVariable() );
- stringBuffer.append(TEXT_8);
- stringBuffer.append( element.getTagVariable() );
- stringBuffer.append(TEXT_9);
- stringBuffer.append( element.getTagInfoVariable() );
- stringBuffer.append(TEXT_10);
- stringBuffer.append( element.getTagVariable() );
- stringBuffer.append(TEXT_11);
- if(element.hasBody()) {
- if(element.requiresNewWriter()) {
- stringBuffer.append(TEXT_12);
- stringBuffer.append( element.getTagVariable() );
- stringBuffer.append(TEXT_13);
- }
- stringBuffer.append(TEXT_14);
- stringBuffer.append( element.getTagVariable() );
- stringBuffer.append(TEXT_15);
- if(element.requiresNewWriter()) {
- stringBuffer.append(TEXT_16);
- }
- stringBuffer.append(TEXT_17);
- }
- stringBuffer.append(TEXT_18);
- return stringBuffer.toString();
- }
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+import org.eclipse.jet.internal.compiler.GenXMLElement;
+
+public class XMLStartGenerator implements JET2Template {
+
+ public static final String _jetns_f = "org.eclipse.jet.formatTags";//$NON-NLS-1$
+public static final String _jetns_c = "org.eclipse.jet.controlTags";//$NON-NLS-1$
+public static final String _jetns_java = "org.eclipse.jet.javaTags";//$NON-NLS-1$
+
+
+
+
+ public XMLStartGenerator() {
+ super();
+ }
+
+ public void generate(JET2Context context, JET2Writer out) {
+
+ final TagInfo _jettd_c_get_6_1 = new TagInfo( "c:get", 6, 1, new String[] {"select", }, new String[] {"$indent", });
+final TagInfo _jettd_c_get_7_1 = new TagInfo( "c:get", 7, 1, new String[] {"select", }, new String[] {"$indent", });
+final TagInfo _jettd_c_get_8_1 = new TagInfo( "c:get", 8, 1, new String[] {"select", }, new String[] {"$indent", });
+final TagInfo _jettd_c_get_9_1 = new TagInfo( "c:get", 9, 1, new String[] {"select", }, new String[] {"$indent", });
+final TagInfo _jettd_c_get_12_1 = new TagInfo( "c:get", 12, 1, new String[] {"select", }, new String[] {"$indent", });
+final TagInfo _jettd_c_get_14_1 = new TagInfo( "c:get", 14, 1, new String[] {"select", }, new String[] {"$indent", });
+final TagInfo _jettd_c_get_16_1 = new TagInfo( "c:get", 16, 1, new String[] {"select", }, new String[] {"$indent", });
+
+
+ out.write("");
+out.write("");
+
+ GenXMLElement element = (GenXMLElement) context.getVariable("element"); //$NON-NLS-1$
+out.write("");
+ RuntimeTagElement _jettag_c_get_6_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_6_1);
+ _jettag_c_get_6_1.setRuntimeParent(null);
+ _jettag_c_get_6_1.setTagInfo(_jettd_c_get_6_1);
+ _jettag_c_get_6_1.doStart(context, out);
+
+ _jettag_c_get_6_1.doEnd();
+out.write("RuntimeTagElement ");
+out.write( element.getTagVariable() );
+out.write(" = context.getTagFactory().createRuntimeTag(_jetns_");
+out.write( element.getNSPrefix() );
+out.write(", \"");
+out.write( element.getTagNCName() );
+out.write("\", \"");
+out.write( element.getName() );
+out.write("\", ");
+out.write( element.getTagInfoVariable() );
+out.write(");\r\n");
+ RuntimeTagElement _jettag_c_get_7_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_7_1);
+ _jettag_c_get_7_1.setRuntimeParent(null);
+ _jettag_c_get_7_1.setTagInfo(_jettd_c_get_7_1);
+ _jettag_c_get_7_1.doStart(context, out);
+
+ _jettag_c_get_7_1.doEnd();
+out.write( element.getTagVariable() );
+out.write(".setRuntimeParent(");
+out.write( element.getParentTagVariable() );
+out.write(");\r\n");
+ RuntimeTagElement _jettag_c_get_8_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_8_1);
+ _jettag_c_get_8_1.setRuntimeParent(null);
+ _jettag_c_get_8_1.setTagInfo(_jettd_c_get_8_1);
+ _jettag_c_get_8_1.doStart(context, out);
+
+ _jettag_c_get_8_1.doEnd();
+out.write( element.getTagVariable() );
+out.write(".setTagInfo(");
+out.write( element.getTagInfoVariable() );
+out.write(");\r\n");
+ RuntimeTagElement _jettag_c_get_9_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_9_1);
+ _jettag_c_get_9_1.setRuntimeParent(null);
+ _jettag_c_get_9_1.setTagInfo(_jettd_c_get_9_1);
+ _jettag_c_get_9_1.doStart(context, out);
+
+ _jettag_c_get_9_1.doEnd();
+out.write( element.getTagVariable() );
+out.write(".doStart(context, out);\r\n");
+ if(element.hasBody()) { out.write("");
+ if(element.requiresNewWriter()) { out.write("");
+ RuntimeTagElement _jettag_c_get_12_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_12_1);
+ _jettag_c_get_12_1.setRuntimeParent(null);
+ _jettag_c_get_12_1.setTagInfo(_jettd_c_get_12_1);
+ _jettag_c_get_12_1.doStart(context, out);
+
+ _jettag_c_get_12_1.doEnd();
+out.write("JET2Writer ");
+out.write( element.getTagVariable() );
+out.write("_saved_out = out;\r\n");
+ } out.write("");
+ RuntimeTagElement _jettag_c_get_14_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_14_1);
+ _jettag_c_get_14_1.setRuntimeParent(null);
+ _jettag_c_get_14_1.setTagInfo(_jettd_c_get_14_1);
+ _jettag_c_get_14_1.doStart(context, out);
+
+ _jettag_c_get_14_1.doEnd();
+out.write("while (");
+out.write( element.getTagVariable() );
+out.write(".okToProcessBody()) {\r\n");
+ if(element.requiresNewWriter()) { out.write("");
+ RuntimeTagElement _jettag_c_get_16_1 = context.getTagFactory().createRuntimeTag(_jetns_c, "get", "c:get", _jettd_c_get_16_1);
+ _jettag_c_get_16_1.setRuntimeParent(null);
+ _jettag_c_get_16_1.setTagInfo(_jettd_c_get_16_1);
+ _jettag_c_get_16_1.doStart(context, out);
+
+ _jettag_c_get_16_1.doEnd();
+out.write(" out = out.newNestedContentWriter();\r\n");
+ } out.write("");
+ } out.write("");
+
+ }
+
}
+ \ No newline at end of file
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/JET2TagException.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/JET2TagException.java
index cf5d2d8..b67e11d 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/JET2TagException.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/JET2TagException.java
@@ -22,7 +22,7 @@ package org.eclipse.jet.taglib;
* Encapsulate an execution error during tag execution.
*
*/
-public class JET2TagException extends Exception
+public class JET2TagException extends RuntimeException
{
/**
diff --git a/plugins/org.eclipse.jet/templates/jet2java.javajet b/plugins/org.eclipse.jet/templates/jet2java.javajet
deleted file mode 100644
index 1c29187..0000000
--- a/plugins/org.eclipse.jet/templates/jet2java.javajet
+++ /dev/null
@@ -1,94 +0,0 @@
-<%@jet package="org.eclipse.jet.internal.compiler.templates"
- class="JET2JavaGenerator"
- imports="org.eclipse.jet.internal.compiler.* org.eclipse.jet.compiler.* org.eclipse.jet.internal.JavaUtil org.eclipse.jet.taglib.TagLibraryReference java.util.Iterator"
- %>
-<%
- JET2CompilationUnit cu = (JET2CompilationUnit)argument;
-
- final StringBuffer declarations = new StringBuffer();
- cu.accept(new DefaultJET2ASTVisitor() {
- public void visit(JET2Declaration declaration) {
- declarations.append(declaration.getJavaContent());
- }
- });
-
- final StringBuffer tagNamespaceVariables = new StringBuffer();
- TagLibraryReference[] tlRefs = cu.getTagLibraryReferences();
- for(int i = 0; i < tlRefs.length; i++ ) {
- ;
- tagNamespaceVariables.append("public static final String _jetns_")
- .append(tlRefs[i].getPrefix())
- .append(" = \"")
- .append(tlRefs[i].getTagLibraryId())
- .append("\";")
- .append("//$NON-NLS-1$")
- .append(NL);
-
- }
-
- final StringBuffer tagDataDeclarations = new StringBuffer();
- cu.accept(new DefaultJET2ASTVisitor() {
- private void writeDecl(XMLElement element) {
- tagDataDeclarations.append("final TagInfo ")
- .append(MethodBodyCreator.tagInfoVariableName(element))
- .append(" = new TagInfo( ")
- .append('"').append(element.getName()).append("\", ")
- .append(element.getLine()).append(", ")
- .append(element.getColumn()).append(", ")
- ;
- tagDataDeclarations.append(" new String[] {");
- for (Iterator i = element.getAttributes().keySet().iterator(); i.hasNext();) {
- String attrName = (String) i.next();
- tagDataDeclarations.append('"').append(attrName).append("\", ");
- }
- tagDataDeclarations.append("}, ");
- tagDataDeclarations.append(" new String[] {");
- for (Iterator i = element.getAttributes().values().iterator(); i.hasNext();) {
- String attrValue = (String) i.next();
- tagDataDeclarations.append(JavaUtil.asJavaQuotedString(attrValue.toCharArray())).append(", ");
- }
- tagDataDeclarations.append("});").append(NL);
- }
-
- public void visit(XMLBodyElement element) {
- writeDecl(element);
- }
-
- public void visit(XMLEmptyElement element) {
- writeDecl(element);
- }
- });
- MethodBodyCreator generatedBody = new MethodBodyCreator();
- cu.accept(generatedBody);
-%>
-package <%= cu.getOutputJavaPackage() %>;
-
-import org.eclipse.jet.JET2Context;
-import org.eclipse.jet.JET2Template;
-import org.eclipse.jet.JET2Writer;
-import org.eclipse.jet.taglib.RuntimeTagElement;
-import org.eclipse.jet.taglib.TagInfo;
-<% for(Iterator i=cu.getImports().iterator();i.hasNext();) {
- String importName = (String)i.next();%>
-import <%=importName%>;
-<% } %>
-
-public class <%= cu.getOutputJavaClassName() %> implements JET2Template {
-
- <%= tagNamespaceVariables %>
-
- <%= declarations %>
-
- public <%= cu.getOutputJavaClassName() %>() {
- super();
- }
-
- public void generate(JET2Context context, JET2Writer out) {
-
- <%= tagDataDeclarations %>
-
- <%= generatedBody.getBuffer() %>
- }
-
-}
- \ No newline at end of file
diff --git a/plugins/org.eclipse.jet/templates/jet2java.jet b/plugins/org.eclipse.jet/templates/jet2java.jet
new file mode 100644
index 0000000..f0ac60e
--- /dev/null
+++ b/plugins/org.eclipse.jet/templates/jet2java.jet
@@ -0,0 +1,81 @@
+<%@jet package="org.eclipse.jet.internal.compiler.templates"
+ class="JET2JavaGenerator"
+ %>
+<%@jet imports="org.eclipse.jet.internal.compiler.*"%>
+<%@jet imports="org.eclipse.jet.compiler.*"%>
+<%@jet imports="org.eclipse.jet.transform.TransformContextExtender"%>
+<%@jet imports="org.eclipse.jet.taglib.TagLibraryReference"%>
+<%@jet imports="java.util.ArrayList"%>
+<%@jet imports="java.util.List"%>
+<%@jet imports="java.util.Iterator"%>
+<%!
+ private XMLElement[] getAllXMLTags(JET2CompilationUnit cu) {
+ final List result = new ArrayList();
+ cu.accept(new DefaultJET2ASTVisitor() {
+ public void visit(XMLBodyElement element) {
+ result.add(element);
+ }
+
+ public void visit(XMLEmptyElement element) {
+ result.add(element);
+ }
+ });
+ return (XMLElement[])result.toArray(new XMLElement[result.size()]);
+ }
+
+ private JET2Declaration[] getAllJavaDeclarations(JET2CompilationUnit cu) {
+ final List result = new ArrayList();
+ cu.accept(new DefaultJET2ASTVisitor() {
+ public void visit(JET2Declaration declaration) {
+ result.add(declaration);
+ }
+ });
+ return (JET2Declaration[])result.toArray(new JET2Declaration[result.size()]);
+ }
+%>
+<%
+ JET2CompilationUnit cu = (JET2CompilationUnit)context.getVariable("cu");
+
+ final JET2Declaration[] allMemberDeclarations = getAllJavaDeclarations(cu);
+ final XMLElement[] allXMLElements = getAllXMLTags(cu);
+
+ final StringBuffer tagNamespaceVariables = new StringBuffer();
+ final TagLibraryReference[] tlRefs = cu.getTagLibraryReferences();
+
+ MethodBodyCreator generatedBody = new MethodBodyCreator(TransformContextExtender.getInstance(context).getLoader());
+ cu.accept(generatedBody);
+%>
+package <%= cu.getOutputJavaPackage() %>;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+<% for(Iterator i=cu.getImports().iterator();i.hasNext();) {
+ String importName = (String)i.next();%>
+import <%=importName%>;
+<% } %>
+
+public class <%= cu.getOutputJavaClassName() %> implements JET2Template {
+<% for(int i = 0; i < tlRefs.length; i++ ) { %>
+ public static final String _jetns_<%= tlRefs[i].getPrefix() %> = "<%= tlRefs[i].getTagLibraryId() %>"; //$NON-NLS-1$
+<% } %>
+<% for(int i = 0; i < allMemberDeclarations.length; i++) { %>
+
+<%= allMemberDeclarations[i].getJavaContent() %>
+<% } %>
+
+ public <%= cu.getOutputJavaClassName() %>() {
+ super();
+ }
+
+ public void generate(final JET2Context context, JET2Writer out) {
+<% for(int i = 0; i < allXMLElements.length; i++) {
+ context.setVariable("element", allXMLElements[i]); %>
+ <c:include template="templates/tagDataDeclarations.jet"/>
+<% } %>
+<%= generatedBody.getBuffer() %>
+ }
+
+}
diff --git a/plugins/org.eclipse.jet/templates/jet2transform.javajet b/plugins/org.eclipse.jet/templates/jet2transform.jet
index 77bdd59..4362b29 100644
--- a/plugins/org.eclipse.jet/templates/jet2transform.javajet
+++ b/plugins/org.eclipse.jet/templates/jet2transform.jet
@@ -1,9 +1,12 @@
<%@jet package="org.eclipse.jet.internal.compiler.templates"
- class="JET2TransformGenerator"
- imports="java.util.Map java.util.Iterator org.eclipse.jet.internal.compiler.LoaderGenerationParameters"
+ class="JET2TransformGenerator"
%>
+<%@jet imports="java.util.Iterator"%>
+<%@jet imports="java.util.Map"%>
+<%@jet imports="org.eclipse.jet.BodyContentWriter"%>
+<%@jet imports="org.eclipse.jet.internal.compiler.LoaderGenerationParameters"%>
<%
-LoaderGenerationParameters parms = (LoaderGenerationParameters)argument;
+LoaderGenerationParameters parms = (LoaderGenerationParameters)context.getVariable("args");
Map templateMap = (Map) parms.getTemplateMap();;
%>
package <%= parms.getPackageName() %>;
@@ -35,7 +38,7 @@ public class <%= parms.getClassName() %> implements JET2TemplateLoader, JET2Temp
<% for(Iterator i = templateMap.entrySet().iterator(); i.hasNext();){
Map.Entry entry = (Map.Entry)i.next();
%>
- pathToFactoryMap.put("<%= entry.getKey() %>",
+ pathToFactoryMap.put("<%= entry.getKey() %>", //$NON-NLS-1$
new TemplateFactoryMethod() {
public JET2Template newTemplate() {
return new <%= entry.getValue() %>();
diff --git a/plugins/org.eclipse.jet/templates/main.jet b/plugins/org.eclipse.jet/templates/main.jet
new file mode 100644
index 0000000..9c22453
--- /dev/null
+++ b/plugins/org.eclipse.jet/templates/main.jet
@@ -0,0 +1,2 @@
+<%@jet class="DummyMain"%>
+<c:log>This transform in not intended to be run.</c:log>
diff --git a/plugins/org.eclipse.jet/templates/tagDataDeclarations.jet b/plugins/org.eclipse.jet/templates/tagDataDeclarations.jet
new file mode 100644
index 0000000..2e58db2
--- /dev/null
+++ b/plugins/org.eclipse.jet/templates/tagDataDeclarations.jet
@@ -0,0 +1,30 @@
+<%@jet class="TagDataDeclGenerator"%>
+<%@jet imports="java.util.Iterator"%>
+<%@jet imports="org.eclipse.jet.taglib.JET2TagException"%>
+<%@jet imports="org.eclipse.jet.compiler.XMLElement"%>
+<%@jet imports="org.eclipse.jet.internal.compiler.MethodBodyCreator"%>
+<%
+ XMLElement element;
+ try {
+ element = (XMLElement)context.getVariable("element");
+ } catch( JET2TagException e) {
+ out.write(e.toString());
+ return;
+ }
+
+ String varName = MethodBodyCreator.tagInfoVariableName(element);
+%>
+ final TagInfo <%= varName %> = new TagInfo("<%=element.getName()%>", //$NON-NLS-1$
+ <%= element.getLine() %>, <%= element.getColumn() %>,
+ new String[] {
+<% for (Iterator i = element.getAttributes().keySet().iterator(); i.hasNext();) {
+ String attrName = (String) i.next(); %>
+ "<%= attrName %>", //$NON-NLS-1$
+<% } %>
+ },
+ new String[] {
+<% for (Iterator i = element.getAttributes().values().iterator(); i.hasNext();) {
+ String attrValue = (String) i.next(); %>
+ "<%= attrValue %>", //$NON-NLS-1$
+<% } %>
+ } );
diff --git a/plugins/org.eclipse.jet/templates/writeJavaExpression.jet b/plugins/org.eclipse.jet/templates/writeJavaExpression.jet
new file mode 100644
index 0000000..54b1571
--- /dev/null
+++ b/plugins/org.eclipse.jet/templates/writeJavaExpression.jet
@@ -0,0 +1,7 @@
+<%@jet class="WriteJavaExpressionTemplate" %>
+<%@jet imports="org.eclipse.jet.compiler.JET2Expression"%>
+<%
+final String indent = (String)context.getVariable("indent"); //$NON-NLS-1$
+final JET2Expression expr = (JET2Expression)context.getVariable("element"); //$NON-NLS-1$
+%>
+<%= indent %>out.write(<%= expr.getJavaContent() %>);
diff --git a/plugins/org.eclipse.jet/templates/writeTextElement.jet b/plugins/org.eclipse.jet/templates/writeTextElement.jet
new file mode 100644
index 0000000..6ed7e53
--- /dev/null
+++ b/plugins/org.eclipse.jet/templates/writeTextElement.jet
@@ -0,0 +1,10 @@
+<%@jet class="WriteTextElementTemplate" %>
+<%@jet imports="org.eclipse.jet.compiler.TextElement"%>
+<%@jet imports="org.eclipse.jet.internal.JavaUtil"%>
+<%
+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) { %>
+<%= indent %>out.write( <%= JavaUtil.asJavaQuotedString(text.getText()) %> ); //$NON-NLS-1$
+<% } %>
diff --git a/plugins/org.eclipse.jet/templates/xmlEnd.javajet b/plugins/org.eclipse.jet/templates/xmlEnd.javajet
deleted file mode 100644
index e1a2d17..0000000
--- a/plugins/org.eclipse.jet/templates/xmlEnd.javajet
+++ /dev/null
@@ -1,15 +0,0 @@
-<%@jet package="org.eclipse.jet.internal.compiler.templates"
- class="XMLEndGenerator"
- imports="org.eclipse.jet.internal.compiler.*"
- %>
-<%
- GenXMLElement element = (GenXMLElement) argument;
-%>
-<% if(element.hasBody()) { %>
- <%= element.getTagVariable() %>.handleBodyContent(out);
- }
-<% if(element.requiresNewWriter()) { %>
- out = <%= element.getTagVariable() %>_saved_out;
-<% } %>
-<% } %>
- <%= element.getTagVariable() %>.doEnd();
diff --git a/plugins/org.eclipse.jet/templates/xmlEnd.jet b/plugins/org.eclipse.jet/templates/xmlEnd.jet
new file mode 100644
index 0000000..b1c5626
--- /dev/null
+++ b/plugins/org.eclipse.jet/templates/xmlEnd.jet
@@ -0,0 +1,13 @@
+<%@jet class="XMLEndGenerator" %>
+<%@jet imports="org.eclipse.jet.internal.compiler.GenXMLElement"%>
+<%
+ GenXMLElement element = (GenXMLElement) context.getVariable("element"); //$NON-NLS-1$
+%>
+<% if(element.hasBody()) { %>
+<c:get select="$indent"/> <%= element.getTagVariable() %>.handleBodyContent(out);
+<c:get select="$indent"/>}
+<% if(element.requiresNewWriter()) { %>
+<c:get select="$indent"/>out = <%= element.getTagVariable() %>_saved_out;
+<% } %>
+<% } %>
+<c:get select="$indent"/><%= element.getTagVariable() %>.doEnd();
diff --git a/plugins/org.eclipse.jet/templates/xmlStart.javajet b/plugins/org.eclipse.jet/templates/xmlStart.javajet
deleted file mode 100644
index 81fc10e..0000000
--- a/plugins/org.eclipse.jet/templates/xmlStart.javajet
+++ /dev/null
@@ -1,21 +0,0 @@
-<%@jet package="org.eclipse.jet.internal.compiler.templates"
- class="XMLStartGenerator"
- imports="org.eclipse.jet.internal.compiler.*"
- %>
-<%
- GenXMLElement element = (GenXMLElement) argument;
-%>
- RuntimeTagElement <%= element.getTagVariable() %> = context.getTagFactory().createRuntimeTag(_jetns_<%= element.getNSPrefix() %>, "<%= element.getTagNCName() %>", "<%= element.getName() %>", <%= element.getTagInfoVariable() %>);
- <%= element.getTagVariable() %>.setRuntimeParent(<%= element.getParentTagVariable() %>);
- <%= element.getTagVariable() %>.setTagInfo(<%= element.getTagInfoVariable() %>);
- <%= element.getTagVariable() %>.doStart(context, out);
-<% if(element.hasBody()) { %>
-<% if(element.requiresNewWriter()) { %>
- JET2Writer <%= element.getTagVariable() %>_saved_out = out;
-<% } %>
- while (<%= element.getTagVariable() %>.okToProcessBody()) {
-<% if(element.requiresNewWriter()) { %>
- out = out.newNestedContentWriter();
-<% } %>
-
-<% } %>
diff --git a/plugins/org.eclipse.jet/templates/xmlStart.jet b/plugins/org.eclipse.jet/templates/xmlStart.jet
new file mode 100644
index 0000000..c0fe1ba
--- /dev/null
+++ b/plugins/org.eclipse.jet/templates/xmlStart.jet
@@ -0,0 +1,18 @@
+<%@jet class="XMLStartGenerator" %>
+<%@jet imports="org.eclipse.jet.internal.compiler.GenXMLElement"%>
+<%
+ GenXMLElement element = (GenXMLElement) context.getVariable("element"); //$NON-NLS-1$
+%>
+<c:get select="$indent"/>RuntimeTagElement <%= element.getTagVariable() %> = context.getTagFactory().createRuntimeTag(_jetns_<%= element.getNSPrefix() %>, "<%= element.getTagNCName() %>", "<%= element.getName() %>", <%= element.getTagInfoVariable() %>);
+<c:get select="$indent"/><%= element.getTagVariable() %>.setRuntimeParent(<%= element.getParentTagVariable() %>);
+<c:get select="$indent"/><%= element.getTagVariable() %>.setTagInfo(<%= element.getTagInfoVariable() %>);
+<c:get select="$indent"/><%= element.getTagVariable() %>.doStart(context, out);
+<% if(element.hasBody()) { %>
+<% if(element.requiresNewWriter()) { %>
+<c:get select="$indent"/>JET2Writer <%= element.getTagVariable() %>_saved_out = out;
+<% } %>
+<c:get select="$indent"/>while (<%= element.getTagVariable() %>.okToProcessBody()) {
+<% if(element.requiresNewWriter()) { %>
+<c:get select="$indent"/> out = out.newNestedContentWriter();
+<% } %>
+<% } %>
diff --git a/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java b/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
index b8c161b..388b5fd 100644
--- a/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
+++ b/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
@@ -7,88 +7,112 @@ import org.eclipse.jet.taglib.RuntimeTagElement;
import org.eclipse.jet.taglib.TagInfo;
public class X implements JET2Template {
+ public static final String _jetns_test = "org.eclipse.jet.tests.TestLibrary"; //$NON-NLS-1$
- public static final String _jetns_test = "org.eclipse.jet.tests.TestLibrary";//$NON-NLS-1$
-
-
-
-
public X() {
super();
}
- public void generate(JET2Context context, JET2Writer out) {
-
- final TagInfo _jettd_test_tokenize_4_1 = new TagInfo( "test:tokenize", 4, 1, new String[] {"sep", "var", "string", }, new String[] {",", "token", "a,b,c,d,e,f,g", });
-final TagInfo _jettd_test_other_5_1 = new TagInfo( "test:other", 5, 1, new String[] {}, new String[] {});
-final TagInfo _jettd_test_isAllUpper_6_1 = new TagInfo( "test:isAllUpper", 6, 1, new String[] {"var", }, new String[] {"token", });
-final TagInfo _jettd_test_upper_8_1 = new TagInfo( "test:upper", 8, 1, new String[] {}, new String[] {});
-final TagInfo _jettd_test_nl_8_29 = new TagInfo( "test:nl", 8, 29, new String[] {}, new String[] {});
-final TagInfo _jettd_test_other_9_1 = new TagInfo( "test:other", 9, 1, new String[] {}, new String[] {});
-
-
- out.write("\r\n\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\"\r\n\r\n");
- RuntimeTagElement _jettag_test_tokenize_4_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "tokenize", "test:tokenize", _jettd_test_tokenize_4_1);
- _jettag_test_tokenize_4_1.setRuntimeParent(null);
- _jettag_test_tokenize_4_1.setTagInfo(_jettd_test_tokenize_4_1);
- _jettag_test_tokenize_4_1.doStart(context, out);
- while (_jettag_test_tokenize_4_1.okToProcessBody()) {
-
-out.write("\r\n");
- RuntimeTagElement _jettag_test_other_5_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_5_1);
- _jettag_test_other_5_1.setRuntimeParent(_jettag_test_tokenize_4_1);
- _jettag_test_other_5_1.setTagInfo(_jettd_test_other_5_1);
- _jettag_test_other_5_1.doStart(context, out);
- while (_jettag_test_other_5_1.okToProcessBody()) {
-
-out.write("some text");
- _jettag_test_other_5_1.handleBodyContent(out);
- }
- _jettag_test_other_5_1.doEnd();
-out.write("\r\n");
- RuntimeTagElement _jettag_test_isAllUpper_6_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "isAllUpper", "test:isAllUpper", _jettd_test_isAllUpper_6_1);
- _jettag_test_isAllUpper_6_1.setRuntimeParent(_jettag_test_tokenize_4_1);
- _jettag_test_isAllUpper_6_1.setTagInfo(_jettd_test_isAllUpper_6_1);
- _jettag_test_isAllUpper_6_1.doStart(context, out);
- while (_jettag_test_isAllUpper_6_1.okToProcessBody()) {
-
-out.write("\r\n");
- _jettag_test_isAllUpper_6_1.handleBodyContent(out);
- }
- _jettag_test_isAllUpper_6_1.doEnd();
-out.write("\r\n");
- RuntimeTagElement _jettag_test_upper_8_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "upper", "test:upper", _jettd_test_upper_8_1);
- _jettag_test_upper_8_1.setRuntimeParent(_jettag_test_tokenize_4_1);
- _jettag_test_upper_8_1.setTagInfo(_jettd_test_upper_8_1);
- _jettag_test_upper_8_1.doStart(context, out);
- JET2Writer _jettag_test_upper_8_1_saved_out = out;
- while (_jettag_test_upper_8_1.okToProcessBody()) {
- out = out.newNestedContentWriter();
-
-out.write("foo");
- _jettag_test_upper_8_1.handleBodyContent(out);
- }
- out = _jettag_test_upper_8_1_saved_out;
- _jettag_test_upper_8_1.doEnd();
- RuntimeTagElement _jettag_test_nl_8_29 = context.getTagFactory().createRuntimeTag(_jetns_test, "nl", "test:nl", _jettd_test_nl_8_29);
- _jettag_test_nl_8_29.setRuntimeParent(_jettag_test_tokenize_4_1);
- _jettag_test_nl_8_29.setTagInfo(_jettd_test_nl_8_29);
- _jettag_test_nl_8_29.doStart(context, out);
-
- _jettag_test_nl_8_29.doEnd();
-out.write("\r\n");
- RuntimeTagElement _jettag_test_other_9_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_9_1);
- _jettag_test_other_9_1.setRuntimeParent(_jettag_test_tokenize_4_1);
- _jettag_test_other_9_1.setTagInfo(_jettd_test_other_9_1);
- _jettag_test_other_9_1.doStart(context, out);
-
- _jettag_test_other_9_1.doEnd();
-out.write("\r\n");
- _jettag_test_tokenize_4_1.handleBodyContent(out);
- }
- _jettag_test_tokenize_4_1.doEnd();
+ public void generate(final JET2Context context, JET2Writer out) {
+ final TagInfo _jettd_test_tokenize_4_1 = new TagInfo("test:tokenize", //$NON-NLS-1$
+ 4, 1,
+ new String[] {
+ "sep", //$NON-NLS-1$
+ "var", //$NON-NLS-1$
+ "string", //$NON-NLS-1$
+ },
+ new String[] {
+ ",", //$NON-NLS-1$
+ "token", //$NON-NLS-1$
+ "a,b,c,d,e,f,g", //$NON-NLS-1$
+ } );
+ final TagInfo _jettd_test_other_5_1 = new TagInfo("test:other", //$NON-NLS-1$
+ 5, 1,
+ new String[] {
+ },
+ new String[] {
+ } );
+ final TagInfo _jettd_test_isAllUpper_6_1 = new TagInfo("test:isAllUpper", //$NON-NLS-1$
+ 6, 1,
+ new String[] {
+ "var", //$NON-NLS-1$
+ },
+ new String[] {
+ "token", //$NON-NLS-1$
+ } );
+ final TagInfo _jettd_test_upper_8_1 = new TagInfo("test:upper", //$NON-NLS-1$
+ 8, 1,
+ new String[] {
+ },
+ new String[] {
+ } );
+ final TagInfo _jettd_test_nl_8_29 = new TagInfo("test:nl", //$NON-NLS-1$
+ 8, 29,
+ new String[] {
+ },
+ new String[] {
+ } );
+ final TagInfo _jettd_test_other_9_1 = new TagInfo("test:other", //$NON-NLS-1$
+ 9, 1,
+ new String[] {
+ },
+ new String[] {
+ } );
+ out.write( "\r\n\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\"\r\n\r\n" ); //$NON-NLS-1$
+ RuntimeTagElement _jettag_test_tokenize_4_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "tokenize", "test:tokenize", _jettd_test_tokenize_4_1);
+ _jettag_test_tokenize_4_1.setRuntimeParent(null);
+ _jettag_test_tokenize_4_1.setTagInfo(_jettd_test_tokenize_4_1);
+ _jettag_test_tokenize_4_1.doStart(context, out);
+ while (_jettag_test_tokenize_4_1.okToProcessBody()) {
+ out.write( "\r\n" ); //$NON-NLS-1$
+ RuntimeTagElement _jettag_test_other_5_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_5_1);
+ _jettag_test_other_5_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_other_5_1.setTagInfo(_jettd_test_other_5_1);
+ _jettag_test_other_5_1.doStart(context, out);
+ while (_jettag_test_other_5_1.okToProcessBody()) {
+ out.write( "some text" ); //$NON-NLS-1$
+ _jettag_test_other_5_1.handleBodyContent(out);
+ }
+ _jettag_test_other_5_1.doEnd();
+ out.write( "\r\n" ); //$NON-NLS-1$
+ RuntimeTagElement _jettag_test_isAllUpper_6_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "isAllUpper", "test:isAllUpper", _jettd_test_isAllUpper_6_1);
+ _jettag_test_isAllUpper_6_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_isAllUpper_6_1.setTagInfo(_jettd_test_isAllUpper_6_1);
+ _jettag_test_isAllUpper_6_1.doStart(context, out);
+ while (_jettag_test_isAllUpper_6_1.okToProcessBody()) {
+ out.write( "\r\n" ); //$NON-NLS-1$
+ _jettag_test_isAllUpper_6_1.handleBodyContent(out);
+ }
+ _jettag_test_isAllUpper_6_1.doEnd();
+ out.write( "\r\n" ); //$NON-NLS-1$
+ RuntimeTagElement _jettag_test_upper_8_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "upper", "test:upper", _jettd_test_upper_8_1);
+ _jettag_test_upper_8_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_upper_8_1.setTagInfo(_jettd_test_upper_8_1);
+ _jettag_test_upper_8_1.doStart(context, out);
+ JET2Writer _jettag_test_upper_8_1_saved_out = out;
+ while (_jettag_test_upper_8_1.okToProcessBody()) {
+ out = out.newNestedContentWriter();
+ out.write( "foo" ); //$NON-NLS-1$
+ _jettag_test_upper_8_1.handleBodyContent(out);
+ }
+ out = _jettag_test_upper_8_1_saved_out;
+ _jettag_test_upper_8_1.doEnd();
+ RuntimeTagElement _jettag_test_nl_8_29 = context.getTagFactory().createRuntimeTag(_jetns_test, "nl", "test:nl", _jettd_test_nl_8_29);
+ _jettag_test_nl_8_29.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_nl_8_29.setTagInfo(_jettd_test_nl_8_29);
+ _jettag_test_nl_8_29.doStart(context, out);
+ _jettag_test_nl_8_29.doEnd();
+ out.write( "\r\n" ); //$NON-NLS-1$
+ RuntimeTagElement _jettag_test_other_9_1 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_9_1);
+ _jettag_test_other_9_1.setRuntimeParent(_jettag_test_tokenize_4_1);
+ _jettag_test_other_9_1.setTagInfo(_jettd_test_other_9_1);
+ _jettag_test_other_9_1.doStart(context, out);
+ _jettag_test_other_9_1.doEnd();
+ out.write( "\r\n" ); //$NON-NLS-1$
+ _jettag_test_tokenize_4_1.handleBodyContent(out);
+ }
+ _jettag_test_tokenize_4_1.doEnd();
}
}
- \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
index 79f3ad8..1339b0b 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
@@ -6,6 +6,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
+import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
@@ -23,7 +24,7 @@ import org.eclipse.jet.compiler.TextElement;
import org.eclipse.jet.compiler.XMLBodyElement;
import org.eclipse.jet.compiler.XMLBodyElementEnd;
import org.eclipse.jet.compiler.XMLEmptyElement;
-import org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator;
+import org.eclipse.jet.internal.compiler.TemplateRunner;
import org.eclipse.jet.taglib.TagLibraryReference;
import org.eclipse.jet.tests.FileUtils;
@@ -243,11 +244,10 @@ public class TestJET2Parser extends TestCase {
JET2CompilationUnit cu = new JET2CompilationUnit();
cu.parse(is, "UTF-8");
- JET2JavaGenerator writer = new JET2JavaGenerator();
-
cu.setOutputJavaPackage(JET2Compiler.DEFAULT_COMPILED_TEMPLATE_PACKAGE);
cu.setOutputJavaClassName("X");
- String result = writer.generate(cu);
+
+ String result = new TemplateRunner().generate("templates/jet2java.jet", Collections.singletonMap("cu", cu));
assertEquals(FileUtils.getFileContents(urlString + ".expected.java", true), result);