use of com.intellij.psi.impl.PsiManagerEx in project intellij by bazelbuild.
the class GlobFindUsagesTest method testInMemoryFileHandledGracefully.
// regression test for b/29267289
@Test
public void testInMemoryFileHandledGracefully() {
createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['**/*.java'])");
LightVirtualFile inMemoryFile = new LightVirtualFile("mockProjectViewFile", ProjectViewLanguage.INSTANCE, "");
FileManager fileManager = ((PsiManagerEx) PsiManager.getInstance(getProject())).getFileManager();
fileManager.setViewProvider(inMemoryFile, fileManager.createFileViewProvider(inMemoryFile, true));
PsiFile psiFile = fileManager.findFile(inMemoryFile);
FindUsages.findAllReferences(psiFile);
}
use of com.intellij.psi.impl.PsiManagerEx in project intellij by bazelbuild.
the class ProjectViewUi method createEditor.
private static EditorEx createEditor(String tooltip) {
Project project = getProject();
LightVirtualFile virtualFile = new LightVirtualFile("mockProjectViewFile", ProjectViewLanguage.INSTANCE, "");
final Document document = ((EditorFactoryImpl) EditorFactory.getInstance()).createDocument(true);
((DocumentImpl) document).setAcceptSlashR(true);
FileDocumentManagerImpl.registerDocument(document, virtualFile);
FileManager fileManager = ((PsiManagerEx) PsiManager.getInstance(project)).getFileManager();
fileManager.setViewProvider(virtualFile, fileManager.createFileViewProvider(virtualFile, true));
if (project.isDefault()) {
// Undo-redo doesn't work with the default project.
// Explicitly turn it off to avoid error dialogs.
UndoUtil.disableUndoFor(document);
}
EditorEx editor = (EditorEx) EditorFactory.getInstance().createEditor(document, project, ProjectViewFileType.INSTANCE, false);
final EditorSettings settings = editor.getSettings();
settings.setLineNumbersShown(false);
settings.setLineMarkerAreaShown(false);
settings.setFoldingOutlineShown(false);
settings.setRightMarginShown(false);
settings.setAdditionalPageAtBottom(false);
editor.getComponent().setMinimumSize(getEditorSize());
editor.getComponent().setPreferredSize(getEditorSize());
editor.getComponent().setToolTipText(tooltip);
editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
editor.getComponent().setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
return editor;
}
Aggregations