@Override public void visitMethod(PsiMethod method) { ArrangementSettingsToken type = method.isConstructor() ? CONSTRUCTOR : METHOD; JavaElementArrangementEntry entry = createNewEntry(method, method.getTextRange(), type, method.getName(), true); if (entry == null) { return; } processEntry(entry, method, method.getBody()); parseProperties(method, entry); myInfo.onMethodEntryCreated(method, entry); MethodSignatureBackedByPsiMethod overridden = SuperMethodsSearch.search(method, null, true, false).findFirst(); if (overridden != null) { myInfo.onOverriddenMethod(overridden.getMethod(), method); } boolean reset = myMethodBodyProcessor.setBaseMethod(method); try { method.accept(myMethodBodyProcessor); } finally { if (reset) { myMethodBodyProcessor.setBaseMethod(null); } } }
private void parseProperties(PsiMethod method, JavaElementArrangementEntry entry) { if (!myGroupingRules.contains(StdArrangementTokens.Grouping.GETTERS_AND_SETTERS)) { return; } String propertyName = null; boolean getter = true; if (PropertyUtil.isSimplePropertyGetter(method)) { propertyName = PropertyUtil.getPropertyNameByGetter(method); } else if (PropertyUtil.isSimplePropertySetter(method)) { propertyName = PropertyUtil.getPropertyNameBySetter(method); getter = false; } if (propertyName == null) { return; } PsiClass containingClass = method.getContainingClass(); String className = null; if (containingClass != null) { className = containingClass.getQualifiedName(); } if (className == null) { className = NULL_CONTENT; } if (getter) { myInfo.registerGetter(propertyName, className, entry); } else { myInfo.registerSetter(propertyName, className, entry); } }
public void visitMethodCallExpression(PsiMethodCallExpression psiMethodCallExpression) { PsiReference reference = psiMethodCallExpression.getMethodExpression().getReference(); if (reference == null) { return; } PsiElement e = reference.resolve(); if (e instanceof PsiMethod) { assert myBaseMethod != null; PsiMethod m = (PsiMethod) e; if (m.getContainingClass() == myBaseMethod.getContainingClass()) { myInfo.registerDependency(myBaseMethod, m); } } // We process all method call expression children because there is a possible case like below: // new Runnable() { // void test(); // }.run(); // Here we want to process that 'Runnable.run()' implementation. super.visitMethodCallExpression(psiMethodCallExpression); }