change FindUsages getWordScanner not to be static.

If it is static then there are multi-threading issues. When indexing multiple threads are running and overwriting the lexer state that the word scanner uses.

I copied the SimplePlugin find usages class and spent hours chasing index out range bugs. I also noticed that the SimplePlugin which I have installed in my plugin dev environment would once in a while cause an exception but I did not pay it much attention. The static word scanner is the source.
This commit is contained in:
Vladimir Schneider 2015-09-16 02:06:53 -04:00
parent 77ee65c204
commit 77a019842c

View File

@ -12,14 +12,11 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class SimpleFindUsagesProvider implements FindUsagesProvider { public class SimpleFindUsagesProvider implements FindUsagesProvider {
private static final DefaultWordsScanner WORDS_SCANNER =
new DefaultWordsScanner(new SimpleLexerAdapter(),
TokenSet.create(SimpleTypes.KEY), TokenSet.create(SimpleTypes.COMMENT), TokenSet.EMPTY);
@Nullable @Nullable
@Override @Override
public WordsScanner getWordsScanner() { public WordsScanner getWordsScanner() {
return WORDS_SCANNER; return new DefaultWordsScanner(new SimpleLexerAdapter(),
TokenSet.create(SimpleTypes.KEY), TokenSet.create(SimpleTypes.COMMENT), TokenSet.EMPTY);;
} }
@Override @Override
@ -62,4 +59,4 @@ public class SimpleFindUsagesProvider implements FindUsagesProvider {
return ""; return "";
} }
} }
} }