Search in sources :

Example 1 with RemoteDebuggingFileFinder

use of com.intellij.javascript.debugger.RemoteDebuggingFileFinder in project intellij-plugins by JetBrains.

the class JstdDebuggingFileFinderProvider method provideFileFinder.

@NotNull
public RemoteDebuggingFileFinder provideFileFinder() throws ExecutionException {
    ResolvedConfiguration resolvedConfiguration = resolveConfiguration();
    BiMap<String, VirtualFile> mappings = HashBiMap.create();
    addAllRemoteUrlMappings(resolvedConfiguration.getTests(), mappings);
    addAllRemoteUrlMappings(resolvedConfiguration.getFilesList(), mappings);
    return new RemoteDebuggingFileFinder(mappings, null);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ResolvedConfiguration(com.google.jstestdriver.config.ResolvedConfiguration) RemoteDebuggingFileFinder(com.intellij.javascript.debugger.RemoteDebuggingFileFinder) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with RemoteDebuggingFileFinder

use of com.intellij.javascript.debugger.RemoteDebuggingFileFinder in project intellij-plugins by JetBrains.

the class KarmaDebugProgramRunner method getDebuggableFileFinder.

private static DebuggableFileFinder getDebuggableFileFinder(@NotNull KarmaServer karmaServer) {
    BiMap<String, VirtualFile> mappings = HashBiMap.create();
    KarmaConfig karmaConfig = karmaServer.getKarmaConfig();
    if (karmaConfig != null) {
        VirtualFile basePath = LocalFileSystem.getInstance().findFileByPath(karmaConfig.getBasePath());
        if (basePath != null && basePath.isValid()) {
            if (karmaConfig.isWebpack()) {
                mappings.put("webpack:///" + basePath.getPath(), basePath);
                VirtualFile nodeModulesDir = basePath.findChild(NodeModuleUtil.NODE_MODULES);
                if (nodeModulesDir != null && nodeModulesDir.isValid() && nodeModulesDir.isDirectory()) {
                    mappings.put(karmaServer.formatUrlWithoutUrlRoot("/base/" + NodeModuleUtil.NODE_MODULES), nodeModulesDir);
                }
            } else {
                mappings.put(karmaServer.formatUrlWithoutUrlRoot("/base"), basePath);
            }
        }
    }
    if (SystemInfo.isWindows) {
        VirtualFile[] roots = ManagingFS.getInstance().getLocalRoots();
        for (VirtualFile root : roots) {
            String key = karmaServer.formatUrlWithoutUrlRoot("/absolute" + root.getName());
            if (mappings.containsKey(key)) {
                LOG.warn("Duplicate mapping for Karma debug: " + key);
            } else {
                mappings.put(key, root);
            }
        }
    } else {
        VirtualFile[] roots = ManagingFS.getInstance().getLocalRoots();
        if (roots.length == 1) {
            mappings.put(karmaServer.formatUrlWithoutUrlRoot("/absolute"), roots[0]);
        }
    }
    return new RemoteDebuggingFileFinder(mappings, null);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RemoteDebuggingFileFinder(com.intellij.javascript.debugger.RemoteDebuggingFileFinder) KarmaConfig(com.intellij.javascript.karma.KarmaConfig)

Aggregations

RemoteDebuggingFileFinder (com.intellij.javascript.debugger.RemoteDebuggingFileFinder)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 ResolvedConfiguration (com.google.jstestdriver.config.ResolvedConfiguration)1 KarmaConfig (com.intellij.javascript.karma.KarmaConfig)1 NotNull (org.jetbrains.annotations.NotNull)1