diff --git a/src/main/java/org/jastadd/tooling/JastAddIcons.java b/src/main/java/org/jastadd/tooling/JastAddIcons.java index 38df87c5cee0aeac53834e0738635e0ceb897a4c..011ca9980e71c02eb890798de3fb76077e169ae1 100644 --- a/src/main/java/org/jastadd/tooling/JastAddIcons.java +++ b/src/main/java/org/jastadd/tooling/JastAddIcons.java @@ -6,10 +6,10 @@ import javax.swing.*; public class JastAddIcons { + public static final Icon FILE = IconLoader.getIcon("/icons/jastadd.svg", JastAddIcons.class); + private JastAddIcons() { throw new IllegalStateException("Utility class"); } - public static final Icon FILE = IconLoader.getIcon("/icons/jastadd.svg", JastAddIcons.class); - } diff --git a/src/main/java/org/jastadd/tooling/RelAstGrammar.java b/src/main/java/org/jastadd/tooling/RelAstGrammar.java index 0aafd2597c60b93c823fdb7e3b8d0106418ddd59..2b6f58f75be1d4eeb5e6c50133dc59b66b1686e7 100644 --- a/src/main/java/org/jastadd/tooling/RelAstGrammar.java +++ b/src/main/java/org/jastadd/tooling/RelAstGrammar.java @@ -1,16 +1,13 @@ package org.jastadd.tooling; - import com.intellij.lang.Language; public class RelAstGrammar extends Language { + public static final RelAstGrammar INSTANCE = new RelAstGrammar(); - public static final RelAstGrammar INSTANCE = new RelAstGrammar(); - - private RelAstGrammar() { - super("JastAddGrammar"); - } - + private RelAstGrammar() { + super("JastAddGrammar"); + } } diff --git a/src/main/java/org/jastadd/tooling/RelAstGrammarColorSettingsPage.java b/src/main/java/org/jastadd/tooling/RelAstGrammarColorSettingsPage.java index bb980d4b616ea414d7a8a808b78c3613ad212326..8acc9f5fdf5d2ce29ca42adb9bfd320fdcfd32c4 100644 --- a/src/main/java/org/jastadd/tooling/RelAstGrammarColorSettingsPage.java +++ b/src/main/java/org/jastadd/tooling/RelAstGrammarColorSettingsPage.java @@ -68,13 +68,13 @@ public class RelAstGrammarColorSettingsPage implements ColorSettingsPage { @NotNull @Override - public AttributesDescriptor[] getAttributeDescriptors() { + public AttributesDescriptor @NotNull [] getAttributeDescriptors() { return DESCRIPTORS; } @NotNull @Override - public ColorDescriptor[] getColorDescriptors() { + public ColorDescriptor @NotNull [] getColorDescriptors() { return ColorDescriptor.EMPTY_ARRAY; } diff --git a/src/main/java/org/jastadd/tooling/RelAstGrammarFileType.java b/src/main/java/org/jastadd/tooling/RelAstGrammarFileType.java index 3d00b9748aea3fea5322cfb42fbdfaf92a92a08a..793a3a47b9c5a247ad0240379ae75c0e564a9b91 100644 --- a/src/main/java/org/jastadd/tooling/RelAstGrammarFileType.java +++ b/src/main/java/org/jastadd/tooling/RelAstGrammarFileType.java @@ -33,7 +33,6 @@ public class RelAstGrammarFileType extends LanguageFileType { } - @Nullable @Override public Icon getIcon() { diff --git a/src/main/java/org/jastadd/tooling/RelAstGrammarReferenceContributor.java b/src/main/java/org/jastadd/tooling/RelAstGrammarReferenceContributor.java index c302968f251a32de7a41d1f13daee492e243db00..326b07524fa33af52382a98d2764d9fea1ba60fa 100644 --- a/src/main/java/org/jastadd/tooling/RelAstGrammarReferenceContributor.java +++ b/src/main/java/org/jastadd/tooling/RelAstGrammarReferenceContributor.java @@ -15,8 +15,8 @@ public class RelAstGrammarReferenceContributor extends PsiReferenceContributor { new PsiReferenceProvider() { @NotNull @Override - public PsiReference[] getReferencesByElement(@NotNull PsiElement element, - @NotNull ProcessingContext context) { + public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, + @NotNull ProcessingContext context) { RelAstGrammarTypeReference typeReference = (RelAstGrammarTypeReference) element; String value = typeReference.getText(); diff --git a/src/main/java/org/jastadd/tooling/RelAstGrammarSyntaxHighlighter.java b/src/main/java/org/jastadd/tooling/RelAstGrammarSyntaxHighlighter.java index fad48b51826737b77d6083c010314e5843b73de5..23bc610ade194ee4c891a330d97c37c2e3edc1f0 100644 --- a/src/main/java/org/jastadd/tooling/RelAstGrammarSyntaxHighlighter.java +++ b/src/main/java/org/jastadd/tooling/RelAstGrammarSyntaxHighlighter.java @@ -62,7 +62,7 @@ public class RelAstGrammarSyntaxHighlighter extends SyntaxHighlighterBase { @NotNull @Override - public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { + public TextAttributesKey @NotNull [] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(RelAstGrammarTypes.ABSTRACT)) { return KEYWORD_KEYS; diff --git a/src/main/java/org/jastadd/tooling/psi/RelAstGrammarElementFactory.java b/src/main/java/org/jastadd/tooling/psi/RelAstGrammarElementFactory.java index 10a87a86f102f4a236019675f51c03ffa7da9480..df3bef4d1782301d2a97cbe908e2a8adc9f530e6 100644 --- a/src/main/java/org/jastadd/tooling/psi/RelAstGrammarElementFactory.java +++ b/src/main/java/org/jastadd/tooling/psi/RelAstGrammarElementFactory.java @@ -5,7 +5,14 @@ import com.intellij.psi.PsiFileFactory; import org.jastadd.tooling.RelAstGrammarFileType; import org.jastadd.tooling.parser.RelAstGrammarTypes; +import java.util.Objects; + public class RelAstGrammarElementFactory { + + private RelAstGrammarElementFactory() { + throw new IllegalStateException("Utility class"); + } + public static RelAstGrammarDeclaredName createDeclaredName(Project project, String name) { final RelAstGrammarFile file = createFile(project, name + ";"); return (RelAstGrammarDeclaredName) file.getFirstChild().getFirstChild(); @@ -13,7 +20,7 @@ public class RelAstGrammarElementFactory { public static RelAstGrammarTypeReference createTypeReference(Project project, String name) { final RelAstGrammarFile file = createFile(project, "X : " + name + ";"); - return (RelAstGrammarTypeReference) (file.getFirstChild().getNode().findChildByType(RelAstGrammarTypes.TYPE_REFERENCE).getPsi()); + return (RelAstGrammarTypeReference) (Objects.requireNonNull(file.getFirstChild().getNode().findChildByType(RelAstGrammarTypes.TYPE_REFERENCE)).getPsi()); } public static RelAstGrammarFile createFile(Project project, String text) { diff --git a/src/main/java/org/jastadd/tooling/psi/RelAstGrammarTypeReferenceManipulator.java b/src/main/java/org/jastadd/tooling/psi/RelAstGrammarTypeReferenceManipulator.java index f05b01aa1bb88a3a7b15d4c9c1d2f4687587974f..38112626dddc2521650a3af32c2e7490ad20fee0 100644 --- a/src/main/java/org/jastadd/tooling/psi/RelAstGrammarTypeReferenceManipulator.java +++ b/src/main/java/org/jastadd/tooling/psi/RelAstGrammarTypeReferenceManipulator.java @@ -26,16 +26,4 @@ public class RelAstGrammarTypeReferenceManipulator extends AbstractElementManipu throw new IncorrectOperationException(e); } } - -// @Nullable -// @Override -// public PsiElement handleContentChange(@NotNull PsiElement element, String newContent) throws IncorrectOperationException { -// if (element instanceof RelAstGrammarTypeReference) { -// RelAstGrammarTypeReference ref = (RelAstGrammarTypeReference) element; -// ref.setName(newContent); -// } else { -// throw new IncorrectOperationException("Called with wrong element type " + element.getClass().getName()); -// } -// return element; -// } } diff --git a/src/main/java/org/jastadd/tooling/psi/impl/RelAstGrammarNamedElementImpl.java b/src/main/java/org/jastadd/tooling/psi/impl/RelAstGrammarNamedElementImpl.java index fd20d16f96cf2dad7696f9874d49f080413b2734..11c41f499e3e529a2cf16b801b251b5a3f934ac1 100644 --- a/src/main/java/org/jastadd/tooling/psi/impl/RelAstGrammarNamedElementImpl.java +++ b/src/main/java/org/jastadd/tooling/psi/impl/RelAstGrammarNamedElementImpl.java @@ -10,7 +10,7 @@ import org.jetbrains.annotations.Nullable; public abstract class RelAstGrammarNamedElementImpl extends ASTWrapperPsiElement implements RelAstGrammarNamedElement { - public RelAstGrammarNamedElementImpl(@NotNull ASTNode node) { + protected RelAstGrammarNamedElementImpl(@NotNull ASTNode node) { super(node); } @@ -21,7 +21,7 @@ public abstract class RelAstGrammarNamedElementImpl extends ASTWrapperPsiElement } @NotNull - public PsiReference[] getReferences() { + public PsiReference @NotNull [] getReferences() { return ReferenceProvidersRegistry.getReferencesFromProviders(this); }