Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138020

Magical strings, which are token spells -> QQmlJSGrammar::spell

    XMLWordPrintable

Details

    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/

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            dima.a Dmitrii Akshintsev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes