Details
-
Suggestion
-
Resolution: Unresolved
-
P4: Low
-
None
-
None
-
None
Description
There are lots of places in our code-base where QQmlJSGrammar::spell could have been used instead of manually typed hard-coded magical strings. For examples:
1. qqmlcompletion.cpp (lot's of manual, magical strings like "var" "property" "signal" "pragma" "import" and other token spells)
2. qqmldomoutwriter.cpp (OutWriter::writeRegion)
3. qqmldomreformatter (ScriptFormatter) full of magical strings, which are essentially token spells
4. qqmljskeywords_p.h with manual hard-coded letter-by-letter comparisons of token spells
5. qqmljslexer.cpp Lexer::scanToken
Even though I don't think it's possible / valuable to change them all as it's probably quite some work, but maybe we could expose a function like tokenSpell somewhere on the higher levels and start using it more actively in places we need token spells instead of repeating ourselves?
additional discussion: https://codereview.qt-project.org/c/qt/qtdeclarative/+/652292/comment/4d80c8b0_5295dd2d/