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
Branches
Tags
1 merge request!1Resolve "Renaming of Nonterminal Does Not Rename All Occurences"
...@@ -19,8 +19,8 @@ public class AspectReferenceContributor extends PsiReferenceContributor { ...@@ -19,8 +19,8 @@ public class AspectReferenceContributor extends PsiReferenceContributor {
@Override @Override
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element,
@NotNull ProcessingContext context) { @NotNull ProcessingContext context) {
JastAddAspectAstTypeName typeReference = (JastAddAspectAstTypeName) element; JastAddAspectAstTypeName astTypeName = (JastAddAspectAstTypeName) element;
String value = typeReference.getText(); String value = astTypeName.getText();
if (value != null) { if (value != null) {
TextRange range = new TextRange(0, value.length()); TextRange range = new TextRange(0, value.length());
return new PsiReference[]{new GrammarReference(element, range)}; return new PsiReference[]{new GrammarReference(element, range)};
...@@ -34,9 +34,9 @@ public class AspectReferenceContributor extends PsiReferenceContributor { ...@@ -34,9 +34,9 @@ public class AspectReferenceContributor extends PsiReferenceContributor {
@Override @Override
public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element,
@NotNull ProcessingContext context) { @NotNull ProcessingContext context) {
JastAddAspectClassOrInterfaceType typeReference = (JastAddAspectClassOrInterfaceType) element; JastAddAspectClassOrInterfaceType classOrInterfaceType = (JastAddAspectClassOrInterfaceType) element;
if (typeReference.getTypeArgumentsList().isEmpty() && typeReference.getJavaIdentifierList().size() == 1) { if (classOrInterfaceType.getTypeArgumentsList().isEmpty() && classOrInterfaceType.getJavaIdentifierList().size() == 1) {
String value = typeReference.getJavaIdentifierList().get(0).getText(); String value = classOrInterfaceType.getJavaIdentifierList().get(0).getText();
if (value != null) { if (value != null) {
TextRange range = new TextRange(0, value.length()); TextRange range = new TextRange(0, value.length());
return new PsiReference[]{new GrammarReference(element, range)}; return new PsiReference[]{new GrammarReference(element, range)};
......
...@@ -24,6 +24,7 @@ public class JastAddAspectAstTypeNameImplExtension extends GrammarNamedElementIm ...@@ -24,6 +24,7 @@ public class JastAddAspectAstTypeNameImplExtension extends GrammarNamedElementIm
ASTNode keyNode = getNode().getFirstChildNode(); ASTNode keyNode = getNode().getFirstChildNode();
if (keyNode != null) { if (keyNode != null) {
JastAddAspectAstTypeName name = AspectElementFactory.createAstTypeName(getProject(), newName); 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(); ASTNode newKeyNode = name.getNode().getFirstChildNode();
getNode().replaceChild(keyNode, newKeyNode); getNode().replaceChild(keyNode, newKeyNode);
} }
......
...@@ -24,6 +24,7 @@ public class JastAddAspectClassOrInterfaceTypeImplExtension extends GrammarNamed ...@@ -24,6 +24,7 @@ public class JastAddAspectClassOrInterfaceTypeImplExtension extends GrammarNamed
ASTNode keyNode = getNode().getFirstChildNode(); ASTNode keyNode = getNode().getFirstChildNode();
if (keyNode != null) { if (keyNode != null) {
JastAddAspectClassOrInterfaceType name = AspectElementFactory.createClassOrInterfaceType(getProject(), newName); 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(); ASTNode newKeyNode = name.getNode().getFirstChildNode();
getNode().replaceChild(keyNode, newKeyNode); getNode().replaceChild(keyNode, newKeyNode);
} }
......
...@@ -5,7 +5,6 @@ import com.intellij.psi.PsiElement; ...@@ -5,7 +5,6 @@ import com.intellij.psi.PsiElement;
import org.jastadd.tooling.grammar.psi.GrammarComponentName; import org.jastadd.tooling.grammar.psi.GrammarComponentName;
import org.jastadd.tooling.grammar.psi.GrammarElementFactory; import org.jastadd.tooling.grammar.psi.GrammarElementFactory;
import org.jastadd.tooling.grammar.psi.GrammarNamedElement; import org.jastadd.tooling.grammar.psi.GrammarNamedElement;
import org.jastadd.tooling.grammar.psi.GrammarTypeName;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class GrammarComponentNameImplExtension extends GrammarNamedElementImpl implements GrammarNamedElement { 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