Spellchecker: WI-36515 IDEA 11.1.3 hanging up on text changes

newBombedCharSequence in spellchecker's splitters [IDEA-CR-30609]
This commit is contained in:
Olga Strizhenko
2018-03-27 14:02:42 +03:00
parent 9d3834f3c8
commit afeed89a59
5 changed files with 16 additions and 6 deletions
@@ -27,6 +27,8 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.intellij.openapi.util.text.StringUtil.newBombedCharSequence;
public class IdentifierSplitter extends BaseSplitter {
private static final IdentifierSplitter INSTANCE = new IdentifierSplitter();
@@ -74,7 +76,7 @@ public class IdentifierSplitter extends BaseSplitter {
for (TextRange word : words) {
boolean uc = Strings.isUpperCased(text, word);
boolean flag = (uc && !isAllWordsAreUpperCased);
Matcher matcher = WORD.matcher(text.substring(word.getStartOffset(), word.getEndOffset()));
Matcher matcher = WORD.matcher(newBombedCharSequence(text.substring(word.getStartOffset(), word.getEndOffset()), 500));
if (matcher.find()) {
TextRange found = matcherRange(word, matcher);
addWord(consumer, flag, found);
@@ -28,10 +28,12 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.intellij.openapi.util.text.StringUtil.newBombedCharSequence;
import static com.intellij.util.io.URLUtil.URL_PATTERN;
public class PlainTextSplitter extends BaseSplitter {
private static final PlainTextSplitter INSTANCE = new PlainTextSplitter();
public static final int DELAY = 500;
public static PlainTextSplitter getInstance() {
return INSTANCE;
@@ -52,14 +54,14 @@ public class PlainTextSplitter extends BaseSplitter {
}
final String substring = range.substring(text).replace('\b', '\n').replace('\f', '\n');
if (Verifier.checkCharacterData(SPLIT_PATTERN.matcher(substring).replaceAll("")) != null) {
if (Verifier.checkCharacterData(SPLIT_PATTERN.matcher(newBombedCharSequence(substring, DELAY)).replaceAll("")) != null) {
return;
}
final TextSplitter ws = TextSplitter.getInstance();
int from = range.getStartOffset();
int till;
Matcher matcher = SPLIT_PATTERN.matcher(range.substring(text));
Matcher matcher = SPLIT_PATTERN.matcher(newBombedCharSequence(range.substring(text), DELAY));
while (true) {
checkCancelled();
List<TextRange> toCheck;
@@ -25,6 +25,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.intellij.openapi.util.text.StringUtil.newBombedCharSequence;
public class PropertiesSplitter extends BaseSplitter {
private static final PropertiesSplitter INSTANCE = new PropertiesSplitter();
@@ -41,7 +43,7 @@ public class PropertiesSplitter extends BaseSplitter {
return;
}
final IdentifierSplitter splitter = IdentifierSplitter.getInstance();
Matcher matcher = WORD.matcher(range.substring(text));
Matcher matcher = WORD.matcher(newBombedCharSequence(range.substring(text), 500));
while (matcher.find()) {
if (matcher.end() - matcher.start() < MIN_RANGE_LENGTH) {
continue;
@@ -24,6 +24,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.intellij.openapi.util.text.StringUtil.newBombedCharSequence;
public class TextSplitter extends BaseSplitter {
private static final TextSplitter INSTANCE = new TextSplitter();
@@ -43,7 +45,7 @@ public class TextSplitter extends BaseSplitter {
protected void doSplit(@NotNull String text, @NotNull TextRange range, Consumer<TextRange> consumer) {
final WordSplitter ws = WordSplitter.getInstance();
Matcher matcher = EXTENDED_WORD_AND_SPECIAL.matcher(text);
Matcher matcher = EXTENDED_WORD_AND_SPECIAL.matcher(newBombedCharSequence(text, 500));
matcher.region(range.getStartOffset(), range.getEndOffset());
while (matcher.find()) {
TextRange found = new TextRange(matcher.start(), matcher.end());
@@ -24,6 +24,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.intellij.openapi.util.text.StringUtil.newBombedCharSequence;
public class WordSplitter extends BaseSplitter {
private static final WordSplitter INSTANCE = new WordSplitter();
@@ -39,7 +41,7 @@ public class WordSplitter extends BaseSplitter {
if (text == null || range.getLength() <= 1) {
return;
}
Matcher specialMatcher = SPECIAL.matcher(text);
Matcher specialMatcher = SPECIAL.matcher(newBombedCharSequence(text, 500));
specialMatcher.region(range.getStartOffset(), range.getEndOffset());
if (specialMatcher.find()) {
TextRange found = new TextRange(specialMatcher.start(), specialMatcher.end());