Highlighting indexer: check existence of referenced context names
ClosedPublic

Authored by dhaumann on Sep 21 2017, 2:50 PM.

Details

Summary

This patch extends the highlighting indexer by collecting a list of all used and all existing context names.
If the used context names are NOT a subset of the existing context names, then we obviously reference an invalid non-existent context.

As test, I changed a rule in abc.xml to switch to context "Barbara", which does not exist. The checker now complains like this:

katehighlightingindexer(10738)/(default) {anonymous}::ContextChecker::check: "/home/dh/kde/kf5/src/frameworks/syntax-highlighting/data/syntax/abc.xml" Reference of non-existing contexts: QSet("Barbara")

It seems all our highlighting files are consistent, which is good. So we don't directly gain anything from this patch apart from catching context errors at compile-time instead of run-time.

This idea can be extended: For instance, we could also check the itemData names with the referenced attributes.

Comments?

Test Plan

make install
make test

Diff Detail

Repository
R216 Syntax Highlighting
Lint
Lint Skipped
Unit
Unit Tests Skipped
dhaumann created this revision.Sep 21 2017, 2:50 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptSep 21 2017, 2:50 PM
Restricted Application added a subscriber: Frameworks. · View Herald Transcript

Maybe worth to note: This patch only detects usage of non-existing contexts.
However, this patch does NOT catch unused contexts (which might be interesting as well).

vkrause accepted this revision.Sep 21 2017, 5:00 PM
vkrause added a subscriber: vkrause.

good idea :)

This revision is now accepted and ready to land.Sep 21 2017, 5:00 PM