Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2011-01-27 09:56:42 -0500
committerpelder2011-01-27 09:56:42 -0500
commitdacb915e6f53091ab65b15b2169ac577a437e338 (patch)
tree61ef49754baec1fe4c2f69cad5a8efa5f73eadb7
parentd26dd2955b37d1bcff7582b3a1529ac9632b0473 (diff)
downloadorg.eclipse.jet-dacb915e6f53091ab65b15b2169ac577a437e338.tar.gz
org.eclipse.jet-dacb915e6f53091ab65b15b2169ac577a437e338.tar.xz
org.eclipse.jet-dacb915e6f53091ab65b15b2169ac577a437e338.zip
[329257] Java HCR Friendly code generation option
-rw-r--r--plugins/org.eclipse.jet-feature/feature.xml2
-rwxr-xr-xplugins/org.eclipse.jet.all-feature/feature.xml2
-rw-r--r--plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/compiler/JETCompilerOptions.java4
-rw-r--r--plugins/org.eclipse.jet.sdk-feature/feature.xml2
-rw-r--r--plugins/org.eclipse.jet/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/SimplifiedCompiler.java11
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/TagUsageVisitor.java43
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/v2/JET2JavaGeneratorNew.java105
-rw-r--r--plugins/org.eclipse.jet/templates/v2/jet2java.jet73
10 files changed, 204 insertions, 42 deletions
diff --git a/plugins/org.eclipse.jet-feature/feature.xml b/plugins/org.eclipse.jet-feature/feature.xml
index de57f86..435ba87 100644
--- a/plugins/org.eclipse.jet-feature/feature.xml
+++ b/plugins/org.eclipse.jet-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.jet"
label="%featureName"
- version="1.1.0.qualifier"
+ version="1.1.1.qualifier"
provider-name="%providerName">
<description url="http://www.eclipse.org/modeling/m2t">
diff --git a/plugins/org.eclipse.jet.all-feature/feature.xml b/plugins/org.eclipse.jet.all-feature/feature.xml
index 72d8a32..6e6b806 100755
--- a/plugins/org.eclipse.jet.all-feature/feature.xml
+++ b/plugins/org.eclipse.jet.all-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.jet.all"
label="%featureName"
- version="1.1.0.qualifier"
+ version="1.1.1.qualifier"
provider-name="%providerName">
<description>
diff --git a/plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF
index ae5c90e..866a6b2 100644
--- a/plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jet.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jet.core
-Bundle-Version: 1.2.0.qualifier
+Bundle-Version: 1.2.1.qualifier
Bundle-Localization: plugin
Eclipse-LazyStart: true
Export-Package: org.eclipse.jet,
diff --git a/plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/compiler/JETCompilerOptions.java b/plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/compiler/JETCompilerOptions.java
index bceb55d..0f2f90a 100644
--- a/plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/compiler/JETCompilerOptions.java
+++ b/plugins/org.eclipse.jet.core/src/org/eclipse/jet/core/compiler/JETCompilerOptions.java
@@ -12,7 +12,7 @@
*
* </copyright>
*
- * $Id: JETCompilerOptions.java,v 1.5 2009/04/07 17:44:50 pelder Exp $
+ * $Id: JETCompilerOptions.java,v 1.6 2011/01/27 14:56:42 pelder Exp $
*/
package org.eclipse.jet.core.compiler;
@@ -194,6 +194,8 @@ public final class JETCompilerOptions {
map.put(OPTION_V1_TEMPLATES_DIR, DEFAULT_V1_TEMPLATES_DIR);
map.put(OPTION_JAVA_OUTPUT_FOLDER, DEFAULT_JAVA_OUTPUT_FOLDER);
map.put(OPTION_USE_JAVA5, DEFAULT_USE_JAVA5);
+
+ map.put("org.eclipse.jet.hcrFriendly", "false");
synchronized (defaultCompileOptionsLock) {
defaultCompileOptions = Collections.unmodifiableMap(map);
diff --git a/plugins/org.eclipse.jet.sdk-feature/feature.xml b/plugins/org.eclipse.jet.sdk-feature/feature.xml
index e1c5f67..7d79a49 100644
--- a/plugins/org.eclipse.jet.sdk-feature/feature.xml
+++ b/plugins/org.eclipse.jet.sdk-feature/feature.xml
@@ -2,7 +2,7 @@
<feature
id="org.eclipse.jet.sdk"
label="%featureName"
- version="1.1.0.qualifier"
+ version="1.1.1.qualifier"
provider-name="%providerName">
<description>
diff --git a/plugins/org.eclipse.jet/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
index 022cc85..b9a71f0 100644
--- a/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jet;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.1.1.qualifier
Bundle-Activator: org.eclipse.jet.internal.InternalJET2Platform
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ant.core;bundle-version="[3.1.100,4.0.0)",
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/SimplifiedCompiler.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/SimplifiedCompiler.java
index f96272f..7db1918 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/SimplifiedCompiler.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/SimplifiedCompiler.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2007, 2009 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 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
@@ -12,7 +12,7 @@
*
* </copyright>
*
- * $Id: SimplifiedCompiler.java,v 1.5 2009/04/07 17:44:54 pelder Exp $
+ * $Id: SimplifiedCompiler.java,v 1.6 2011/01/27 14:56:41 pelder Exp $
*/
package org.eclipse.jet.internal.compiler;
@@ -55,6 +55,7 @@ import org.eclipse.jet.taglib.TagLibraryReference;
public final class SimplifiedCompiler implements IJETCompiler
{
+ private static final String OPTION_KEY_HCR_FRIENDLY = "org.eclipse.jet.hcrFriendly"; //$NON-NLS-1$
private static final String JET_TEMPLATE_MAP_PROPERTIES = "jetTemplateMap.properties"; //$NON-NLS-1$
private static final class NullTemplateResolver implements ITemplateResolver
@@ -365,7 +366,11 @@ public final class SimplifiedCompiler implements IJETCompiler
TemplateRunner templateRunner = new TemplateRunner();
// XXX make this more open
String cgTemplatePath = jetSpec == JETAST.JET_SPEC_V1 ? "templates/v1/jet2java.jet" : "templates/v2/jet2java.jet"; //$NON-NLS-1$ //$NON-NLS-2$
- String code = templateRunner.generate(cgTemplatePath, Collections.singletonMap("cu", cu)); //$NON-NLS-1$
+ final Map jetVariables = new HashMap();
+ jetVariables.put("cu", cu); //$NON-NLS-1$
+ jetVariables.put("hcrFriendly", //$NON-NLS-1$
+ Boolean.valueOf((String)options.get(OPTION_KEY_HCR_FRIENDLY)));
+ String code = templateRunner.generate(cgTemplatePath, jetVariables);
// save the code to the output location
String outputPath = outputPath(cu.getOutputJavaPackage(), cu.getOutputJavaClassName());
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/TagUsageVisitor.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/TagUsageVisitor.java
index fa19876..81d9537 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/TagUsageVisitor.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/TagUsageVisitor.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2010 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
@@ -12,18 +12,21 @@
*
* </copyright>
*
- * $Id: TagUsageVisitor.java,v 1.1 2007/04/04 14:59:32 pelder Exp $
+ * $Id: TagUsageVisitor.java,v 1.2 2011/01/27 14:56:41 pelder Exp $
*/
package org.eclipse.jet.internal.compiler;
import java.util.ArrayList;
import java.util.HashSet;
+import java.util.IdentityHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.jet.core.parser.ast.JETASTVisitor;
import org.eclipse.jet.core.parser.ast.JETCompilationUnit;
import org.eclipse.jet.core.parser.ast.XMLBodyElement;
+import org.eclipse.jet.core.parser.ast.XMLElement;
import org.eclipse.jet.core.parser.ast.XMLEmptyElement;
import org.eclipse.jet.taglib.TagLibraryReference;
@@ -34,19 +37,36 @@ public class TagUsageVisitor extends JETASTVisitor
{
private boolean hasTags = false;
+ private boolean hasAttributelessTags = false;
+
private Set nsPrefixesUsed = new HashSet();
+ private Map tagOrdinals = new IdentityHashMap();
+
+ private void handleTagElement(XMLElement xmlTagElement) {
+ nsPrefixesUsed.add(xmlTagElement.getNSPrefix());
+ hasTags = true;
+ if(!tagOrdinals.containsKey(xmlTagElement)) {
+ tagOrdinals.put(xmlTagElement, new Integer(tagOrdinals.size()));
+ }
+ if(xmlTagElement.getAttributes().size() == 0) {
+ hasAttributelessTags = true;
+ }
+ }
+
+ public boolean hasAttributelessTags() {
+ return hasAttributelessTags;
+ }
+
public boolean visit(XMLBodyElement xmlBodyElement)
{
- nsPrefixesUsed.add(xmlBodyElement.getNSPrefix());
- hasTags = true;
+ handleTagElement(xmlBodyElement);
return true;
}
public boolean visit(XMLEmptyElement xmlEmptyElement)
{
- nsPrefixesUsed.add(xmlEmptyElement.getNSPrefix());
- hasTags = true;
+ handleTagElement(xmlEmptyElement);
return true;
}
@@ -76,4 +96,15 @@ public class TagUsageVisitor extends JETASTVisitor
return (TagLibraryReference[])usedRefs.toArray(new TagLibraryReference[usedRefs.size()]);
}
+ public int ordinal(XMLElement xmlTagElement) {
+ Integer result = (Integer)tagOrdinals.get(xmlTagElement);
+ if(result == null) {
+ throw new IllegalStateException("Tag ordinals have not yet been computed"); //$NON-NLS-1$
+ }
+ return result.intValue();
+ }
+
+ public String ordinalExpr(XMLElement xmlTagElement) {
+ return "[" + ordinal(xmlTagElement) + "]"; //$NON-NLS-1$//$NON-NLS-2$
+ }
}
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 5c5189a..740f274 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
@@ -24,8 +24,10 @@ public class JET2JavaGeneratorNew implements JET2Template {
public void generate(final JET2Context context, final JET2Writer __out) {
JET2Writer out = __out;
+ final boolean hcrFriendly = context.hasVariable("hcrFriendly") //$NON-NLS-1$
+ ? ((Boolean)context.getVariable("hcrFriendly")).booleanValue() : false; //$NON-NLS-1$
JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
- TagUsageVisitor tuv = new TagUsageVisitor();
+ final TagUsageVisitor tuv = new TagUsageVisitor();
cu.accept(tuv);
TagLibraryReference[] tlrefs = tuv.getUsedTagLibraryReferences(cu);
Arrays.sort(tlrefs, new Comparator() {
@@ -95,23 +97,18 @@ cu.accept(new V2CodeGenVisitor(context,out, "") { //$NON-NLS-1$
out.write("public class "); //$NON-NLS-1$
out.write( cu.getOutputJavaClassName() );
-
- if (cu.getExtend() != null) {
-
- out.write(" extends "); //$NON-NLS-1$
- out.write( cu.getExtend() );
-
- }
out.write(" implements JET2Template {"); //$NON-NLS-1$
out.write(NL);
- for(int i = 0; i < tlrefs.length; i++ ) {
+ if(!hcrFriendly) {
+ for(int i = 0; i < tlrefs.length; i++ ) {
out.write(" private static final String _jetns_"); //$NON-NLS-1$
out.write( tlrefs[i].getPrefix() );
out.write(" = \""); //$NON-NLS-1$
out.write( tlrefs[i].getTagLibraryId() );
out.write("\"; //$NON-NLS-1$"); //$NON-NLS-1$
out.write(NL);
- }
+ }
+ }
out.write(NL);
cu.accept(new V2CodeGenVisitor(context,out) {
public boolean visit(JavaDeclaration decl) {
@@ -138,7 +135,7 @@ cu.accept(new V2CodeGenVisitor(context,out, "") { //$NON-NLS-1$
out.write(" = System.getProperty(\"line.separator\"); //$NON-NLS-1$"); //$NON-NLS-1$
out.write(NL);
}
- if(tuv.hasTags()) {
+ if(tuv.hasTags() && !hcrFriendly) {
out.write(" "); //$NON-NLS-1$
out.write(NL);
cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
@@ -188,9 +185,87 @@ cu.accept(new V2CodeGenVisitor(context,out, "") { //$NON-NLS-1$
}
});
}
+ if(tuv.hasTags() && hcrFriendly) {
+ out.write(NL);
+ out.write(" private TagInfo[] _init_tagInfo() { "); //$NON-NLS-1$
+ out.write(NL);
+ if(tuv.hasAttributelessTags()) {
+ out.write(" final String[] EMPTY_STRING_ARRAY = new String[0];"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ out.write(" return new TagInfo[] {"); //$NON-NLS-1$
+ out.write(NL);
+ cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
+ public boolean visit(XMLBodyElement e) {
+ doElementVisit(e);
+ return true;
+ }
+ public boolean visit(XMLEmptyElement e) {
+ doElementVisit(e);
+ return true;
+ }
+ public void doElementVisit(XMLElement e) {
+
+ out.write(" new TagInfo(\""); //$NON-NLS-1$
+ out.write(e.getName());
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ out.write(" "); //$NON-NLS-1$
+ out.write( e.getLine() );
+ out.write(", "); //$NON-NLS-1$
+ out.write( e.getColumn() );
+ out.write(","); //$NON-NLS-1$
+ out.write(NL);
+ if(e.getAttributes().size() > 0) {
+ out.write(" new String[] {"); //$NON-NLS-1$
+ out.write(NL);
+ for (Iterator i = e.getAttributes().keySet().iterator(); i.hasNext();) {
+ out.write(" \""); //$NON-NLS-1$
+ out.write( (String) i.next() );
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ 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(" \""); //$NON-NLS-1$
+ out.write( JavaUtil.escapeJavaString(attrValue.toCharArray()) );
+ out.write("\", //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ out.write(" } ),"); //$NON-NLS-1$
+ out.write(NL);
+ } else {
+ out.write(" EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY ),"); //$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(" public void generate(final JET2Context context, final JET2Writer __out) {"); //$NON-NLS-1$
out.write(NL);
+ if(hcrFriendly) {
+ for(int i = 0; i < tlrefs.length; i++ ) {
+ out.write(" final String _jetns_"); //$NON-NLS-1$
+ out.write( tlrefs[i].getPrefix() );
+ out.write(" = \""); //$NON-NLS-1$
+ out.write( tlrefs[i].getTagLibraryId() );
+ out.write("\"; //$NON-NLS-1$"); //$NON-NLS-1$
+ out.write(NL);
+ }
+ if(tuv.hasTags()) {
+ out.write(" final TagInfo[] _td_ = _init_tagInfo();"); //$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$
@@ -252,7 +327,7 @@ cu.accept(new V2CodeGenVisitor(context,out, "") { //$NON-NLS-1$
out.write("\", \""); //$NON-NLS-1$
out.write( e.getName() );
out.write("\", _td_"); //$NON-NLS-1$
- out.write( tagInfoVar(e) );
+ out.write( hcrFriendly ? tuv.ordinalExpr(e) : tagInfoVar(e) );
out.write("); //$NON-NLS-1$ //$NON-NLS-2$"); //$NON-NLS-1$
out.write(NL);
out.write(" "); //$NON-NLS-1$
@@ -264,7 +339,7 @@ cu.accept(new V2CodeGenVisitor(context,out, "") { //$NON-NLS-1$
out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
out.write(".setTagInfo(_td_"); //$NON-NLS-1$
- out.write( tagInfoVar(e) );
+ out.write( hcrFriendly ? tuv.ordinalExpr(e) : tagInfoVar(e) );
out.write(");"); //$NON-NLS-1$
out.write(NL);
out.write(" "); //$NON-NLS-1$
@@ -322,7 +397,7 @@ cu.accept(new V2CodeGenVisitor(context,out, "") { //$NON-NLS-1$
out.write("\", \""); //$NON-NLS-1$
out.write( e.getName() );
out.write("\", _td_"); //$NON-NLS-1$
- out.write( tagInfoVar(e) );
+ out.write( hcrFriendly ? tuv.ordinalExpr(e) : tagInfoVar(e) );
out.write("); //$NON-NLS-1$ //$NON-NLS-2$"); //$NON-NLS-1$
out.write(NL);
out.write(" "); //$NON-NLS-1$
@@ -334,7 +409,7 @@ cu.accept(new V2CodeGenVisitor(context,out, "") { //$NON-NLS-1$
out.write(" "); //$NON-NLS-1$
out.write( tagVar(e) );
out.write(".setTagInfo(_td_"); //$NON-NLS-1$
- out.write( tagInfoVar(e) );
+ out.write( hcrFriendly ? tuv.ordinalExpr(e) : tagInfoVar(e) );
out.write(");"); //$NON-NLS-1$
out.write(NL);
out.write(" "); //$NON-NLS-1$
diff --git a/plugins/org.eclipse.jet/templates/v2/jet2java.jet b/plugins/org.eclipse.jet/templates/v2/jet2java.jet
index d176461..654030f 100644
--- a/plugins/org.eclipse.jet/templates/v2/jet2java.jet
+++ b/plugins/org.eclipse.jet/templates/v2/jet2java.jet
@@ -11,8 +11,10 @@
<%@jet imports="java.util.Iterator"%>
<%@jet imports="org.eclipse.jet.internal.JavaUtil"%>
<%
+ final boolean hcrFriendly = context.hasVariable("hcrFriendly") //$NON-NLS-1$
+ ? ((Boolean)context.getVariable("hcrFriendly")).booleanValue() : false; //$NON-NLS-1$
JETCompilationUnit cu = (JETCompilationUnit)context.getVariable("cu"); //$NON-NLS-1$
- TagUsageVisitor tuv = new TagUsageVisitor();
+ final TagUsageVisitor tuv = new TagUsageVisitor();
cu.accept(tuv);
TagLibraryReference[] tlrefs = tuv.getUsedTagLibraryReferences(cu);
Arrays.sort(tlrefs, new Comparator() {
@@ -65,13 +67,12 @@ import <%= (String)i.next() %>;
}
});
%>
-public class <%= cu.getOutputJavaClassName() %><%
- if (cu.getExtend() != null) {
- %> extends <%= cu.getExtend() %><%
- }%> implements JET2Template {
-<% for(int i = 0; i < tlrefs.length; i++ ) { %>
+public class <%= cu.getOutputJavaClassName() %> implements JET2Template {
+<% if(!hcrFriendly) {
+ for(int i = 0; i < tlrefs.length; i++ ) { %>
private static final String _jetns_<%= tlrefs[i].getPrefix() %> = "<%= tlrefs[i].getTagLibraryId() %>"; //$NON-NLS-1$
-<% } %>
+<% }
+ } %>
<% cu.accept(new V2CodeGenVisitor(context,out) {
public boolean visit(JavaDeclaration decl) {
@@ -90,7 +91,7 @@ public class <%= cu.getOutputJavaClassName() %><%
private static final String <%=nlConstantName%> = System.getProperty("line.separator"); //$NON-NLS-1$
<% } %>
-<% if(tuv.hasTags()) { %>
+<% if(tuv.hasTags() && !hcrFriendly) { %>
<% cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
public boolean visit(XMLBodyElement e) {
@@ -119,8 +120,56 @@ public class <%= cu.getOutputJavaClassName() %><%
<% }
}); %>
<% } %>
+<% if(tuv.hasTags() && hcrFriendly) { %>
+
+ private TagInfo[] _init_tagInfo() {
+<% if(tuv.hasAttributelessTags()) { %>
+ final String[] EMPTY_STRING_ARRAY = new String[0];
+<% } %>
+ return new TagInfo[] {
+<% cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
+ public boolean visit(XMLBodyElement e) {
+ doElementVisit(e);
+ return true;
+ }
+ public boolean visit(XMLEmptyElement e) {
+ doElementVisit(e);
+ return true;
+ }
+ public void doElementVisit(XMLElement e) {
+%>
+ new TagInfo("<%=e.getName()%>", //$NON-NLS-1$
+ <%= e.getLine() %>, <%= e.getColumn() %>,
+<% if(e.getAttributes().size() > 0) { %>
+ new String[] {
+<% for (Iterator i = e.getAttributes().keySet().iterator(); i.hasNext();) { %>
+ "<%= (String) i.next() %>", //$NON-NLS-1$
+<% } %>
+ },
+ new String[] {
+<% for (Iterator i = e.getAttributes().values().iterator(); i.hasNext();) {
+ String attrValue = (String) i.next(); %>
+ "<%= JavaUtil.escapeJavaString(attrValue.toCharArray()) %>", //$NON-NLS-1$
+<% } %>
+ } ),
+<% } else { %>
+ EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY ),
+<% } %>
+<% }
+ }); %>
+ };
+ }
+<% } %>
public void generate(final JET2Context context, final JET2Writer __out) {
+<% if(hcrFriendly) {
+ for(int i = 0; i < tlrefs.length; i++ ) { %>
+ final String _jetns_<%= tlrefs[i].getPrefix() %> = "<%= tlrefs[i].getTagLibraryId() %>"; //$NON-NLS-1$
+<% }
+ if(tuv.hasTags()) { %>
+ final TagInfo[] _td_ = _init_tagInfo();
+<% }
+ } %>
JET2Writer out = __out;
<% cu.accept(new V2CodeGenVisitor(context,out, " ") { //$NON-NLS-1$
public boolean visit(TextElement text) {
@@ -155,9 +204,9 @@ public class <%= cu.getOutputJavaClassName() %><%
}
public boolean visit(XMLBodyElement e) {
%>
- RuntimeTagElement <%= tagVar(e) %> = context.getTagFactory().createRuntimeTag(_jetns_<%= e.getNSPrefix() %>, "<%= e.getTagNCName() %>", "<%= e.getName() %>", _td_<%= tagInfoVar(e) %>); //$NON-NLS-1$ //$NON-NLS-2$
+ RuntimeTagElement <%= tagVar(e) %> = context.getTagFactory().createRuntimeTag(_jetns_<%= e.getNSPrefix() %>, "<%= e.getTagNCName() %>", "<%= e.getName() %>", _td_<%= hcrFriendly ? tuv.ordinalExpr(e) : tagInfoVar(e) %>); //$NON-NLS-1$ //$NON-NLS-2$
<%= tagVar(e) %>.setRuntimeParent(<%= parentTagVar(e) %>);
- <%= tagVar(e) %>.setTagInfo(_td_<%= tagInfoVar(e) %>);
+ <%= tagVar(e) %>.setTagInfo(_td_<%= hcrFriendly ? tuv.ordinalExpr(e) : tagInfoVar(e) %>);
<%= tagVar(e) %>.doStart(context, out);
<% if(requiresOwnWriter(e)) { %>
JET2Writer <%= tagVar(e) %>_saved_out = out;
@@ -184,9 +233,9 @@ public class <%= cu.getOutputJavaClassName() %><%
}
public boolean visit(XMLEmptyElement e) {
%>
- RuntimeTagElement <%= tagVar(e) %> = context.getTagFactory().createRuntimeTag(_jetns_<%= e.getNSPrefix() %>, "<%= e.getTagNCName() %>", "<%= e.getName() %>", _td_<%= tagInfoVar(e) %>); //$NON-NLS-1$ //$NON-NLS-2$
+ RuntimeTagElement <%= tagVar(e) %> = context.getTagFactory().createRuntimeTag(_jetns_<%= e.getNSPrefix() %>, "<%= e.getTagNCName() %>", "<%= e.getName() %>", _td_<%= hcrFriendly ? tuv.ordinalExpr(e) : tagInfoVar(e) %>); //$NON-NLS-1$ //$NON-NLS-2$
<%= tagVar(e) %>.setRuntimeParent(<%= parentTagVar(e) %>);
- <%= tagVar(e) %>.setTagInfo(_td_<%= tagInfoVar(e) %>);
+ <%= tagVar(e) %>.setTagInfo(_td_<%= hcrFriendly ? tuv.ordinalExpr(e) : tagInfoVar(e) %>);
<%= tagVar(e) %>.doStart(context, out);
<%= tagVar(e) %>.doEnd();
<%

Back to the top