diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties index 5a9566f10765..5ccb19b400aa 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties @@ -105,4 +105,5 @@ add.to.resources=Add to resources add.type.customizer.to.resources=Add type customizer script to resources target.0.does.not.exist=Target ''{0}'' does not exist target.annotation.is.unused=@Target is unused -change.lvalue.type=Change variable ''{0}'' type to ''{1}'' \ No newline at end of file +change.lvalue.type=Change variable ''{0}'' type to ''{1}'' +replace.qualified.name.with.import=Replace qualified name with import \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java index 3383cbb6151c..49ec3ceede6e 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java @@ -50,6 +50,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; public class UnnecessaryQualifiedReferenceInspection extends BaseInspection { private static final Logger LOG = Logger.getInstance(UnnecessaryQualifiedReferenceInspection.class); + @NotNull @Override protected BaseInspectionVisitor buildVisitor() { return new BaseInspectionVisitor() { @@ -84,7 +85,10 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection { final PsiElement parent = ref.getParent(); if (parent instanceof GrMethodCall) { final GrMethodCall copy = (GrMethodCall)parent.copy(); - ((GrReferenceExpression)copy.getInvokedExpression()).setQualifier(null); + GrReferenceExpression invoked = (GrReferenceExpression)copy.getInvokedExpression(); + assert invoked != null; + + invoked.setQualifier(null); copyResolved = ((GrReferenceExpression)copy.getInvokedExpression()).resolve(); } @@ -116,7 +120,7 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection { } @Override - protected GroovyFix buildFix(PsiElement location) { + protected GroovyFix buildFix(@NotNull PsiElement location) { return new GroovyFix() { @Override protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { @@ -128,7 +132,7 @@ public class UnnecessaryQualifiedReferenceInspection extends BaseInspection { @NotNull @Override public String getName() { - return GroovyInspectionBundle.message("unnecessary.qualified.reference"); + return GroovyInspectionBundle.message("replace.qualified.name.with.import"); } }; }