Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-04-06 08:15:52 +0000
committerpelder2006-04-06 08:15:52 +0000
commitbc38c517915485c0098f34d211e8466967ffac2d (patch)
treeaab5ce01e38483db01a6430a4ab8e7ba7e64795d /plugins/org.eclipse.jet/templates
parent8ea3b729df7d062f3c7e68a8a2c3c7d2f40d80c7 (diff)
downloadorg.eclipse.jet-bc38c517915485c0098f34d211e8466967ffac2d.tar.gz
org.eclipse.jet-bc38c517915485c0098f34d211e8466967ffac2d.tar.xz
org.eclipse.jet-bc38c517915485c0098f34d211e8466967ffac2d.zip
[131187] Implement overriding of JET templates plus tags to support.
Diffstat (limited to 'plugins/org.eclipse.jet/templates')
-rw-r--r--plugins/org.eclipse.jet/templates/jet2java.javajet17
-rw-r--r--plugins/org.eclipse.jet/templates/jet2transform.javajet23
2 files changed, 25 insertions, 15 deletions
diff --git a/plugins/org.eclipse.jet/templates/jet2java.javajet b/plugins/org.eclipse.jet/templates/jet2java.javajet
index f13dfc7..c4ba6b0 100644
--- a/plugins/org.eclipse.jet/templates/jet2java.javajet
+++ b/plugins/org.eclipse.jet/templates/jet2java.javajet
@@ -1,6 +1,6 @@
<%@jet package="org.eclipse.jet.internal.compiler.templates"
class="JET2JavaGenerator"
- imports="org.eclipse.jet.internal.compiler.* org.eclipse.jet.compiler.* java.util.Iterator"
+ imports="org.eclipse.jet.internal.compiler.* org.eclipse.jet.compiler.* org.eclipse.jet.taglib.TagLibraryReference java.util.Iterator java.util.Map"
%>
<%
JET2CompilationUnit cu = (JET2CompilationUnit)argument;
@@ -13,19 +13,18 @@
});
final StringBuffer tagNamespaceVariables = new StringBuffer();
- cu.accept(new DefaultJET2ASTVisitor() {
- public void visit(JET2Directive directive) {
- if("taglib".equals(directive.getName())) {
+ TagLibraryReference[] tlRefs = cu.getTagLibraryReferences();
+ for(int i = 0; i < tlRefs.length; i++ ) {
+ ;
tagNamespaceVariables.append("public static final String _jetns_")
- .append(directive.getAttributes().get("prefix"))
+ .append(tlRefs[i].getPrefix())
.append(" = \"")
- .append(directive.getAttributes().get("id"))
+ .append(tlRefs[i].getTagLibraryId())
.append("\";")
.append("//$NON-NLS-1$")
.append(NL);
- }
- }
- });
+
+ }
final StringBuffer tagDataDeclarations = new StringBuffer();
cu.accept(new DefaultJET2ASTVisitor() {
diff --git a/plugins/org.eclipse.jet/templates/jet2transform.javajet b/plugins/org.eclipse.jet/templates/jet2transform.javajet
index c29f539..77bdd59 100644
--- a/plugins/org.eclipse.jet/templates/jet2transform.javajet
+++ b/plugins/org.eclipse.jet/templates/jet2transform.javajet
@@ -1,27 +1,31 @@
<%@jet package="org.eclipse.jet.internal.compiler.templates"
class="JET2TransformGenerator"
- imports="java.util.Map java.util.Iterator"
+ imports="java.util.Map java.util.Iterator org.eclipse.jet.internal.compiler.LoaderGenerationParameters"
%>
<%
-Map templateMap = (Map) argument;
+LoaderGenerationParameters parms = (LoaderGenerationParameters)argument;
+Map templateMap = (Map) parms.getTemplateMap();;
%>
-package org.eclipse.jet.compiled;
+package <%= parms.getPackageName() %>;
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 _jet_transformation implements JET2TemplateLoader {
+public class <%= parms.getClassName() %> implements JET2TemplateLoader, JET2TemplateLoaderExtension {
private interface TemplateFactoryMethod {
public abstract JET2Template newTemplate();
}
private Map pathToFactoryMap = null;
+
+ private JET2TemplateLoader delegate = null;
- public _jet_transformation() {
+ public <%= parms.getClassName() %>() {
super();
}
@@ -40,8 +44,15 @@ public class _jet_transformation implements JET2TemplateLoader {
<% } %>
}
TemplateFactoryMethod factory = (TemplateFactoryMethod)pathToFactoryMap.get(templatePath);
- return factory == null ? null : factory.newTemplate();
+ return factory == null ? delegate == null ? null : delegate.getTemplate(templatePath) : factory.newTemplate();
}
+ public void setDelegateLoader(JET2TemplateLoader loader) {
+ this.delegate = loader;
+ }
+
+ public JET2TemplateLoader getDelegateLoader() {
+ return delegate;
+ }
}

Back to the top