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