Skip to content
Snippets Groups Projects
Commit 2357108c authored by Johannes Mey's avatar Johannes Mey
Browse files

code cleanup

parent 690ff513
Branches
Tags
No related merge requests found
Showing with 21 additions and 30 deletions
......@@ -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);
}
package org.jastadd.tooling;
import com.intellij.lang.Language;
public class RelAstGrammar extends Language {
public static final RelAstGrammar INSTANCE = new RelAstGrammar();
private RelAstGrammar() {
super("JastAddGrammar");
}
}
......@@ -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;
}
......
......@@ -33,7 +33,6 @@ public class RelAstGrammarFileType extends LanguageFileType {
}
@Nullable
@Override
public Icon getIcon() {
......
......@@ -15,7 +15,7 @@ public class RelAstGrammarReferenceContributor extends PsiReferenceContributor {
new PsiReferenceProvider() {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element,
@NotNull ProcessingContext context) {
RelAstGrammarTypeReference typeReference = (RelAstGrammarTypeReference) element;
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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;
// }
}
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment