Search in sources :

Example 66 with LightVirtualFile

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

the class PythonRunConfigurationProducer method isConfigurationFromContext.

@Override
public boolean isConfigurationFromContext(PythonRunConfiguration configuration, ConfigurationContext context) {
    final Location location = context.getLocation();
    if (location == null)
        return false;
    final PsiFile script = location.getPsiElement().getContainingFile();
    if (!isAvailable(location, script))
        return false;
    final VirtualFile virtualFile = script.getVirtualFile();
    if (virtualFile == null)
        return false;
    if (virtualFile instanceof LightVirtualFile)
        return false;
    final String workingDirectory = configuration.getWorkingDirectory();
    final String scriptName = configuration.getScriptName();
    final String path = virtualFile.getPath();
    return scriptName.equals(path) || path.equals(new File(workingDirectory, scriptName).getAbsolutePath());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PsiFile(com.intellij.psi.PsiFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) PsiFile(com.intellij.psi.PsiFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Location(com.intellij.execution.Location)

Example 67 with LightVirtualFile

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

the class PythonConsoleParsingTest method createFile.

@Override
protected PsiFile createFile(String name, String text) {
    LightVirtualFile originalFile = new LightVirtualFile(name, myLanguage, text);
    LightVirtualFile virtualFile = new LightVirtualFile(name, myLanguage, text);
    virtualFile.setOriginalFile(originalFile);
    originalFile.setCharset(CharsetToolkit.UTF8_CHARSET);
    originalFile.putUserData(LanguageLevel.KEY, myLanguageLevel);
    PyConsoleUtil.markIPython(originalFile);
    return createFile(virtualFile);
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile)

Example 68 with LightVirtualFile

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

the class LibraryUtil method getTestGlobalLibrary.

@TestOnly
static // we cannot use LocalFileSystem, because our test can run outside the idea
VirtualFile getTestGlobalLibrary(boolean isPlayer) {
    String name = (isPlayer ? "player" : "air") + "-catalog.xml";
    File file = new File(DebugPathManager.getTestDataPath() + "/lib/playerglobal", name);
    assert file.exists();
    try {
        return new LightVirtualFile(name, XmlFileType.INSTANCE, IOUtil.getCharSequence(file), StandardCharsets.UTF_8, 0);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) TestOnly(org.jetbrains.annotations.TestOnly)

Example 69 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)

Aggregations

LightVirtualFile (com.intellij.testFramework.LightVirtualFile)69 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 NotNull (org.jetbrains.annotations.NotNull)10 Nullable (org.jetbrains.annotations.Nullable)10 IpnbFile (org.jetbrains.plugins.ipnb.format.IpnbFile)7 Document (com.intellij.openapi.editor.Document)6 FileElement (com.intellij.psi.impl.source.tree.FileElement)6 FileType (com.intellij.openapi.fileTypes.FileType)5 PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)5 FileManager (com.intellij.psi.impl.file.impl.FileManager)5 Project (com.intellij.openapi.project.Project)4 SingleRootFileViewProvider (com.intellij.psi.SingleRootFileViewProvider)4 Language (com.intellij.lang.Language)3 FileViewProvider (com.intellij.psi.FileViewProvider)3 PsiFile (com.intellij.psi.PsiFile)3 PsiFileFactoryImpl (com.intellij.psi.impl.PsiFileFactoryImpl)3 File (java.io.File)3 IpnbCell (org.jetbrains.plugins.ipnb.format.cells.IpnbCell)3 VirtualFileWindow (com.intellij.injected.editor.VirtualFileWindow)2 MockDocument (com.intellij.mock.MockDocument)2