Search in sources :

Example 26 with PsiManagerEx

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);
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PsiFile(com.intellij.psi.PsiFile) FileManager(com.intellij.psi.impl.file.impl.FileManager) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx) Test(org.junit.Test)

Example 27 with PsiManagerEx

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;
}
Also used : Project(com.intellij.openapi.project.Project) EditorSettings(com.intellij.openapi.editor.EditorSettings) EditorEx(com.intellij.openapi.editor.ex.EditorEx) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Document(com.intellij.openapi.editor.Document) EditorFactoryImpl(com.intellij.openapi.editor.impl.EditorFactoryImpl) DocumentImpl(com.intellij.openapi.editor.impl.DocumentImpl) FileManager(com.intellij.psi.impl.file.impl.FileManager) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx)

Aggregations

PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)27 FileManager (com.intellij.psi.impl.file.impl.FileManager)8 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)8 PsiModificationTracker (com.intellij.psi.util.PsiModificationTracker)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 FileElement (com.intellij.psi.impl.source.tree.FileElement)5 Document (com.intellij.openapi.editor.Document)3 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)3 Project (com.intellij.openapi.project.Project)2 PsiFile (com.intellij.psi.PsiFile)2 SingleRootFileViewProvider (com.intellij.psi.SingleRootFileViewProvider)2 XmlFile (com.intellij.psi.xml.XmlFile)2 File (java.io.File)2 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)1 ASTNode (com.intellij.lang.ASTNode)1 Disposable (com.intellij.openapi.Disposable)1 EditorSettings (com.intellij.openapi.editor.EditorSettings)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 DocumentImpl (com.intellij.openapi.editor.impl.DocumentImpl)1 EditorFactoryImpl (com.intellij.openapi.editor.impl.EditorFactoryImpl)1