将工具输出中的绝对文件路径和行号转换为超链接

时间:2016-10-25 12:40:52

标签: intellij-idea webstorm elm jetbrains-ide

这是一个示例输出:

/usr/local/bin/node /usr/local/bin/elm-make src/elm/Main.elm --output=builds/main.js
-- TYPE MISMATCH ---------------------------------------------- src/elm/Main.elm

The type annotation for `init` does not match its definition.

35| init : Maybe Route.Location -> ( Model, Cmd Msg )
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The type annotation is saying:

    Maybe Route.Location -> ( { route : Maybe Route.Location }, Cmd Msg )

But I am inferring that the definition has this type:

    Maybe Route.Location
    -> ( { route : Maybe Route.Location -> Route.Model }, Cmd a )

Detected errors in 1 module.

Process finished with exit code 1

这是我提出的正则表达式:

http://regexr.com/3egqu

但是,创建输出过滤器就像这样:

enter image description here

不起作用。

到目前为止,我只知道以下工作:------ ($FILE_PATH$)

它将文件路径转换为链接:

enter image description here

帮我找到一种方法,将行号包含在链接中。

1 个答案:

答案 0 :(得分:2)

这是我提出的内容;

首先,

elm-make --report json

以结构化JSON输出构建错误;

$ elm-make --report json src/main.elm
[{"tag":"unused import","overview":"Module `Bootstrap.CDN` is unused.","details":"Best to remove it. Don't save code quality for later!","region":{"start":{"line":3,"column":1},"end":{"line":3,"column":28}},"type":"warning","file":"src/main.elm"}]

现在,您可以通过jq (see here).管道输出,将其重新格式化为

elm make src/main.elm --report json --output ./public/app.js | \
jq '.[] | { type: .type, file: .file, line: .region.start.line|tostring, tag: .tag, column: .region.start.column|tostring, tag: .tag, details: .details }' | \
jq --raw-output '. | "[" + (.type|ascii_upcase) + "] " + .file + ":" + .line + ":" + .column + " " + .tag + " -- " + .details + "\n"'

为您提供重新格式化的输出;

[WARNING] src/main.elm:9:1 unused import -- Best to remove it. Don't save code quality for later!

[WARNING] src/main.elm:17:1 missing type annotation -- I inferred the type annotation so you can copy it into your code:

main : Program Never Model Main.Msg

您使用格式

在intellij中选择
$FILE_PATH$:$LINE$:$COLUMN$ $MESSAGE$

然后,您可以单击错误消息以跳转到文件,并在工具提示中显示错误文本。