use of com.intellij.psi.PsiMember in project intellij-community by JetBrains.
the class RemoveMiddlemanDialog method createCenterPanel.
protected JComponent createCenterPanel() {
final JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 5, 0));
final MemberSelectionPanel selectionPanel = new MemberSelectionPanel("&Methods to inline", delegateMethods, "Delete");
final MemberSelectionTable table = selectionPanel.getTable();
table.setMemberInfoModel(new DelegatingMemberInfoModel<PsiMember, MemberInfo>(table.getMemberInfoModel()) {
@Override
public int checkForProblems(@NotNull final MemberInfo member) {
return hasSuperMethods(member) ? ERROR : OK;
}
@Override
public String getTooltipText(final MemberInfo member) {
if (hasSuperMethods(member))
return "Deletion will break type hierarchy";
return super.getTooltipText(member);
}
private boolean hasSuperMethods(final MemberInfo member) {
if (member.isChecked() && member.isToAbstract()) {
final PsiMember psiMember = member.getMember();
if (psiMember instanceof PsiMethod && ((PsiMethod) psiMember).findDeepestSuperMethods().length > 0) {
return true;
}
}
return false;
}
});
panel.add(selectionPanel, BorderLayout.CENTER);
return panel;
}
use of com.intellij.psi.PsiMember in project intellij-community by JetBrains.
the class ExtractSuperclassDialog method createCenterPanel.
protected JComponent createCenterPanel() {
JPanel panel = new JPanel(new BorderLayout());
final MemberSelectionPanel memberSelectionPanel = new MemberSelectionPanel(RefactoringBundle.message("members.to.form.superclass"), myMemberInfos, RefactoringBundle.message("make.abstract"));
panel.add(memberSelectionPanel, BorderLayout.CENTER);
final MemberInfoModel<PsiMember, MemberInfo> memberInfoModel = new UsesAndInterfacesDependencyMemberInfoModel<PsiMember, MemberInfo>(mySourceClass, null, false, myContainmentVerifier) {
@Override
public Boolean isFixedAbstract(MemberInfo member) {
return Boolean.TRUE;
}
};
memberInfoModel.memberInfoChanged(new MemberInfoChange<>(myMemberInfos));
memberSelectionPanel.getTable().setMemberInfoModel(memberInfoModel);
memberSelectionPanel.getTable().addMemberInfoChangeListener(memberInfoModel);
panel.add(myDocCommentPanel, BorderLayout.EAST);
return panel;
}
use of com.intellij.psi.PsiMember in project intellij-community by JetBrains.
the class MissedTestsDialog method disableMethodsWithTests.
private void disableMethodsWithTests(List<MemberInfo> info) {
final Set<String> existingNames = new HashSet<>();
final String prefix = getTestPrefix(existingNames);
existingNames.addAll(ContainerUtil.map(myTestClass.getMethods(), method -> StringUtil.decapitalize(StringUtil.trimStart(method.getName(), prefix))));
for (MemberInfo memberInfo : info) {
final PsiMember member = memberInfo.getMember();
memberInfo.setChecked(!(member instanceof PsiMethod && existingNames.contains(member.getName())));
}
}
use of com.intellij.psi.PsiMember in project intellij-community by JetBrains.
the class JavaReflectionNavigationTest method doTestImpl.
private void doTestImpl(String name, String mainClassText) {
PsiReference reference = getReference(mainClassText);
assertEquals("Reference text", name, reference.getCanonicalText());
PsiElement resolved = reference.resolve();
assertNotNull("Reference is not resolved: " + reference.getCanonicalText(), resolved);
assertTrue("Target is a member", resolved instanceof PsiMember);
PsiMember member = (PsiMember) resolved;
assertEquals("Target name", name, member.getName());
}
use of com.intellij.psi.PsiMember in project intellij-community by JetBrains.
the class ResolverProcessor method isAccessible.
protected boolean isAccessible(@NotNull PsiNamedElement namedElement) {
if (namedElement instanceof GrField) {
final GrField field = (GrField) namedElement;
if (PsiUtil.isAccessible(myPlace, field)) {
return true;
}
for (GrAccessorMethod method : field.getGetters()) {
if (PsiUtil.isAccessible(myPlace, method)) {
return true;
}
}
final GrAccessorMethod setter = field.getSetter();
if (setter != null && PsiUtil.isAccessible(myPlace, setter)) {
return true;
}
return false;
}
return !(namedElement instanceof PsiMember) || PsiUtil.isAccessible(myPlace, ((PsiMember) namedElement));
}
Aggregations