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;
}
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;
}
Aggregations