Search in sources :

Example 1 with Transformation

use of org.jetbrains.plugins.groovy.codeInspection.changeToOperator.transformations.Transformation in project intellij-community by JetBrains.

the class ChangeToOperatorInspection method buildVisitor.

@NotNull
@Override
protected BaseInspectionVisitor buildVisitor() {
    return new BaseInspectionVisitor() {

        @Override
        public void visitMethodCallExpression(@NotNull GrMethodCallExpression methodCall) {
            final String methodName = getMethodName(methodCall);
            if (methodName == null)
                return;
            Transformation transformation = TRANSFORMATIONS.get(methodName);
            if (transformation == null)
                return;
            PsiElement highlightElement = getHighlightElement(methodCall);
            if (highlightElement == null)
                return;
            if (transformation.couldApply(methodCall, getOptions())) {
                registerError(highlightElement, message("replace.with.operator.message", methodName), new LocalQuickFix[] { getFix(transformation, methodName) }, GENERIC_ERROR_OR_WARNING);
            }
        }
    };
}
Also used : Transformation(org.jetbrains.plugins.groovy.codeInspection.changeToOperator.transformations.Transformation) BaseInspectionVisitor(org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor) GrMethodCallExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression) NotNull(org.jetbrains.annotations.NotNull) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 NotNull (org.jetbrains.annotations.NotNull)1 BaseInspectionVisitor (org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor)1 Transformation (org.jetbrains.plugins.groovy.codeInspection.changeToOperator.transformations.Transformation)1 GrMethodCallExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression)1