[Geany-Devel] How are ctags used?

Lex Trotman elextr at xxxxx
Mon Mar 19 22:49:37 UTC 2018


On 20 March 2018 at 07:25, Lars Paulsen <lars_paulsen at web.de> wrote:
> Hello,
>
> I have got a question regarding the design of Geany or better say how do the
> components work together regarding ctags.

Ignore Scintilla for parsing, it ONLY does highlighting, and the
parser results have to be passed to Scintilla to get it to specify
colouring of different classes of identifiers.

>
> I think I understood that ctags files can contain global tag definitions,
> e.g. for external APIs. Lexers are there for the syntax highlighting.
> Scintilla is the editor component. But which part parses the code at the
> current cursor position during typing to decide when an existing ctag shall
> be displayed in a calltip? E.g. the user types "printf(" and the argument
> list appears (read from ctags). Where is the parsing/recognition of the
> "printf(" done?

Open files are parsed as you type by a ctags parser to extract top
level symbol definitions.  This result is stored in memory.

For files you don't usually open and which don't often change, eg
system API files, the symbols can be stored in tags files so they can
be loaded without parsing the source, see
https://www.geany.org/manual/current/index.html#generating-a-global-tags-file
and these tags files are set to load automagically if a file of the
specific type is opened in Geany.

Autocompletion works by recognising trigger characters like`(`.  It
then searches backward for the preceeding word (I think using the
filetypes word char list, to be confirmed) and then looks that word up
in all the loaded symbols, either from tags files or from on-the-fly
parsing.  Its because it looks for the name in all loaded symbols for
that filetype that you often get so many irrelevant hits.

Without checking I would assume that if the trigger character is `(`
it only accepts function definitions and if its `.` or `->` it only
accepts structures and classes and other hierarchical entities.

Cheers
Lex

>
> Thanks in advance.
>
> Greetings,
> Lars
>
> _______________________________________________
> Devel mailing list
> Devel at lists.geany.org
> https://lists.geany.org/cgi-bin/mailman/listinfo/devel


More information about the Devel mailing list