inspections-openapi

This commit is contained in:
Dmitry Jemerov
2009-08-29 14:29:17 +04:00
parent b120bad5ac
commit 6b271e756f
21 changed files with 0 additions and 4 deletions
-1
View File
@@ -30,7 +30,6 @@
<orderEntry type="module" module-name="extensions" exported="" />
<orderEntry type="module" module-name="icons" />
<orderEntry type="module" module-name="resources_eng" exported="" />
<orderEntry type="module" module-name="inspections-openapi" exported="" />
<orderEntry type="module" module-name="execution-openapi" exported="" />
<orderEntry type="library" exported="" name="NanoXML" level="project" />
<orderEntry type="library" exported="" name="microba" level="project" />
@@ -0,0 +1,81 @@
/*
* User: anna
* Date: 18-Dec-2007
*/
package com.intellij.codeInspection;
import com.intellij.codeInspection.ex.EntryPointsManager;
import com.intellij.codeInspection.lang.GlobalInspectionContextExtension;
import com.intellij.codeInspection.reference.RefClass;
import com.intellij.codeInspection.reference.RefField;
import com.intellij.codeInspection.reference.RefManager;
import com.intellij.codeInspection.reference.RefMethod;
import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiReference;
import com.intellij.util.Processor;
public abstract class GlobalJavaInspectionContext implements GlobalInspectionContextExtension<GlobalJavaInspectionContext> {
public static final Key<GlobalJavaInspectionContext> CONTEXT = Key.create("GlobalJavaInspectionContext");
public interface DerivedClassesProcessor extends Processor<PsiClass> {
}
public interface DerivedMethodsProcessor extends Processor<PsiMethod> {
}
public interface UsagesProcessor extends Processor<PsiReference> {
}
/**
* Requests that usages of the specified class outside the current analysis
* scope be passed to the specified processor.
*
* @param refClass the reference graph node for the class whose usages should be processed.
* @param p the processor to pass the usages to.
*/
public abstract void enqueueClassUsagesProcessor(RefClass refClass, UsagesProcessor p);
/**
* Requests that derived classes of the specified class outside the current analysis
* scope be passed to the specified processor.
*
* @param refClass the reference graph node for the class whose derived classes should be processed.
* @param p the processor to pass the classes to.
*/
public abstract void enqueueDerivedClassesProcessor(RefClass refClass, DerivedClassesProcessor p);
/**
* Requests that implementing or overriding methods of the specified method outside
* the current analysis scope be passed to the specified processor.
*
* @param refMethod the reference graph node for the method whose derived methods should be processed.
* @param p the processor to pass the methods to.
*/
public abstract void enqueueDerivedMethodsProcessor(RefMethod refMethod, DerivedMethodsProcessor p);
/**
* Requests that usages of the specified field outside the current analysis
* scope be passed to the specified processor.
*
* @param refField the reference graph node for the field whose usages should be processed.
* @param p the processor to pass the usages to.
*/
public abstract void enqueueFieldUsagesProcessor(RefField refField, UsagesProcessor p);
/**
* Requests that usages of the specified method outside the current analysis
* scope be passed to the specified processor.
*
* @param refMethod the reference graph node for the method whose usages should be processed.
* @param p the processor to pass the usages to.
*/
public abstract void enqueueMethodUsagesProcessor(RefMethod refMethod, UsagesProcessor p);
public abstract EntryPointsManager getEntryPointsManager(RefManager manager);
public Key<GlobalJavaInspectionContext> getID() {
return CONTEXT;
}
}
@@ -0,0 +1,31 @@
/*
* User: anna
* Date: 19-Dec-2007
*/
package com.intellij.codeInspection;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInspection.reference.RefManager;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
public abstract class GlobalJavaInspectionTool extends GlobalInspectionTool implements CustomSuppressableInspectionTool {
public boolean queryExternalUsagesRequests(final InspectionManager manager,
final GlobalInspectionContext globalContext,
final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
return queryExternalUsagesRequests(globalContext.getRefManager(), globalContext.getExtension(GlobalJavaInspectionContext.CONTEXT), problemDescriptionsProcessor);
}
protected boolean queryExternalUsagesRequests(RefManager manager, GlobalJavaInspectionContext globalContext, ProblemDescriptionsProcessor processor) {
return false;
}
@Nullable
public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
return SuppressManager.getInstance().createSuppressActions(HighlightDisplayKey.find(getShortName()));
}
public boolean isSuppressedFor(final PsiElement element) {
return SuppressManager.getInstance().isSuppressedFor(element, getShortName());
}
}
@@ -0,0 +1,50 @@
/*
* User: anna
* Date: 19-Dec-2007
*/
package com.intellij.codeInspection;
import com.intellij.codeInspection.lang.HTMLComposerExtension;
import com.intellij.codeInspection.reference.RefClass;
import com.intellij.codeInspection.reference.RefMethod;
import com.intellij.lang.Language;
import com.intellij.lang.StdLanguages;
import com.intellij.openapi.util.Key;
public abstract class HTMLJavaHTMLComposer implements HTMLComposerExtension<HTMLJavaHTMLComposer> {
public static final Key<HTMLJavaHTMLComposer> COMPOSER = Key.create("HTMLJavaComposer");
public abstract void appendClassOrInterface(StringBuffer buf, RefClass refClass, boolean capitalizeFirstLetter);
public static String getClassOrInterface(RefClass refClass, boolean capitalizeFirstLetter) {
if (refClass.isInterface()) {
return capitalizeFirstLetter ? InspectionsBundle.message("inspection.export.results.capitalized.interface") : InspectionsBundle.message("inspection.export.results.interface");
}
else if (refClass.isAbstract()) {
return capitalizeFirstLetter ? InspectionsBundle.message("inspection.export.results.capitalized.abstract.class") : InspectionsBundle.message("inspection.export.results.abstract.class");
}
else {
return capitalizeFirstLetter ? InspectionsBundle.message("inspection.export.results.capitalized.class") : InspectionsBundle.message("inspection.export.results.class");
}
}
public abstract void appendClassExtendsImplements(StringBuffer buf, RefClass refClass);
public abstract void appendDerivedClasses(StringBuffer buf, RefClass refClass);
public abstract void appendLibraryMethods(StringBuffer buf, RefClass refClass);
public abstract void appendSuperMethods(StringBuffer buf, RefMethod refMethod);
public abstract void appendDerivedMethods(StringBuffer buf, RefMethod refMethod);
public abstract void appendTypeReferences(StringBuffer buf, RefClass refClass);
public Key<HTMLJavaHTMLComposer> getID() {
return COMPOSER;
}
public Language getLanguage() {
return StdLanguages.JAVA;
}
}
@@ -0,0 +1,48 @@
/*
* User: anna
* Date: 24-Dec-2007
*/
package com.intellij.codeInspection;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.psi.PsiDocCommentOwner;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiModifierListOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
public abstract class SuppressManager {
public static final String SUPPRESS_INSPECTIONS_ANNOTATION_NAME = "java.lang.SuppressWarnings";
public static SuppressManager getInstance() {
return ServiceManager.getService(SuppressManager.class);
}
public abstract SuppressIntentionAction[] createSuppressActions(HighlightDisplayKey key);
public abstract boolean isSuppressedFor(final PsiElement element, final String toolId);
public abstract PsiElement getElementMemberSuppressedIn(final PsiDocCommentOwner owner, final String inspectionToolID);
@Nullable
public abstract PsiElement getAnnotationMemberSuppressedIn(PsiModifierListOwner owner, String inspectionToolID);
@Nullable
public abstract PsiElement getDocCommentToolSuppressedIn(PsiDocCommentOwner owner, String inspectionToolID);
@NotNull
public abstract Collection<String> getInspectionIdsSuppressedInAnnotation(PsiModifierListOwner owner);
@Nullable
public abstract String getSuppressedInspectionIdsIn(PsiElement element);
@Nullable
public abstract PsiElement getElementToolSuppressedIn(PsiElement place, String toolId);
public abstract boolean canHave15Suppressions(PsiElement file);
public abstract boolean alreadyHas14Suppressions(PsiDocCommentOwner commentOwner);
}
@@ -0,0 +1,37 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
*
* 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.intellij.codeInspection.deadCode;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public abstract class UnusedCodeExtension implements JDOMExternalizable {
@NotNull
public abstract String getDisplayName();
public abstract boolean isEntryPoint(RefElement refElement);
public abstract boolean isEntryPoint(PsiElement psiElement);
public abstract boolean isSelected();
public abstract void setSelected(boolean selected);
@Nullable
public String [] getIgnoreAnnotations() {
return null;
}
}
@@ -0,0 +1,38 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
*
* 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.
*/
/*
* User: anna
* Date: 28-Feb-2007
*/
package com.intellij.codeInspection.ex;
import com.intellij.codeInspection.reference.RefElement;
import com.intellij.codeInspection.reference.RefManager;
public interface EntryPointsManager {
void resolveEntryPoints(RefManager manager);
void addEntryPoint(RefElement newEntryPoint, boolean isPersistent);
void removeEntryPoint(RefElement anEntryPoint);
RefElement[] getEntryPoints();
void cleanup();
boolean isAddNonJavaEntries();
}
@@ -0,0 +1,29 @@
<!--
~ Copyright 2000-2007 JetBrains s.r.o.
~
~ 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.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><body bgcolor="white">
Provides interfaces for registering and implementing code inspections. To register inspections,
a plugin should implement the {@link com.intellij.codeInspection.InspectionToolProvider} interface and return the
list of inspection classes from the <code>getInspectionClasses()</code> method.
An inspection is a class extending {@link com.intellij.codeInspection.LocalInspectionTool}. During background code
analysis or when the "Inspect Code..." action is invoked,, IDEA calls the inspection
to inspect individual files, classes, methods and fields, and if the inspection detects any problems,
it returns an array of {@link com.intellij.codeInspection.ProblemDescriptor} classes reporting the problem. Each problem
descriptor can return a list of {@link com.intellij.codeInspection.LocalQuickFix} classes, each of which represents an
action which the user can invoke by pressing Alt-Enter in order to fix the problem detected
by the inspection.
</body></html>
@@ -0,0 +1,71 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
*
* 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.intellij.codeInspection.reference;
import com.intellij.psi.PsiClass;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* User: anna
* Date: 27-Dec-2005
*/
public interface RefClass extends RefJavaElement {
@NotNull
HashSet<RefClass> getBaseClasses();
@NotNull
HashSet<RefClass> getSubClasses();
@NotNull
ArrayList<RefMethod> getConstructors();
@NotNull
Set<RefElement> getInTypeReferences();
@NotNull
Set<RefElement> getInstanceReferences();
RefMethod getDefaultConstructor();
@NotNull
List<RefMethod> getLibraryMethods();
boolean isAnonymous();
boolean isInterface();
boolean isUtilityClass();
boolean isAbstract();
boolean isApplet();
boolean isServlet();
boolean isTestCase();
boolean isLocalClass();
boolean isSelfInheritor(PsiClass psiClass);
PsiClass getElement();
}
@@ -0,0 +1,56 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
*
* 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.intellij.codeInspection.reference;
import com.intellij.psi.PsiField;
/**
* A node in the reference graph corresponding to a Java field.
*
* @author anna
* @since 6.0
*/
public interface RefField extends RefJavaElement {
/**
* Checks if the field is used for reading.
*
* @return true if the field has read accesses, false otherwise.
*/
boolean isUsedForReading();
/**
* Checks if the field is used for writing.
*
* @return true if the field has write accesses, false otherwise.
*/
boolean isUsedForWriting();
/**
* Checks if the only write access of the field is its initializer.
*
* @return true if the only write access of the field is its initializer, false otherwise.
*/
boolean isOnlyAssignedInInitializer();
/**
* Returns the reference graph node for the class to which the field belongs.
*
* @return the owner class of the field.
*/
RefClass getOwnerClass();
PsiField getElement();
}
@@ -0,0 +1,25 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
*
* 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.intellij.codeInspection.reference;
/**
* A node in the reference graph corresponding to the implicit constructor of a Java class.
*
* @author anna
* @since 6.0
*/
public interface RefImplicitConstructor extends RefMethod {
}
@@ -0,0 +1,59 @@
/*
* User: anna
* Date: 18-Dec-2007
*/
package com.intellij.codeInspection.reference;
import com.intellij.psi.Modifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
public interface RefJavaElement extends RefElement {
/**
* Returns the collection of references used in this element.
* @return the collection of used types
*/
@NotNull
Collection<RefClass> getOutTypeReferences();
/**
* Checks if the element is <code>final</code>.
*
* @return true if the element is final, false otherwise.
*/
boolean isFinal();
/**
* Checks if the element is <code>static</code>.
*
* @return true if the element is static, false otherwise.
*/
boolean isStatic();
/**
* Checks if the element directly references any elements marked as deprecated.
*
* @return true if the element references any deprecated elements, false otherwise.
*/
boolean isUsesDeprecatedApi();
/**
* Checks if the element is, or belongs to, a synthetic class or method created for a JSP page.
*
* @return true if the element is a synthetic JSP element, false otherwise.
*/
boolean isSyntheticJSP();
/**
* Returns the access modifier for the element, as one of the keywords from the
* {@link com.intellij.psi.PsiModifier} class.
*
* @return the modifier, or null if the element does not have any access modifier.
*/
@Nullable
@Modifier
String getAccessModifier();
}
@@ -0,0 +1,64 @@
/*
* User: anna
* Date: 18-Dec-2007
*/
package com.intellij.codeInspection.reference;
import com.intellij.codeInspection.ex.EntryPointsManager;
import com.intellij.codeInspection.lang.RefManagerExtension;
import com.intellij.lang.Language;
import com.intellij.lang.StdLanguages;
import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.PsiParameter;
import org.jetbrains.annotations.NonNls;
public abstract class RefJavaManager implements RefManagerExtension<RefJavaManager> {
@NonNls public static final String CLASS = "class";
@NonNls public static final String METHOD = "method";
@NonNls public static final String FIELD = "field";
@NonNls public static final String PARAMETER = "parameter";
//used in OfflineProjectDescriptor
@NonNls public static final String PACKAGE = "package";
public static final Key<RefJavaManager> MANAGER = Key.create("RefJavaManager");
/**
* Creates (if necessary) and returns the reference graph node for the package
* with the specified name.
*
* @param packageName the name of the package for which the reference graph node is requested.
* @return the node for the package.
*/
public abstract RefPackage getPackage(String packageName);
/**
* Creates (if necessary) and returns the reference graph node for the specified PSI parameter.
*
* @param param the parameter for which the reference graph node is requested.
* @param index the index of the parameter in its parameter list.
* @return the node for the element, or null if the element is not valid or does not have
* a corresponding reference graph node type (is not a field, method, class or file).
*/
public abstract RefParameter getParameterReference(PsiParameter param, int index);
public abstract RefPackage getDefaultPackage();
public abstract PsiMethod getAppMainPattern();
public abstract PsiMethod getAppPremainPattern();
public abstract PsiClass getApplet();
public abstract PsiClass getServlet();
public abstract EntryPointsManager getEntryPointsManager();
public Language getLanguage() {
return StdLanguages.JAVA;
}
public Key<RefJavaManager> getID() {
return MANAGER;
}
}
@@ -0,0 +1,57 @@
/*
* User: anna
* Date: 21-Dec-2007
*/
package com.intellij.codeInspection.reference;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.psi.*;
import org.jetbrains.annotations.Nullable;
public abstract class RefJavaUtil {
public abstract void addReferences(final PsiModifierListOwner psiFrom, final RefJavaElement ref, @Nullable PsiElement findIn);
public abstract RefClass getTopLevelClass(RefElement refElement);
public abstract boolean isInheritor(RefClass subClass, RefClass superClass);
@Nullable //default package name
public abstract String getPackageName(RefEntity refEntity);
@Nullable
public abstract RefClass getOwnerClass(RefManager refManager, PsiElement psiElement);
@Nullable
public abstract RefClass getOwnerClass(RefElement refElement);
public abstract int compareAccess(String a1, String a2);
public abstract String getAccessModifier(PsiModifierListOwner psiElement);
public abstract void setAccessModifier(RefJavaElement refElement, String newAccess);
public abstract void setIsStatic(RefJavaElement refElement, boolean isStatic);
public abstract void setIsFinal(RefJavaElement refElement, boolean isFinal);
public abstract boolean isMethodOnlyCallsSuper(final PsiMethod derivedMethod);
public static boolean isDeprecated(PsiElement psiResolved) {
return psiResolved instanceof PsiDocCommentOwner && ((PsiDocCommentOwner)psiResolved).isDeprecated();
}
@Nullable
public static RefPackage getPackage(RefEntity refEntity) {
while (refEntity != null && !(refEntity instanceof RefPackage)) refEntity = refEntity.getOwner();
return (RefPackage)refEntity;
}
public static RefJavaUtil getInstance() {
return ServiceManager.getService(RefJavaUtil.class);
}
public abstract boolean isCallToSuperMethod(PsiExpression expression, PsiMethod method);
public abstract void addTypeReference(PsiElement psiElement, PsiType psiType, RefManager refManager);
}
@@ -0,0 +1,46 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
*
* 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.intellij.codeInspection.reference;
/**
* Visitor for reference graph nodes.
*
* @see RefEntity#accept
* @see RefManager#iterate
* @since 6.0
*/
public class RefJavaVisitor extends RefVisitor {
public void visitField(RefField field) {
visitElement(field);
}
public void visitMethod(RefMethod method) {
visitElement(method);
}
public void visitParameter(RefParameter parameter) {
visitElement(parameter);
}
public void visitClass(RefClass aClass) {
visitElement(aClass);
}
public void visitPackage(RefPackage aPackage) {
visitElement(aPackage);
}
}
@@ -0,0 +1,158 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
*
* 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.intellij.codeInspection.reference;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiModifierListOwner;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
/**
* A node in the reference graph corresponding to a Java method.
*
* @author anna
* @since 6.0
*/
public interface RefMethod extends RefJavaElement {
/**
* Returns the collection of the direct super methods of this method in the
* analysis scope.
*
* @return the collection of super methods.
* @see com.intellij.psi.PsiMethod#findSuperMethods()
* @see #hasSuperMethods
*/
@NotNull Collection<RefMethod> getSuperMethods();
/**
* Returns the collection of the overriding methods of this method in the
* analysis scope.
*
* @return the collection of overriding methods.
*/
@NotNull Collection<RefMethod> getDerivedMethods();
/**
* Checks if this method has a body (that is, not a method of an interface or an abstract
* method).
*
* @return true if the method has a body, false otherwise.
*/
boolean hasBody();
/**
* Checks if the method has no body or its body contains no statements besides
* (possibly) a call to its super method.
*
* @return true if the element has no body or the body is empty, false otherwise.
*/
boolean isBodyEmpty();
/**
* Checks if the method has a body which consists only of the call to its super method.
*
* @return true if the method only calls its super method, false otherwise.
*/
boolean isOnlyCallsSuper();
/**
* Checks if the method is a test method in a testcase class.
*
* @return true if the method is a test method, false otherwise.
*/
boolean isTestMethod();
/**
* Checks if the signature of the method matches the signature of the standard <code>main</code>
* or <code>premain</code> method.
*
* @return true if the method can be a main function of the application, false otherwise.
*/
boolean isAppMain();
/**
* Checks if the method has super methods either in the analysis scope or outside of it.
*
* @return true if the method has super methods, false otherwise.
* @see #getSuperMethods()
*/
boolean hasSuperMethods();
/**
* Checks if the method overrides a method outside the current analysis scope.
*
* @return true if the method overrides a method not in the analysis scope, false otherwise.
*/
boolean isExternalOverride();
/**
* Checks if the method is a constructor.
*
* @return true if the method is a constructor, false otherwise.
*/
boolean isConstructor();
/**
* Checks if the method is abstract.
*
* @return true if the method is abstract, false otherwise.
*/
boolean isAbstract();
/**
* Checks if the return value of the method is used by any of its callers.
*
* @return true if the method return value is used, false otherwise.
*/
boolean isReturnValueUsed();
/**
* If the method always returns the same value, returns that value (the name of a static
* final field or the text of a literal expression). Otherwise, returns null.
*
* @return the method return value or null if it's different or impossible to determine.
*/
@Nullable String getReturnValueIfSame();
/**
* Returns the list of exceptions which are included in the <code>throws</code> list
* of the method but cannot be actually thrown.
*
* @return the list of exceptions declared but not thrown, or null if there are no
* such exceptions.
*/
@Nullable PsiClass[] getUnThrownExceptions();
/**
* Returns the list of reference graph nodes for the method parameters.
*
* @return the method parameters.
*/
@NotNull RefParameter[] getParameters();
/**
* Returns the class to which the method belongs.
*
* @return the class instance.
*/
RefClass getOwnerClass();
PsiModifierListOwner getElement();
boolean isCalledOnSubClass();
}
@@ -0,0 +1,32 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
*
* 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.intellij.codeInspection.reference;
/**
* A node in the reference graph corresponding to a Java package.
*
* @author anna
* @since 6.0
* @see RefManager#getPackage
*/
public interface RefPackage extends RefEntity {
/**
* Returns the full-qualified name for the package, or an empty string for the default package.
*
* @return the full-qualified name for the package.
*/
String getQualifiedName();
}
@@ -0,0 +1,67 @@
/*
* Copyright 2000-2007 JetBrains s.r.o.
*
* 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.intellij.codeInspection.reference;
import com.intellij.psi.PsiParameter;
import org.jetbrains.annotations.Nullable;
/**
* A node in the reference graph corresponding to a Java method parameter.
*
* @author anna
* @since 6.0
*/
public interface RefParameter extends RefJavaElement {
/**
* Checks if the parameter is used for reading.
*
* @return true if the parameter has read accesses, false otherwise.
*/
boolean isUsedForReading();
/**
* Checks if the parameter is used for writing.
*
* @return true if the parameter has write accesses, false otherwise.
*/
boolean isUsedForWriting();
/**
* Returns the index of the parameter in the parameter list of its owner method.
*
* @return the index of the parameter.
*/
int getIndex();
/**
* If all invocations of the method pass the same value to the parameter, returns
* that value (the name of a static final field or the text of a literal expression).
* Otherwise, returns null.
*
* @return the parameter value or null if it's different or impossible to determine.
*/
@Nullable String getActualValueIfSame();
/**
* Marks the parameter as referenced for reading or writing.
*
* @param forWriting true if the parameter is marked as referenced for writing, false
* otherwise.
*/
void parameterReferenced(final boolean forWriting);
PsiParameter getElement();
}