use of com.intellij.ide.structureView.StructureViewTreeElement in project intellij-community by JetBrains.
the class AbstractListBuilder method selectElement.
public final void selectElement(final Object element, VirtualFile virtualFile) {
if (element == null) {
return;
}
try {
AbstractTreeNode node = goDownToElement(element, virtualFile);
if (node == null)
return;
AbstractTreeNode parentElement = node.getParent();
if (parentElement == null)
return;
buildList(parentElement);
for (int i = 0; i < myModel.getSize(); i++) {
if (myModel.getElementAt(i) instanceof AbstractTreeNode) {
final AbstractTreeNode desc = (AbstractTreeNode) myModel.getElementAt(i);
if (desc.getValue() instanceof StructureViewTreeElement) {
StructureViewTreeElement treeelement = (StructureViewTreeElement) desc.getValue();
if (element.equals(treeelement.getValue())) {
selectItem(i);
break;
}
} else {
if (element.equals(desc.getValue())) {
selectItem(i);
break;
}
}
}
}
} finally {
updateParentTitle();
}
}
use of com.intellij.ide.structureView.StructureViewTreeElement in project intellij-plugins by JetBrains.
the class MarkdownStructureElement method getChildrenBase.
@NotNull
@Override
public Collection<StructureViewTreeElement> getChildrenBase() {
final List<StructureViewTreeElement> childrenElements = new ArrayList<>();
final PsiElement myElement = getElement();
if (myElement == null)
return childrenElements;
final PsiElement structureContainer = myElement instanceof MarkdownFile ? myElement.getFirstChild() : getParentOfType(myElement, TRANSPARENT_CONTAINERS);
if (structureContainer == null) {
return Collections.emptyList();
}
final MarkdownPsiElement currentHeader = myElement instanceof MarkdownHeaderImpl ? ((MarkdownHeaderImpl) myElement) : null;
processContainer(structureContainer, currentHeader, currentHeader, element -> childrenElements.add(new MarkdownStructureElement(element)));
return childrenElements;
}
use of com.intellij.ide.structureView.StructureViewTreeElement in project intellij-plugins by JetBrains.
the class StructureViewTreeModel method getRoot.
@NotNull
@Override
public StructureViewTreeElement getRoot() {
final XmlFile xmlFile = getPsiFile();
final DomFileElement<DomElement> fileElement = DomManager.getDomManager(xmlFile.getProject()).getFileElement(xmlFile, DomElement.class);
if (fileElement == null) {
return new XmlFileTreeElement(xmlFile);
}
return new com.intellij.struts2.structure.StructureViewTreeElement(fileElement.getRootElement().createStableCopy());
}
use of com.intellij.ide.structureView.StructureViewTreeElement in project android by JetBrains.
the class StructureViewTest method testManifestStructure.
public void testManifestStructure() throws Exception {
copyFileToProject("manifest/MyActivity.java", "src/p1/p2/MyActivity.java");
deleteManifest();
final VirtualFile file = copyFileToProject("manifest/structure_view_test.xml", "AndroidManifest.xml");
final PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(file);
assertInstanceOf(psiFile, XmlFile.class);
final DomStructureViewBuilder builder = new DomStructureViewBuilder(((XmlFile) psiFile), DomStructureViewBuilderProvider.DESCRIPTOR);
final StructureViewTreeElement root = builder.createStructureViewModel(null).getRoot();
assertNotNull(root);
final String expected = "Manifest\n" + " Application\n" + " Activity\n" + " Intent Filter\n" + " Action (android.intent.action.MAIN)\n" + " Category (android.intent.category.LAUNCHER)\n" + " Activity Alias\n" + " Intent Filter\n" + " Action (android.intent.action.CREATE_SHORTCUT)\n" + " Category (android.intent.category.DEFAULT)\n";
assertEquals(expected, dumpTree(root));
}
use of com.intellij.ide.structureView.StructureViewTreeElement in project intellij-plugins by JetBrains.
the class FlexTreeStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull AbstractTreeNode parent, @NotNull Collection<AbstractTreeNode> children, ViewSettings settings) {
List<AbstractTreeNode> result = new ArrayList<>();
if (parent instanceof SwfQualifiedNamedElementNode || parent instanceof FlexFileNode) {
if (((ProjectViewNode) parent).getSettings().isShowMembers()) {
JSQualifiedNamedElement parentElement = getElement(parent);
if (parentElement != null) {
JSStructureViewElement structureViewElement = parentElement instanceof XmlBackedJSClassImpl ? new FlexStructureViewElement(((XmlBackedJSClassImpl) parentElement), (XmlFile) parentElement.getContainingFile(), false) : new JSStructureViewElement(parentElement, false, true);
StructureViewTreeElement[] structureViewChildren = structureViewElement.getChildren();
for (final StructureViewTreeElement structureViewChild : structureViewChildren) {
if (structureViewChild instanceof JSStructureViewElement) {
PsiElement childElement = ((JSStructureViewElement) structureViewChild).getValue();
result.add(new FlexClassMemberNode((JSElement) childElement, ((ProjectViewNode) parent).getSettings()));
} else {
result.add(new UnknownNode(parentElement.getProject(), structureViewChild, ((ProjectViewNode) parent).getSettings()));
}
}
}
}
} else {
for (final AbstractTreeNode child : children) {
Object o = child.getValue();
if (o instanceof JSFileImpl && !(o instanceof PsiCompiledFile) && DialectDetector.isActionScript((PsiFile) o) || o instanceof XmlFile && JavaScriptSupportLoader.isFlexMxmFile((PsiFile) o)) {
result.add(new FlexFileNode((PsiFile) o, ((ProjectViewNode) parent).getSettings()));
continue;
}
result.add(child);
}
}
return result;
}
Aggregations