Package com.googlecode.equalsnhashcode.inspections

Source Code of com.googlecode.equalsnhashcode.inspections.EqualsInspection

/*
*   Copyright [2008] [Anay Nayak]
*
*    Licensed under the Apache License, Version 2.0 (the "License");
*    you may not use this file except in compliance with the License.
*    You may obtain a copy of the License at
*
*        http://www.apache.org/licenses/LICENSE-2.0
*
*    Unless required by applicable law or agreed to in writing, software
*    distributed under the License is distributed on an "AS IS" BASIS,
*    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*    See the License for the specific language governing permissions and
*    limitations under the License.
*/

package com.googlecode.equalsnhashcode.inspections;

import com.googlecode.equalsnhashcode.finders.EqualsMethodFinder;
import com.googlecode.equalsnhashcode.finders.ProblemFinder;
import com.intellij.codeInsight.daemon.GroupNames;
import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class EqualsInspection extends LocalInspectionTool {
    private static final String FIELD_NOT_INCLUDED_IN_EQUALS_METHOD = "field '%s' not included in equals method";

    @Nullable
    public ProblemDescriptor[] checkClass(@NotNull PsiClass psiClass, @NotNull InspectionManager inspectionManager, boolean onTheFly) {
        PsiMethod psiMethod = new EqualsMethodFinder(psiClass).find();
        List<ProblemDescriptor> equalsProblemDescriptors = new ProblemFinder(psiClass, inspectionManager, FIELD_NOT_INCLUDED_IN_EQUALS_METHOD).process(psiMethod);
        return equalsProblemDescriptors.toArray(new ProblemDescriptor[equalsProblemDescriptors.size()]);
    }

    public boolean runForWholeFile() {
        return true;
    }

    @Nls
    @NotNull
    public String getGroupDisplayName() {
        return GroupNames.BUGS_GROUP_NAME;
    }

    @Nls
    @NotNull
    public String getDisplayName() {
        return "field not used in equals()";
    }

    @NonNls
    @NotNull
    public String getShortName() {
        return "EqualsInspection";
    }

    public boolean isEnabledByDefault() {
        return true;
    }


}

TOP

Related Classes of com.googlecode.equalsnhashcode.inspections.EqualsInspection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.