mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
skip leading .* in reg exp used for todo pattern when building index: it makes sense for todo highlighting but increases matching due to backtracking enormously (IDEA-74104)
This commit is contained in:
+1
-1
@@ -213,7 +213,7 @@ public abstract class PlatformIdTableBuilding {
|
||||
}
|
||||
OccurrenceConsumer occurrenceConsumer = new OccurrenceConsumer(null, true);
|
||||
for (IndexPattern indexPattern : indexPatterns) {
|
||||
Pattern pattern = indexPattern.getPattern();
|
||||
Pattern pattern = indexPattern.getOptimizedIndexingPattern();
|
||||
if (pattern != null) {
|
||||
Matcher matcher = pattern.matcher(chars);
|
||||
while (matcher.find()) {
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ public class TodoIndex extends FileBasedIndexExtension<TodoIndexEntry, Integer>
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 7;
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.regex.PatternSyntaxException;
|
||||
*/
|
||||
public class IndexPattern {
|
||||
@NotNull private String myPatternString;
|
||||
private Pattern myOptimizedIndexingPattern;
|
||||
private boolean myCaseSensitive;
|
||||
private Pattern myPattern;
|
||||
|
||||
@@ -53,6 +54,10 @@ public class IndexPattern {
|
||||
return myPattern;
|
||||
}
|
||||
|
||||
public Pattern getOptimizedIndexingPattern() {
|
||||
return myOptimizedIndexingPattern;
|
||||
}
|
||||
|
||||
public boolean isCaseSensitive() {
|
||||
return myCaseSensitive;
|
||||
}
|
||||
@@ -68,16 +73,21 @@ public class IndexPattern {
|
||||
}
|
||||
|
||||
private void compilePattern() {
|
||||
try{
|
||||
if (myCaseSensitive){
|
||||
myPattern = Pattern.compile(myPatternString);
|
||||
try {
|
||||
int flags = 0;
|
||||
if (!myCaseSensitive) {
|
||||
flags = Pattern.CASE_INSENSITIVE;
|
||||
}
|
||||
else{
|
||||
myPattern = Pattern.compile(myPatternString, Pattern.CASE_INSENSITIVE);
|
||||
myPattern = Pattern.compile(myPatternString, flags);
|
||||
String optimizedPattern = myPatternString;
|
||||
if (optimizedPattern.startsWith(".*")) {
|
||||
optimizedPattern = optimizedPattern.substring(".*".length());
|
||||
}
|
||||
myOptimizedIndexingPattern = Pattern.compile(optimizedPattern, flags);
|
||||
}
|
||||
catch(PatternSyntaxException e){
|
||||
myPattern = null;
|
||||
myOptimizedIndexingPattern = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ public abstract class BaseFilterLexer extends DelegateLexer implements IdTableBu
|
||||
todoScanningState = new TodoScanningState(patterns, matchers);
|
||||
|
||||
for (int i = 0; i < patterns.length; ++i) {
|
||||
Pattern pattern = patterns[i].getPattern();
|
||||
Pattern pattern = patterns[i].getOptimizedIndexingPattern();
|
||||
|
||||
if (pattern != null) {
|
||||
matchers[i] = pattern.matcher("");
|
||||
|
||||
Reference in New Issue
Block a user