Skip to content

Commit

Permalink
Fix GLSLFindUsagesProvider violating thread safety requirements
Browse files Browse the repository at this point in the history
Took 23 minutes
  • Loading branch information
Darkyenus committed Mar 28, 2019
1 parent 0d51358 commit 7318118
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 5 additions & 1 deletion META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@

<category>Custom Languages</category>
<vendor>Foundation</vendor>
<idea-version since-build="139.1117"/>

<!-- Since at least 144 (2016), because we require Java 8, which is bundled since then -->
<!-- https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under -->
<!-- Until build is not set, because we hope it will work. -->
<idea-version since-build="144"/>
<depends>com.intellij.modules.lang</depends>

<version>1.18-SNAPSHOT</version>
Expand Down
2 changes: 1 addition & 1 deletion src/glslplugin/annotation/Annotator.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public abstract class Annotator<T extends PsiElement> {
/**
* To be called only from glslplugin.annotation.Annotator
*/
@SuppressWarnings("unchecked")
final void annotateGeneric(PsiElement element, AnnotationHolder holder) {
//noinspection unchecked
annotate((T) element, holder);
}
}
15 changes: 9 additions & 6 deletions src/glslplugin/extensions/GLSLFindUsagesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7318118

Please sign in to comment.