Search in sources :

Example 11 with PsiMember

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;
}
Also used : MemberSelectionTable(com.intellij.refactoring.ui.MemberSelectionTable) MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) PsiMethod(com.intellij.psi.PsiMethod) MemberSelectionPanel(com.intellij.refactoring.ui.MemberSelectionPanel) PsiMember(com.intellij.psi.PsiMember)

Example 12 with PsiMember

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;
}
Also used : MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) MemberSelectionPanel(com.intellij.refactoring.ui.MemberSelectionPanel) UsesAndInterfacesDependencyMemberInfoModel(com.intellij.refactoring.util.classMembers.UsesAndInterfacesDependencyMemberInfoModel) PsiMember(com.intellij.psi.PsiMember)

Example 13 with PsiMember

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())));
    }
}
Also used : ActionListener(java.awt.event.ActionListener) TestFramework(com.intellij.testIntegration.TestFramework) JavaPsiFacade(com.intellij.psi.JavaPsiFacade) MemberSelectionTable(com.intellij.refactoring.ui.MemberSelectionTable) ContainerUtil(com.intellij.util.containers.ContainerUtil) HashSet(java.util.HashSet) CodeInsightBundle(com.intellij.codeInsight.CodeInsightBundle) PsiClass(com.intellij.psi.PsiClass) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Project(com.intellij.openapi.project.Project) MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) PsiMember(com.intellij.psi.PsiMember) JBCheckBox(com.intellij.ui.components.JBCheckBox) IncorrectOperationException(com.intellij.util.IncorrectOperationException) PsiMethod(com.intellij.psi.PsiMethod) StringUtil(com.intellij.openapi.util.text.StringUtil) Collection(java.util.Collection) Set(java.util.Set) Template(com.intellij.codeInsight.template.Template) ActionEvent(java.awt.event.ActionEvent) TestIntegrationUtils(com.intellij.testIntegration.TestIntegrationUtils) java.awt(java.awt) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) Function(com.intellij.util.Function) ScrollPaneFactory(com.intellij.ui.ScrollPaneFactory) javax.swing(javax.swing) MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) PsiMethod(com.intellij.psi.PsiMethod) HashSet(java.util.HashSet) PsiMember(com.intellij.psi.PsiMember)

Example 14 with PsiMember

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());
}
Also used : PsiReference(com.intellij.psi.PsiReference) PsiElement(com.intellij.psi.PsiElement) PsiMember(com.intellij.psi.PsiMember)

Example 15 with PsiMember

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));
}
Also used : GrField(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField) GrAccessorMethod(org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod) PsiMember(com.intellij.psi.PsiMember)

Aggregations

PsiMember (com.intellij.psi.PsiMember)19 PsiElement (com.intellij.psi.PsiElement)5 PsiMethod (com.intellij.psi.PsiMethod)5 PsiClass (com.intellij.psi.PsiClass)4 MemberInfo (com.intellij.refactoring.util.classMembers.MemberInfo)4 Project (com.intellij.openapi.project.Project)3 ArrayList (java.util.ArrayList)3 LookupElement (com.intellij.codeInsight.lookup.LookupElement)2 StringUtil (com.intellij.openapi.util.text.StringUtil)2 PsiModifierList (com.intellij.psi.PsiModifierList)2 MemberSelectionPanel (com.intellij.refactoring.ui.MemberSelectionPanel)2 MemberSelectionTable (com.intellij.refactoring.ui.MemberSelectionTable)2 RowIcon (com.intellij.ui.RowIcon)2 ContainerUtil (com.intellij.util.containers.ContainerUtil)2 List (java.util.List)2 AnalysisScope (com.intellij.analysis.AnalysisScope)1 CodeInsightBundle (com.intellij.codeInsight.CodeInsightBundle)1 CodeInsightSettings (com.intellij.codeInsight.CodeInsightSettings)1 CamelHumpMatcher (com.intellij.codeInsight.completion.impl.CamelHumpMatcher)1 LookupManager (com.intellij.codeInsight.lookup.LookupManager)1