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); } }
@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); } } }
@Nullable private JavaElementArrangementEntry createNewEntry( @NotNull PsiElement element, @NotNull TextRange range, @NotNull ArrangementSettingsToken type, @Nullable String name, boolean canArrange) { if (!isWithinBounds(range)) { return null; } DefaultArrangementEntry current = getCurrent(); JavaElementArrangementEntry entry; if (canArrange) { TextRange expandedRange = myDocument == null ? null : ArrangementUtil.expandToLine(range, myDocument); TextRange rangeToUse = expandedRange == null ? range : expandedRange; entry = new JavaElementArrangementEntry(current, rangeToUse, type, name, true); } else { entry = new JavaElementArrangementEntry(current, range, type, name, false); } myEntries.put(element, entry); if (current == null) { myInfo.addEntry(entry); } else { current.addChild(entry); } return 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); }