Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/parser/Scanner.java1
-rw-r--r--bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/util/PublicScanner.java10
-rw-r--r--bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/FastJavaPartitionScanner.java30
3 files changed, 31 insertions, 10 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/parser/Scanner.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/parser/Scanner.java
index b1c8c151..b8414261 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/parser/Scanner.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/compiler/parser/Scanner.java
@@ -4329,7 +4329,6 @@ protected boolean checkIfRegExp() throws IndexOutOfBoundsException, InvalidInput
boolean inCharacterClass = false;
try {
loop: while (true) {
-
switch(this.currentCharacter) {
case '\\' :
// read next character
diff --git a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/util/PublicScanner.java b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/util/PublicScanner.java
index 66fd6eb0..4dea3a33 100644
--- a/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/util/PublicScanner.java
+++ b/bundles/org.eclipse.wst.jsdt.core/src/org/eclipse/wst/jsdt/internal/core/util/PublicScanner.java
@@ -4125,6 +4125,7 @@ protected boolean checkIfRegExp() throws IndexOutOfBoundsException, InvalidInput
int previousPosition = this.currentPosition;
int previousUnicodePtr = this.withoutUnicodePtr;
boolean regExp = false;
+ boolean onCharList = false;
// consume next character
this.unicodeAsBackSlash = false;
@@ -4140,7 +4141,7 @@ protected boolean checkIfRegExp() throws IndexOutOfBoundsException, InvalidInput
}
try {
- while (this.currentCharacter != '/' &&
+ while ((onCharList || (this.currentCharacter != '/' && !onCharList )) &&
this.currentCharacter != '\r' && this.currentCharacter != '\n') {
if (this.currentCharacter == '\\') {
@@ -4166,6 +4167,10 @@ protected boolean checkIfRegExp() throws IndexOutOfBoundsException, InvalidInput
if (scanEscapeCharacter() && this.withoutUnicodePtr != 0) {
unicodeStore();
}
+ } else if (this.currentCharacter == '[') {
+ onCharList = true;
+ } else if(this.currentCharacter == ']') {
+ onCharList = false;
}
// consume next character
@@ -4184,10 +4189,9 @@ protected boolean checkIfRegExp() throws IndexOutOfBoundsException, InvalidInput
}
}
- if (this.currentCharacter == '/') {
+ if (this.currentCharacter == '/' && !onCharList) {
regExp = true;
}
-
}
// Check for valid RegExp options
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/FastJavaPartitionScanner.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/FastJavaPartitionScanner.java
index 7c412d11..a88059f0 100644
--- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/FastJavaPartitionScanner.java
+++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/FastJavaPartitionScanner.java
@@ -81,7 +81,7 @@ public class FastJavaPartitionScanner implements IPartitionTokenScanner, IJavaSc
int lastNonWhitespaceChar = NONE;
int currentChar = NONE;
-
+ boolean onCharList = false;
while (true) {
if (!Character.isWhitespace((char)currentChar))
lastNonWhitespaceChar = currentChar;
@@ -251,9 +251,10 @@ public class FastJavaPartitionScanner implements IPartitionTokenScanner, IJavaSc
default:
//check if regexp
fLast= NONE; // ignore fLast
- if (fTokenLength > 0)
+ onCharList = false; //reset char list;
+ if (fTokenLength > 0) {
return preFix(JAVASCRIPT, REGULAR_EXPRESSION, NONE, 1);
- else {
+ } else {
preFix(JAVASCRIPT, REGULAR_EXPRESSION, NONE, 1);
fTokenOffset += fTokenLength;
fTokenLength= fPrefixLength;
@@ -398,10 +399,27 @@ public class FastJavaPartitionScanner implements IPartitionTokenScanner, IJavaSc
fLast= (fLast == BACKSLASH) ? NONE : BACKSLASH;
fTokenLength++;
break;
-
+ case '[':
+ onCharList = true;
+ consume();
+ break;
+ case ']':
+ onCharList = false;
+ if (fLast==SLASH || fLast==REGULAR_EXPRESSION_END)
+ {
+ fTokenLength--;
+ fScanner.unread();
+ return postFix(REGULAR_EXPRESSION);
+ }
+ consume();
+ break;
case '/':
- fLast= (fLast == BACKSLASH) ? NONE : SLASH;
- fTokenLength++;
+ if (!onCharList) {
+ fLast= (fLast == BACKSLASH) ? NONE : SLASH;
+ fTokenLength++;
+ } else {
+ consume();
+ }
break;
case 'g':

Back to the top