Search in sources :

Example 1 with PsiFunctionalExpression

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

the class TypeHierarchyNodeDescriptor method update.

public final boolean update() {
    boolean changes = super.update();
    if (getPsiElement() == null) {
        final String invalidPrefix = IdeBundle.message("node.hierarchy.invalid");
        if (!myHighlightedText.getText().startsWith(invalidPrefix)) {
            myHighlightedText.getBeginning().addText(invalidPrefix, HierarchyNodeDescriptor.getInvalidPrefixAttributes());
        }
        return true;
    }
    if (changes && myIsBase) {
        final LayeredIcon icon = new LayeredIcon(2);
        icon.setIcon(getIcon(), 0);
        icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0);
        setIcon(icon);
    }
    final PsiElement psiElement = getPsiClass();
    final CompositeAppearance oldText = myHighlightedText;
    myHighlightedText = new CompositeAppearance();
    TextAttributes classNameAttributes = null;
    if (myColor != null) {
        classNameAttributes = new TextAttributes(myColor, null, null, null, Font.PLAIN);
    }
    if (psiElement instanceof PsiClass) {
        myHighlightedText.getEnding().addText(ClassPresentationUtil.getNameForClass((PsiClass) psiElement, false), classNameAttributes);
        myHighlightedText.getEnding().addText(" (" + JavaHierarchyUtil.getPackageName((PsiClass) psiElement) + ")", HierarchyNodeDescriptor.getPackageNameAttributes());
    } else if (psiElement instanceof PsiFunctionalExpression) {
        myHighlightedText.getEnding().addText(ClassPresentationUtil.getFunctionalExpressionPresentation(((PsiFunctionalExpression) psiElement), false));
    }
    myName = myHighlightedText.getText();
    if (!Comparing.equal(myHighlightedText, oldText)) {
        changes = true;
    }
    return changes;
}
Also used : LayeredIcon(com.intellij.ui.LayeredIcon) PsiFunctionalExpression(com.intellij.psi.PsiFunctionalExpression) PsiClass(com.intellij.psi.PsiClass) CompositeAppearance(com.intellij.openapi.roots.ui.util.CompositeAppearance) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) PsiElement(com.intellij.psi.PsiElement)

Example 2 with PsiFunctionalExpression

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

the class JavaCompilerElementRetriever method retrieveFunExpressionsByIndices.

@NotNull
static PsiFunctionalExpression[] retrieveFunExpressionsByIndices(@NotNull TIntHashSet indices, @NotNull PsiFileWithStubSupport psiFile) {
    StubTree tree = psiFile.getStubTree();
    boolean foreign = tree == null;
    if (foreign) {
        tree = ((PsiFileImpl) psiFile).calcStubTree();
    }
    PsiFunctionalExpression[] result = new PsiFunctionalExpression[indices.size()];
    int resIdx = 0;
    int funExprIdx = 0;
    for (StubElement<?> element : tree.getPlainList()) {
        if (FUN_EXPR.contains(element.getStubType()) && indices.contains(funExprIdx++)) {
            result[resIdx++] = (PsiFunctionalExpression) element.getPsi();
        }
    }
    if (result.length != resIdx) {
        final CompilerReferenceServiceImpl compilerReferenceService = (CompilerReferenceServiceImpl) CompilerReferenceService.getInstance(psiFile.getProject());
        final Set<Module> state = compilerReferenceService.getDirtyScopeHolder().getAllDirtyModules();
        final VirtualFile file = psiFile.getVirtualFile();
        final Module moduleForFile = ProjectFileIndex.getInstance(psiFile.getProject()).getModuleForFile(file);
        LOG.error("Compiler functional expression index doesn't match to stub index.\n" + "Functional expression indices: " + indices + "\n" + "Does the file belong to dirty scope?: " + state.contains(moduleForFile), new Attachment(psiFile.getName(), psiFile.getText()));
        return ContainerUtil.filter(result, Objects::nonNull).toArray(PsiFunctionalExpression.EMPTY_ARRAY);
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) StubTree(com.intellij.psi.stubs.StubTree) PsiFunctionalExpression(com.intellij.psi.PsiFunctionalExpression) Attachment(com.intellij.openapi.diagnostic.Attachment) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiFunctionalExpression (com.intellij.psi.PsiFunctionalExpression)2 Attachment (com.intellij.openapi.diagnostic.Attachment)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 Module (com.intellij.openapi.module.Module)1 CompositeAppearance (com.intellij.openapi.roots.ui.util.CompositeAppearance)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 StubTree (com.intellij.psi.stubs.StubTree)1 LayeredIcon (com.intellij.ui.LayeredIcon)1 NotNull (org.jetbrains.annotations.NotNull)1