Search in sources :

Example 1 with PsiManagerEx

use of com.intellij.psi.impl.PsiManagerEx in project intellij-community by JetBrains.

the class PyMultiFileResolveTestCase method doResolve.

protected PsiElement doResolve(PsiFile psiFile) {
    final PsiReference ref = PyResolveTestCase.findReferenceByMarker(psiFile);
    final PsiManagerEx psiManager = (PsiManagerEx) myFixture.getPsiManager();
    psiManager.setAssertOnFileLoadingFilter(new VirtualFileFilter() {

        @Override
        public boolean accept(VirtualFile file) {
            FileType fileType = file.getFileType();
            return fileType == PythonFileType.INSTANCE;
        }
    }, myFixture.getTestRootDisposable());
    final PsiElement result;
    if (ref instanceof PsiPolyVariantReference) {
        final ResolveResult[] resolveResults = ((PsiPolyVariantReference) ref).multiResolve(false);
        result = resolveResults.length == 0 || !resolveResults[0].isValidResult() ? null : resolveResults[0].getElement();
    } else {
        result = ref.resolve();
    }
    psiManager.setAssertOnFileLoadingFilter(VirtualFileFilter.NONE, myFixture.getTestRootDisposable());
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFileFilter(com.intellij.openapi.vfs.VirtualFileFilter) FileType(com.intellij.openapi.fileTypes.FileType) PythonFileType(com.jetbrains.python.PythonFileType) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx)

Example 2 with PsiManagerEx

use of com.intellij.psi.impl.PsiManagerEx in project intellij-community by JetBrains.

the class PyExpressionCodeFragmentImpl method clone.

protected PyExpressionCodeFragmentImpl clone() {
    final PyExpressionCodeFragmentImpl clone = (PyExpressionCodeFragmentImpl) cloneImpl((FileElement) calcTreeElement().clone());
    clone.myPhysical = false;
    clone.myOriginalFile = this;
    FileManager fileManager = ((PsiManagerEx) getManager()).getFileManager();
    SingleRootFileViewProvider cloneViewProvider = (SingleRootFileViewProvider) fileManager.createFileViewProvider(new LightVirtualFile(getName(), getLanguage(), getText()), false);
    cloneViewProvider.forceCachedPsi(clone);
    clone.myViewProvider = cloneViewProvider;
    return clone;
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileElement(com.intellij.psi.impl.source.tree.FileElement) SingleRootFileViewProvider(com.intellij.psi.SingleRootFileViewProvider) FileManager(com.intellij.psi.impl.file.impl.FileManager) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx)

Example 3 with PsiManagerEx

use of com.intellij.psi.impl.PsiManagerEx in project intellij-community by JetBrains.

the class DomStubTest method prepareFile.

protected XmlFile prepareFile(String path) {
    VirtualFile virtualFile = myFixture.copyFileToProject(path);
    assertNotNull(virtualFile);
    XmlFile file = (XmlFile) ((PsiManagerEx) getPsiManager()).getFileManager().findFile(virtualFile);
    assertFalse(file.getNode().isParsed());
    ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), virtualFile, file);
    assertNotNull("Can't build stubs for " + path, tree);
    ((PsiManagerImpl) getPsiManager()).cleanupForNextTest();
    file = (XmlFile) getPsiManager().findFile(virtualFile);
    assertNotNull(file);
    return file;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlFile(com.intellij.psi.xml.XmlFile) PsiManagerImpl(com.intellij.psi.impl.PsiManagerImpl) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx) ObjectStubTree(com.intellij.psi.stubs.ObjectStubTree)

Example 4 with PsiManagerEx

use of com.intellij.psi.impl.PsiManagerEx in project intellij-community by JetBrains.

the class DomStubUsingTest method testFileLoading.

public void testFileLoading() {
    XmlFile file = prepareFile("foo.xml");
    ((PsiManagerEx) getPsiManager()).setAssertOnFileLoadingFilter(VirtualFileFilter.ALL, myFixture.getTestRootDisposable());
    DomFileElement<Foo> element = DomManager.getDomManager(getProject()).getFileElement(file, Foo.class);
    assertNotNull(element);
    GenericDomValue<String> id = element.getRootElement().getId();
    assertEquals("foo", id.getValue());
}
Also used : XmlFile(com.intellij.psi.xml.XmlFile) Foo(com.intellij.util.xml.stubs.model.Foo) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx)

Example 5 with PsiManagerEx

use of com.intellij.psi.impl.PsiManagerEx in project intellij-community by JetBrains.

the class IpnbPyFragment method clone.

protected IpnbPyFragment clone() {
    final IpnbPyFragment clone = (IpnbPyFragment) cloneImpl((FileElement) calcTreeElement().clone());
    clone.myPhysical = false;
    clone.myOriginalFile = this;
    FileManager fileManager = ((PsiManagerEx) getManager()).getFileManager();
    SingleRootFileViewProvider cloneViewProvider = (SingleRootFileViewProvider) fileManager.createFileViewProvider(new LightVirtualFile(getName(), getLanguage(), getText()), false);
    cloneViewProvider.forceCachedPsi(clone);
    clone.myViewProvider = cloneViewProvider;
    return clone;
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileElement(com.intellij.psi.impl.source.tree.FileElement) 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