summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDawid PakuĊ‚a2013-10-18 15:40:40 (EDT)
committerChris2013-10-23 10:46:49 (EDT)
commit2c92d8d63e92a105cd3ed3429551328ca8acef30 (patch)
tree1676825c17184b20228602ac9f0d653d97cb5610
parenta311d91d8bbb9aa4ff496fcab8376a340e9ecdfd (diff)
downloadwebtools.jsdt.core-2c92d8d63e92a105cd3ed3429551328ca8acef30.zip
webtools.jsdt.core-2c92d8d63e92a105cd3ed3429551328ca8acef30.tar.gz
webtools.jsdt.core-2c92d8d63e92a105cd3ed3429551328ca8acef30.tar.bz2
[404832] - JavaScript error on valid regexv201310231449
-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 b1c8c15..b841426 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 66fd6eb..4dea3a3 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 7c412d1..a88059f 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':