From 7318118ee655693dcb3316ab1c0e3137d4c84a83 Mon Sep 17 00:00:00 2001 From: Darkyenus Date: Thu, 28 Mar 2019 12:24:06 +0100 Subject: [PATCH] Fix GLSLFindUsagesProvider violating thread safety requirements Took 23 minutes --- META-INF/plugin.xml | 6 +++++- src/glslplugin/annotation/Annotator.java | 2 +- .../extensions/GLSLFindUsagesProvider.java | 15 +++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index 5945e042..0e782c2e 100755 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -24,7 +24,11 @@ Custom Languages Foundation - + + + + + com.intellij.modules.lang 1.18-SNAPSHOT diff --git a/src/glslplugin/annotation/Annotator.java b/src/glslplugin/annotation/Annotator.java index dbafef4c..95a400cb 100755 --- a/src/glslplugin/annotation/Annotator.java +++ b/src/glslplugin/annotation/Annotator.java @@ -41,8 +41,8 @@ public abstract class Annotator { /** * To be called only from glslplugin.annotation.Annotator */ + @SuppressWarnings("unchecked") final void annotateGeneric(PsiElement element, AnnotationHolder holder) { - //noinspection unchecked annotate((T) element, holder); } } diff --git a/src/glslplugin/extensions/GLSLFindUsagesProvider.java b/src/glslplugin/extensions/GLSLFindUsagesProvider.java index 5150b14d..e222cd46 100644 --- a/src/glslplugin/extensions/GLSLFindUsagesProvider.java +++ b/src/glslplugin/extensions/GLSLFindUsagesProvider.java @@ -16,15 +16,18 @@ * Created by abigail on 26/06/15. */ public class GLSLFindUsagesProvider implements FindUsagesProvider { - private static final DefaultWordsScanner WORDS_SCANNER = - new DefaultWordsScanner(new GLSLFlexAdapter(), - TokenSet.create(GLSLTokenTypes.IDENTIFIER), - TokenSet.create(GLSLTokenTypes.COMMENT_LINE, GLSLTokenTypes.COMMENT_BLOCK), - TokenSet.create(GLSLTokenTypes.PREPROCESSOR_STRING)); + @Nullable @Override public WordsScanner getWordsScanner() { - return WORDS_SCANNER; + /* + This method must either return thread safe instance (which DefaultWordsScanner is not!) + or a new instance. This is required, otherwise errors will happen. + */ + return new DefaultWordsScanner(new GLSLFlexAdapter(), + TokenSet.create(GLSLTokenTypes.IDENTIFIER), + TokenSet.create(GLSLTokenTypes.COMMENT_LINE, GLSLTokenTypes.COMMENT_BLOCK), + TokenSet.create(GLSLTokenTypes.PREPROCESSOR_STRING)); } @Override