use of com.intellij.ide.hierarchy.HierarchyNodeDescriptor in project intellij-community by JetBrains.
the class PyCallHierarchyTest method dump.
private static void dump(final HierarchyTreeStructure treeStructure, @Nullable HierarchyNodeDescriptor descriptor, int level, StringBuilder b) {
if (level > 10) {
for (int i = 0; i < level; i++) b.append(" ");
b.append("<Probably infinite part skipped>\n");
return;
}
if (descriptor == null)
descriptor = (HierarchyNodeDescriptor) treeStructure.getRootElement();
for (int i = 0; i < level; i++) b.append(" ");
descriptor.update();
b.append("<node text=\"").append(descriptor.getHighlightedText().getText()).append("\"").append(treeStructure.getBaseDescriptor() == descriptor ? " base=\"true\"" : "");
final Object[] children = treeStructure.getChildElements(descriptor);
if (children.length > 0) {
b.append(">\n");
for (Object o : children) {
HierarchyNodeDescriptor d = (HierarchyNodeDescriptor) o;
dump(treeStructure, d, level + 1, b);
}
for (int i = 0; i < level; i++) b.append(" ");
b.append("</node>\n");
} else {
b.append("/>\n");
}
}
use of com.intellij.ide.hierarchy.HierarchyNodeDescriptor in project kotlin by JetBrains.
the class KotlinCallTreeStructure method addNodeDescriptorForElement.
protected static void addNodeDescriptorForElement(PsiReference reference, PsiElement element, Map<PsiElement, HierarchyNodeDescriptor> declarationToDescriptorMap, HierarchyNodeDescriptor descriptor, boolean wrapAsLightElements) {
HierarchyNodeDescriptor d = declarationToDescriptorMap.get(element);
if (d == null) {
d = createNodeDescriptor(element.getProject(), element, descriptor, true, wrapAsLightElements);
if (d == null)
return;
declarationToDescriptorMap.put(element, d);
} else if (d instanceof CallHierarchyNodeDescriptor) {
((CallHierarchyNodeDescriptor) d).incrementUsageCount();
}
if (d instanceof CallHierarchyNodeDescriptor) {
((CallHierarchyNodeDescriptor) d).addReference(reference);
} else if (d instanceof KotlinCallHierarchyNodeDescriptor) {
((KotlinCallHierarchyNodeDescriptor) d).addReference(reference);
}
}
use of com.intellij.ide.hierarchy.HierarchyNodeDescriptor in project intellij-community by JetBrains.
the class HierarchyViewTestBase method checkHierarchyTreeStructure.
private static void checkHierarchyTreeStructure(final HierarchyTreeStructure treeStructure, final Element rootElement) {
final HierarchyNodeDescriptor rootNodeDescriptor = (HierarchyNodeDescriptor) treeStructure.getRootElement();
rootNodeDescriptor.update();
if (rootElement == null || !NODE_ELEMENT_NAME.equals(rootElement.getName())) {
throw new IllegalArgumentException("Incorrect root element in verification resource");
}
checkNodeDescriptorRecursively(treeStructure, rootNodeDescriptor, rootElement);
}
use of com.intellij.ide.hierarchy.HierarchyNodeDescriptor in project intellij-community by JetBrains.
the class HierarchyViewTestBase method dump.
private static void dump(final HierarchyTreeStructure treeStructure, @Nullable HierarchyNodeDescriptor descriptor, int level, StringBuilder b) {
if (level > 10) {
for (int i = 0; i < level; i++) b.append(" ");
b.append("<Probably infinite part skipped>\n");
return;
}
if (descriptor == null)
descriptor = (HierarchyNodeDescriptor) treeStructure.getRootElement();
for (int i = 0; i < level; i++) b.append(" ");
descriptor.update();
b.append("<node text=\"").append(descriptor.getHighlightedText().getText()).append("\"").append(treeStructure.getBaseDescriptor() == descriptor ? " base=\"true\"" : "");
final Object[] children = treeStructure.getChildElements(descriptor);
if (children.length > 0) {
b.append(">\n");
for (Object o : children) {
HierarchyNodeDescriptor d = (HierarchyNodeDescriptor) o;
dump(treeStructure, d, level + 1, b);
}
for (int i = 0; i < level; i++) b.append(" ");
b.append("</node>\n");
} else {
b.append("/>\n");
}
}
use of com.intellij.ide.hierarchy.HierarchyNodeDescriptor in project intellij-community by JetBrains.
the class OverrideImplementMethodAction method actionPerformed.
public final void actionPerformed(final AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
final MethodHierarchyBrowser methodHierarchyBrowser = (MethodHierarchyBrowser) MethodHierarchyBrowserBase.DATA_KEY.getData(dataContext);
if (methodHierarchyBrowser == null)
return;
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null)
return;
final String commandName = event.getPresentation().getText();
ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(project, () -> {
try {
final HierarchyNodeDescriptor[] selectedDescriptors = methodHierarchyBrowser.getSelectedDescriptors();
if (selectedDescriptors.length > 0) {
final List<VirtualFile> files = new ArrayList<>(selectedDescriptors.length);
for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) {
final PsiFile containingFile = ((MethodHierarchyNodeDescriptor) selectedDescriptor).getPsiClass().getContainingFile();
if (containingFile != null) {
final VirtualFile vFile = containingFile.getVirtualFile();
if (vFile != null) {
files.add(vFile);
}
}
}
final ReadonlyStatusHandler.OperationStatus status = ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(VfsUtil.toVirtualFileArray(files));
if (!status.hasReadonlyFiles()) {
for (HierarchyNodeDescriptor selectedDescriptor : selectedDescriptors) {
final PsiElement aClass = ((MethodHierarchyNodeDescriptor) selectedDescriptor).getPsiClass();
if (aClass instanceof PsiClass) {
OverrideImplementUtil.overrideOrImplement((PsiClass) aClass, methodHierarchyBrowser.getBaseMethod());
}
}
ToolWindowManager.getInstance(project).activateEditorComponent();
} else {
ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(project, status.getReadonlyFilesMessage(), commandName));
}
}
} catch (IncorrectOperationException e) {
LOG.error(e);
}
}, commandName, null));
}
Aggregations