首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将工具输出中的绝对文件路径和行号转换为超链接。

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

Stack Overflow用户
提问于 2016-10-25 12:40:52
回答 1查看 182关注 0票数 4

这是一个示例输出:

代码语言:javascript
复制
/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

但是,在其中创建输出筛选器的方式如下:

不起作用。

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

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

帮助我找到一种方法,包括在链接中的行号。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-11 20:24:42

这是我想出的;

第一,

代码语言:javascript
复制
elm-make --report json

输出结构化JSON中的构建错误;

代码语言:javascript
复制
$ 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 (见这里)。将输出转换为

代码语言:javascript
复制
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"'

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

代码语言:javascript
复制
[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中使用以下格式获取

代码语言:javascript
复制
$FILE_PATH$:$LINE$:$COLUMN$ $MESSAGE$

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40240254

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档