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

minor cleanup and warning removal

parent 1f5392d9
No related branches found
No related tags found
1 merge request!1Resolve "Renaming of Nonterminal Does Not Rename All Occurences"
This commit is part of merge request !1. Comments created here will be created in the context of that merge request.
......@@ -19,8 +19,8 @@ public class AspectReferenceContributor extends PsiReferenceContributor {
@Override
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element,
@NotNull ProcessingContext context) {
JastAddAspectAstTypeName typeReference = (JastAddAspectAstTypeName) element;
String value = typeReference.getText();
JastAddAspectAstTypeName astTypeName = (JastAddAspectAstTypeName) element;
String value = astTypeName.getText();
if (value != null) {
TextRange range = new TextRange(0, value.length());
return new PsiReference[]{new GrammarReference(element, range)};
......@@ -34,9 +34,9 @@ public class AspectReferenceContributor extends PsiReferenceContributor {
@Override
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element,
@NotNull ProcessingContext context) {
JastAddAspectClassOrInterfaceType typeReference = (JastAddAspectClassOrInterfaceType) element;
if (typeReference.getTypeArgumentsList().isEmpty() && typeReference.getJavaIdentifierList().size() == 1) {
String value = typeReference.getJavaIdentifierList().get(0).getText();
JastAddAspectClassOrInterfaceType classOrInterfaceType = (JastAddAspectClassOrInterfaceType) element;
if (classOrInterfaceType.getTypeArgumentsList().isEmpty() && classOrInterfaceType.getJavaIdentifierList().size() == 1) {
String value = classOrInterfaceType.getJavaIdentifierList().get(0).getText();
if (value != null) {
TextRange range = new TextRange(0, value.length());
return new PsiReference[]{new GrammarReference(element, range)};
......
......@@ -24,6 +24,7 @@ public class JastAddAspectAstTypeNameImplExtension extends GrammarNamedElementIm
ASTNode keyNode = getNode().getFirstChildNode();
if (keyNode != null) {
JastAddAspectAstTypeName name = AspectElementFactory.createAstTypeName(getProject(), newName);
assert name != null; // we know the name is not null because we always create the same one
ASTNode newKeyNode = name.getNode().getFirstChildNode();
getNode().replaceChild(keyNode, newKeyNode);
}
......
......@@ -24,6 +24,7 @@ public class JastAddAspectClassOrInterfaceTypeImplExtension extends GrammarNamed
ASTNode keyNode = getNode().getFirstChildNode();
if (keyNode != null) {
JastAddAspectClassOrInterfaceType name = AspectElementFactory.createClassOrInterfaceType(getProject(), newName);
assert name != null; // we know the name is not null because we always create the same one
ASTNode newKeyNode = name.getNode().getFirstChildNode();
getNode().replaceChild(keyNode, newKeyNode);
}
......
......@@ -5,7 +5,6 @@ import com.intellij.psi.PsiElement;
import org.jastadd.tooling.grammar.psi.GrammarComponentName;
import org.jastadd.tooling.grammar.psi.GrammarElementFactory;
import org.jastadd.tooling.grammar.psi.GrammarNamedElement;
import org.jastadd.tooling.grammar.psi.GrammarTypeName;
import org.jetbrains.annotations.NotNull;
public class GrammarComponentNameImplExtension extends GrammarNamedElementImpl implements GrammarNamedElement {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment