本文整理匯總了Java中com.intellij.ide.structureView.StructureViewModel.dispose方法的典型用法代碼示例。如果您正苦於以下問題:Java StructureViewModel.dispose方法的具體用法?Java StructureViewModel.dispose怎麽用?Java StructureViewModel.dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.ide.structureView.StructureViewModel
的用法示例。
在下文中一共展示了StructureViewModel.dispose方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testFileStructureForClass
import com.intellij.ide.structureView.StructureViewModel; //導入方法依賴的package包/類
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);
}
}
示例2: addNavigationElements
import com.intellij.ide.structureView.StructureViewModel; //導入方法依賴的package包/類
private static void addNavigationElements(Collection<PsiElement> array, PsiFile element) {
StructureViewBuilder structureViewBuilder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(element);
if (structureViewBuilder instanceof TreeBasedStructureViewBuilder) {
TreeBasedStructureViewBuilder builder = (TreeBasedStructureViewBuilder) structureViewBuilder;
StructureViewModel model = builder.createStructureViewModel(null);
try {
addStructureViewElements(model.getRoot(), array, element);
}
finally {
model.dispose();
}
}
}
示例3: getQualifiedName
import com.intellij.ide.structureView.StructureViewModel; //導入方法依賴的package包/類
public String getQualifiedName() {
String presentableUrl = myFile.getPresentableUrl();
if (myFile.isDirectory()) return presentableUrl;
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
final PsiFile psiFile = PsiManager.getInstance(myProject).findFile(myFile);
if (psiFile == null) return presentableUrl;
StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(psiFile);
if (builder instanceof TreeBasedStructureViewBuilder) {
StructureViewModel model = ((TreeBasedStructureViewBuilder)builder).createStructureViewModel(null);
Object element;
try {
element = model.getCurrentEditorElement();
}
finally {
model.dispose();
}
if (element instanceof NavigationItem) {
ItemPresentation presentation = ((NavigationItem)element).getPresentation();
if (presentation != null) {
presentableUrl = ((NavigationItem)element).getName() + " " + presentation.getLocationString();
}
}
}
return IdeBundle.message("bookmark.file.X.line.Y", presentableUrl, getLine() + 1);
}
示例4: invoke
import com.intellij.ide.structureView.StructureViewModel; //導入方法依賴的package包/類
@RequiredDispatchThread
@Override
public void invoke(@Nonnull final Project project, @Nonnull final Editor editor, @Nonnull PsiFile file) {
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiElement container = null;
WeakReference<LightweightHint> ref = editor.getUserData(MY_LAST_HINT_KEY);
LightweightHint hint = SoftReference.dereference(ref);
if (hint != null && hint.isVisible()){
hint.hide();
container = hint.getUserData(CONTAINER_KEY);
if (container != null && !container.isValid()){
container = null;
}
}
StructureViewBuilder builder = LanguageStructureViewBuilder.INSTANCE.getStructureViewBuilder(file);
if (builder instanceof TreeBasedStructureViewBuilder) {
StructureViewModel model = ((TreeBasedStructureViewBuilder) builder).createStructureViewModel(editor);
boolean goOneLevelUp = true;
try {
if (container == null) {
goOneLevelUp = false;
Object element = model.getCurrentEditorElement();
if (element instanceof PsiElement) {
container = (PsiElement) element;
}
}
}
finally {
model.dispose();
}
while(true) {
if (container == null || container instanceof PsiFile) {
return;
}
if (goOneLevelUp) {
goOneLevelUp = false;
}
else {
if (!isDeclarationVisible(container, editor)) {
break;
}
}
container = container.getParent();
while(container != null && DeclarationRangeUtil.getPossibleDeclarationAtRange(container) == null) {
container = container.getParent();
if (container instanceof PsiFile) return;
}
}
}
if (container == null) {
return;
}
final TextRange range = DeclarationRangeUtil.getPossibleDeclarationAtRange(container);
if (range == null) {
return;
}
final PsiElement _container = container;
ApplicationManager.getApplication().invokeLater(() -> {
LightweightHint hint1 = EditorFragmentComponent.showEditorFragmentHint(editor, range, true, true);
if (hint1 != null) {
hint1.putUserData(CONTAINER_KEY, _container);
editor.putUserData(MY_LAST_HINT_KEY, new WeakReference<>(hint1));
}
});
}
示例5: testFileStructureForClass
import com.intellij.ide.structureView.StructureViewModel; //導入方法依賴的package包/類
public void testFileStructureForClass()
{
final PsiJavaPackage 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);
}
}