To be able to perform changes in our tag mappings without possibly invalidating existing tag files, store also the ctags kind letter to the tag file and use it instead of the mapped type when available.
See https://github.com/geany/geany/pull/3049#issuecomment-1129756250 You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3208
-- Commit Summary --
* Add ctags kind letter to tag manager tag files * Modify unit tests to contain the newly added ctags kind letter
-- File Changes --
M src/tagmanager/tm_source_file.c (11) M src/tagmanager/tm_tag.h (2) M tests/ctags/1795612.js.tags (8) M tests/ctags/1850914.js.tags (6) M tests/ctags/1878155.js.tags (8) M tests/ctags/1880687.js.tags (82) M tests/ctags/2023624.js.tags (4) M tests/ctags/3184782.sql.tags (10) M tests/ctags/3470609.js.tags (24) M tests/ctags/3526726.tex.tags (296) M tests/ctags/68hc11.asm.tags (20) M tests/ctags/Package.pm.tags (24) M tests/ctags/actionscript/as-first-token.as.tags (2) M tests/ctags/actionscript/classes.as.tags (24) M tests/ctags/actionscript/const.as.tags (10) M tests/ctags/actionscript/const2.as.tags (4) M tests/ctags/actionscript/method-attributes.as.tags (18) M tests/ctags/actionscript/packages.as.tags (12) M tests/ctags/actionscript/sampler.as.tags (30) M tests/ctags/ada-adb.adb.tags (38) M tests/ctags/ada-ads.ads.tags (32) M tests/ctags/ada-expression-function-generic.adb.tags (10) M tests/ctags/ada-expression-function.adb.tags (18) M tests/ctags/ada-overriding.ads.tags (6) M tests/ctags/ada-package-generic.ads.tags (18) M tests/ctags/ada-task.adb.tags (10) M tests/ctags/angle_bracket.cpp.tags (6) M tests/ctags/anonymous_functions.php.tags (16) M tests/ctags/array-spec.f90.tags (12) M tests/ctags/array_ref_and_out.cs.tags (10) M tests/ctags/array_spec.f90.tags (16) M tests/ctags/arraylist.js.tags (16) M tests/ctags/attributes.cs.tags (12) M tests/ctags/auto.f.tags (8) M tests/ctags/backslashes.c.tags (22) M tests/ctags/bit_field.c.tags (46) M tests/ctags/block.f90.tags (12) M tests/ctags/bracematch.js.tags (12) M tests/ctags/bug1020715.c.tags (2) M tests/ctags/bug1020715.cpp.tags (2) M tests/ctags/bug1086609.c.tags (2) M tests/ctags/bug1093123.cpp.tags (2) M tests/ctags/bug1111214-j-chan.v.tags (6) M tests/ctags/bug1111214.v.tags (2) M tests/ctags/bug1201689.c.tags (2) M tests/ctags/bug1447756.java.tags (4) M tests/ctags/bug1458930.c.tags (4) M tests/ctags/bug1466117.c.tags (6) M tests/ctags/bug1491666.c.tags (8) M tests/ctags/bug1515910.cs.tags (18) M tests/ctags/bug1548443.cpp.tags (8) M tests/ctags/bug1563476.cpp.tags (6) M tests/ctags/bug1570779.sql.tags (8) M tests/ctags/bug1575055.cpp.tags (6) M tests/ctags/bug1585745.cpp.tags (12) M tests/ctags/bug1611054.cs.tags (6) M tests/ctags/bug1691412.java.tags (6) M tests/ctags/bug1742588.rb.tags (6) M tests/ctags/bug1743330.v.tags (2) M tests/ctags/bug1764143.h.tags (4) M tests/ctags/bug1764148.py.tags (2) M tests/ctags/bug1770479.cpp.tags (4) M tests/ctags/bug1773926.cpp.tags (8) M tests/ctags/bug1777344.java.tags (18) M tests/ctags/bug1799340.cpp.tags (6) M tests/ctags/bug1799343-1.cpp.tags (12) M tests/ctags/bug1799343-2.cpp.tags (28) M tests/ctags/bug1800065.cs.tags (6) M tests/ctags/bug1809024.py.tags (2) M tests/ctags/bug1830343.cs.tags (4) M tests/ctags/bug1830344.cs.tags (4) M tests/ctags/bug1856363.py.tags (2) M tests/ctags/bug1906062.py.tags (4) M tests/ctags/bug1907083.cpp.tags (8) M tests/ctags/bug1924919.cpp.tags (6) M tests/ctags/bug1938565.sql.tags (10) M tests/ctags/bug1944150.sql.tags (2) M tests/ctags/bug1950327.js.tags (26) M tests/ctags/bug1988026.py.tags (8) M tests/ctags/bug1988027.py.tags (2) M tests/ctags/bug1988130.py.tags (4) M tests/ctags/bug2049723.java.tags (6) M tests/ctags/bug2075402.py.tags (4) M tests/ctags/bug2117073.java.tags (6) M tests/ctags/bug2374109.vhd.tags (4) M tests/ctags/bug2411878.cs.tags (4) M tests/ctags/bug2747828.v.tags (2) M tests/ctags/bug2777310.js.tags (10) M tests/ctags/bug2781264.rb.tags (6) M tests/ctags/bug2886870.tex.tags (78) M tests/ctags/bug2888482.js.tags (4) M tests/ctags/bug3036476.js.tags (8) M tests/ctags/bug3168705.py.tags (6) M tests/ctags/bug3571233.js.tags (20) M tests/ctags/bug507864.c.tags (4) M tests/ctags/bug538629.asm.tags (2) M tests/ctags/bug556645.c.tags (4) M tests/ctags/bug556646.c.tags (40) M tests/ctags/bug565813.f90.tags (14) M tests/ctags/bug612019.pas.tags (6) M tests/ctags/bug612621.pl.tags (4) M tests/ctags/bug620288.f.tags (4) M tests/ctags/bug639639.h.tags (8) M tests/ctags/bug639644.hpp.tags (4) M tests/ctags/bug665086.cpp.tags (6) M tests/ctags/bug670433.f90.tags (8) M tests/ctags/bug699171.py.tags (4) M tests/ctags/bug722501.sql.tags (2) M tests/ctags/bug726712.f90.tags (6) M tests/ctags/bug726875.f90.tags (6) M tests/ctags/bug734933.f90.tags (32) M tests/ctags/bug762027.v.tags (4) M tests/ctags/bug814263.java.tags (6) M tests/ctags/bug823000.sql.tags (6) M tests/ctags/bug842077.pl.tags (2) M tests/ctags/bug849591.cpp.tags (2) M tests/ctags/bug852368.cpp.tags (2) M tests/ctags/bug858165.f90.tags (10) M tests/ctags/bug872494.cpp.tags (6) M tests/ctags/bug877956.f90.tags (6) M tests/ctags/bug960316.v.tags (12) M tests/ctags/bug961001.v.tags (16) M tests/ctags/byte.f.tags (20) M tests/ctags/c-digraphs.c.tags (22) M tests/ctags/c-trigraphs.c.tags (28) M tests/ctags/case_sensitivity.php.tags (32) M tests/ctags/char-selector.f90.tags (20) M tests/ctags/classes.php.tags (14) M tests/ctags/cobol/helloworld.cbl.tags (20) M tests/ctags/cobol/helloworld2.cbl.tags (20) M tests/ctags/cobol/levels.cbl.tags (42) M tests/ctags/cobol/quoted-program-id.cbl.tags (8) M tests/ctags/cobol/simple.cbl.tags (42) M tests/ctags/common.f.tags (8) M tests/ctags/complex-return.js.tags (38) M tests/ctags/continuation.f90.tags (8) M tests/ctags/continuation.mak.tags (4) M tests/ctags/countall.sql.tags (14) M tests/ctags/cpp_destructor.cpp.tags (6) M tests/ctags/css-at-rules.css.tags (4) M tests/ctags/css-at-supports.css.tags (2) M tests/ctags/css-attribute-selectors.css.tags (10) M tests/ctags/css-comma-no-space.css.tags (4) M tests/ctags/css-namespace-selectors.css.tags (6) M tests/ctags/css-pseudo-classes.css.tags (22) M tests/ctags/css-simple.css.tags (20) M tests/ctags/css-singlequote-in-comment-issue2.css.tags (4) M tests/ctags/css-tag-types.css.tags (72) M tests/ctags/css-trivial.css.tags (10) M tests/ctags/cxx11-final.cpp.tags (16) M tests/ctags/cxx11-noexcept.cpp.tags (8) M tests/ctags/cxx11-override.cpp.tags (16) M tests/ctags/cxx11-raw-strings.cpp.tags (44) M tests/ctags/cxx11enum.cpp.tags (36) M tests/ctags/cxx14-combined.cpp.tags (10) M tests/ctags/cython_sample.pyx.tags (22) M tests/ctags/cython_sample2.pyx.tags (6) M tests/ctags/db-trig.sql.tags (4) M tests/ctags/debian_432872.f90.tags (4) M tests/ctags/directives.c.tags (38) M tests/ctags/dopbl2.f.tags (2) M tests/ctags/dotted-names.json.tags (38) M tests/ctags/enum.c.tags (8) M tests/ctags/enum.f90.tags (94) M tests/ctags/enum.java.tags (24) M tests/ctags/enumerators.f90.tags (56) M tests/ctags/events.cs.tags (28) M tests/ctags/extern_variable.h.tags (4) M tests/ctags/forall_module.f90.tags (8) M tests/ctags/format.pl.tags (4) M tests/ctags/fortran_associate.f90.tags (8) M tests/ctags/fortran_line_continuation.f90.tags (4) M tests/ctags/func_typedef.h.tags (2) M tests/ctags/gdscript-inner-class.gd.tags (76) M tests/ctags/gdscript-modifiers.gd.tags (26) M tests/ctags/gdscript-no-implicit-class.gd.tags (68) M tests/ctags/geany.nsi.tags (40) M tests/ctags/general.cs.tags (28) M tests/ctags/hex2dec.sql.tags (4) M tests/ctags/implied_program.f.tags (2) M tests/ctags/indexer.cs.tags (8) M tests/ctags/infinite_loop.java.tags (2) M tests/ctags/ingres_procedures.sql.tags (12) M tests/ctags/initialization.f90.tags (6) M tests/ctags/interface_indexers.cs.tags (10) M tests/ctags/interface_properties.cs.tags (16) M tests/ctags/interfaces.f90.tags (14) M tests/ctags/internal.cs.tags (4) M tests/ctags/intro.tex.tags (26) M tests/ctags/intro_orig.tex.tags (82) M tests/ctags/invalid_name.f90.tags (14) M tests/ctags/java_enum.java.tags (28) M tests/ctags/js-broken-strings.js.tags (8) M tests/ctags/js-class-related-unterminated.js.tags (32) M tests/ctags/js-const.js.tags (14) M tests/ctags/js-implicit-semicolons.js.tags (28) M tests/ctags/js-let.js.tags (14) M tests/ctags/js-scope.js.tags (6) M tests/ctags/js-signature.js.tags (18) M tests/ctags/js-string-continuation.js.tags (10) M tests/ctags/js-sub-block-scope.js.tags (14) M tests/ctags/js-unknown-construct-nesting.js.tags (8) M tests/ctags/jsFunc_tutorial.js.tags (140) M tests/ctags/julia-corner_cases.jl.tags (130) M tests/ctags/keyword_abstract.cs.tags (14) M tests/ctags/keyword_catch_try.cs.tags (6) M tests/ctags/keyword_class.cs.tags (16) M tests/ctags/keyword_const.cs.tags (16) M tests/ctags/keyword_delegate.cs.tags (22) M tests/ctags/keyword_enum.cs.tags (26) M tests/ctags/keyword_event.cs.tags (42) M tests/ctags/keyword_explicit.cs.tags (12) M tests/ctags/keyword_extern.cs.tags (6) M tests/ctags/keyword_implicit.cs.tags (12) M tests/ctags/keyword_interface.cs.tags (16) M tests/ctags/keyword_names.f90.tags (14) M tests/ctags/keyword_namespace.cs.tags (16) M tests/ctags/keyword_out.cs.tags (6) M tests/ctags/keyword_override.cs.tags (18) M tests/ctags/keyword_params.cs.tags (8) M tests/ctags/keyword_private.cs.tags (14) M tests/ctags/keyword_protected.cs.tags (10) M tests/ctags/keyword_public.cs.tags (10) M tests/ctags/keyword_sealed.cs.tags (10) M tests/ctags/keyword_static.cs.tags (18) M tests/ctags/keyword_struct.cs.tags (12) M tests/ctags/keyword_virtual.cs.tags (36) M tests/ctags/keyword_volatile.cs.tags (8) M tests/ctags/labels.sql.tags (2) M tests/ctags/lanus.for.tags (10) M tests/ctags/line_directives.c.tags (6) M tests/ctags/local.c.tags (4) M tests/ctags/macros.c.tags (10) M tests/ctags/make-comment-in-rule.mak.tags (2) M tests/ctags/make-gnumake-pattern-rules.mak.tags (10) M tests/ctags/make-multi-target.mak.tags (8) M tests/ctags/make-parentheses.mak.tags (8) M tests/ctags/make-target-with-parentheses.mak.tags (4) M tests/ctags/make-variable-on-cmdline.mak.tags (2) M tests/ctags/masm.asm.tags (22) M tests/ctags/matlab_backtracking.m.tags (2) M tests/ctags/matlab_test.m.tags (6) M tests/ctags/maze.erl.tags (20) M tests/ctags/members.f90.tags (14) M tests/ctags/misc_types.f.tags (6) M tests/ctags/misc_types.f90.tags (32) M tests/ctags/mode.php.tags (20) M tests/ctags/moniker.x68.asm.tags (30) M tests/ctags/namelist.f.tags (2) M tests/ctags/namespace.cpp.tags (12) M tests/ctags/namespaces.php.tags (26) M tests/ctags/namespaces2.php.tags (22) M tests/ctags/no_terminator.js.tags (10) M tests/ctags/non-ascii-ident1.php.tags (8) M tests/ctags/numlib.f90.tags (6) M tests/ctags/objectivec_implementation.mm.tags (22) M tests/ctags/objectivec_interface.mm.tags (46) M tests/ctags/objectivec_property.mm.tags (8) M tests/ctags/objectivec_protocol.mm.tags (4) M tests/ctags/parenthesis-rvalue.js.tags (44) M tests/ctags/php5_5_class_kw.php.tags (8) M tests/ctags/preprocessor.f90.tags (8) M tests/ctags/procedure_pointer_module.f90.tags (8) M tests/ctags/process_order.c.tags (12) M tests/ctags/procpoint.f90.tags (24) M tests/ctags/property.cs.tags (14) M tests/ctags/prototype.h.tags (4) M tests/ctags/pure_elem.f95.tags (8) M tests/ctags/py-skipped-string.py.tags (6) M tests/ctags/py_constructor_arglist.py.tags (48) M tests/ctags/python-anonymous-nestlevel_ctags-bug-356.py.tags (6) M tests/ctags/python-comments.py.tags (2) M tests/ctags/qualified_types.f90.tags (20) M tests/ctags/random.sql.tags (36) M tests/ctags/readlob.sql.tags (18) M tests/ctags/readlong.sql.tags (16) M tests/ctags/recursive.f95.tags (16) M tests/ctags/refcurs.sql.tags (14) M tests/ctags/regexp.js.tags (32) M tests/ctags/return-hint.zep.tags (8) M tests/ctags/return-types.go.tags (10) M tests/ctags/ruby-block-call.rb.tags (4) M tests/ctags/ruby-doc.rb.tags (8) M tests/ctags/ruby-namespaced-class.rb.tags (6) M tests/ctags/ruby-scope-after-anonymous-class.rb.tags (6) M tests/ctags/ruby-sf-bug-364.rb.tags (14) M tests/ctags/rules.t2t.tags (42) M tests/ctags/sample.t2t.tags (26) M tests/ctags/secondary_fcn_name.js.tags (10) M tests/ctags/semicolon.f90.tags (6) M tests/ctags/shebang.js.tags (2) M tests/ctags/signature.cpp.tags (10) M tests/ctags/simple.abc.tags (12) M tests/ctags/simple.asciidoc.tags (24) M tests/ctags/simple.bas.tags (14) M tests/ctags/simple.clj.tags (12) M tests/ctags/simple.conf.tags (46) M tests/ctags/simple.d.tags (46) M tests/ctags/simple.diff.tags (8) M tests/ctags/simple.docbook.tags (12)
-- Patch Links --
https://github.com/geany/geany/pull/3208.patch https://github.com/geany/geany/pull/3208.diff
In addition to this, I think we might also consider enabling writing the following tag information:
* `tm_tag_attr_inheritance_t` - useful if we enable inheritance e.g. for scope autocompletion * `tm_tag_attr_local_t` - these are tags local to the file like `static` variables - we might want to disable those for autocompletion (completely for global tags, for workspace tags only for the same file as the edited one)
IIUC this may not be such a good idea, see [comment](https://github.com/geany/geany/pull/3049#issuecomment-1130910163)
This is a continuation of https://github.com/geany/geany/pull/3049#issuecomment-1130910163:
IIUC what would happen now is that a symbol in an olde tags file will show as a different kind from what it would show as if the source file file was open in Geany, or the tags file re-generated. But it would still load, and will still show as the same kind it always did.
If it were only a matter of showing it as a different type, it probably wouldn't be such a big problem. I'm more worried about more advanced stuff like scope autocompletion or things like
https://github.com/geany/geany/blob/37d20a823fb1bca67cea57ef73aa9e64009d8138...
where we make decisions based on the mapped type. And then you have some language mappings that were probably made just based on what was free (or what looked good in the symbol tree in the sidebar) like the namespace here:
https://github.com/geany/geany/blob/37d20a823fb1bca67cea57ef73aa9e64009d8138...
What I was thinking is that if we had the original ctags kind in the file, we could fix such mappings invisibly to the user in the future and users wouldn't need to regenerate such files by themselves.
IIUC both of those mean relevant symbols from tags files from before the mapping change will change the kind they show. That may not be right, for example one of the recent parser updates split a kind into two IIRC (was it Ada? can't remember and too lazy to search) so now old file symbols using the letter that was split will all show as one of the halves. So both 1. and 2. will show something different for existing tags files.
I'm not sure if I understand completely the first part but the last sentence is what will actually happen if we don't store the ctags kind letter. Suppose you generate
1. `ctags.tags` file with `ctags` for some C sources. 2. `1-38.C.tags` with Geany 1.38 for the same C sources. 3. `1-39.C.tags` with Geany 1.39 for the same C sources.
and that there's some change in the mapping between 1.38 and 1.39. When you load `ctags.tag`, it will reflect the current Geany's version mappings while `1-38.C.tags` will (forever) represent the mapping made in 1.38 and `1-39.C.tags` will (forever) represent the mapping made in 1.39. So `1-38.C.tags` will show something different than `1-39.C.tags` (which should be the same as `ctags.tags` in Geany 1.39 but in Geany 1.40 it may be something different again).
And if the parser removed a letter what happens, do we need to keep it in the mapping? Hopefully ctags will never reuse the same letter for a totally different kind, then we would have to complain to ctags?
I think kind letters are the "API" of ctags and that ctags is rather conservative about these. The situation in this relase was rather exceptional because we were replacing some parsers which existed only in Geany with parsers that didn't exist in ctags at all and which were developed completely independently of their Geany versions. So I don't think this will be common.
In any case what I should have done in the patch (and which I'm going to update) is to ignore the kind letter if it doesn't map to anything (the case of the potentially removed kind in ctags parser) and use the stored mapped kind instead.
One more possibility is to store the kind letter to the tags files and not to do anything with it for now and decide later whether we want to use it or not.
@techee pushed 1 commit.
df6b42a4062c94b4321437281e9772e1763beaeb Fall back to stored kind mapping if kind letter doesn't map to anything
Closed #3208.
What I was thinking is that if we had the original ctags kind in the file, we could fix such mappings invisibly to the user in the future and users wouldn't need to regenerate such files by themselves.
Its ok having the original kind in the file, but how do we know what it originally mapped to so we can invisibly fix changes?
I closed this PR because I think using the official ctags file format is "the future" and that we should ship those with Geany and encourage users to use it. The TM tag file format is good for our unit tests so we know to what internal value the mapping happened.
Its ok having the original kind in the file, but how do we know what it originally mapped to so we can invisibly fix changes?
The idea was that if we found the original ctags kind in the file, we would use that one and perform the mapping based on the current mapping tables used in Geany - the same thing we do already for ctags files. If not found, we'd use the "legacy" `tm_tag_...` value stored in the file.
Oh, I misunderstood, if its only being added to tagmanager tags files then thats fine, although not sure why to bother if the tmtags is going away.
I closed this PR because I think using the official ctags file format is "the future" and that we should ship those with Geany and encourage users to use it.
Which brings me to one more thing - we should document which format is the recommended one. So in #3049 I added one more commit for your red pen:
https://github.com/geany/geany/pull/3049/commits/bc49cd2750dacf0bb5f82b7f30d...
(I re-shuffled some sections so the diff is bigger than the actual changes, the commit message should say what was changed.)
github-comments@lists.geany.org