Sublime Forum

Problem with file_regex

#1

Hello,

I currently have a problem with how the file_regex config works in build_systems. My problem is with visual studio outputting all file in a relative way based on their .vcxproj location. Since my .sln include multiple .vcxproj located in different folder, I can’t seem to find a way for ST2 to open the error containing file correctly.

The errors message look like this:

1>…\tests\math\test_quaternion.cpp(103): error C2078: too many initializers

and I match them with the following build system configuration:

    {
        "name": "Build Gear 4 Win64",
        "cmd":
        
            "C:/Program Files (x86)/Microsoft Visual Studio 10.0/Common7/IDE/devenv.com",
            "F:/p4/technology-group-playground/gear/team/solutions/win64/vc10/Gear4_win64.sln",
            "/build",
            "debug",
            "/project",
            "gear_core_win64_tests"
        ],
        "file_regex": "^\\d>\\.\\\\\\w]*\\\\(\\w+\\.\\w+)\\((\\d+)\\):()\\s(.*)$"
    }

My example line would provide only test_quaternion.cpp as the captured file name. but when I click on the error line, ST2 will try to open test_quaternion.cpp in the folder where my .sublime-project is located.

Is there a way to make ST2 search for the captured file name with the same algorithm as ctrl+p does? Using Goto Anything and typing test_quaternion.cpp:103 will get me exactly at the correct place.

I’m taking any suggestion you may have.
Thanks

0 Likes

#2

Here is a small question to go with my previous post.

Is it possible to have the build window highlight the matching line in the log? This would help greatly in quickly finding the error in a big compilation log.

And here is a small request to go with this post :smile:

Could we have the option to split the file_regex into an error_regex and warning_regex? Again with the possibility to highlight the errors and the warnings with different color in the log.

Also, for those that are interested, I’ve slightly updated the regex for it to work better with error message explaining templates error:

“file_regex”: “^\d+>\s*\.\\\w]\\(\w+\.\w+)\((\d+)\)\s:()\s*(.*)$”

0 Likes

#3

If you set a working_dir in your build system, then all paths will be interpreted as being relative to that.

Unfortunately, the current setup doesn’t support a scenario where different error messages need to be relative to different directories.

0 Likes

#4

I used this regex that was provided…

“file_regex”: “^\d+>\s*.\\w]\(\w+.\w+)((\d+))\s:()\s*(.*)$”

and it is broken on my windows sublimetext3…

My build system stops working and the editor highlight all the \d, \s, … in red.

Why is this?

0 Likes

#5

The content of the build system is JSON, which means that the strings are JSON strings. The \ character is special inside of them; it represents the escape character…

The text \d is thus interpreted as a character escape in the JSON string, but it’s not a valid one because JSON supports a very limited set of character escapes. Sublime knows that so the syntax highlighting points out that they’re incorrect so that you can fix them.

In order to fix the problem you need to escape all of the \ characters, e.g. \\d. The regex as presented above is doing that for the first \w, but not the rest. I assume that was an oversight on the part of the original poster when he shared what he was using.

0 Likes

#6

also, posts migrated from the old forums tend to be missing some [ characters

1 Like