IDEADEV-31824 (Incorrect "manual array copy" warning)
[fedora-idea.git] / plugins / InspectionGadgets / src / com / siyeh / ig / bugs / MisspelledCompareToInspection.java
blobe595d8a309f5c2667fb99720e09de0d502359ed9
1 /*
2 * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.siyeh.ig.bugs;
18 import com.intellij.psi.PsiMethod;
19 import com.intellij.psi.PsiParameterList;
20 import com.siyeh.HardcodedMethodConstants;
21 import com.siyeh.InspectionGadgetsBundle;
22 import com.siyeh.ig.BaseInspection;
23 import com.siyeh.ig.BaseInspectionVisitor;
24 import com.siyeh.ig.InspectionGadgetsFix;
25 import com.siyeh.ig.fixes.RenameFix;
26 import org.jetbrains.annotations.NonNls;
27 import org.jetbrains.annotations.NotNull;
29 public class MisspelledCompareToInspection extends BaseInspection {
31 @NotNull
32 public String getDisplayName() {
33 return InspectionGadgetsBundle.message(
34 "misspelled.compareto.display.name");
37 @NotNull
38 public String buildErrorString(Object... infos) {
39 return InspectionGadgetsBundle.message(
40 "misspelled.compareto.problem.descriptor");
43 protected InspectionGadgetsFix buildFix(Object... infos) {
44 return new RenameFix(HardcodedMethodConstants.COMPARE_TO);
47 public BaseInspectionVisitor buildVisitor() {
48 return new MisspelledCompareToVisitor();
51 private static class MisspelledCompareToVisitor
52 extends BaseInspectionVisitor {
54 @Override public void visitMethod(@NotNull PsiMethod method) {
55 //note: no call to super
56 @NonNls final String methodName = method.getName();
57 if (!"compareto".equals(methodName)) {
58 return;
60 final PsiParameterList parameterList = method.getParameterList();
61 if (parameterList.getParametersCount() != 1) {
62 return;
64 registerMethodError(method);