Fix #864 Note that I didn't workout regex since it seems to break group number conventions. Also for this to work we must reset LANG envvar (maybe provide an option?) since gcc translates words "error", "warning", "note". ![image](https://user-images.githubusercontent.com/7345761/31590454-3365d686-b219-11e...)
You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1649
-- Commit Summary --
* warning support
-- File Changes --
M data/filedefs/filetypes.common (1) M src/build.c (14) M src/build.h (2) M src/editor.h (3) M src/filetypes.c (3) M src/filetypes.h (11) M src/highlighting.c (7) M src/msgwindow.c (48) M src/msgwindow.h (6)
-- Patch Links --
https://github.com/geany/geany/pull/1649.patch https://github.com/geany/geany/pull/1649.diff
Note that I didn't workout regex since it seems to break group number conventions.
Not sure what you mean, can you expand?
Also for this to work we must reset LANG envvar (maybe provide an option?) since gcc translates words "error", "warning", "note".
Well, the regex is there for that purpose, it can have any words in it, you just need to allow for a warning regex as well as the error regex.
The user can set the locale in their command if they need to (at least on Linux, not sure about Windows).
An alternative to having separate error and warning regexes could be to use separate named captures for error and warning.
Not sure what you mean, can you expand?
While I was implementing this issue I haven't traced any usage of regexp (I've inserted printf's). It seems they are defined in filetype config files. 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.
----
Compiler generated line type I think should be defined by translation. Here are the examples: ``` main.c:19:2: error: use of undeclared identifier 'b' main.c:13:6: warning: unused variable ‘a’ [-Wunused-variable] main.c:19:2: ошибка: использование необъявленного идентификатора 'b' main.c:13:6: предупреждение: неиспользуемая переменная ‘a’ [-Wunused-variable] ``` Algorithm suggesion pseudocode: ``` linetypestring = splittedline[typeindex]; linetypestring.tolower(); if(linetypestring.find("err") OR linetypestring.find(translate(current_locale, "error"))) linetype = ERROR; else if(linetypestring.find("warn") OR linetypestring.find(translate(current_locale, "warning"))) linetype = WARNING; ... and so on ``` I don't know how do regexps can solve this problem
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.
Oh, didn't know about named subpatterns, I thought glib supports only sequential subpatterns. BTW it seems that backreferences do not support named groups.
I think I should document this convetions at least as a comment for `filetypes_parse_error_message`. The problem with regexps is solved.
I would also elaborate i18n of non-regex parsing method (`parse_file_line`) according to the algorithm I've described above.
BTW it seems that backreferences do not support named groups.
From the glib regex syntax description:
``` Back references to named subpatterns use the Perl syntax \k<name> or \k'name' or the Python syntax (?P=name). ```
but I admit its not easy to find. And named back references are also numbered too of course.
I think I should document this convetions at least as a comment for filetypes_parse_error_message
Don't worry I will hound you to document it adequately in the manual before the PR will get accepted, erm I mean _help_ you of course :)
IMHO the hard coded error parsing really should not be encouraged any more due to its limitations, lack of maintenance and failure to support newer tools.
@Yanpas pushed 1 commit.
efbb6f7 regex support
It seems that glib isn't able to fetch named subpatterns inside groups line: `main.c:5:2: error: 'a' undeclared (first use in this function)` regex: `(?<file>[^:]+):(?<line>[0-9]+):([0-9]+): ((?<error>error)|(?<warning>warning)).+`
`g_match_info_fetch_named_pos` returns false.
line: main.c:5:2: error: 'a' undeclared (first use in this function)
What is this error from? line 5 of "main.c" ?
@Yanpas pushed 1 commit.
e6af531 fix named subpattern finding
Yes, it's an exmaple of error. Fifth line 5 in "main.c" file. I've fixed the code and now regexp form previous comment works. Only documentation left?
Oooooh, its just your test file, I thought you were getting the error compiling Geany :)
Menu item "Document" -> "Remove error indicators" shoud be renamed to "Remove compiler indicators" I guess
Well, the indicators come from any build, not just compilers, so I would suggest "Remove Build Indicators"
I agree with @elextr, `compiler` would be too specific as we use the Build infrastructure here also for many other tools than compilers.
This will close/fix #447 when merged.
@Yanpas ping, where is this up to?
What do you mean?
Well, nothing has happened since last year, and there are conflicts so I was not sure if you were still working on it.
I do not working on it since there are no updates and tasks to do in this PR. If geany's team is willing to merge it I will resolve the conflicts.
Well, nobody has suggested rejecting it, but it wasn't obvious that it was ready for testing (hence my question), and then without the conflicts being fixed nobody can test it either.
I expect the conflicts are due to the PR that made error colours configurable by CSS, so you would need to accept that, and then extend it to allow a configuring warning colour as well.
OK, will handle it
@Yanpas pushed 1 commit.
59a71e0 Merge branch 'master' into warnings
@Yanpas pushed 1 commit.
2ca4fe13a3c2a9d9443442aec47202089f1ef921 warning, regex support
Closed #1649.
github-comments@lists.geany.org