"Fossies" - the Fresh Open Source Software Archive

Member "qt-creator-opensource-src-5.0.2/src/libs/3rdparty/syntax-highlighting/patches/0006-Syntax-Highlighter-return-all-definitions-for-a-file.patch" (30 Sep 2021, 3310 Bytes) of package /linux/misc/qt-creator-opensource-src-5.0.2.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Diff source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 From 4b64058fe7d788ac79c16a08b280ce05d500e9fb Mon Sep 17 00:00:00 2001
    2 From: Alessandro Portale <alessandro.portale@qt.io>
    3 Date: Tue, 12 Feb 2019 19:32:54 +0100
    4 Subject: [PATCH 6/6] Syntax Highlighter: return all definitions for a file
    5  name/mimetype
    6 
    7 Can be used to create user controls to switch between
    8 multiple definitions for a file or mime type.
    9 
   10 Change-Id: I5fd3744db1e819d0d6f8448a53adaf9d2c7c168d
   11 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
   12 ---
   13  src/lib/repository.cpp | 17 +++++++++++++----
   14  src/lib/repository.h   | 12 ++++++++++++
   15  2 files changed, 25 insertions(+), 4 deletions(-)
   16 
   17 diff --git a/src/lib/repository.cpp b/src/lib/repository.cpp
   18 index 6b2fabd..922225a 100644
   19 --- a/src/lib/repository.cpp
   20 +++ b/src/lib/repository.cpp
   21 @@ -78,7 +78,7 @@ Definition Repository::definitionForName(const QString& defName) const
   22      return d->m_defs.value(defName);
   23  }
   24  
   25 -static Definition bestCandidate(QVector<Definition>& candidates)
   26 +static Definition bestCandidate(QVector<Definition> &&candidates)
   27  {
   28      if (candidates.isEmpty())
   29          return Definition();
   30 @@ -91,6 +91,11 @@ static Definition bestCandidate(QVector<Definition>& candidates)
   31  }
   32  
   33  Definition Repository::definitionForFileName(const QString& fileName) const
   34 +{
   35 +    return bestCandidate(definitionsForFileName(fileName));
   36 +}
   37 +
   38 +QVector<Definition> Repository::definitionsForFileName(const QString &fileName) const
   39  {
   40      QFileInfo fi(fileName);
   41      const auto name = fi.fileName();
   42 @@ -106,10 +111,15 @@ Definition Repository::definitionForFileName(const QString& fileName) const
   43          }
   44      }
   45  
   46 -    return bestCandidate(candidates);
   47 +    return candidates;
   48  }
   49  
   50  Definition Repository::definitionForMimeType(const QString& mimeType) const
   51 +{
   52 +    return bestCandidate(definitionsForMimeType(mimeType));
   53 +}
   54 +
   55 +QVector<Definition> Repository::definitionsForMimeType(const QString &mimeType) const
   56  {
   57      QVector<Definition> candidates;
   58      for (auto it = d->m_defs.constBegin(); it != d->m_defs.constEnd(); ++it) {
   59 @@ -121,8 +131,7 @@ Definition Repository::definitionForMimeType(const QString& mimeType) const
   60              }
   61          }
   62      }
   63 -
   64 -    return bestCandidate(candidates);
   65 +    return candidates;
   66  }
   67  
   68  QVector<Definition> Repository::definitions() const
   69 diff --git a/src/lib/repository.h b/src/lib/repository.h
   70 index c35da5e..e4e9bed 100644
   71 --- a/src/lib/repository.h
   72 +++ b/src/lib/repository.h
   73 @@ -166,6 +166,13 @@ public:
   74       */
   75      Definition definitionForFileName(const QString &fileName) const;
   76  
   77 +    /**
   78 +     * Returns all Definition%s for the file named @p fileName.
   79 +     * The match is performed based on the \e extensions and @e mimetype of
   80 +     * the definition files.
   81 +     */
   82 +    QVector<Definition> definitionsForFileName(const QString &fileName) const;
   83 +
   84      /**
   85       * Returns the best matching Definition to the type named @p mimeType
   86       *
   87 @@ -176,6 +183,11 @@ public:
   88       */
   89      Definition definitionForMimeType(const QString &mimeType) const;
   90  
   91 +    /**
   92 +     * Returns all Definition%s to the type named @p mimeType
   93 +     */
   94 +    QVector<Definition> definitionsForMimeType(const QString &mimeType) const;
   95 +
   96      /**
   97       * Returns all available Definition%s.
   98       * Definition%ss are ordered by translated section and translated names,
   99 -- 
  100 2.20.1.windows.1
  101