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

dom: support semantic analysis for dependencies

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.8
    • 6.7
    • QML: Tooling
    • None
    • 404963f8a (dev), 9d3126b2e (dev), 1a32fdda6 (dev), 447b56439 (dev), e561321a4 (dev), d5663c9fd (dev)

      Make Dom's dependency loading work with qqmljsscope dependency loading, instead of having duplicate qqmljsscopes.

       

      From the chat:

      So, while investigating how to make QTBUG-113827 (find usages on multiple files) work, I realised that there was a misconception in QQmlDomAstCreatorWithQQmlJSScope.

       

      The idea behind QQmlDomAstCreatorWithQQmlJSScope was to combine a QQmlDomAstCreator (that creates a Dom for one file) and a QmlJSimportVisitor (that creates a tree of QQmlJSScopes for one file), to be able to insert the QQmlJSScope inside the Dom during construction (like this it is easier to map where to put which QQmlJSScope in which DomItem).

       

      Let's say we have two files Base.qml and Derived.qml in the implicit import directory. qmlls will try to load both files in the Dom, and one would expect to have one Dom with two files and one tree of QQmlJSScopes.... except we end up with two identical trees of QQmlJSScope: one for each QmlFile( =Dom representation of one qml file). This means we can't use `==` to compare scopes from one QmlFile to another QmlFile, which breaks the find usages feature of qmlls for multiple files.

       

      So why two QQmlJSScope trees? Well, it turns out that QmlJSimportVisitor processes its imports via QQmlJSImporter which in turn imports files of the implicit import directory lazily via QmlJSImportVisitor.

       

      So once I have loaded any file in the Dom (let's say Base.qml), I already have a tree of QQmlJSScope's for Base.qml and Derived.qml!

      And if I load Derived.qml in the Dom, I will get another tree of QQmlJSScope's for Base.qml and Derived.qml... The good news: If I load a third file Third.qml, then (because we reuse the same QQmlJSImporter), then QQmlJSImporter should find Base.qml (from the Derived.qml loading) and Derived.qml (from the Base.qml loading) in the cache and won't attempt to recreate the QQmlJSScope trees again.

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

            sami.shalayel Sami Shalayel
            sami.shalayel Sami Shalayel
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: