Search in sources :

Example 86 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.

the class JsonParserTest method testFile.

public void testFile() throws IOException {
    final String fileName = "testData/SymPy.ipynb";
    final String fileText = IpnbTestCase.getFileText(fileName);
    final IpnbFile ipnbFile = IpnbParser.parseIpnbFile(fileText, new LightVirtualFile());
    assertNotNull(ipnbFile);
    assertEquals(31, ipnbFile.getCells().size());
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile) IpnbFile(org.jetbrains.plugins.ipnb.format.IpnbFile)

Example 87 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.

the class JsonParserTest method testMarkdownCells.

public void testMarkdownCells() throws IOException {
    final String fileName = "testData/SymPy.ipynb";
    final String fileText = IpnbTestCase.getFileText(fileName);
    final IpnbFile ipnbFile = IpnbParser.parseIpnbFile(fileText, new LightVirtualFile());
    assertNotNull(ipnbFile);
    final List<IpnbCell> cells = ipnbFile.getCells();
    Iterables.removeIf(cells, new Predicate<IpnbCell>() {

        @Override
        public boolean apply(IpnbCell cell) {
            return !(cell instanceof IpnbMarkdownCell);
        }
    });
    assertEquals(7, cells.size());
}
Also used : IpnbCell(org.jetbrains.plugins.ipnb.format.cells.IpnbCell) IpnbMarkdownCell(org.jetbrains.plugins.ipnb.format.cells.IpnbMarkdownCell) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) IpnbFile(org.jetbrains.plugins.ipnb.format.IpnbFile)

Example 88 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project intellij-plugins by JetBrains.

the class LiveObjectsNode method getNavigatable.

@Override
public Navigatable getNavigatable() {
    if (navigatableCache == null) {
        final VirtualFile virtualFile = new LightVirtualFile(runConfigurationName, new LiveObjectsFileType(), "") {

            @NotNull
            @Override
            public String getPath() {
                return getName();
            }
        };
        virtualFile.putUserData(ProfileData.CONTROLLER, liveModelController);
        virtualFile.putUserData(ProfileData.PROFILING_MANAGER, profilingManager);
        navigatableCache = new OpenFileDescriptor(module.getProject(), virtualFile);
    }
    return navigatableCache;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) LiveObjectsFileType(com.jetbrains.actionscript.profiler.file.LiveObjectsFileType)

Example 89 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project oxy-template-support-plugin by mutant-industries.

the class CompiledPreviewUpdater method run.

@Override
public void run() {
    for (FileEditor fileEditor : FileEditorManager.getInstance(project).getAllEditors()) {
        if (!(fileEditor instanceof TextEditor)) {
            continue;
        }
        EditorEx editor = (EditorEx) ((TextEditor) fileEditor).getEditor();
        VirtualFile virtualFile = editor.getVirtualFile();
        Language language = virtualFile instanceof LightVirtualFile ? ((LightVirtualFile) virtualFile).getLanguage() : null;
        if (language != CompiledPreview.INSTANCE) {
            continue;
        }
        PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
        PsiFile originalFile;
        if (psiFile == null || (originalFile = psiFile.getUserData(CompiledPreviewController.ORIGINAL_FILE_KEY)) == null) {
            continue;
        }
        project.getComponent(CompiledPreviewController.class).showCompiledCode(originalFile, editor.getDocument());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) EditorEx(com.intellij.openapi.editor.ex.EditorEx) Language(com.intellij.lang.Language) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PsiFile(com.intellij.psi.PsiFile)

Example 90 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project Perl5-IDEA by Camelcade.

the class PerlUseStrictInspection method buildVisitor.

@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
    return new PerlVisitor() {

        @Override
        public void visitFile(PsiFile file) {
            if (file.getViewProvider() instanceof InjectedFileViewProvider || !file.isWritable() || !file.isPhysical() || file.getVirtualFile() instanceof LightVirtualFile) {
                return;
            }
            FileType fileType = file.getFileType();
            if (!(fileType instanceof PerlFileType) || !((PerlFileType) fileType).checkStrictPragma()) {
                return;
            }
            for (PerlUseStatement useStatement : PsiTreeUtil.findChildrenOfType(file, PerlUseStatement.class)) {
                if (useStatement.getPackageProcessor() instanceof PerlStrictProvider) {
                    return;
                }
            }
            holder.registerProblem(file, PerlBundle.message("perl.inspection.use.strict"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new PerlUsePackageQuickFix("strict"));
        }
    };
}
Also used : InjectedFileViewProvider(com.intellij.psi.impl.source.tree.injected.InjectedFileViewProvider) PerlFileType(com.perl5.lang.perl.fileTypes.PerlFileType) PerlStrictProvider(com.perl5.lang.perl.extensions.packageprocessor.PerlStrictProvider) PerlUsePackageQuickFix(com.perl5.lang.perl.idea.quickfixes.PerlUsePackageQuickFix) FileType(com.intellij.openapi.fileTypes.FileType) PerlFileType(com.perl5.lang.perl.fileTypes.PerlFileType) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PsiFile(com.intellij.psi.PsiFile) PerlVisitor(com.perl5.lang.perl.psi.PerlVisitor) PerlUseStatement(com.perl5.lang.perl.psi.PerlUseStatement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LightVirtualFile (com.intellij.testFramework.LightVirtualFile)102 VirtualFile (com.intellij.openapi.vfs.VirtualFile)26 NotNull (org.jetbrains.annotations.NotNull)14 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)13 Nullable (org.jetbrains.annotations.Nullable)13 PsiFile (com.intellij.psi.PsiFile)12 Project (com.intellij.openapi.project.Project)11 Document (com.intellij.openapi.editor.Document)9 FileEditor (com.intellij.openapi.fileEditor.FileEditor)8 FileType (com.intellij.openapi.fileTypes.FileType)8 PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)7 FileManager (com.intellij.psi.impl.file.impl.FileManager)7 IpnbFile (org.jetbrains.plugins.ipnb.format.IpnbFile)7 BlobExplorerFileEditor (com.microsoft.intellij.helpers.storage.BlobExplorerFileEditor)6 QueueFileEditor (com.microsoft.intellij.helpers.storage.QueueFileEditor)6 TableFileEditor (com.microsoft.intellij.helpers.storage.TableFileEditor)6 Language (com.intellij.lang.Language)5 PsiFileFactoryImpl (com.intellij.psi.impl.PsiFileFactoryImpl)5 FileElement (com.intellij.psi.impl.source.tree.FileElement)5 FileViewProvider (com.intellij.psi.FileViewProvider)4