File indexing completed on 2024-05-12 04:02:18
0001 /* 0002 SPDX-FileCopyrightText: 2016 Volker Krause <vkrause@kde.org> 0003 SPDX-FileCopyrightText: 2020 Jonathan Poelen <jonathan.poelen@gmail.com> 0004 0005 SPDX-License-Identifier: MIT 0006 */ 0007 0008 #ifndef KSYNTAXHIGHLIGHTING_DEFINITION_P_H 0009 #define KSYNTAXHIGHLIGHTING_DEFINITION_P_H 0010 0011 #include "definitionref_p.h" 0012 #include "highlightingdata_p.hpp" 0013 #include "state.h" 0014 #include "worddelimiters_p.h" 0015 0016 #include <QHash> 0017 #include <QList> 0018 #include <QSet> 0019 #include <QString> 0020 0021 #include <vector> 0022 0023 QT_BEGIN_NAMESPACE 0024 class QCborMap; 0025 class QXmlStreamReader; 0026 QT_END_NAMESPACE 0027 0028 namespace KSyntaxHighlighting 0029 { 0030 class Repository; 0031 0032 class DefinitionData 0033 { 0034 public: 0035 DefinitionData(); 0036 ~DefinitionData(); 0037 0038 DefinitionData(const DefinitionData &) = delete; 0039 DefinitionData &operator=(const DefinitionData &) = delete; 0040 0041 static DefinitionData *get(const Definition &def) 0042 { 0043 return def.d.get(); 0044 } 0045 0046 bool isLoaded() const; 0047 bool loadMetaData(const QString &definitionFileName); 0048 bool loadMetaData(const QString &fileName, const QCborMap &obj); 0049 0050 void clear(); 0051 0052 enum class OnlyKeywords : bool; 0053 0054 bool load(OnlyKeywords onlyKeywords = OnlyKeywords(false)); 0055 bool loadLanguage(QXmlStreamReader &reader); 0056 void loadHighlighting(QXmlStreamReader &reader, OnlyKeywords onlyKeywords); 0057 void loadContexts(QXmlStreamReader &reader); 0058 void loadItemData(QXmlStreamReader &reader); 0059 void loadGeneral(QXmlStreamReader &reader); 0060 void loadComments(QXmlStreamReader &reader); 0061 void loadFoldingIgnoreList(QXmlStreamReader &reader); 0062 void loadSpellchecking(QXmlStreamReader &reader); 0063 bool checkKateVersion(QStringView verStr); 0064 0065 void resolveContexts(); 0066 0067 void resolveIncludeKeywords(); 0068 0069 KeywordList *keywordList(const QString &name); 0070 0071 Context *initialContext(); 0072 Context *contextByName(QStringView name); 0073 0074 Format formatByName(const QString &name) const; 0075 0076 quint16 foldingRegionId(const QString &foldName); 0077 0078 void addImmediateIncludedDefinition(const Definition &def); 0079 0080 DefinitionRef q; 0081 uint64_t id = 0; 0082 0083 Repository *repo = nullptr; 0084 QHash<QString, KeywordList> keywordLists; 0085 std::vector<Context> contexts; 0086 QHash<QString, Format> formats; 0087 // data loaded from xml file and emptied after loading contexts 0088 QList<HighlightingContextData> contextDatas; 0089 // Definition referenced by IncludeRules and ContextSwitch 0090 QList<DefinitionRef> immediateIncludedDefinitions; 0091 WordDelimiters wordDelimiters; 0092 WordDelimiters wordWrapDelimiters; 0093 bool keywordIsLoaded = false; 0094 bool hasFoldingRegions = false; 0095 bool indentationBasedFolding = false; 0096 QStringList foldingIgnoreList; 0097 QString singleLineCommentMarker; 0098 CommentPosition singleLineCommentPosition = CommentPosition::StartOfLine; 0099 QString multiLineCommentStartMarker; 0100 QString multiLineCommentEndMarker; 0101 QList<QPair<QChar, QString>> characterEncodings; 0102 0103 QString fileName; 0104 QString name = QStringLiteral(QT_TRANSLATE_NOOP("Language", "None")); 0105 QByteArray nameUtf8; 0106 mutable QString translatedName; 0107 QString section; 0108 QByteArray sectionUtf8; 0109 mutable QString translatedSection; 0110 QString style; 0111 QString indenter; 0112 QString author; 0113 QString license; 0114 QList<QString> mimetypes; 0115 QList<QString> extensions; 0116 Qt::CaseSensitivity caseSensitive = Qt::CaseSensitive; 0117 int version = 0; 0118 int priority = 0; 0119 bool hidden = false; 0120 0121 // cache that is used to unify states in AbstractHighlighter::highlightLine 0122 mutable QSet<State> unify; 0123 }; 0124 } 0125 0126 #endif