Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2009-01-26 15:38:57 -0500
committerpelder2009-01-26 15:38:57 -0500
commitab1d8b3c14a03096f8cabc689f7555956950a74c (patch)
tree37b0e222e70f7fccd02844e4356dd1f5ec69913d
parent103d14e84b8684d9c62af6dfe2a4793cd7ae4d1c (diff)
downloadorg.eclipse.jet-ab1d8b3c14a03096f8cabc689f7555956950a74c.tar.gz
org.eclipse.jet-ab1d8b3c14a03096f8cabc689f7555956950a74c.tar.xz
org.eclipse.jet-ab1d8b3c14a03096f8cabc689f7555956950a74c.zip
[262422] StringIndexOutOfBoundsException when using content assist in a scriptlet
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java4
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java2
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java8
-rw-r--r--plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java8
4 files changed, 11 insertions, 11 deletions
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java
index c67a185..2adf8c1 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/JETEditorHelper.java
@@ -201,8 +201,8 @@ public class JETEditorHelper {
public static boolean checkOffsetPositions(String javaSource, String jetSource, int jetOffset, int javaOffset, int checkDepth) {
boolean result = false;
- String javaCheckString = javaSource.substring(javaOffset, javaOffset + checkDepth);
- String jetCheckString = jetSource.substring(jetOffset, jetOffset + checkDepth);
+ String javaCheckString = javaSource.substring(javaOffset, Math.min(javaSource.length(), javaOffset + checkDepth));
+ String jetCheckString = jetSource.substring(jetOffset, Math.min(jetSource.length(), jetOffset + checkDepth));
result = javaCheckString.compareTo(jetCheckString) == 0;
if (!result) {
System.err.println("position matching error");
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java
index 31d8a11..845e288 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaDeclarationAssistProcessor.java
@@ -53,7 +53,7 @@ public class JETJavaDeclarationAssistProcessor extends AbstractJETAssistProcesso
int javaOffset = javaStartOffset + (offset - javaContentStart);
// check that the positions matches
- JETEditorHelper.checkOffsetPositions(javaSource, viewer.getDocument().get(), offset, javaOffset, 15);
+ JETEditorHelper.checkOffsetPositions(javaSource, viewer.getDocument().get(), javaContentStart, javaStartOffset, declaration.getJavaEnd() - javaContentStart);
IJavaCompletionProposal javaCompletionProposals[] = JETEditorHelper
.getJavaCompletionProposal(javaProject, cu, javaSource, viewer, javaOffset);
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java
index 6735803..fbfc977 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaExpressionAssistProcessor.java
@@ -57,13 +57,13 @@ public class JETJavaExpressionAssistProcessor extends AbstractJETAssistProcessor
Map mappingPositions = new HashMap();
String javaSource = editor.compilationHelper().getJavaCode(cu, mappingPositions);
int javaStartOffset = ((Position)mappingPositions.get(expression)).offset;
- int javaOffset = javaStartOffset + (offset - javaContentStart);
-
// check that the positions matches
- JETEditorHelper.checkOffsetPositions(javaSource, viewer.getDocument().get(), offset, javaOffset, 15);
+ JETEditorHelper.checkOffsetPositions(javaSource, viewer.getDocument().get(), javaContentStart, javaStartOffset, expression.getJavaEnd() - javaContentStart);
+ // calculate where the cursor would be (offset) within the javaSource...
+ int javaCursorOffset = javaStartOffset + (offset - javaContentStart);
IJavaCompletionProposal javaCompletionProposals[] = JETEditorHelper
- .getJavaCompletionProposal(javaProject, cu, javaSource, viewer, javaOffset);
+ .getJavaCompletionProposal(javaProject, cu, javaSource, viewer, javaCursorOffset);
JETEditorHelper.adjustResults(javaCompletionProposals, offset);
return javaCompletionProposals;
} else {
diff --git a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java
index b939083..c25e71d 100644
--- a/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java
+++ b/plugins/org.eclipse.jet.editor/src/org/eclipse/jet/internal/editor/contentassist/JETJavaScriptletAssistProcessor.java
@@ -51,13 +51,13 @@ public class JETJavaScriptletAssistProcessor extends AbstractJETAssistProcessor
Map mappingPositions = new HashMap();
String javaSource = editor.compilationHelper().getJavaCode(cu, mappingPositions);
int javaStartOffset = ((Position)mappingPositions.get(scriptlet)).offset;
- int javaOffset = javaStartOffset + (offset - javaContentStart);
-
// check that the positions matches
- JETEditorHelper.checkOffsetPositions(javaSource, viewer.getDocument().get(), offset, javaOffset, 15);
+ JETEditorHelper.checkOffsetPositions(javaSource, viewer.getDocument().get(), javaContentStart, javaStartOffset, scriptlet.getJavaEnd() - javaContentStart);
+ // calculate where the cursor would be (offset) within the javaSource...
+ int javaCursorOffset = javaStartOffset + (offset - javaContentStart);
IJavaCompletionProposal javaCompletionProposals[] = JETEditorHelper
- .getJavaCompletionProposal(javaProject, cu, javaSource, viewer, javaOffset);
+ .getJavaCompletionProposal(javaProject, cu, javaSource, viewer, javaCursorOffset);
JETEditorHelper.adjustResults(javaCompletionProposals, offset);
return javaCompletionProposals;
} else {

Back to the top