Search in sources :

Example 6 with PsiMember

use of com.intellij.psi.PsiMember in project intellij-community by JetBrains.

the class MemberSelectionTable method getOverrideIcon.

@Override
protected Icon getOverrideIcon(MemberInfo memberInfo) {
    PsiMember member = memberInfo.getMember();
    Icon overrideIcon = MemberSelectionTable.EMPTY_OVERRIDE_ICON;
    if (member instanceof PsiMethod) {
        if (Boolean.TRUE.equals(memberInfo.getOverrides())) {
            overrideIcon = AllIcons.General.OverridingMethod;
        } else if (Boolean.FALSE.equals(memberInfo.getOverrides())) {
            overrideIcon = AllIcons.General.ImplementingMethod;
        } else {
            overrideIcon = MemberSelectionTable.EMPTY_OVERRIDE_ICON;
        }
    }
    return overrideIcon;
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) RowIcon(com.intellij.ui.RowIcon) PsiMember(com.intellij.psi.PsiMember)

Example 7 with PsiMember

use of com.intellij.psi.PsiMember in project intellij-community by JetBrains.

the class MissedTestsDialog method updateMethodsTable.

private void updateMethodsTable() {
    List<MemberInfo> infos = TestIntegrationUtils.extractClassMethods(mySourceClass, myIncludeInheritedCb.isSelected());
    Set<PsiMember> selectedMethods = new HashSet<>();
    for (MemberInfo each : myTable.getSelectedMemberInfos()) {
        selectedMethods.add(each.getMember());
    }
    for (MemberInfo each : infos) {
        each.setChecked(selectedMethods.contains(each.getMember()));
    }
    myTable.setMemberInfos(infos);
}
Also used : MemberInfo(com.intellij.refactoring.util.classMembers.MemberInfo) HashSet(java.util.HashSet) PsiMember(com.intellij.psi.PsiMember)

Example 8 with PsiMember

use of com.intellij.psi.PsiMember in project intellij-community by JetBrains.

the class AnnotatedMacro method calculateLookupItems.

@Override
public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) {
    final Query<PsiMember> query = findAnnotated(context, params);
    if (query != null) {
        Set<LookupElement> set = new LinkedHashSet<>();
        final String secondParamValue = params.length > 1 ? params[1].calculateResult(context).toString() : null;
        final boolean isShortName = secondParamValue != null && !Boolean.valueOf(secondParamValue);
        final Project project = context.getProject();
        final PsiClass findInClass = secondParamValue != null ? JavaPsiFacade.getInstance(project).findClass(secondParamValue, GlobalSearchScope.allScope(project)) : null;
        for (PsiMember object : query.findAll()) {
            if (findInClass != null && !object.getContainingClass().equals(findInClass))
                continue;
            boolean isClazz = object instanceof PsiClass;
            final String name = isShortName || !isClazz ? object.getName() : ((PsiClass) object).getQualifiedName();
            set.add(LookupElementBuilder.create(name));
        }
        return set.toArray(new LookupElement[set.size()]);
    }
    return LookupElement.EMPTY_ARRAY;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Project(com.intellij.openapi.project.Project) PsiClass(com.intellij.psi.PsiClass) LookupElement(com.intellij.codeInsight.lookup.LookupElement) PsiMember(com.intellij.psi.PsiMember)

Example 9 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 10 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)

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