com.intellij.codeInspection
Class LocalInspectionTool

java.lang.Object
  extended by com.intellij.codeInspection.LocalInspectionTool

public abstract class LocalInspectionTool
extends java.lang.Object

Implement this abstract class in order to provide new inspection tool functionality. The major API limitation here is subclasses should be stateless. Thus check<XXX> methods will be called in no particular order and instances of this class provided by InspectionToolProvider.getInspectionClasses() will be created on demand. The other important thing is problem anchors (PsiElements) reported by check<XXX> methods should lie under corresponding first parameter of one method.


Constructor Summary
LocalInspectionTool()
           
 
Method Summary
 ProblemDescriptor[] checkClass(PsiClass aClass, InspectionManager manager, boolean isOnTheFly)
          Override this to report problems at class level.
 ProblemDescriptor[] checkField(PsiField field, InspectionManager manager, boolean isOnTheFly)
          Override this to report problems at field level.
 ProblemDescriptor[] checkFile(PsiFile file, InspectionManager manager, boolean isOnTheFly)
          Override this to report problems at file level.
 ProblemDescriptor[] checkMethod(PsiMethod method, InspectionManager manager, boolean isOnTheFly)
          Override this to report problems at method level.
 javax.swing.JComponent createOptionsPanel()
           
 HighlightDisplayLevel getDefaultLevel()
           
abstract  java.lang.String getDisplayName()
           
abstract  java.lang.String getGroupDisplayName()
           
 java.lang.String getID()
           
abstract  java.lang.String getShortName()
           
 boolean isEnabledByDefault()
           
 void readSettings(org.jdom.Element node)
          Read in settings from xml config.
 void writeSettings(org.jdom.Element node)
          Store current settings in xml config.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalInspectionTool

public LocalInspectionTool()
Method Detail

checkMethod

@Nullable
public ProblemDescriptor[] checkMethod(PsiMethod method,
                                                InspectionManager manager,
                                                boolean isOnTheFly)
Override this to report problems at method level.

Parameters:
method - to check.
manager - InspectionManager to ask for ProblemDescriptor's from.
isOnTheFly - true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
Returns:
null if no problems found or not applicable at method level.

checkClass

@Nullable
public ProblemDescriptor[] checkClass(PsiClass aClass,
                                               InspectionManager manager,
                                               boolean isOnTheFly)
Override this to report problems at class level.

Parameters:
aClass - to check.
manager - InspectionManager to ask for ProblemDescriptor's from.
isOnTheFly - true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
Returns:
null if no problems found or not applicable at class level.

checkField

@Nullable
public ProblemDescriptor[] checkField(PsiField field,
                                               InspectionManager manager,
                                               boolean isOnTheFly)
Override this to report problems at field level.

Parameters:
field - to check.
manager - InspectionManager to ask for ProblemDescriptor's from.
isOnTheFly - true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
Returns:
null if no problems found or not applicable at field level.

checkFile

@Nullable
public ProblemDescriptor[] checkFile(PsiFile file,
                                              InspectionManager manager,
                                              boolean isOnTheFly)
Override this to report problems at file level.

Parameters:
file - to check.
manager - InspectionManager to ask for ProblemDescriptor's from.
isOnTheFly - true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
Returns:
null if no problems found or not applicable at field level.

getGroupDisplayName

public abstract java.lang.String getGroupDisplayName()

getDisplayName

public abstract java.lang.String getDisplayName()

getShortName

public abstract java.lang.String getShortName()
Returns:
short name that is used in two cases: \inspectionDescriptions\<short_name>.html resource may contain short inspection description to be shown in "Inspect Code..." dialog and also provide some file name convention when using offline inspection or export to HTML function. Should be unique among all inspections.

getDefaultLevel

public HighlightDisplayLevel getDefaultLevel()
Returns:
highlighting level for this inspection tool that is used in default settings

isEnabledByDefault

public boolean isEnabledByDefault()

createOptionsPanel

@Nullable
public javax.swing.JComponent createOptionsPanel()
Returns:
null if no UI options required

getID

public java.lang.String getID()
Returns:
descriptive name to be used in "suppress" comments and annotations, must consist of [a-zA-Z_0-9]+

readSettings

public void readSettings(org.jdom.Element node)
                  throws InvalidDataException
Read in settings from xml config. Default implementation uses DefaultJDOMExternalizer so you may use public fields like int TOOL_OPTION to store your options.

Parameters:
node - to read settings from.
Throws:
InvalidDataException

writeSettings

public void writeSettings(org.jdom.Element node)
                   throws WriteExternalException
Store current settings in xml config. Default implementation uses DefaultJDOMExternalizer so you may use public fields like int TOOL_OPTION to store your options.

Parameters:
node - to store settings to.
Throws:
WriteExternalException