[125182][124931] fixes for XMLJSPRegion helper (and corresponding test change)
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 4807a43..7ff4afd 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
@@ -872,7 +872,6 @@
helper.reset(blockText, startOfBlock);
// force parse
helper.forceParse();
- helper.writeToBuffers();
}
/*
@@ -1536,7 +1535,6 @@
getIncludes().push(fileLocation);
JSPIncludeRegionHelper helper = new JSPIncludeRegionHelper(this);
helper.parse(fileLocation);
- helper.writeToBuffers();
getIncludes().pop();
}
}
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
index 5c84f95..8bb1689 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/java/XMLJSPRegionHelper.java
@@ -11,7 +11,6 @@
package org.eclipse.jst.jsp.core.internal.java;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -48,10 +47,6 @@
protected String fTextToParse = null;
// need this if not at the start of the document (eg. parsing just a script block)
protected int fStartOfTextToParse = 0;
- // buffers for text that this class parses
- protected List fScriptlets = new ArrayList();
- protected List fExpressions = new ArrayList();
- protected List fDeclarations = new ArrayList();
// name of the open tag that was last handled (if we are interested in it)
protected String fTagname = null;
protected String fTextBefore = ""; //$NON-NLS-1$
@@ -105,23 +100,6 @@
forceParse();
}
- /*
- * writes out scriptlet, expression, and declaration buffers
- * to the ongoing buffers in the JSPTranslator (calls to outer JSPTranslator methods)
- */
- public void writeToBuffers() {
- IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
- // currentNode should be the <%@page include="xxx"%> StructuredDocumentRegion
- for (int i = 0; i < fScriptlets.size(); i++) {
- this.fTranslator.translateScriptletString((String) fScriptlets.get(i), currentNode, currentNode.getStartOffset(), currentNode.getLength());
- }
- for (int i = 0; i < fExpressions.size(); i++) {
- this.fTranslator.translateExpressionString((String) fExpressions.get(i), currentNode, currentNode.getStartOffset(), currentNode.getLength());
- }
- for (int i = 0; i < fDeclarations.size(); i++) {
- this.fTranslator.translateDeclarationString((String) fDeclarations.get(i), currentNode, currentNode.getStartOffset(), currentNode.getLength());
- }
- }
/*
* listens to parser node parsed events
@@ -221,23 +199,23 @@
}
private void startScope(String tagName) {
- //IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
+ IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
StringBuffer text = new StringBuffer();
text.append("{ // <"); //$NON-NLS-1$
text.append(tagName);
text.append(">\n"); //$NON-NLS-1$
- //this.fTranslator.translateScriptletString(text.toString(), currentNode, currentNode.getStartOffset(), currentNode.getLength()); //$NON-NLS-1$
- fScriptlets.add(text.toString());
+ this.fTranslator.translateScriptletString(text.toString(), currentNode, currentNode.getStartOffset(), currentNode.getLength()); //$NON-NLS-1$
+
}
private void endScope(String tagName) {
- //IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
+ IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
StringBuffer text = new StringBuffer();
text.append("} // </"); //$NON-NLS-1$
text.append(tagName);
text.append(">\n"); //$NON-NLS-1$
- //this.fTranslator.translateScriptletString(text.toString(), currentNode, currentNode.getStartOffset(), currentNode.getLength()); //$NON-NLS-1$
- fScriptlets.add(text.toString());
+ this.fTranslator.translateScriptletString(text.toString(), currentNode, currentNode.getStartOffset(), currentNode.getLength()); //$NON-NLS-1$
+
}
public void resetNodes() {
@@ -264,19 +242,22 @@
protected void processDeclaration(IStructuredDocumentRegion sdRegion) {
prepareText(sdRegion);
- fDeclarations.add(fStrippedText);
+ IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
+ this.fTranslator.translateDeclarationString(fStrippedText, currentNode, currentNode.getStartOffset(), currentNode.getLength());
fPossibleOwner = JSPTranslator.DECLARATION;
}
protected void processExpression(IStructuredDocumentRegion sdRegion) {
prepareText(sdRegion);
- fExpressions.add(fStrippedText);
+ IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
+ this.fTranslator.translateExpressionString(fStrippedText, currentNode, currentNode.getStartOffset(), currentNode.getLength());
fPossibleOwner = JSPTranslator.EXPRESSION;
}
protected void processScriptlet(IStructuredDocumentRegion sdRegion) {
prepareText(sdRegion);
- fScriptlets.add(fStrippedText);
+ IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
+ this.fTranslator.translateScriptletString(fStrippedText, currentNode, currentNode.getStartOffset(), currentNode.getLength());
fPossibleOwner = JSPTranslator.SCRIPTLET;
}
@@ -308,8 +289,9 @@
suffix = "new " + beanClass + "();\n"; //$NON-NLS-1$ //$NON-NLS-2$
beanDecl = prefix + suffix;
}
-
- fScriptlets.add(beanDecl);
+
+ IStructuredDocumentRegion currentNode = fTranslator.getCurrentNode();
+ this.fTranslator.translateScriptletString(beanDecl, currentNode, currentNode.getStartOffset(), currentNode.getLength());
fPossibleOwner = JSPTranslator.SCRIPTLET;
}
}
@@ -385,7 +367,7 @@
while (it.hasNext()) {
nameRegion = (ITextRegion) it.next();
if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- textRegionText = sdRegionText.substring(nameRegion.getStart(), nameRegion.getEnd());
+ textRegionText = sdRegionText.substring(nameRegion.getStart(), nameRegion.getTextEnd());
if (textRegionText.equalsIgnoreCase(attrName)) {
while (it.hasNext()) {
valueRegion = (ITextRegion) it.next();