Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-28813

Code completion doesn't work properly with inline components defined in external doc

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 9.0.1
    • Quick / QML Support
    • None

    Description

      Description

      For properties with the type of inline component that is defined in other QML documents the code completion doesn't work unless the property type is changed to `var`

      Steps to reproduce

      1. create a simple qml project with the following files:
        • main.qml
          import QtQuick
          import QtQuick.Window
          
          Window {
              width: 640
              height: 480
              visible: true
              title: qsTr("Hello World")    
             
              ValuesProvider {
                  id: valuesProvider
              }    
              
              MouseArea {
                  id: ma
                  hoverEnabled: true
                  property ValuesProvider.ValuesSet currentValues: valuesProvider.defaultValues
                  states: [
                      State {
                          name: "hover"
                          when: ma.pressed
                          PropertyChanges {
                              target: ma
                              currentValues: valuesProvider.hoverValues
                          }
                      },
                      State {
                          name: "pressed"
                          when: ma.pressed
                          PropertyChanges {
                              target: ma
                              currentValues: valuesProvider.pressedValues
                          }
                      }
                  ]
              }
          } 
        • ValuesProvider.qml
          import QtQuick
          import QtQmlQtObject {
              id: root    
              component ValuesSet : QtObject {
                  property int val1: 0
                  property int val2: 2
                  property int val3: 3
              }    
              property ValuesSet defaultValues: ValuesSet {}
              property ValuesSet pressedValues: ValuesSet {
                  val3: 8
              }
              property ValuesSet hoverValues: ValuesSet {
                  val1: 10
                  val2: 4
              }
          }
          
      1. start adding new property for `ma` (average of values from `currentValues` property)
        `property real valuesAvarage: currentValues.`
      2. Wait for the code completion popup to appear
      3. change the `currentValues` property type to var (`property var currentValues: valuesProvider.defaultValues`)
      4. Repeat steps 2 and 3

      Actual result

      Popup doesn't show properties of ValuesSet type instead it interprets property type as ValuesProvider (unless changed to `var` type)

      Expected result

      Code completion works appropriately with both scenarios

      Possible bug location:

      Due to limited capacity, I'm not able to build and debug the Qt Creator but this please looks suspicious to me (maybe another case handling is missing)
      https://github.com/qt-creator/qt-creator/blob/master/src/libs/qmljs/qmljscontext.cpp#L108

      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
            pnogaj Przemysław Nogaj
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes