use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class Java15FormInspection method checkComponentProperties.
protected void checkComponentProperties(Module module, final IComponent component, final FormErrorCollector collector) {
final GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
final PsiManager psiManager = PsiManager.getInstance(module.getProject());
final PsiClass aClass = JavaPsiFacade.getInstance(psiManager.getProject()).findClass(component.getComponentClassName(), scope);
if (aClass == null) {
return;
}
for (final IProperty prop : component.getModifiedProperties()) {
final PsiMethod getter = PropertyUtil.findPropertyGetter(aClass, prop.getName(), false, true);
if (getter == null)
continue;
final LanguageLevel languageLevel = LanguageLevelUtil.getEffectiveLanguageLevel(module);
if (Java15APIUsageInspection.getLastIncompatibleLanguageLevel(getter, languageLevel) != null) {
registerError(component, collector, prop, "@since " + Java15APIUsageInspection.getShortName(languageLevel));
}
}
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class GroovyMethodOverrideHandler method handleInsert.
@Override
public void handleInsert(InsertionContext context, LookupElement item) {
context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset());
PsiMethod method = (PsiMethod) item.getObject();
List<PsiMethod> prototypes = OverrideImplementUtil.overrideOrImplementMethod(myPsiClass, method, false);
context.commitDocument();
GenerateMembersUtil.insertMembersAtOffset(context.getFile(), context.getStartOffset(), OverrideImplementUtil.convert2GenerationInfos(prototypes));
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class GrMethodMergingContributor method handleAutoCompletionPossibility.
@Override
public AutoCompletionDecision handleAutoCompletionPossibility(@NotNull AutoCompletionContext context) {
final CompletionParameters parameters = context.getParameters();
if (parameters.getCompletionType() != CompletionType.SMART && parameters.getCompletionType() != CompletionType.BASIC) {
return null;
}
boolean needInsertBrace = false;
boolean needInsertParenth = false;
final LookupElement[] items = context.getItems();
if (items.length > 1) {
String commonName = null;
final ArrayList<PsiMethod> allMethods = new ArrayList<>();
for (LookupElement item : items) {
Object o = item.getPsiElement();
if (item.getUserData(JavaCompletionUtil.FORCE_SHOW_SIGNATURE_ATTR) != null || !(o instanceof PsiMethod)) {
return AutoCompletionDecision.SHOW_LOOKUP;
}
final PsiMethod method = (PsiMethod) o;
final JavaChainLookupElement chain = item.as(JavaChainLookupElement.CLASS_CONDITION_KEY);
final String name = method.getName() + "#" + (chain == null ? "" : chain.getQualifier().getLookupString());
if (commonName != null && !commonName.equals(name)) {
return AutoCompletionDecision.SHOW_LOOKUP;
}
if (hasOnlyClosureParams(method)) {
needInsertBrace = true;
} else {
needInsertParenth = true;
}
if (needInsertBrace && needInsertParenth) {
return AutoCompletionDecision.SHOW_LOOKUP;
}
commonName = name;
allMethods.add(method);
}
for (LookupElement item : items) {
JavaCompletionUtil.putAllMethods(item, allMethods);
}
return AutoCompletionDecision.insertItem(JavaMethodMergingContributor.findBestOverload(items));
}
return super.handleAutoCompletionPossibility(context);
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class CreateParameterFromUsageFix method findScope.
private void findScope(@NotNull final GrReferenceExpression ref, @NotNull final Editor editor, final Project project) {
PsiElement place = ref;
final List<GrMethod> scopes = new ArrayList<>();
while (true) {
final GrMethod parent = PsiTreeUtil.getParentOfType(place, GrMethod.class);
if (parent == null)
break;
scopes.add(parent);
place = parent;
}
if (scopes.size() == 1) {
final GrMethod owner = scopes.get(0);
final PsiMethod toSearchFor;
toSearchFor = SuperMethodWarningUtil.checkSuperMethod(owner, RefactoringBundle.message("to.refactor"));
//if it is null, refactoring was canceled
if (toSearchFor == null)
return;
showDialog(toSearchFor, ref, project);
} else if (scopes.size() > 1) {
myEnclosingMethodsPopup = MethodOrClosureScopeChooser.create(scopes, editor, this, (owner, element) -> {
showDialog((PsiMethod) owner, ref, project);
return null;
});
myEnclosingMethodsPopup.showInBestPositionFor(editor);
}
}
use of com.intellij.psi.PsiMethod in project intellij-community by JetBrains.
the class ConvertJunitAssertionToAssertStatementIntention method processIntention.
@Override
protected void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor) throws IncorrectOperationException {
GrMethodCall methodCall = (GrMethodCall) element;
PsiMethod method = methodCall.resolveMethod();
if (method == null)
return;
GrStatement replacementElement = getReplacementElement(method, methodCall);
if (replacementElement == null)
return;
((GrMethodCall) element).replaceWithStatement(replacementElement);
}
Aggregations