Uploaded image for project: 'Qt Design Studio'
  1. Qt Design Studio
  2. QDS-9542

Resolve possible QML module imports on project level and not document level

    XMLWordPrintable

Details

    • User Story
    • Resolution: Done
    • Not Evaluated
    • QDS 4.1
    • None
    • Model and Rewriter
    • None
    • QDS Berlin - 2023 Week 15/16
    • 6035ff939 (qds/dev), 34c69766d (qds/dev), ece03f55a (qds/dev)

    Description

      Currently we resolve the possible imports for each document seperatly.
      Resolving the possible imports is slow and gets slower in Qt 6.5, because more modules are added.

      The possible imports only depend on the import paths and are a property of the project.
      Currently we determine the possible imports for each document twice, since the possible imports do not settle immediatly.
      Therefore we compare the number and consider the possible imports as settled if the number of imports does not change anymore.

      This is quite noticable when using QDS especially QDS 4.1 with Qt 6.5. Switching files is slow unless the file has been already opened twice.

      Solution:

      Move the possible imports to QmlDesignerProjectManager and ExternalDependenciesInterface and make it independ of single documents.

      The QmlDesignerProjectManager would determine the possible imports per project. We can use the same heuristic for settling. Once the numer of possible imports does not change we consider it settled. The import paths are part of the QmlProject anyway.

      Directory imports are handled seperatly already.
      Note that there is DocumentManager::resetPossibleImports(), which is called if new modules are added. This has to continue to work and reset the possible imports of the
      QmlDesignerProjectManager instead.

      See:

      TextToModelMerger::setupPossibleImports
      
      if (m_possibleImportKeys.isEmpty() || projectUrl != lastProjectUrl)
              m_possibleImportKeys = snapshot.importDependencies()->libraryImports(viewContext);
      

      snapshot.importDependencies()->libraryImports(viewContext);

      See:

      ExternalDependenciesInterface
      

      See:

      See:

      QmlDesignerProjectManager
      
        // Clear possible imports cache if code model hasn't settled yet
              const int importKeysSize = m_possibleImportKeys.size();
              if (m_previousPossibleImportsSize != importKeysSize)
                  m_possibleImportKeys.clear();
              m_previousPossibleImportsSize = importKeysSize;
      

      See also

      void DocumentManager::resetPossibleImports()
      {
          for (const auto &[key, value] : m_designDocuments) {
              if (RewriterView *view = value->rewriterView())
                  view->resetPossibleImports();
          }
      }
      

      The possible imports are reset for each rewriter view at the moment.

      Attachments

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

        Activity

          People

            bubke Marco Bubke
            thohartm Thomas Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes