[Github-comments] [geany/geany] warning support (#1649)

elextr notifications at xxxxx
Mon Oct 16 12:26:25 UTC 2017


> Also I didn't find convetions for regexp. For example mapping of group number, type and meaning (e.g groupn:2; meaning:line number; type:integer). I don't think it's a good idea to hardcode such mapping.

The use of the regex is described in the [Geany manual](https://www.geany.org/manual/current/index.html#build-settings-section), it must have two captures, one for the filename and one for the line number.  It doesn't matter what order they are since the line number is all digits and the other is the filename.

Since extracting both warning and error information is starting to make the regex more complex I suggest using named captures so the mapping is explicit.

For regex syntax see https://developer.gnome.org/glib/stable/glib-regex-syntax.html and especially section `named subpatterns` (sorry Glib has no anchors to internal sections).

As an example lets run a compiler in a locale called "Faux French" where error messages look like:

```
Erreur:my.file:123: le blah
Attention:my.file:456: le more blah
```

a regex like:

```
(?:(?<error>Erreur)/(?<warning>Attention)):(?<file>[^:]+):(?<line>[0-9]+)
```

would provide named matches for the two lines above:

| error | warning | file | line |
|--------|------------|------|------|
| Erreur | no match | my.file | 123 |
| no match | Attention | my.file | 456 |

As you can see only the `error` named capture matches for error messages and only the `warning` named capture matches for warnings, so Geany could use that to tell the them apart without caring what language the contents of the match are in, and `file` and `line` named captures match for both.  The other benefit for using named captures is that they can be in any order in the message and never get confused.

Also if the regex did not have named captures the existing method of assuming an all digit capture is line number can still be used, so its backward compatible with any regexes users have already configured.

An keeping to one regex means you don't have to change any GUIS or config file loading or storing, just the code in `filetypes_parse_error_message()` to use the new regexes.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1649#issuecomment-336871080
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20171016/d27727d3/attachment-0001.html>


More information about the Github-comments mailing list