Search in sources :

Example 1 with SemVer

use of com.intellij.util.text.SemVer in project intellij-plugins by JetBrains.

the class TsLintLanguageService method parseResults.

@Nullable
private static List<TsLinterError> parseResults(@NotNull JSLanguageServiceAnswer answer, @NotNull String path) {
    final JsonObject element = answer.getElement();
    final JsonElement error = element.get("error");
    if (error != null) {
        return Collections.singletonList(new TsLinterError(error.getAsString()));
    }
    final JsonElement body = parseBody(element);
    if (body == null)
        return null;
    final String version = element.get("version").getAsString();
    final SemVer tsLintVersion = SemVer.parseFromText(version);
    final boolean isZeroBased = TsLintOutputJsonParser.isVersionZeroBased(tsLintVersion);
    final TsLintOutputJsonParser parser = new TsLintOutputJsonParser(path, body, isZeroBased);
    return ContainerUtil.newArrayList(parser.getErrors());
}
Also used : JsonElement(com.google.gson.JsonElement) TsLinterError(com.intellij.lang.javascript.linter.tslint.execution.TsLinterError) JsonObject(com.google.gson.JsonObject) SemVer(com.intellij.util.text.SemVer) TsLintOutputJsonParser(com.intellij.lang.javascript.linter.tslint.execution.TsLintOutputJsonParser) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 TsLintOutputJsonParser (com.intellij.lang.javascript.linter.tslint.execution.TsLintOutputJsonParser)1 TsLinterError (com.intellij.lang.javascript.linter.tslint.execution.TsLinterError)1 SemVer (com.intellij.util.text.SemVer)1 Nullable (org.jetbrains.annotations.Nullable)1