Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* User: anna
* Date: 18-Dec-2007
*/
package com.intellij.java.analysis.codeInspection;

import com.intellij.java.analysis.codeInspection.ex.EntryPointsManager;
import consulo.annotation.access.RequiredReadAction;
import consulo.language.editor.inspection.GlobalInspectionContextExtension;
import com.intellij.java.analysis.codeInspection.reference.RefClass;
import com.intellij.java.analysis.codeInspection.reference.RefField;
Expand All @@ -32,67 +28,71 @@
import consulo.language.psi.PsiReference;
import consulo.application.util.function.Processor;

/**
* @author anna
* @since 2007-12-18
*/
public abstract class GlobalJavaInspectionContext implements GlobalInspectionContextExtension<GlobalJavaInspectionContext> {
public static final Key<GlobalJavaInspectionContext> CONTEXT = Key.create("GlobalJavaInspectionContext");
public static final Key<GlobalJavaInspectionContext> CONTEXT = Key.create("GlobalJavaInspectionContext");

public interface DerivedClassesProcessor extends Processor<PsiClass> {
}
public interface DerivedClassesProcessor extends Processor<PsiClass> {
}

public interface DerivedMethodsProcessor extends Processor<PsiMethod> {
}
public interface DerivedMethodsProcessor extends Processor<PsiMethod> {
}

public interface UsagesProcessor extends Processor<PsiReference> {
}
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 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 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 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 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);
/**
* 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, @RequiredReadAction UsagesProcessor p);

public abstract EntryPointsManager getEntryPointsManager(RefManager manager);
public abstract EntryPointsManager getEntryPointsManager(RefManager manager);

@Override
public Key<GlobalJavaInspectionContext> getID() {
return CONTEXT;
}
@Override
public Key<GlobalJavaInspectionContext> getID() {
return CONTEXT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private static PsiMethod findWrapper(PsiType type, @Nonnull PsiClassType expecte
}

@Override
@RequiredReadAction
public boolean isAvailable(@Nonnull Project project, Editor editor, PsiFile file) {
return myExpression.isValid()
&& myExpression.getManager().isInProject(myExpression)
Expand All @@ -125,10 +126,9 @@ public void invoke(@Nonnull Project project, Editor editor, PsiFile file) throws
assert wrapper != null;
PsiElementFactory factory = JavaPsiFacade.getInstance(file.getProject()).getElementFactory();
String methodCallText = "Foo." + wrapper.getName() + "()";
PsiMethodCallExpression call = (PsiMethodCallExpression)factory.createExpressionFromText(methodCallText, null);
PsiMethodCallExpression call = (PsiMethodCallExpression) factory.createExpressionFromText(methodCallText, null);
call.getArgumentList().add(myExpression);
((PsiReferenceExpression)call.getMethodExpression().getQualifierExpression())
.bindToElement(wrapper.getContainingClass());
((PsiReferenceExpression) call.getMethodExpression().getQualifierExpression()).bindToElement(wrapper.getContainingClass());
myExpression.replace(call);
}

Expand All @@ -155,7 +155,7 @@ public static void registerWrapAction(
PsiSubstitutor substitutor = candidate.getSubstitutor();
PsiElement element = candidate.getElement();
assert element != null;
PsiMethod method = (PsiMethod)element;
PsiMethod method = (PsiMethod) element;
PsiParameter[] parameters = method.getParameterList().getParameters();
if (!method.isVarArgs() && parameters.length != expressions.length) {
continue;
Expand Down
Loading
Loading