Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2009-01-26 16:51:28 -0500
committerpelder2009-01-26 16:51:28 -0500
commitf95cba0614a278505e0036bef154ad6f84b32ccf (patch)
treefeeb654389c6d0464d888053a0f0b433d47c37a5
parentc3149e5839e8078f39a27807b59a32df65e40b03 (diff)
downloadorg.eclipse.jet-f95cba0614a278505e0036bef154ad6f84b32ccf.tar.gz
org.eclipse.jet-f95cba0614a278505e0036bef154ad6f84b32ccf.tar.xz
org.eclipse.jet-f95cba0614a278505e0036bef154ad6f84b32ccf.zip
[262429] 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