Details

    • Type: Technical task
    • Status: In Progress
    • Priority: P2: Important
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: QML: Tooling

      Description

      It should be possible to annotate nodes, properties,... to add extra metadata and behaviour to the existing QML model in an extensible way that would need minimal grammar changes.

      The main drawback of an annotation with respect to a keyword is that typos will not be catched if we allow undeclared annotations.
      If annotation have to be declared somewhere, than that limitation is not there.

      I would go with @QmlLikeObject for the annotations, and attach all the annotations to the first non annotation line, be it a type, property, binding, assignment, Behaviour,... and make them available in the DOM API.

      @Annotation1
      @Annotation2{arg1:y}
      Bla{
       @Annotation1
       property int x: 4
      
        @Annotation3
        y:4
      
        @Annotation4{
           arg1: 3
           arg2: “bla”
        }
        function f(i){}
      }
      

      I would not put them in comments, and they should refer to the type, property, function,… immediately after all the annotations.

      In the DOM model then every type, property,… would have a list annotations.
      The reason to use this syntax are the following:

      • minimal changes to the grammar
      • flexible (can cover basically all use cases I can think of)
      • The annotations can be declared without introducing new syntax (we could use @Annotation in declaring them, or they could have a separate file extension)
      • we can provide tooling/typo detection,… by requiring all annotations to be declared
      • documenting can be done in a similar way to QML

      With it the example given by Thomas could become adding the following qml annotation declarations
      'Extra' (Annotating node with extra arbitrary properties)
      'Invisible' (Item is invisible in editor)
      'Lock' (Item is locked in editor)
      'InternalId' (internal id)

      TimeLine {
         
          @Extra{
            property color color: "blue"
            property bool expanded: true
            property bool locked: false
            property bool visible: false
          }
          @Invisible
          @Locked
          @InternalId{ value: 4234354656 }
         TimeLineGroupGroup {  
          }
      
          @Extra{
            property color color: "blue"
            property bool expanded: true
            property bool locked: false
            property bool visible: false
          }
          @Invisible
          @Locked
          @InternalId{ value: 4234354656 }
          TimeLineGroupGroup {
              Annotations.color: "blue"
          }
      }
      

        Attachments

          Issue Links

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

            Activity

              People

              • Assignee:
                fawzi Fawzi Mohamed
                Reporter:
                thohartm Thomas Hartmann
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes