KSyntaxHighlighting meta data

Dominik Haumann dhaumann at kde.org
Wed Aug 1 21:31:03 BST 2018


Hi everyone,

I just discussed quickly with Christoph: In his branch, KTextEditor
uses KSyntaxHighlighting to do highlighting - this is a very nice
first step :-)

But we also identified that a lot of stuff is currently missing in the
KSyntaxHighlighting API, namely all the metadata like:
- language element: style - needed for information
- language element: indenter - needed for restrict allowed indenters
- general element: comment start / end markers for single line and multi-line
- general element: keyword sensitivity
- spellcheck information: which escape sequences should be replaced,
e.g. in LaTeX.xml
- and much more

Two years back I already added the to Definition the functions
    bool indentationBasedFoldingEnabled() const;
    QStringList foldingIgnoreList() const;

We could now start to add all this above to the Definition as
additional information. However, this is strictly speaking very
tightly related to KTextEditor, and possibly often not of interest to
other users of the KSyntaxHighlighting API.

So we have the following options:
- Add many getters to Definition. Flexible, but we have to keep API
compatibility for all added functions.
- Add a new class like DefinitionMetaData (or better named), that
includes all this information. Maybe a bit cleaner, API compatibility
still holds.
- Add a general getter that allows to query key/values like
definition.get(key) -> QVariant. This could also be a QVariantMap or
similar... This is flexible, but we have no type safety, and behavior
changes still possibly imply problems. We could also have a solution
that has both: e.g. QVariantMap Definition::metaData(MetaDataType t),
where MetaDataType is an enum of e.g. { Language, General,
Indentation, Spellchecking, ...}

I think it makes sense to start this discussion now, so that we can
decide on a solution by next week and implement this.

Maybe it first makes sense to come up with a complete list of what we need?

Greetings
Dominik


More information about the KWrite-Devel mailing list