在mac vim上使用ant编译时寻找更好的errorformat

时间:2012-12-18 13:22:41

标签: vim ant

目前我在mac上使用的efmset efm=%A\ %#[javac]\ %f:%l:\ %m,%A\ %#[aapt]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#。它实际上可以找到错误位置并显示一个简短的错误信息,但细节我只能通过切换到终端来获得。

顺便说一下,efm对archlinux非常有用。

这是输出:

-compile:
    [javac] Compiling 8 source files to /Users/ccheng/workspace_tb/Android_RollingBall/bin/classes
    [javac] /Users/ccheng/workspace_tb/Android_RollingBall/src/hongbosb/rollingball/GLDrawable.java:22: incompatible types
    [javac] found   : void
    [javac] required: int
    [javac]         mEnvProgram = Utils.loadProgram(context, "environment_vertex_shader.glsl", "environment_fragment_shader.glsl");
    [javac]                                        ^
    [javac] /Users/ccheng/workspace_tb/Android_RollingBall/src/hongbosb/rollingball/EnvironmentGLDrawable.java:15: cannot find symbol
    [javac] symbol  : constructor GLDrawable()
    [javac] location: class hongbosb.rollingball.GLDrawable
    [javac]     public EnvironmentGLDrawable(Context context) {
    [javac]                                                   ^
    [javac] /Users/ccheng/workspace_tb/Android_RollingBall/src/hongbosb/rollingball/MyRenderer.java:31: cannot find symbol
    [javac] symbol  : variable context
    [javac] location: class hongbosb.rollingball.MyRenderer
    [javac]         mEnvironment = new EnvironmentGLDrawable(context);
    [javac]                                                  ^
    [javac] 3 errors

以下是我的vim错过的。

[javac] found   : void
        [javac] required: int
        [javac]         mEnvProgram = Utils.loadProgram(context, "environment_vertex_shader.glsl", "environment_fragment_shader.glsl");
        [javac]                                        ^
        [javac]

1 个答案:

答案 0 :(得分:2)

好的,我要重新格式化,以便(对我而言)处理... ...

let fmt = '%A\ %#[javac]\ %f:%l:\ %m,'
      \ . '%A\ %#[aapt]\ %f:%l:\ %m,'
      \ . '%-Z\ %#[javac]\ %p^,'
      \ . '%-C%.%#'
execute 'set errorformat=' . fmt

javac探测器中只有一行可以抓取一条消息。你只需要添加更多。在%-C行上方的某处添加以下内容:

      \ . '%C\ %#[javac]\ %m,'

你可能也想为aapt消息做一些类似的事情,虽然如果那些是单行的,那么我认为你只是打击开始它的行的%A部分; %A表示它是多行消息的开头,因此在%Z匹配之前,它会将其后面的所有内容视为aapt消息的一部分。 %-C位表示“匹配这个是无趣的”;这些是您告诉vim跳过的多行消息中的内容(例如,未显示的内容)。