Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Amerson2014-04-24 01:27:03 +0000
committerNick Sandonato2014-04-24 01:32:43 +0000
commit4478ecc9956eb5672c08d83e3cb5f94be9c15596 (patch)
tree388ae64f9d54d8d521a6028a56b5e2dafae63e9d
parentb82839975098a03384564c97238ba80217f575a7 (diff)
downloadwebtools.sourceediting-4478ecc9956eb5672c08d83e3cb5f94be9c15596.tar.gz
webtools.sourceediting-4478ecc9956eb5672c08d83e3cb5f94be9c15596.tar.xz
webtools.sourceediting-4478ecc9956eb5672c08d83e3cb5f94be9c15596.zip
[432978] JSPTranslator can generate incorrect source for JSPs that use particular taglibs multiple times in one JSP filev201404240239
Signed-off-by: Gregory Amerson <gregory.amerson@liferay.com>
-rw-r--r--bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java15
-rw-r--r--bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/taglib/TaglibVariable.java14
2 files changed, 21 insertions, 8 deletions
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java
index 7160e59514..65f1a23711 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/JSPTranslator.java
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Frits Jalvingh - contributions for bug 150794
+ * Gregory Amerson - [bug 432978] better support for multiple AT_BEGIN variables
*******************************************************************************/
package org.eclipse.jst.jsp.core.internal.java;
@@ -332,6 +333,9 @@ public class JSPTranslator implements Externalizable {
/** The model path as it was persisted */
private IPath fSavedModelPath = null;
+ /** the set of variable names that we have declared */
+ private Set fDeclSet = new HashSet();
+
/**
* A structure for holding a region collection marker and list of variable
* information. The region can be used later for positioning validation
@@ -640,7 +644,7 @@ public class JSPTranslator implements Externalizable {
fFoundNonTranslatedCode = false;
fCodeTranslated = false;
-
+ fDeclSet.clear();
}
/**
@@ -976,7 +980,14 @@ public class JSPTranslator implements Externalizable {
*/
for (int i = 0; i < taglibVars.length; i++) {
if (taglibVars[i].getScope() == VariableInfo.AT_BEGIN) {
- decl = taglibVars[i].getDeclarationString(fContext);
+ // check to see if we have already declared this variable once, if so then just reassign it instead
+ if (fDeclSet.contains(taglibVars[i].getVarName())) {
+ decl = taglibVars[i].getDeclarationString(false, fContext, TaglibVariable.M_REASSIGN);
+ }
+ else {
+ decl = taglibVars[i].getDeclarationString(fContext);
+ fDeclSet.add( taglibVars[i].getVarName() );
+ }
appendToBuffer(decl, fUserCode, true, customTag);
}
}
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/taglib/TaglibVariable.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/taglib/TaglibVariable.java
index 1d811f9b5c..d66c29068a 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/taglib/TaglibVariable.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/taglib/TaglibVariable.java
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Gregory Amerson - [bug 432978] better support for multiple AT_BEGIN variables
*******************************************************************************/
package org.eclipse.jst.jsp.core.internal.taglib;
@@ -31,8 +32,9 @@ public class TaglibVariable {
private final static String AT_BEGIN = "AT_BEGIN";
private final static String NESTED = "NESTED";
- public static final int M_PRIVATE = 1;
- public static final int M_NONE = 0;
+ public static final int M_PRIVATE = 2;
+ public static final int M_NONE = 1;
+ public static final int M_REASSIGN = 4;
/**
*
@@ -122,19 +124,19 @@ public class TaglibVariable {
* variables and ILocalVariable has no "doc range"
*/
if (includeDoc && getDescription() != null) {
- if (style == M_PRIVATE) {
+ if ((style & M_PRIVATE) > 0) {
declaration = "/** " + ENDL + StringUtils.replace(getDescription(), "*/", "*\\/") + ENDL + " */ " + ENDL + "private " + getVarClass() + " " + getVarName() + " = (" + getVarClass() + ") "+context+".getAttribute(\"" + getVarName() + "\");" + ENDL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
}
else {
- declaration = "/** " + ENDL + StringUtils.replace(getDescription(), "*/", "*\\/") + ENDL + " */ " + ENDL + getVarClass() + " " + getVarName() + " = (" + getVarClass() + ") "+context+".getAttribute(\"" + getVarName() + "\");" + ENDL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ declaration = "/** " + ENDL + StringUtils.replace(getDescription(), "*/", "*\\/") + ENDL + " */ " + ENDL + (((style & M_REASSIGN) > 0 ) ? "" : getVarClass()) + " " + getVarName() + " = (" + getVarClass() + ") "+context+".getAttribute(\"" + getVarName() + "\");" + ENDL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
}
}
else {
- if (style == M_PRIVATE) {
+ if ((style & M_PRIVATE) > 0 ) {
declaration = "private " + getVarClass() + " " + getVarName() + " = (" + getVarClass() + ") "+context+".getAttribute(\"" + getVarName() + "\");" + ENDL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
}
else {
- declaration = getVarClass() + " " + getVarName() + " = (" + getVarClass() + ") "+context+".getAttribute(\"" + getVarName() + "\");" + ENDL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ declaration = (((style & M_REASSIGN) > 0 ) ? "" : getVarClass()) + " " + getVarName() + " = (" + getVarClass() + ") "+context+".getAttribute(\"" + getVarName() + "\");" + ENDL; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
}
return declaration;

Back to the top