From 77a019842ca1f29aa1e8495f70344e0089181a85 Mon Sep 17 00:00:00 2001 From: Vladimir Schneider Date: Wed, 16 Sep 2015 02:06:53 -0400 Subject: [PATCH] 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. --- .../src/com/simpleplugin/SimpleFindUsagesProvider.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/simple_language_plugin/src/com/simpleplugin/SimpleFindUsagesProvider.java b/simple_language_plugin/src/com/simpleplugin/SimpleFindUsagesProvider.java index c766cd3b9..b4b0ab12c 100644 --- a/simple_language_plugin/src/com/simpleplugin/SimpleFindUsagesProvider.java +++ b/simple_language_plugin/src/com/simpleplugin/SimpleFindUsagesProvider.java @@ -12,14 +12,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; 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 @Override public WordsScanner getWordsScanner() { - return WORDS_SCANNER; + return new DefaultWordsScanner(new SimpleLexerAdapter(), + TokenSet.create(SimpleTypes.KEY), TokenSet.create(SimpleTypes.COMMENT), TokenSet.EMPTY);; } @Override @@ -62,4 +59,4 @@ public class SimpleFindUsagesProvider implements FindUsagesProvider { return ""; } } -} \ No newline at end of file +}