Search in sources :

Example 6 with StructureViewBuilder

use of com.intellij.ide.structureView.StructureViewBuilder in project intellij-community by JetBrains.

the class ViewStructureAction method createPopup.

@Nullable
public static FileStructurePopup createPopup(@NotNull Project project, @NotNull FileEditor fileEditor) {
    StructureViewBuilder structureViewBuilder = fileEditor.getStructureViewBuilder();
    if (structureViewBuilder == null)
        return null;
    StructureView structureView = structureViewBuilder.createStructureView(fileEditor, project);
    StructureViewModel model = structureView.getTreeModel();
    if (model instanceof PlaceHolder) {
        //noinspection unchecked
        ((PlaceHolder) model).setPlace(TreeStructureUtil.PLACE);
    }
    return createStructureViewPopup(project, fileEditor, structureView);
}
Also used : StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) StructureView(com.intellij.ide.structureView.StructureView) PlaceHolder(com.intellij.ui.PlaceHolder) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with StructureViewBuilder

use of com.intellij.ide.structureView.StructureViewBuilder in project intellij-community by JetBrains.

the class FileStructureDialogTest method testFileStructureForClass.

public void testFileStructureForClass() throws Exception {
    final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(getPackageDirectory());
    assertNotNull(aPackage);
    final PsiClass psiClass = aPackage.getClasses()[0];
    final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
    assertNotNull(virtualFile);
    final StructureViewBuilder structureViewBuilder = StructureViewBuilder.PROVIDER.getStructureViewBuilder(virtualFile.getFileType(), virtualFile, myProject);
    assertNotNull(structureViewBuilder);
    final StructureViewModel structureViewModel = ((TreeBasedStructureViewBuilder) structureViewBuilder).createStructureViewModel(null);
    final EditorFactory factory = EditorFactory.getInstance();
    assertNotNull(factory);
    final Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
    assertNotNull(document);
    final Editor editor = factory.createEditor(document, myProject);
    try {
        final FileStructureDialog dialog = new FileStructureDialog(structureViewModel, editor, myProject, psiClass, new Disposable() {

            @Override
            public void dispose() {
                structureViewModel.dispose();
            }
        }, true);
        try {
            final CommanderPanel panel = dialog.getPanel();
            assertListsEqual((ListModel) panel.getModel(), "Inner1\n" + "Inner2\n" + "__method(): void\n" + "_myField1: int\n" + "_myField2: String\n");
        } finally {
            dialog.close(0);
        }
    } finally {
        factory.releaseEditor(editor);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Disposable(com.intellij.openapi.Disposable) TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) EditorFactory(com.intellij.openapi.editor.EditorFactory) TreeBasedStructureViewBuilder(com.intellij.ide.structureView.TreeBasedStructureViewBuilder) StructureViewModel(com.intellij.ide.structureView.StructureViewModel) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage) Document(com.intellij.openapi.editor.Document) CommanderPanel(com.intellij.ide.commander.CommanderPanel) FileStructureDialog(com.intellij.ide.util.FileStructureDialog) Editor(com.intellij.openapi.editor.Editor)

Example 8 with StructureViewBuilder

use of com.intellij.ide.structureView.StructureViewBuilder in project intellij-plugins by JetBrains.

the class CfmlStructureViewTest method createStructureViewModel.

private StructureView createStructureViewModel() {
    VirtualFile virtualFile = myFixture.getFile().getVirtualFile();
    final FileType fileType = virtualFile.getFileType();
    final StructureViewBuilder structureViewBuilder;
    if (fileType == CfmlFileType.INSTANCE) {
        CfmlFileViewProvider viewProvider = (CfmlFileViewProvider) myFixture.getFile().getViewProvider();
        structureViewBuilder = LanguageStructureViewBuilder.INSTANCE.forLanguage(viewProvider.getBaseLanguage()).getStructureViewBuilder(viewProvider.getPsi(viewProvider.getBaseLanguage()));
    } else {
        structureViewBuilder = StructureViewBuilder.PROVIDER.getStructureViewBuilder(fileType, virtualFile, getProject());
    }
    return structureViewBuilder.createStructureView(FileEditorManager.getInstance(getProject()).getSelectedEditor(virtualFile), getProject());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LanguageStructureViewBuilder(com.intellij.lang.LanguageStructureViewBuilder) StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) FileType(com.intellij.openapi.fileTypes.FileType) CfmlFileType(com.intellij.coldFusion.model.files.CfmlFileType) CfmlFileViewProvider(com.intellij.coldFusion.model.files.CfmlFileViewProvider)

Example 9 with StructureViewBuilder

use of com.intellij.ide.structureView.StructureViewBuilder in project intellij-plugins by JetBrains.

the class HbStructureViewTest method testStructureView.

public void testStructureView(PsiFile file, Consumer<StructureViewComposite> consumer) {
    final VirtualFile vFile = file.getVirtualFile();
    final FileEditor fileEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(vFile);
    final StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(file);
    assert builder != null;
    StructureViewComposite composite = null;
    try {
        composite = (StructureViewComposite) builder.createStructureView(fileEditor, file.getProject());
        consumer.consume(composite);
    } finally {
        if (composite != null)
            Disposer.dispose(composite);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LanguageStructureViewBuilder(com.intellij.lang.LanguageStructureViewBuilder) StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) FileEditor(com.intellij.openapi.fileEditor.FileEditor) StructureViewComposite(com.intellij.ide.structureView.impl.StructureViewComposite)

Example 10 with StructureViewBuilder

use of com.intellij.ide.structureView.StructureViewBuilder in project idea-handlebars by dmarcotte.

the class HbStructureViewTest method testStructureView.

public void testStructureView(PsiFile file, Consumer<StructureViewComposite> consumer) {
    final VirtualFile vFile = file.getVirtualFile();
    final FileEditor fileEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(vFile);
    final StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(file);
    assert builder != null;
    StructureViewComposite composite = null;
    try {
        composite = (StructureViewComposite) builder.createStructureView(fileEditor, file.getProject());
        consumer.consume(composite);
    } finally {
        if (composite != null)
            Disposer.dispose(composite);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LanguageStructureViewBuilder(com.intellij.lang.LanguageStructureViewBuilder) StructureViewBuilder(com.intellij.ide.structureView.StructureViewBuilder) FileEditor(com.intellij.openapi.fileEditor.FileEditor) StructureViewComposite(com.intellij.ide.structureView.impl.StructureViewComposite)

Aggregations

StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)18 LanguageStructureViewBuilder (com.intellij.lang.LanguageStructureViewBuilder)11 TreeBasedStructureViewBuilder (com.intellij.ide.structureView.TreeBasedStructureViewBuilder)9 StructureViewModel (com.intellij.ide.structureView.StructureViewModel)8 PsiFile (com.intellij.psi.PsiFile)7 Nullable (org.jetbrains.annotations.Nullable)7 FileEditor (com.intellij.openapi.fileEditor.FileEditor)6 StructureView (com.intellij.ide.structureView.StructureView)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 StructureViewComposite (com.intellij.ide.structureView.impl.StructureViewComposite)4 Editor (com.intellij.openapi.editor.Editor)4 HbPsiFile (com.dmarcotte.handlebars.psi.HbPsiFile)2 TemplateLanguageStructureViewBuilder (com.intellij.ide.structureView.impl.TemplateLanguageStructureViewBuilder)2 StructureViewComponent (com.intellij.ide.structureView.newStructureView.StructureViewComponent)2 TreeElement (com.intellij.ide.util.treeView.smartTree.TreeElement)2 PsiStructureViewFactory (com.intellij.lang.PsiStructureViewFactory)2 PsiElement (com.intellij.psi.PsiElement)2 ElixirFile (org.elixir_lang.psi.ElixirFile)2 CfmlFileType (com.intellij.coldFusion.model.files.CfmlFileType)1 CfmlFileViewProvider (com.intellij.coldFusion.model.files.CfmlFileViewProvider)1