diff options
Diffstat (limited to 'src/libs/3rdparty/syntax-highlighting/src/lib/definition.h')
-rw-r--r-- | src/libs/3rdparty/syntax-highlighting/src/lib/definition.h | 108 |
1 files changed, 63 insertions, 45 deletions
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/definition.h b/src/libs/3rdparty/syntax-highlighting/src/lib/definition.h index 6f0dba9a45..e69492bee4 100644 --- a/src/libs/3rdparty/syntax-highlighting/src/lib/definition.h +++ b/src/libs/3rdparty/syntax-highlighting/src/lib/definition.h @@ -1,24 +1,8 @@ /* - Copyright (C) 2016 Volker Krause <vkrause@kde.org> - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> + SPDX-FileCopyrightText: 2020 Jonathan Poelen <jonathan.poelen@gmail.com> + + SPDX-License-Identifier: MIT */ #ifndef KSYNTAXHIGHLIGHTING_DEFINITION_H @@ -26,20 +10,14 @@ #include "ksyntaxhighlighting_export.h" -#include <QTypeInfo> +#include <QList> #include <QPair> - +#include <QString> #include <memory> +#include <qobjectdefs.h> -QT_BEGIN_NAMESPACE -class QChar; -class QString; -class QStringList; -template <typename T> class QVector; -QT_END_NAMESPACE - -namespace KSyntaxHighlighting { - +namespace KSyntaxHighlighting +{ class Context; class Format; class KeywordList; @@ -51,8 +29,7 @@ class DefinitionData; * @since 5.50 * @see Definition::singleLineCommentPosition() */ -enum class CommentPosition -{ +enum class CommentPosition { //! The comment marker is inserted at the beginning of a line at column 0 StartOfLine = 0, //! The comment marker is inserted after leading whitespaces right befire @@ -94,7 +71,7 @@ enum class CommentPosition * singleLineCommentMarker() and multiLineCommentMarker() provide comment * markers that can be used for commenting/uncommenting code. Similarly, * formats() returns a list of Format items defined by this Definition (which - * equal the itemDatas of a highlighing definition file). includedDefinitions() + * equal the itemDatas of a highlighting definition file). includedDefinitions() * returns a list of all included Definition%s referenced by this Definition via * the rule IncludeRules, which is useful for displaying all Format items for * color configuration in the user interface. @@ -104,6 +81,13 @@ enum class CommentPosition */ class KSYNTAXHIGHLIGHTING_EXPORT Definition { + Q_GADGET + Q_PROPERTY(QString name READ name) + Q_PROPERTY(QString translatedName READ translatedName) + Q_PROPERTY(QString section READ section) + Q_PROPERTY(QString translatedSection READ translatedSection) + Q_PROPERTY(QString author READ author) + Q_PROPERTY(QString license READ license) public: /** * Default constructor, creating an empty (invalid) Definition instance. @@ -114,6 +98,14 @@ public: Definition(); /** + * Move constructor. + * This definition takes the Definition data from @p other. + * @note @p other may only be assigned to or destroyed afterwards. + * @since 5.86 + */ + Definition(Definition &&other) noexcept; + + /** * Copy constructor. * Both this definition as well as @p other share the Definition data. */ @@ -125,10 +117,18 @@ public: ~Definition(); /** - * Assignment operator. + * Move assignment operator. + * This definition takes the Definition data from @p other. + * @note @p other may only be assigned to or destroyed afterwards. + * @since 5.86 + */ + Definition &operator=(Definition &&other) noexcept; + + /** + * Copy assignment operator. * Both this definition as well as @p rhs share the Definition data. */ - Definition& operator=(const Definition &rhs); + Definition &operator=(const Definition &rhs); /** * Checks two definitions for equality. @@ -181,13 +181,13 @@ public: /** * Mime types associated with this syntax definition. */ - QVector<QString> mimeTypes() const; + QList<QString> mimeTypes() const; /** * File extensions associated with this syntax definition. * The returned list contains wildcards. */ - QVector<QString> extensions() const; + QList<QString> extensions() const; /** * Returns the definition version. @@ -329,16 +329,34 @@ public: /** * Returns the list of keywords for the keyword list @p name. * @since 5.49 - * @see keywordLists() + * @see keywordLists(), setKeywordList() + */ + QStringList keywordList(const QString &name) const; + + /** + * Set the contents of the keyword list @p name to @p content. + * Only existing keywordLists() can be changed. For non-existent keyword lists, + * false is returned. + * + * Whenever you change a keyword list, make sure to trigger a rehighlight of + * your documents. In case you are using QSyntaxHighlighter via SyntaxHighlighter, + * this can be done by calling SyntaxHighlighter::rehighlight(). + * + * @note In general, changing keyword lists via setKeywordList() is discouraged, + * since if a keyword list name in the syntax highlighting definition + * file changes, the call setKeywordList() may suddenly fail. + * + * @see keywordList(), keywordLists() + * @since 5.62 */ - QStringList keywordList(const QString& name) const; + bool setKeywordList(const QString &name, const QStringList &content); /** * Returns a list of all Format items used by this definition. * The order of the Format items equals the order of the itemDatas in the xml file. * @since 5.49 */ - QVector<Format> formats() const; + QList<Format> formats() const; /** * Returns a list of Definitions that are referenced with the IncludeRules rule. @@ -347,7 +365,7 @@ public: * * @since 5.49 */ - QVector<Definition> includedDefinitions() const; + QList<Definition> includedDefinitions() const; /** * Returns the marker that starts a single line comment. @@ -378,7 +396,7 @@ public: * the string \"{A} represents the character Ä. * @since 5.50 */ - QVector<QPair<QChar, QString>> characterEncodings() const; + QList<QPair<QChar, QString>> characterEncodings() const; /** * @} @@ -387,14 +405,14 @@ public: private: friend class DefinitionData; friend class DefinitionRef; - explicit Definition(const std::shared_ptr<DefinitionData> &dd); + KSYNTAXHIGHLIGHTING_NO_EXPORT explicit Definition(std::shared_ptr<DefinitionData> &&dd); std::shared_ptr<DefinitionData> d; }; } QT_BEGIN_NAMESPACE -Q_DECLARE_TYPEINFO(KSyntaxHighlighting::Definition, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(KSyntaxHighlighting::Definition, Q_RELOCATABLE_TYPE); QT_END_NAMESPACE #endif |