Search in sources :

Example 1 with YamlParser

use of com.google.jstestdriver.config.YamlParser in project intellij-plugins by JetBrains.

the class JstdTestFilePathIndex method doIndexConfigFile.

@NotNull
private static Map<String, Void> doIndexConfigFile(@NotNull Reader configFileReader, @NotNull BasePaths initialBasePaths) {
    YamlParser yamlParser = new YamlParser();
    final Map<String, Void> map = new THashMap<>();
    ParsedConfiguration parsedConfiguration = (ParsedConfiguration) yamlParser.parse(configFileReader, initialBasePaths);
    PathResolver pathResolver = new PathResolver(parsedConfiguration.getBasePaths(), Collections.emptySet(), new DisplayPathSanitizer());
    FlagsImpl flags = new FlagsImpl();
    flags.setServer("test:1");
    ResolvedConfiguration resolvedConfiguration = (ResolvedConfiguration) parsedConfiguration.resolvePaths(pathResolver, flags);
    doPutAll(map, resolvedConfiguration.getTests());
    doPutAll(map, resolvedConfiguration.getFilesList());
    return map;
}
Also used : YamlParser(com.google.jstestdriver.config.YamlParser) DisplayPathSanitizer(com.google.jstestdriver.util.DisplayPathSanitizer) ResolvedConfiguration(com.google.jstestdriver.config.ResolvedConfiguration) ParsedConfiguration(com.google.jstestdriver.config.ParsedConfiguration) THashMap(gnu.trove.THashMap) PathResolver(com.google.jstestdriver.PathResolver) FlagsImpl(com.google.jstestdriver.FlagsImpl) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with YamlParser

use of com.google.jstestdriver.config.YamlParser in project intellij-plugins by JetBrains.

the class JstdDebuggingFileFinderProvider method resolveConfiguration.

@NotNull
private ResolvedConfiguration resolveConfiguration() throws ExecutionException {
    VirtualFile configVirtualFile = VfsUtil.findFileByIoFile(myConfigFile, false);
    if (configVirtualFile == null) {
        throw new ExecutionException("Cannot find JsTestDriver configuration file " + myConfigFile.getAbsolutePath());
    }
    BasePaths dirBasePaths = new BasePaths(myConfigFile.getParentFile());
    final byte[] content;
    try {
        content = configVirtualFile.contentsToByteArray();
    } catch (IOException e) {
        throw new ExecutionException("Cannot read JsTestDriver configuration file " + configVirtualFile.getPath());
    }
    Reader reader = new InputStreamReader(new ByteArrayInputStream(content), Charset.defaultCharset());
    try {
        YamlParser yamlParser = new YamlParser();
        ParsedConfiguration parsedConfiguration = (ParsedConfiguration) yamlParser.parse(reader, dirBasePaths);
        JstdConfigParsingUtils.wipeCoveragePlugin(parsedConfiguration);
        return JstdConfigParsingUtils.resolveConfiguration(parsedConfiguration);
    } catch (Exception e) {
        String message = "Malformed JsTestDriver configuration file " + configVirtualFile.getPath();
        LOG.warn(message, e);
        throw new ExecutionException(message);
    } finally {
        try {
            reader.close();
        } catch (IOException ignored) {
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) YamlParser(com.google.jstestdriver.config.YamlParser) ParsedConfiguration(com.google.jstestdriver.config.ParsedConfiguration) ExecutionException(com.intellij.execution.ExecutionException) BasePaths(com.google.jstestdriver.model.BasePaths) ExecutionException(com.intellij.execution.ExecutionException) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ParsedConfiguration (com.google.jstestdriver.config.ParsedConfiguration)2 YamlParser (com.google.jstestdriver.config.YamlParser)2 NotNull (org.jetbrains.annotations.NotNull)2 FlagsImpl (com.google.jstestdriver.FlagsImpl)1 PathResolver (com.google.jstestdriver.PathResolver)1 ResolvedConfiguration (com.google.jstestdriver.config.ResolvedConfiguration)1 BasePaths (com.google.jstestdriver.model.BasePaths)1 DisplayPathSanitizer (com.google.jstestdriver.util.DisplayPathSanitizer)1 ExecutionException (com.intellij.execution.ExecutionException)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 THashMap (gnu.trove.THashMap)1