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

qmlformat: Reorder imports alphabetically

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.10.0 FF, 6.11
    • 6.8
    • QML: Tooling
    • None
    • All
    • 57b681eb5 (dev)

      Reorder imports alphabetically: 

      qqmldomexternalitems.cpp

      void QmlFile::writeOut(const DomItem &self, OutWriter &ow) const
      {
          ensurePopulated();
          for (const DomItem &p : self.field(Fields::pragmas).values()) {
              p.writeOut(ow);
          }
          auto imports = self.field(Fields::imports).values();
          std::stable_sort (imports.begin(), imports.end(),
                                                      [=](const DomItem& item1, const DomItem& item2) {
              const auto uri1 = item1[QStringLiteral(u"uri")].toString();
              const auto uri2 = item2[QStringLiteral(u"uri")].toString();
              return uri1 < uri2;
          });
          for (const DomItem& i : imports) {
              i.writeOut(ow);
          }
          ow.ensureNewline(2);
          DomItem mainC = self.field(Fields::components).key(QString()).index(0);
          mainC.writeOut(ow);
      }
       

      Also needed to disable the internal stability checks because they are not done on the output and fail after this change.

       

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

            qtqmlteam Qt Qml Team User
            ovidiu.tepescu Ovidiu Tepescu
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes