Search in sources :

Example 1 with SingleRootFileViewProvider

use of com.intellij.psi.SingleRootFileViewProvider 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 2 with SingleRootFileViewProvider

use of com.intellij.psi.SingleRootFileViewProvider in project intellij-plugins by JetBrains.

the class DartExpressionCodeFragmentImpl method clone.

protected DartExpressionCodeFragmentImpl clone() {
    final DartExpressionCodeFragmentImpl clone = (DartExpressionCodeFragmentImpl) cloneImpl((FileElement) calcTreeElement().clone());
    clone.myPhysical = false;
    clone.myOriginalFile = this;
    final FileManager fileManager = ((PsiManagerEx) getManager()).getFileManager();
    final SingleRootFileViewProvider cloneViewProvider = (SingleRootFileViewProvider) fileManager.createFileViewProvider(new LightVirtualFile(getName(), getLanguage(), getText()), false);
    clone.myViewProvider = cloneViewProvider;
    cloneViewProvider.forceCachedPsi(clone);
    clone.init(getContentElementType(), getContentElementType());
    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 SingleRootFileViewProvider

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

the class TemplateDataElementType method createPsiFileFromSource.

protected PsiFile createPsiFileFromSource(final Language language, CharSequence sourceCode, PsiManager manager) {
    @NonNls final LightVirtualFile virtualFile = new LightVirtualFile("foo", createTemplateFakeFileType(language), sourceCode, LocalTimeCounter.currentTime());
    FileViewProvider viewProvider = new SingleRootFileViewProvider(manager, virtualFile, false) {

        @Override
        @NotNull
        public Language getBaseLanguage() {
            return language;
        }
    };
    // Since we're already inside a template language PSI that was built regardless of the file size (for whatever reason), 
    // there should also be no file size checks for template data files.
    SingleRootFileViewProvider.doNotCheckFileSizeLimit(virtualFile);
    return viewProvider.getPsi(language);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) FileViewProvider(com.intellij.psi.FileViewProvider) SingleRootFileViewProvider(com.intellij.psi.SingleRootFileViewProvider) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) SingleRootFileViewProvider(com.intellij.psi.SingleRootFileViewProvider)

Example 4 with SingleRootFileViewProvider

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

the class JavaParsingTestCase method createPsiFile.

private PsiFile createPsiFile(final String name, final String text, final TestParser parser) {
    if (TEST_FILE_ELEMENT_TYPE == null) {
        TEST_FILE_ELEMENT_TYPE = new MyIFileElementType();
    }
    TEST_PARSER = parser;
    final LightVirtualFile virtualFile = new LightVirtualFile(name + '.' + myFileExt, StdFileTypes.JAVA, text, -1);
    final FileViewProvider viewProvider = new SingleRootFileViewProvider(PsiManager.getInstance(getProject()), virtualFile, true);
    return new PsiJavaFileImpl(viewProvider) {

        @NotNull
        @Override
        protected FileElement createFileElement(@NotNull final CharSequence text) {
            return new FileElement(TEST_FILE_ELEMENT_TYPE, text);
        }
    };
}
Also used : FileViewProvider(com.intellij.psi.FileViewProvider) SingleRootFileViewProvider(com.intellij.psi.SingleRootFileViewProvider) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileElement(com.intellij.psi.impl.source.tree.FileElement) SingleRootFileViewProvider(com.intellij.psi.SingleRootFileViewProvider) PsiJavaFileImpl(com.intellij.psi.impl.source.PsiJavaFileImpl) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SingleRootFileViewProvider (com.intellij.psi.SingleRootFileViewProvider)4 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)4 FileElement (com.intellij.psi.impl.source.tree.FileElement)3 FileViewProvider (com.intellij.psi.FileViewProvider)2 PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)2 FileManager (com.intellij.psi.impl.file.impl.FileManager)2 PsiJavaFileImpl (com.intellij.psi.impl.source.PsiJavaFileImpl)1 NonNls (org.jetbrains.annotations.NonNls)1 NotNull (org.jetbrains.annotations.NotNull)1