Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2009-10-08 10:35:04 -0400
committerpelder2009-10-08 10:35:04 -0400
commit6faf3584adfd66827cea17212918e714e52562fc (patch)
treedd58f1e6723fbfae1173088ee0d9ecf8801da3ed
parentebce11daa034a839c55a11c63bc88a46bee8031b (diff)
downloadorg.eclipse.jet-6faf3584adfd66827cea17212918e714e52562fc.tar.gz
org.eclipse.jet-6faf3584adfd66827cea17212918e714e52562fc.tar.xz
org.eclipse.jet-6faf3584adfd66827cea17212918e714e52562fc.zip
[288403] JET deletes content within c:userRegion section after regenerating
-rw-r--r--plugins/org.eclipse.jet-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/templates/CodeGenTemplateLoader.java148
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/UserRegionHelper.java5
4 files changed, 84 insertions, 73 deletions
diff --git a/plugins/org.eclipse.jet-feature/feature.xml b/plugins/org.eclipse.jet-feature/feature.xml
index 322d40b..e5edffe 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="0.9.2.qualifier"
+ version="0.9.3.qualifier"
provider-name="%providerName">
<description url="http://www.eclipse.org/modeling/m2t">
diff --git a/plugins/org.eclipse.jet/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet/META-INF/MANIFEST.MF
index 057ee46..9bb17c1 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: 0.9.4.qualifier
+Bundle-Version: 0.9.5.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/templates/CodeGenTemplateLoader.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
index 41cd8b5..4674f13 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/compiler/templates/CodeGenTemplateLoader.java
@@ -3,90 +3,96 @@ package org.eclipse.jet.internal.compiler.templates;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.jet.JET2Template;
import org.eclipse.jet.JET2TemplateLoader;
import org.eclipse.jet.JET2TemplateLoaderExtension;
-import org.eclipse.jet.JET2Template;
-
-public class CodeGenTemplateLoader implements JET2TemplateLoader, JET2TemplateLoaderExtension {
- private static final class TemplateFactoryMethod {
+public class CodeGenTemplateLoader implements JET2TemplateLoader,
+ JET2TemplateLoaderExtension {
- private final String templatePath;
- private final String templateClass;
-
- public TemplateFactoryMethod(String templatePath, String templateClass) {
- this.templatePath = templatePath;
- this.templateClass = templateClass;
-
- }
-
- public String getTemplateClass() {
- return this.templateClass;
- }
-
- public String getTemplatePath() {
- return this.templatePath;
- }
-
- public JET2Template newTemplate() {
- JET2Template template = null;
- try {
- template = (JET2Template) Class.forName(this.templateClass).newInstance();
- } catch (InstantiationException e) {
- // ignore
- } catch (IllegalAccessException e) {
- // ignore
- } catch (ClassNotFoundException e) {
- // ignore
- }
- return template;
- }
-
-
- }
-
- private Map pathToFactoryMap = null;
-
private JET2TemplateLoader delegate = null;
- public CodeGenTemplateLoader() {
- super();
+ private final static Map pathToTemplateOrdinalMap = new HashMap(11);
+ static {
+ pathToTemplateOrdinalMap.put("templates/jet2java.jet", //$NON-NLS-1$
+ new Integer(0));
+ pathToTemplateOrdinalMap.put("templates/jet2transform.jet", //$NON-NLS-1$
+ new Integer(1));
+ pathToTemplateOrdinalMap.put("templates/jetTemplateMap.properties.jet", //$NON-NLS-1$
+ new Integer(2));
+ pathToTemplateOrdinalMap.put("templates/main.jet", //$NON-NLS-1$
+ new Integer(3));
+ pathToTemplateOrdinalMap.put("templates/tagDataDeclarations.jet", //$NON-NLS-1$
+ new Integer(4));
+ pathToTemplateOrdinalMap.put("templates/v1/jet2java.jet", //$NON-NLS-1$
+ new Integer(5));
+ pathToTemplateOrdinalMap.put("templates/v2/jet2java.jet", //$NON-NLS-1$
+ new Integer(6));
+ pathToTemplateOrdinalMap.put("templates/writeJavaExpression.jet", //$NON-NLS-1$
+ new Integer(7));
+ pathToTemplateOrdinalMap.put("templates/writeTextElement.jet", //$NON-NLS-1$
+ new Integer(8));
+ pathToTemplateOrdinalMap.put("templates/xmlEnd.jet", //$NON-NLS-1$
+ new Integer(9));
+ pathToTemplateOrdinalMap.put("templates/xmlStart.jet", //$NON-NLS-1$
+ new Integer(10));
}
- public JET2Template getTemplate(String templatePath) {
- if(this.pathToFactoryMap == null) {
- initPathToFactoryMap();
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jet.JET2TemplateLoader#getTemplate(java.lang.String)
+ */
+ public JET2Template getTemplate(final String templatePath) {
+ final Integer ordinal = (Integer)pathToTemplateOrdinalMap.get(templatePath);
+ if(ordinal != null) {
+ switch (ordinal.intValue()) {
+ case 0: // templates/jet2java.jet
+ return new org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator();
+ case 1: // templates/jet2transform.jet
+ return new org.eclipse.jet.internal.compiler.templates.JET2TransformGenerator();
+ case 2: // templates/jetTemplateMap.properties.jet
+ return new org.eclipse.jet.internal.compiler.templates.JETTemplateMapGenerator();
+ case 3: // templates/main.jet
+ return new org.eclipse.jet.internal.compiler.templates.DummyMain();
+ case 4: // templates/tagDataDeclarations.jet
+ return new org.eclipse.jet.internal.compiler.templates.TagDataDeclGenerator();
+ case 5: // templates/v1/jet2java.jet
+ return new org.eclipse.jet.internal.compiler.templates.v1.JET1JavaGenerator();
+ case 6: // templates/v2/jet2java.jet
+ return new org.eclipse.jet.internal.compiler.templates.v2.JET2JavaGeneratorNew();
+ case 7: // templates/writeJavaExpression.jet
+ return new org.eclipse.jet.internal.compiler.templates.WriteJavaExpressionTemplate();
+ case 8: // templates/writeTextElement.jet
+ return new org.eclipse.jet.internal.compiler.templates.WriteTextElementTemplate();
+ case 9: // templates/xmlEnd.jet
+ return new org.eclipse.jet.internal.compiler.templates.XMLEndGenerator();
+ case 10: // templates/xmlStart.jet
+ return new org.eclipse.jet.internal.compiler.templates.XMLStartGenerator();
+ default:
+ break;
+ }
}
- TemplateFactoryMethod factory = (TemplateFactoryMethod)this.pathToFactoryMap.get(templatePath);
- return factory == null ? this.delegate == null ? null : this.delegate.getTemplate(templatePath) : factory.newTemplate();
+ return this.delegate != null ? this.delegate.getTemplate(templatePath) : null;
}
- private void addTemplate(String templatePath, String templateClass) {
- this.pathToFactoryMap.put(templatePath,
- new TemplateFactoryMethod(templatePath, templateClass));
- }
-
- private void initPathToFactoryMap() {
- this.pathToFactoryMap = new HashMap(11);
- addTemplate("templates/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/jet2transform.jet", "org.eclipse.jet.internal.compiler.templates.JET2TransformGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/jetTemplateMap.properties.jet", "org.eclipse.jet.internal.compiler.templates.JETTemplateMapGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/main.jet", "org.eclipse.jet.internal.compiler.templates.DummyMain" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/tagDataDeclarations.jet", "org.eclipse.jet.internal.compiler.templates.TagDataDeclGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/v1/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.v1.JET1JavaGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/v2/jet2java.jet", "org.eclipse.jet.internal.compiler.templates.v2.JET2JavaGeneratorNew" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/writeJavaExpression.jet", "org.eclipse.jet.internal.compiler.templates.WriteJavaExpressionTemplate" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/writeTextElement.jet", "org.eclipse.jet.internal.compiler.templates.WriteTextElementTemplate" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/xmlEnd.jet", "org.eclipse.jet.internal.compiler.templates.XMLEndGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
- addTemplate("templates/xmlStart.jet", "org.eclipse.jet.internal.compiler.templates.XMLStartGenerator" ); //$NON-NLS-1$ //$NON-NLS-2$
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jet.JET2TemplateLoaderExtension#getDelegateLoader()
+ */
+ public JET2TemplateLoader getDelegateLoader() {
+ return this.delegate;
}
- public void setDelegateLoader(JET2TemplateLoader loader) {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jet.JET2TemplateLoaderExtension#setDelegateLoader(org.eclipse
+ * .jet.JET2TemplateLoader)
+ */
+ public void setDelegateLoader(final JET2TemplateLoader loader) {
this.delegate = loader;
}
-
- public JET2TemplateLoader getDelegateLoader() {
- return this.delegate;
- }
}
-
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/UserRegionHelper.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/UserRegionHelper.java
index 995a898..2d1dfb3 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/UserRegionHelper.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/UserRegionHelper.java
@@ -163,6 +163,11 @@ public final class UserRegionHelper implements IWriterListener, IWriterListenerE
for (int i = 0; i < icPositions.length; i++)
{
Position pos = icPositions[i];
+ if(pos.isDeleted()) {
+ // positions get deleted when the surrounding user region gets replaced...
+ // ignore these
+ continue;
+ }
if (pos.offset + pos.length > userRegionPosition.offset + userRegionPosition.length)
{
return null;

Back to the top