Sublime Forum

Build system regex captures

#1

Hey :slightly_smiling:

I’m trying to have a build system work woth this sort of output:

  == lib/blah/store.ex ==
  70: LineLength: Line length should not exceed 80 chars (was 90).
  71: LineLength: Line length should not exceed 80 chars (was 90).

There are multiple references of named captures around, so I came up with:

    "file_regex": "^\\=\\= (?'filename'.*) \\=\\=$",
    "line_regex": "^(?'line\\ number'[0-9]+): (?'error\\ message'.*)"

It gets the filename and the line number correctly. But the error message show as == lib/blah/store.ex ==.
I am pretty sure the capture fields are not named correctly in the docs (Some contain space, sometimes it’s file name sometimes it’s filename).

Is there any consistent documentation about capturing the fields in an arbitrary order anywhere?

My initial attempt was without named capture groups:

    "file_regex": "^\\=\\= (.*) \\=\\=$",
    "line_regex": "^([0-9]+): (.*)"

Exact same result, like if the named capture groups (Described as “fields” in the docs) are not caught.

Thanks!
Doodloo.

0 Likes

#2

Solved by changing the output format of the build tool. It’s not really a solution, as sublime can apparently not be configured via build systems when the occurence of the filename / line / column / message is in a different order in the outputs.

0 Likes

#3

You can get it to work by adding another empty capture group to fill the column number result. This worked for me with your build output:
"file_regex": "^\\=\\= (.*) \\=\\=$", "line_regex": "^([0-9]+): ()(.*)",

1 Like

#4

The build results regular expressions to not support named capture groups.

0 Likes

#5

@ProfessorSil It doesn’t work for me. What is the inline message you get, the actual error message or the file name / full output? The expected behaviour is to only display the error messages inline with the source code, not the full output log (If not, it kind of defeat the purpose of having a capture for the message, which works for other outputs). I guess it doesn’t matter as it was possible to change the tooling format output. Thanks anyway :slightly_smiling:

@FichteFoll Thanks for your help. Unless you’re a developer of Sublime, I’d be very curious to hear about your sources.

Now another one, consider this error output now:

     # Mind the leading spaces...
     test/output_test.exs:57
     Expected truthy, got false

The regexp I wrote is this one:

^     ([^\\s].+):([0-9]+)([0..9]*?)\n     (.+)$

I know the regexp is correct, when testing the regex somewhere else, the captures are correct https://regex101.com/r/iyS4J2/1/ . But Sublime chokes on opening the file / displaying anything on the line number. Oddly enough, Sublime still highlights the relevant lines of the log when cycling with F4, meaning that the regexp is correctly applied.

Any hint? What’s the problem with Subline regexp?

0 Likes

#6

The regexes only operate on one line at a time, unfortunately, so matching \n something is impossible

also partially related:

0 Likes

#7

@kingkeith Thanks for your help! Amazing, I didn’t know there was an issue tracker for Sublime. Thanks!

I guess I’m going to have to sed the output of my tooling then :slight_smile: Too bad, I really liked the rspec / exunit format in my console!

Thanks!

0 Likes

#8

it’s most noticable with Python - one of the ST devs commented on it here:

0 Likes

#9

feel free to submit a PR to the unofficial docs to make this page clearer:
http://sublime-text-unofficial-documentation.readthedocs.io/en/latest/reference/build_systems/configuration.html#capturing-build-system-results

0 Likes