[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ktexteditor/syntax-highlighting] src/syntax: delete massive amounts of old code, we can later see h
From: Christoph Cullmann <null () kde ! org>
Date: 2018-07-31 20:20:05
Message-ID: E1fkb7l-0006g6-Nw () code ! kde ! org
[Download RAW message or body]
Git commit dd5af6afc72749554a18ee56614451c2d8dbf4cb by Christoph Cullmann.
Committed on 31/07/2018 at 20:19.
Pushed by cullmann into branch 'syntax-highlighting'.
delete massive amounts of old code, we can later see how to fill the members with \
info
M +0 -902 src/syntax/katehighlight.cpp
M +1 -14 src/syntax/katehighlight.h
M +0 -23 src/syntax/katesyntaxmanager.cpp
M +0 -24 src/syntax/katesyntaxmanager.h
https://commits.kde.org/ktexteditor/dd5af6afc72749554a18ee56614451c2d8dbf4cb
diff --git a/src/syntax/katehighlight.cpp b/src/syntax/katehighlight.cpp
index 61e6a959..1257e404 100644
--- a/src/syntax/katehighlight.cpp
+++ b/src/syntax/katehighlight.cpp
@@ -383,9 +383,6 @@ void KateHighlighting::init()
m_contexts.push_back(new KateHlContext(identifier, 0,
KateHlContextModification(), false, KateHlContextModification(),
false, false, false, KateHlContextModification()));
-
- // clear domdocument cache
- KateHlManager::self()->syntax.clearCache();
}
/**
@@ -405,82 +402,6 @@ void \
KateHighlighting::createKateExtendedAttribute(QList<KTextEditor::Attribute: list = \
internalIDList; }
-/**
- * Adds the styles of the currently parsed highlight to the itemdata list
- */
-void KateHighlighting::addToKateExtendedAttributeList()
-{
- //Tell the syntax document class which file we want to parse and which data \
group
- KateHlManager::self()->syntax.setIdentifier(buildIdentifier);
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getGroupInfo(QStringLiteral("highlighting"), \
QStringLiteral("itemData"));
-
- // use global color instance, creation is expensive!
- const KateDefaultColors \
&colors(KTextEditor::EditorPrivate::self()->defaultColors());
-
- //begin with the real parsing
- while (KateHlManager::self()->syntax.nextGroup(data)) {
- // read all attributes
- const QString color = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("color"));
- const QString selColor = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("selColor"));
- const QString bold = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("bold"));
- const QString italic = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("italic"));
- const QString underline = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("underline"));
- const QString strikeOut = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("strikeOut"));
- const QString bgColor = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("backgroundColor"));
- const QString selBgColor = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("selBackgroundColor"));
- const QString spellChecking = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("spellChecking"));
- const QString fontFamily = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("fontFamily"));
-
- const QString itemDataName = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("name")).simplified();
- const QString defStyleName = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("defStyleNum"));
-
- KTextEditor::Attribute::Ptr newData(new KTextEditor::Attribute(
- buildPrefix + itemDataName,
- \
static_cast<KTextEditor::DefaultStyle> \
(KateHlManager::defaultStyleNameToIndex(defStyleName))));
-
- /* here the custom style overrides are specified, if needed */
- if (!color.isEmpty()) {
- newData->setForeground(colors.adaptToScheme(QColor(color), \
KateDefaultColors::ForegroundColor));
- }
- if (!selColor.isEmpty()) {
- newData->setSelectedForeground(colors.adaptToScheme(QColor(selColor), \
KateDefaultColors::ForegroundColor));
- }
- if (!bold.isEmpty()) {
- newData->setFontBold(isTrue(bold));
- }
- if (!italic.isEmpty()) {
- newData->setFontItalic(isTrue(italic));
- }
- // new attributes for the new rendering view
- if (!underline.isEmpty()) {
- newData->setFontUnderline(isTrue(underline));
- }
- if (!strikeOut.isEmpty()) {
- newData->setFontStrikeOut(isTrue(strikeOut));
- }
- if (!bgColor.isEmpty()) {
- newData->setBackground(colors.adaptToScheme(QColor(bgColor), \
KateDefaultColors::BackgroundColor));
- }
- if (!selBgColor.isEmpty()) {
- newData->setSelectedBackground(colors.adaptToScheme(QColor(selBgColor), \
KateDefaultColors::BackgroundColor));
- }
- // is spellchecking desired?
- if (!spellChecking.isEmpty()) {
- newData->setSkipSpellChecking(!(isTrue(spellChecking)));
- }
- if (!fontFamily.isEmpty()) {
- newData->setFontFamily(fontFamily);
- }
-
- internalIDList.append(newData);
- }
-
- //clean up
- if (data) {
- KateHlManager::self()->syntax.freeGroupInfo(data);
- }
-}
-
/**
* KateHighlighting - lookupAttrName
* This function is a helper for makeContextList and createKateHlItem. It looks the \
given @@ -506,195 +427,6 @@ int KateHighlighting::lookupAttrName(const QString \
&name, QList<KTextEditor::At return 0;
}
-/**
- * KateHighlighting - createKateHlItem
- * This function is a helper for makeContextList. It parses the xml file for
- * information.
- *
- * @param data Data about the item read from the xml file
- * @param iDl List of all available itemData entries.
- * Needed for attribute name->index translation
- * @param RegionList list of code folding region names
- * @param ContextNameList list of context names
- *
- * @return A pointer to the newly created item object
- */
-KateHlItem *KateHighlighting::createKateHlItem(KateSyntaxContextData *data,
- QList<KTextEditor::Attribute::Ptr> &iDl,
- QStringList *RegionList,
- QStringList *ContextNameList)
-{
- // No highlighting -> exit
- if (noHl) {
- return nullptr;
- }
-
- // get the (tagname) itemd type
- const QString dataname = KateHlManager::self()->syntax.groupItemData(data, \
QString());
-
- // code folding region handling:
- const QString beginRegionStr = KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("beginRegion"));
- const QString endRegionStr = KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("endRegion"));
-
- signed char regionId = 0;
- signed char regionId2 = 0;
-
- if (!beginRegionStr.isEmpty()) {
- regionId = RegionList->indexOf(beginRegionStr);
-
- if (regionId == -1) { // if the region name doesn't already exist, add it to \
the list
- (*RegionList) << beginRegionStr;
- regionId = RegionList->indexOf(beginRegionStr);
- }
-
- regionId++;
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "########### BEG REG: " << beginRegionStr << " NUM: " \
<< regionId;
-#endif
- }
-
- if (!endRegionStr.isEmpty()) {
- regionId2 = RegionList->indexOf(endRegionStr);
-
- if (regionId2 == -1) { // if the region name doesn't already exist, add it \
to the list
- (*RegionList) << endRegionStr;
- regionId2 = RegionList->indexOf(endRegionStr);
- }
-
- regionId2 = -regionId2 - 1;
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "########### END REG: " << endRegionStr << " NUM: " << \
regionId2;
-#endif
- }
-
- int attr = 0;
- const QString tmpAttr = KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("attribute")).simplified();
- bool onlyConsume = tmpAttr.isEmpty();
-
- // only relevant for non consumer
- if (!onlyConsume) {
- if (QStringLiteral("%1").arg(tmpAttr.toInt()) == tmpAttr) {
- errorsAndWarnings += i18n(
- "<b>%1</b>: Deprecated syntax. Attribute (%2) \
not addressed by symbolic name<br />",
- buildIdentifier, tmpAttr);
- attr = tmpAttr.toInt();
- } else {
- attr = lookupAttrName(tmpAttr, iDl);
- }
- }
-
- // Info about context switch
- KateHlContextModification context = -1;
- QString unresolvedContext;
- const QString tmpcontext = KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("context"));
- if (!tmpcontext.isEmpty()) {
- context = getContextModificationFromString(ContextNameList, tmpcontext, \
unresolvedContext);
- }
-
- // Get the char parameter (eg DetectChar)
- QChar chr;
- if (! KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("char")).isEmpty()) {
- chr = (KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("char"))).at(0);
- }
-
- // Get the String parameter (eg. StringDetect)
- const QString stringdata = KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("String"));
-
- // Get a second char parameter (char1) (eg Detect2Chars)
- QChar chr1;
- if (! KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("char1")).isEmpty()) {
- chr1 = (KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("char1"))).at(0);
- }
-
- // Will be removed eventually. Atm used for StringDetect, WordDetect, keyword \
and RegExp
- const QString &insensitive_str = \
KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("insensitive"));
- bool insensitive = isTrue(insensitive_str);
-
- // for regexp only
- bool minimal = isTrue(KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("minimal")));
-
- // dominik: look ahead and do not change offset. so we can change contexts w/o \
changing offset1.
- bool lookAhead = isTrue(KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("lookAhead")));
-
- bool dynamic = isTrue(KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("dynamic")));
-
- bool firstNonSpace = isTrue(KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("firstNonSpace")));
-
- int column = -1;
- QString colStr = KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("column"));
- if (!colStr.isEmpty()) {
- column = colStr.toInt();
- }
-
- // Create the item corresponding to its type and set its parameters
- KateHlItem *tmpItem;
-
- if (dataname == QLatin1String("keyword")) {
- bool keywordInsensitive = insensitive_str.isEmpty() ? !casesensitive : \
insensitive;
- KateHlKeyword *keyword = new KateHlKeyword(attr, context, regionId, \
regionId2, keywordInsensitive,
- m_additionalData[ buildIdentifier ]->deliminator);
-
- //Get the entries for the keyword lookup list
- keyword->addList(KateHlManager::self()->syntax.finddata(QStringLiteral("highlighting"), \
stringdata));
- tmpItem = keyword;
- } else if (dataname == QLatin1String("Float")) {
- tmpItem = (new KateHlFloat(attr, context, regionId, regionId2));
- } else if (dataname == QLatin1String("Int")) {
- tmpItem = (new KateHlInt(attr, context, regionId, regionId2));
- } else if (dataname == QLatin1String("DetectChar")) {
- tmpItem = (new KateHlCharDetect(attr, context, regionId, regionId2, chr));
- } else if (dataname == QLatin1String("Detect2Chars")) {
- tmpItem = (new KateHl2CharDetect(attr, context, regionId, regionId2, chr, \
chr1));
- } else if (dataname == QLatin1String("RangeDetect")) {
- tmpItem = (new KateHlRangeDetect(attr, context, regionId, regionId2, chr, \
chr1));
- } else if (dataname == QLatin1String("LineContinue")) {
- tmpItem = (new KateHlLineContinue(attr, context, regionId, regionId2, chr));
- } else if (dataname == QLatin1String("StringDetect")) {
- tmpItem = (new KateHlStringDetect(attr, context, regionId, regionId2, \
stringdata, insensitive));
- } else if (dataname == QLatin1String("WordDetect")) {
- tmpItem = (new KateHlWordDetect(attr, context, regionId, regionId2, \
stringdata, insensitive));
- } else if (dataname == QLatin1String("AnyChar")) {
- tmpItem = (new KateHlAnyChar(attr, context, regionId, regionId2, \
stringdata));
- } else if (dataname == QLatin1String("RegExpr")) {
- tmpItem = (new KateHlRegExpr(attr, context, regionId, regionId2, stringdata, \
insensitive, minimal));
- } else if (dataname == QLatin1String("HlCChar")) {
- tmpItem = (new KateHlCChar(attr, context, regionId, regionId2));
- } else if (dataname == QLatin1String("HlCHex")) {
- tmpItem = (new KateHlCHex(attr, context, regionId, regionId2));
- } else if (dataname == QLatin1String("HlCOct")) {
- tmpItem = (new KateHlCOct(attr, context, regionId, regionId2));
- } else if (dataname == QLatin1String("HlCFloat")) {
- tmpItem = (new KateHlCFloat(attr, context, regionId, regionId2));
- } else if (dataname == QLatin1String("HlCStringChar")) {
- tmpItem = (new KateHlCStringChar(attr, context, regionId, regionId2));
- } else if (dataname == QLatin1String("DetectSpaces")) {
- tmpItem = (new KateHlDetectSpaces(attr, context, regionId, regionId2));
- } else if (dataname == QLatin1String("DetectIdentifier")) {
- tmpItem = (new KateHlDetectIdentifier(attr, context, regionId, regionId2));
- } else {
- // oops, unknown type. Perhaps a spelling error in the xml file
- return nullptr;
- }
-
- // set lookAhead & dynamic properties
- tmpItem->lookAhead = lookAhead;
- tmpItem->dynamic = dynamic;
- tmpItem->firstNonSpace = firstNonSpace;
- tmpItem->column = column;
- tmpItem->onlyConsume = onlyConsume;
-
- if (!unresolvedContext.isEmpty()) {
- unresolvedContextReferences.insert(&(tmpItem->ctx), unresolvedContext);
- }
-
- // remember all to delete them
- m_hlItemCleanupList.append(tmpItem);
-
- return tmpItem;
-}
-
int KateHighlighting::attribute(int ctx) const
{
return m_contexts[ctx]->attr;
@@ -789,640 +521,6 @@ const QHash<QString, QChar> \
&KateHighlighting::characterEncodings(int attrib) co
return m_additionalData[ hlKeyForAttrib(attrib) ]->characterEncodings;
}
-/**
- * Helper for makeContextList. It parses the xml file for
- * information, how single or multi line comments are marked
- */
-void KateHighlighting::readCommentConfig()
-{
- KateHlManager::self()->syntax.setIdentifier(buildIdentifier);
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getGroupInfo(QStringLiteral("general"), \
QStringLiteral("comment"));
-
- QString cmlStart, cmlEnd, cmlRegion, cslStart;
- CSLPos cslPosition = CSLPosColumn0;
-
- if (data) {
- while (KateHlManager::self()->syntax.nextGroup(data)) {
- if (KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("name")) == QLatin1String("singleLine")) {
- cslStart = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("start"));
- QString cslpos = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("position"));
- if (cslpos == QLatin1String("afterwhitespace")) {
- cslPosition = CSLPosAfterWhitespace;
- } else {
- cslPosition = CSLPosColumn0;
- }
- } else if (KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("name")) == QLatin1String("multiLine")) {
- cmlStart = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("start"));
- cmlEnd = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("end"));
- cmlRegion = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("region"));
- }
- }
-
- KateHlManager::self()->syntax.freeGroupInfo(data);
- }
-
- m_additionalData[buildIdentifier]->singleLineCommentMarker = cslStart;
- m_additionalData[buildIdentifier]->singleLineCommentPosition = cslPosition;
- m_additionalData[buildIdentifier]->multiLineCommentStart = cmlStart;
- m_additionalData[buildIdentifier]->multiLineCommentEnd = cmlEnd;
- m_additionalData[buildIdentifier]->multiLineRegion = cmlRegion;
-}
-
-void KateHighlighting::readEmptyLineConfig()
-{
- KateHlManager::self()->syntax.setIdentifier(buildIdentifier);
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getGroupInfo(QStringLiteral("general"), \
QStringLiteral("emptyLine"));
-
- QLinkedList<QRegularExpression> exprList;
-
- if (data) {
- while (KateHlManager::self()->syntax.nextGroup(data)) {
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "creating an empty line regular expression";
-#endif
-
- QString regexprline = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("regexpr"));
- bool regexprcase = isTrue(KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("casesensitive")));
- exprList.append(QRegularExpression(regexprline, !regexprcase ? \
QRegularExpression::CaseInsensitiveOption : \
QRegularExpression::NoPatternOption));
- }
- KateHlManager::self()->syntax.freeGroupInfo(data);
- }
-
- m_additionalData[buildIdentifier]->emptyLines = exprList;
-}
-
-/**
- * Helper for makeContextList. It parses the xml file for information,
- * if keywords should be treated case(in)sensitive and creates the keyword
- * delimiter list. Which is the default list, without any given weak deliminiators
- */
-void KateHighlighting::readGlobalKeywordConfig()
-{
- deliminator = stdDeliminator();
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "readGlobalKeywordConfig:BEGIN";
-#endif
-
- // Tell the syntax document class which file we want to parse
- KateHlManager::self()->syntax.setIdentifier(buildIdentifier);
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getConfig(QStringLiteral("general"), \
QStringLiteral("keywords"));
-
- if (data) {
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "Found global keyword config";
-#endif
-
- casesensitive = isTrue(KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("casesensitive")));
-
- //get the weak deliminators
- weakDeliminator = (KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("weakDeliminator")));
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "weak delimiters are: " << weakDeliminator;
-#endif
-
- // remove any weakDelimitars (if any) from the default list and store this \
list.
- for (int s = 0; s < weakDeliminator.length(); s++) {
- int f = deliminator.indexOf(weakDeliminator[s]);
-
- if (f > -1) {
- deliminator.remove(f, 1);
- }
- }
-
- QString addDelim = (KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("additionalDeliminator")));
-
- if (!addDelim.isEmpty()) {
- deliminator = deliminator + addDelim;
- }
-
- KateHlManager::self()->syntax.freeGroupInfo(data);
- } else {
- //Default values
- casesensitive = true;
- weakDeliminator = QString();
- }
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "readGlobalKeywordConfig:END";
- qCDebug(LOG_KTE) << "delimiterCharacters are: " << deliminator;
-#endif
-
- m_additionalData[buildIdentifier]->deliminator = deliminator;
-}
-
-/**
- * Helper for makeContextList. It parses the xml file for any wordwrap
- * deliminators, characters * at which line can be broken. In case no keyword
- * tag is found in the xml file, the wordwrap deliminators list defaults to the
- * standard denominators. In case a keyword tag is defined, but no
- * wordWrapDeliminator attribute is specified, the deliminator list as computed
- * in readGlobalKeywordConfig is used.
- */
-void KateHighlighting::readWordWrapConfig()
-{
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "readWordWrapConfig:BEGIN";
-#endif
-
- // Tell the syntax document class which file we want to parse
- KateHlManager::self()->syntax.setIdentifier(buildIdentifier);
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getConfig(QStringLiteral("general"), \
QStringLiteral("keywords"));
-
- QString wordWrapDeliminator = stdDeliminator();
- if (data) {
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "Found global keyword config";
-#endif
-
- wordWrapDeliminator = (KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("wordWrapDeliminator")));
- //when no wordWrapDeliminator is defined use the deliminator list
- if (wordWrapDeliminator.length() == 0) {
- wordWrapDeliminator = deliminator;
- }
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "word wrap deliminators are " << wordWrapDeliminator;
-#endif
-
- KateHlManager::self()->syntax.freeGroupInfo(data);
- }
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "readWordWrapConfig:END";
-#endif
-
- m_additionalData[buildIdentifier]->wordWrapDeliminator = wordWrapDeliminator;
-}
-
-void KateHighlighting::readIndentationConfig()
-{
- m_indentation = QString();
-
- KateHlManager::self()->syntax.setIdentifier(buildIdentifier);
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getConfig(QStringLiteral("general"), \
QStringLiteral("indentation"));
-
- if (data) {
- m_indentation = (KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("mode")));
-
- KateHlManager::self()->syntax.freeGroupInfo(data);
- }
-}
-
-void KateHighlighting::readFoldingConfig()
-{
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "readfoldignConfig:BEGIN";
-#endif
-
- // Tell the syntax document class which file we want to parse
- KateHlManager::self()->syntax.setIdentifier(buildIdentifier);
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getConfig(QStringLiteral("general"), \
QStringLiteral("folding"));
-
- if (data) {
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "Found global keyword config";
-#endif
-
- m_foldingIndentationSensitive = \
isTrue(KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("indentationsensitive")));
-
- KateHlManager::self()->syntax.freeGroupInfo(data);
- } else {
- //Default values
- m_foldingIndentationSensitive = false;
- }
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "readfoldingConfig:END";
- qCDebug(LOG_KTE) << "############################ use indent for fold are: " << \
m_foldingIndentationSensitive;
-#endif
-}
-
-void KateHighlighting::readSpellCheckingConfig()
-{
- KateHlManager::self()->syntax.setIdentifier(buildIdentifier);
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getGroupInfo(QStringLiteral("spellchecking"), \
QStringLiteral("encoding"));
-
- if (data) {
- while (KateHlManager::self()->syntax.nextGroup(data)) {
- QString encoding = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("string"));
- QString character = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("char"));
- QString ignored = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("ignored"));
-
- const bool ignoredIsTrue = isTrue(ignored);
- if (encoding.isEmpty() || (character.isEmpty() && !ignoredIsTrue)) {
- continue;
- }
- QRegularExpression newLineRegExp(QStringLiteral("\\r|\\n"));
- if (encoding.indexOf(newLineRegExp) >= 0) {
- encoding.replace(newLineRegExp, QStringLiteral("<\\n|\\r>"));
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "Encoding" << encoding
- << "contains new-line characters. Ignored.";
-#endif
- }
- QChar c = (character.isEmpty() || ignoredIsTrue) ? QChar() : \
character[0];
- addCharacterEncoding(buildIdentifier, encoding, c);
- }
-
- KateHlManager::self()->syntax.freeGroupInfo(data);
- }
-
- data = KateHlManager::self()->syntax.getConfig(QStringLiteral("spellchecking"), \
QStringLiteral("configuration"));
- if (data) {
- QString policy = KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("encodingReplacementPolicy"));
- QString policyLowerCase = policy.toLower();
- int p;
-
- if (policyLowerCase == QLatin1String("encodewhenpresent")) {
- p = KTextEditor::DocumentPrivate::EncodeWhenPresent;
- } else if (policyLowerCase == QLatin1String("encodealways")) {
- p = KTextEditor::DocumentPrivate::EncodeAlways;
- } else {
- p = KTextEditor::DocumentPrivate::EncodeNever;
- }
-
- m_additionalData[buildIdentifier]->encodedCharactersInsertionPolicy = p;
-
- KateHlManager::self()->syntax.freeGroupInfo(data);
- }
-}
-
-void KateHighlighting::createContextNameList(QStringList *ContextNameList, int \
ctx0)
-{
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "creatingContextNameList:BEGIN";
-#endif
-
- if (ctx0 == 0) {
- ContextNameList->clear();
- }
-
- KateHlManager::self()->syntax.setIdentifier(buildIdentifier);
-
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getGroupInfo(QStringLiteral("highlighting"), \
QStringLiteral("context"));
-
- int id = ctx0;
-
- if (data) {
- while (KateHlManager::self()->syntax.nextGroup(data)) {
- QString tmpAttr = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("name")).simplified();
- if (tmpAttr.isEmpty()) {
- tmpAttr = QStringLiteral("!KATE_INTERNAL_DUMMY! %1").arg(id);
- errorsAndWarnings += i18n("<b>%1</b>: Deprecated syntax. Context %2 \
has no symbolic name<br />", buildIdentifier, id - ctx0);
- } else {
- tmpAttr = buildPrefix + tmpAttr;
- }
- (*ContextNameList) << tmpAttr;
- id++;
- }
- KateHlManager::self()->syntax.freeGroupInfo(data);
- }
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "creatingContextNameList:END";
-#endif
-}
-
-KateHlContextModification \
KateHighlighting::getContextModificationFromString(QStringList *ContextNameList, \
QString tmpLineEndContext, /*NO CONST*/ QString &unres)
-{
- // nothing unresolved
- unres = QString();
-
- // context to push on stack
- int context = -1;
-
- // number of contexts to pop
- int pops = 0;
-
- // we allow arbitrary #stay and #pop at the start
- bool anyFound = false;
- while (tmpLineEndContext.startsWith(QLatin1String("#stay")) ||
- tmpLineEndContext.startsWith(QLatin1String("#pop"))) {
- // ignore stay
- if (tmpLineEndContext.startsWith(QLatin1String("#stay"))) {
- tmpLineEndContext.remove(0, 5);
- } else { // count the pops
- ++pops;
- tmpLineEndContext.remove(0, 4);
- }
-
- anyFound = true;
- }
-
- /**
- * we want a ! if we have found any pop or push and still have stuff in the \
string...
- */
- if (anyFound && !tmpLineEndContext.isEmpty()) {
- if (tmpLineEndContext.startsWith(QLatin1Char('!'))) {
- tmpLineEndContext.remove(0, 1);
- }
- }
-
- /**
- * empty string, done
- */
- if (tmpLineEndContext.isEmpty()) {
- return KateHlContextModification(context, pops);
- }
-
- /**
- * handle the remaining string, this might be a ##contextname
- * or a normal contextname....
- */
- if (tmpLineEndContext.contains(QLatin1String("##"))) {
- int o = tmpLineEndContext.indexOf(QLatin1String("##"));
- // FIXME at least with 'foo##bar'-style contexts the rules are picked up
- // but the default attribute is not
- QString tmp = tmpLineEndContext.mid(o + 2);
- if (!embeddedHls.contains(tmp)) {
- embeddedHls.insert(tmp, KateEmbeddedHlInfo());
- }
- unres = tmp + QLatin1Char(':') + tmpLineEndContext.left(o);
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "unres = " << unres;
-#endif
-
- context = 0;
- }
-
- else {
- context = ContextNameList->indexOf(buildPrefix + tmpLineEndContext);
- if (context == -1) {
- context = tmpLineEndContext.toInt();
- errorsAndWarnings += i18n(
- "<B>%1</B>:Deprecated syntax. Context %2 not \
addressed by a symbolic name"
- , buildIdentifier, tmpLineEndContext);
- }
-//#warning restructure this the name list storage.
-// context=context+buildContext0Offset;
- }
-
- return KateHlContextModification(context, pops);
-}
-
-/**
- * Add one highlight to the contextlist.
- *
- * @return the number of contexts after this is added.
- */
-int KateHighlighting::addToContextList(const QString &ident, int ctx0)
-{
- //qCDebug(LOG_KTE)<<"=== Adding hl with ident '"<<ident<<"' ctx0="<<ctx0;
-
- buildIdentifier = ident;
- QString dummy;
-
- // Let the syntax document class know, which file we'd like to parse
- if (!KateHlManager::self()->syntax.setIdentifier(ident)) {
- noHl = true;
- KMessageBox::information(QApplication::activeWindow(), i18n(
- "Since there has been an error parsing the \
highlighting description, "
- "this highlighting will be disabled"));
- return 0;
- }
-
- // only read for the own stuff
- if (identifier == ident) {
- readIndentationConfig();
- }
-
- RegionList << QStringLiteral("!KateInternal_TopLevel!");
-
- m_hlIndex[internalIDList.count()] = ident;
- m_ctxIndex[ctx0] = ident;
-
- // clear and reuse or create new
- if (m_additionalData[ident]) {
- *m_additionalData[ident] = HighlightPropertyBag();
- } else {
- m_additionalData.insert(ident, new HighlightPropertyBag);
- }
-
- // fill out the propertybag
- readCommentConfig();
- readEmptyLineConfig();
- readGlobalKeywordConfig();
- readWordWrapConfig();
-
- // only read for ourself
- if (identifier == ident) {
- readFoldingConfig();
- }
-
- readSpellCheckingConfig();
-
- // This list is needed for the translation of the attribute parameter,
- // if the itemData name is given instead of the index
- addToKateExtendedAttributeList();
- QList<KTextEditor::Attribute::Ptr> iDl = internalIDList;
-
- createContextNameList(&ContextNameList, ctx0);
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "Parsing Context structure";
-#endif
-
- //start the real work
- uint i = buildContext0Offset;
- KateSyntaxContextData *data = \
KateHlManager::self()->syntax.getGroupInfo(QStringLiteral("highlighting"), \
QStringLiteral("context"));
- if (data) {
- while (KateHlManager::self()->syntax.nextGroup(data)) {
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "Found a context in file, building structure now";
-#endif
-
- //BEGIN - Translation of the attribute parameter
- QString tmpAttr = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("attribute")).simplified();
- int attr;
- if (QStringLiteral("%1").arg(tmpAttr.toInt()) == tmpAttr) {
- attr = tmpAttr.toInt();
- } else {
- attr = lookupAttrName(tmpAttr, iDl);
- }
- //END - Translation of the attribute parameter
-
- QString tmpLineEndContext = \
KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("lineEndContext")).simplified();
- KateHlContextModification context;
-
- context = getContextModificationFromString(&ContextNameList, \
tmpLineEndContext, dummy);
-
- QString tmpNIBF = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("noIndentationBasedFolding"));
- bool noIndentationBasedFolding = isTrue(tmpNIBF);
-
- //BEGIN get fallthrough props
- KateHlContextModification ftc = 0; // fallthrough context
- QString tmpFt = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("fallthrough"));
- const bool ft = isTrue(tmpFt);
- if (ft) {
- QString tmpFtc = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("fallthroughContext"));
-
- ftc = getContextModificationFromString(&ContextNameList, tmpFtc, \
dummy);
-
- // stay is not allowed, we need to #pop or push some context...
- if (ftc.type == KateHlContextModification::doNothing) {
- ftc = 0;
- }
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "Setting fall through context (context " << i << \
"): " << ftc.newContext;
-#endif
- }
- //END fallthrough props
-
- // empty line context
- QString emptyLineContext = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("lineEmptyContext"));
- KateHlContextModification emptyLineContextModification;
- if (!emptyLineContext.isEmpty()) {
- emptyLineContextModification = \
getContextModificationFromString(&ContextNameList, emptyLineContext, \
dummy);
- }
-
- QString tmpDynamic = KateHlManager::self()->syntax.groupData(data, \
QStringLiteral("dynamic"));
- bool dynamic = isTrue(tmpDynamic);
-
- KateHlContext *ctxNew = new KateHlContext(
- ident,
- attr,
- context,
- ft, ftc, dynamic, noIndentationBasedFolding,
- !emptyLineContext.isEmpty(), emptyLineContextModification);
-
- m_contexts.push_back(ctxNew);
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "INDEX: " << i << " LENGTH " << m_contexts.size() - \
1;
-#endif
-
- //Let's create all items for the context
- while (KateHlManager::self()->syntax.nextItem(data)) {
-// qCDebug(LOG_KTE)<< "In make Contextlist: Item:";
-
- // KateHlIncludeRules : add a pointer to each item in that context
- // TODO add a attrib includeAttrib
- QString tag = KateHlManager::self()->syntax.groupItemData(data, \
QString());
- if (tag == QLatin1String("IncludeRules")) { //if the new item is an \
Include rule, we have to take special care
- QString incCtx = \
KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("context"));
- QString incAttrib = \
KateHlManager::self()->syntax.groupItemData(data, \
QStringLiteral("includeAttrib"));
- bool includeAttrib = isTrue(incAttrib);
-
- // only context refernces of type Name, ##Name, and \
Subname##Name are allowed
- if (incCtx.startsWith(QLatin1String("##")) || \
(!incCtx.startsWith(QLatin1Char('#')))) {
- int incCtxi = incCtx.indexOf(QLatin1String("##"));
- //#stay, #pop is not interesting here
- if (incCtxi >= 0) {
- QString incSet = incCtx.mid(incCtxi + 2);
- QString incCtxN = incSet + QLatin1Char(':') + \
incCtx.left(incCtxi);
-
- //a cross highlighting reference
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "Cross highlight reference \
<IncludeRules>, context " << incCtxN;
-#endif
-
- KateHlIncludeRule *ir = new KateHlIncludeRule(i, \
m_contexts[i]->items.count(), incCtxN, includeAttrib);
-
- //use the same way to determine cross hl file references \
as other items do
- if (!embeddedHls.contains(incSet)) {
- embeddedHls.insert(incSet, KateEmbeddedHlInfo());
- }
-#ifdef HIGHLIGHTING_DEBUG
- else {
- qCDebug(LOG_KTE) << "Skipping embeddedHls.insert for \
" << incCtxN;
- }
-#endif
-
- unresolvedContextReferences.insert(&(ir->incCtx), \
incCtxN);
-
- includeRules.append(ir);
- } else {
- // a local reference -> just initialize the include rule \
structure
- incCtx = buildPrefix + incCtx.simplified();
- includeRules.append(new KateHlIncludeRule(i, \
m_contexts[i]->items.count(), incCtx, includeAttrib));
- }
- }
-
- continue;
- }
-// TODO -- can we remove the block below??
-#if 0
- QString tag = \
KateHlManager::self()->syntax.groupKateExtendedAttribute(data, \
QString());
- if (tag == "IncludeRules") {
- // attrib context: the index (jowenn, i think using names here
- // would be a cool feat, goes for mentioning the context in
- // any item. a map or dict?)
- int ctxId = getIdFromString(&ContextNameList,
- \
KateHlManager::self()->syntax.groupKateExtendedAttribute(data, QString("context")), \
dummy); // the index is *required*
- if (ctxId > -1) { // we can even reuse rules of 0 if we want \
to:)
- qCDebug(LOG_KTE) << "makeContextList[" << i << "]: including \
all items of context " << ctxId;
- if (ctxId < (int) i) { // must be defined
- for (c = m_contexts[ctxId]->items.first(); c; c = \
m_contexts[ctxId]->items.next()) {
- m_contexts[i]->items.append(c);
- }
- } else {
- qCDebug(LOG_KTE) << "Context " << ctxId << "not defined. \
You can not include the rules of an undefined context";
- }
- }
- continue; // while nextItem
- }
-#endif
- KateHlItem *c = createKateHlItem(data, iDl, &RegionList, \
&ContextNameList);
- if (c) {
- m_contexts[i]->items.append(c);
-
- // Not supported completely atm and only one level. \
Subitems.(all have
- // to be matched to at once)
- KateSyntaxContextData *datasub = \
KateHlManager::self()->syntax.getSubItems(data);
- for (bool tmpbool = \
KateHlManager::self()->syntax.nextItem(datasub);
- tmpbool;
- tmpbool = \
KateHlManager::self()->syntax.nextItem(datasub)) {
- c->subItems.resize(c->subItems.size() + 1);
- c->subItems[c->subItems.size() - 1] = \
createKateHlItem(datasub, iDl, &RegionList, &ContextNameList);
- }
- KateHlManager::self()->syntax.freeGroupInfo(datasub);
- }
- }
- i++;
- }
-
- KateHlManager::self()->syntax.freeGroupInfo(data);
- } else {
- // error handling: no "context" element at all in the xml file
- noHl = true;
- qCWarning(LOG_KTE) << "There is no \"context\" in the highlighting file:" << \
buildIdentifier;
- }
-
- if (RegionList.count() != 1) {
- folding = true;
- }
-
- folding = folding || m_foldingIndentationSensitive;
-
- //BEGIN Resolve multiline region if possible
- if (!m_additionalData[ ident ]->multiLineRegion.isEmpty()) {
- long commentregionid = RegionList.indexOf(m_additionalData[ ident \
]->multiLineRegion);
- if (-1 == commentregionid) {
- errorsAndWarnings += i18n(
- "<b>%1</b>: Specified multiline comment region \
(%2) could not be resolved<br />"
- , buildIdentifier, m_additionalData[ ident \
]->multiLineRegion);
- m_additionalData[ ident ]->multiLineRegion.clear();
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "ERROR comment region attribute could not be \
resolved";
-#endif
- } else {
- m_additionalData[ ident ]->multiLineRegion = \
QString::number(commentregionid + 1);
-
-#ifdef HIGHLIGHTING_DEBUG
- qCDebug(LOG_KTE) << "comment region resolved to:" << m_additionalData[ \
ident ]->multiLineRegion;
-#endif
- }
- }
- //END Resolve multiline region if possible
- return i;
-}
-
void KateHighlighting::clearAttributeArrays()
{
// just clear the hashed attributes, we create them lazy again
diff --git a/src/syntax/katehighlight.h b/src/syntax/katehighlight.h
index 2448e156..69b4679f 100644
--- a/src/syntax/katehighlight.h
+++ b/src/syntax/katehighlight.h
@@ -372,22 +372,9 @@ private:
private:
void init();
- int addToContextList(const QString &ident, int ctx0);
- void addToKateExtendedAttributeList();
void createKateExtendedAttribute(QList<KTextEditor::Attribute::Ptr> &list);
- void readGlobalKeywordConfig();
- void readWordWrapConfig();
- void readCommentConfig();
- void readEmptyLineConfig();
- void readIndentationConfig();
- void readFoldingConfig();
- void readSpellCheckingConfig();
-
- KateHlItem *createKateHlItem(KateSyntaxContextData *data, \
QList<KTextEditor::Attribute::Ptr> &iDl, QStringList *RegionList, QStringList \
*ContextList);
- int lookupAttrName(const QString &name, QList<KTextEditor::Attribute::Ptr> \
&iDl);
- void createContextNameList(QStringList *ContextNameList, int ctx0);
- KateHlContextModification getContextModificationFromString(QStringList \
*ContextNameList, QString tmpLineEndContext,/*NO CONST*/ QString &unres); + int \
lookupAttrName(const QString &name, QList<KTextEditor::Attribute::Ptr> &iDl);
QList<KTextEditor::Attribute::Ptr> internalIDList;
diff --git a/src/syntax/katesyntaxmanager.cpp b/src/syntax/katesyntaxmanager.cpp
index 97a13dc4..7d1149e8 100644
--- a/src/syntax/katesyntaxmanager.cpp
+++ b/src/syntax/katesyntaxmanager.cpp
@@ -63,8 +63,6 @@ KateHlManager::KateHlManager()
{
// Let's build the Mode List
setupModeList();
-
- lastCtxsReset.start();
}
KateHlManager::~KateHlManager()
@@ -677,29 +675,8 @@ QString KateHlManager::nameForIdentifier(const QString \
&identifier) return QString();
}
-bool KateHlManager::resetDynamicCtxs()
-{
- if (forceNoDCReset) {
- return false;
- }
-
- if (lastCtxsReset.elapsed() < KATE_DYNAMIC_CONTEXTS_RESET_DELAY) {
- return false;
- }
-
- dynamicCtxsCount = 0;
- lastCtxsReset.start();
-
- return true;
-}
-
void KateHlManager::reload()
{
- // clear syntax document cache
- syntax.clearCache();
-
- resetDynamicCtxs();
-
for(int i = 0; i < highlights(); i++)
{
getHl(i)->reload();
diff --git a/src/syntax/katesyntaxmanager.h b/src/syntax/katesyntaxmanager.h
index 22726b71..9102c7fd 100644
--- a/src/syntax/katesyntaxmanager.h
+++ b/src/syntax/katesyntaxmanager.h
@@ -24,7 +24,6 @@
#include "katetextline.h"
#include "kateextendedattribute.h"
-#include "katesyntaxdocument.h"
#include <KSyntaxHighlighting/Definition>
#include <KSyntaxHighlighting/Repository>
@@ -54,11 +53,6 @@ public:
static KateHlManager *self();
- KateSyntaxDocument *syntaxDocument()
- {
- return &syntax;
- }
-
inline KConfig *getKConfig()
{
return &m_config;
@@ -83,18 +77,6 @@ public:
QString hlSection(int n);
bool hlHidden(int n);
- void incDynamicCtxs()
- {
- ++dynamicCtxsCount;
- }
- void setForceNoDCReset(bool b)
- {
- forceNoDCReset = b;
- }
-
- // be carefull: all documents hl should be invalidated after having successfully \
called this method!
- bool resetDynamicCtxs();
-
void reload();
Q_SIGNALS:
@@ -160,12 +142,6 @@ private:
KConfig m_config;
QStringList commonSuffixes;
-
- KateSyntaxDocument syntax;
-
- int dynamicCtxsCount = 0;
- QTime lastCtxsReset;
- bool forceNoDCReset = false;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic