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 member= s 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(QLi= stsyntax.setIdentifier(buildIdentifier); - KateSyntaxContextData *data =3D KateHlManager::self()->syntax.getGroup= Info(QStringLiteral("highlighting"), QStringLiteral("itemData")); - - // use global color instance, creation is expensive! - const KateDefaultColors &colors(KTextEditor::EditorPrivate::self()->de= faultColors()); - - //begin with the real parsing - while (KateHlManager::self()->syntax.nextGroup(data)) { - // read all attributes - const QString color =3D KateHlManager::self()->syntax.groupData(da= ta, QStringLiteral("color")); - const QString selColor =3D KateHlManager::self()->syntax.groupData= (data, QStringLiteral("selColor")); - const QString bold =3D KateHlManager::self()->syntax.groupData(dat= a, QStringLiteral("bold")); - const QString italic =3D KateHlManager::self()->syntax.groupData(d= ata, QStringLiteral("italic")); - const QString underline =3D KateHlManager::self()->syntax.groupDat= a(data, QStringLiteral("underline")); - const QString strikeOut =3D KateHlManager::self()->syntax.groupDat= a(data, QStringLiteral("strikeOut")); - const QString bgColor =3D KateHlManager::self()->syntax.groupData(= data, QStringLiteral("backgroundColor")); - const QString selBgColor =3D KateHlManager::self()->syntax.groupDa= ta(data, QStringLiteral("selBackgroundColor")); - const QString spellChecking =3D KateHlManager::self()->syntax.grou= pData(data, QStringLiteral("spellChecking")); - const QString fontFamily =3D KateHlManager::self()->syntax.groupDa= ta(data, QStringLiteral("fontFamily")); - - const QString itemDataName =3D KateHlManager::self()->syntax.group= Data(data, QStringLiteral("name")).simplified(); - const QString defStyleName =3D KateHlManager::self()->syntax.group= Data(data, QStringLiteral("defStyleNum")); - - KTextEditor::Attribute::Ptr newData(new KTextEditor::Attribute( - buildPrefix + itemDataName, - static_cast (KateHlManager::defaultStyleNameToIndex(defStyleName)))); - - /* here the custom style overrides are specified, if needed */ - if (!color.isEmpty()) { - newData->setForeground(colors.adaptToScheme(QColor(color), Kat= eDefaultColors::ForegroundColor)); - } - if (!selColor.isEmpty()) { - newData->setSelectedForeground(colors.adaptToScheme(QColor(sel= Color), 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), K= ateDefaultColors::BackgroundColor)); - } - if (!selBgColor.isEmpty()) { - newData->setSelectedBackground(colors.adaptToScheme(QColor(sel= BgColor), 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, QListindex 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 &iDl, - QStringList *RegionList, - QStringList *ContextNameList) -{ - // No highlighting -> exit - if (noHl) { - return nullptr; - } - - // get the (tagname) itemd type - const QString dataname =3D KateHlManager::self()->syntax.groupItemData= (data, QString()); - - // code folding region handling: - const QString beginRegionStr =3D KateHlManager::self()->syntax.groupIt= emData(data, QStringLiteral("beginRegion")); - const QString endRegionStr =3D KateHlManager::self()->syntax.groupItem= Data(data, QStringLiteral("endRegion")); - - signed char regionId =3D 0; - signed char regionId2 =3D 0; - - if (!beginRegionStr.isEmpty()) { - regionId =3D RegionList->indexOf(beginRegionStr); - - if (regionId =3D=3D -1) { // if the region name doesn't already ex= ist, add it to the list - (*RegionList) << beginRegionStr; - regionId =3D RegionList->indexOf(beginRegionStr); - } - - regionId++; - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "########### BEG REG: " << beginRegionStr << = " NUM: " << regionId; -#endif - } - - if (!endRegionStr.isEmpty()) { - regionId2 =3D RegionList->indexOf(endRegionStr); - - if (regionId2 =3D=3D -1) { // if the region name doesn't already e= xist, add it to the list - (*RegionList) << endRegionStr; - regionId2 =3D RegionList->indexOf(endRegionStr); - } - - regionId2 =3D -regionId2 - 1; - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "########### END REG: " << endRegionStr << " = NUM: " << regionId2; -#endif - } - - int attr =3D 0; - const QString tmpAttr =3D KateHlManager::self()->syntax.groupItemData(= data, QStringLiteral("attribute")).simplified(); - bool onlyConsume =3D tmpAttr.isEmpty(); - - // only relevant for non consumer - if (!onlyConsume) { - if (QStringLiteral("%1").arg(tmpAttr.toInt()) =3D=3D tmpAttr) { - errorsAndWarnings +=3D i18n( - "%1: Deprecated syntax. Attrib= ute (%2) not addressed by symbolic name
", - buildIdentifier, tmpAttr); - attr =3D tmpAttr.toInt(); - } else { - attr =3D lookupAttrName(tmpAttr, iDl); - } - } - - // Info about context switch - KateHlContextModification context =3D -1; - QString unresolvedContext; - const QString tmpcontext =3D KateHlManager::self()->syntax.groupItemDa= ta(data, QStringLiteral("context")); - if (!tmpcontext.isEmpty()) { - context =3D getContextModificationFromString(ContextNameList, tmpc= ontext, unresolvedContext); - } - - // Get the char parameter (eg DetectChar) - QChar chr; - if (! KateHlManager::self()->syntax.groupItemData(data, QStringLiteral= ("char")).isEmpty()) { - chr =3D (KateHlManager::self()->syntax.groupItemData(data, QString= Literal("char"))).at(0); - } - - // Get the String parameter (eg. StringDetect) - const QString stringdata =3D KateHlManager::self()->syntax.groupItemDa= ta(data, QStringLiteral("String")); - - // Get a second char parameter (char1) (eg Detect2Chars) - QChar chr1; - if (! KateHlManager::self()->syntax.groupItemData(data, QStringLiteral= ("char1")).isEmpty()) { - chr1 =3D (KateHlManager::self()->syntax.groupItemData(data, QStrin= gLiteral("char1"))).at(0); - } - - // Will be removed eventually. Atm used for StringDetect, WordDetect, = keyword and RegExp - const QString &insensitive_str =3D KateHlManager::self()->syntax.group= ItemData(data, QStringLiteral("insensitive")); - bool insensitive =3D isTrue(insensitive_str); - - // for regexp only - bool minimal =3D isTrue(KateHlManager::self()->syntax.groupItemData(da= ta, QStringLiteral("minimal"))); - - // dominik: look ahead and do not change offset. so we can change cont= exts w/o changing offset1. - bool lookAhead =3D isTrue(KateHlManager::self()->syntax.groupItemData(= data, QStringLiteral("lookAhead"))); - - bool dynamic =3D isTrue(KateHlManager::self()->syntax.groupItemData(da= ta, QStringLiteral("dynamic"))); - - bool firstNonSpace =3D isTrue(KateHlManager::self()->syntax.groupItemD= ata(data, QStringLiteral("firstNonSpace"))); - - int column =3D -1; - QString colStr =3D KateHlManager::self()->syntax.groupItemData(data, Q= StringLiteral("column")); - if (!colStr.isEmpty()) { - column =3D colStr.toInt(); - } - - // Create the item corresponding to its type and set its parameters - KateHlItem *tmpItem; - - if (dataname =3D=3D QLatin1String("keyword")) { - bool keywordInsensitive =3D insensitive_str.isEmpty() ? !casesensi= tive : insensitive; - KateHlKeyword *keyword =3D new KateHlKeyword(attr, context, region= Id, regionId2, keywordInsensitive, - m_additionalData[ buildIdentifier ]->deliminator); - - //Get the entries for the keyword lookup list - keyword->addList(KateHlManager::self()->syntax.finddata(QStringLit= eral("highlighting"), stringdata)); - tmpItem =3D keyword; - } else if (dataname =3D=3D QLatin1String("Float")) { - tmpItem =3D (new KateHlFloat(attr, context, regionId, regionId2)); - } else if (dataname =3D=3D QLatin1String("Int")) { - tmpItem =3D (new KateHlInt(attr, context, regionId, regionId2)); - } else if (dataname =3D=3D QLatin1String("DetectChar")) { - tmpItem =3D (new KateHlCharDetect(attr, context, regionId, regionI= d2, chr)); - } else if (dataname =3D=3D QLatin1String("Detect2Chars")) { - tmpItem =3D (new KateHl2CharDetect(attr, context, regionId, region= Id2, chr, chr1)); - } else if (dataname =3D=3D QLatin1String("RangeDetect")) { - tmpItem =3D (new KateHlRangeDetect(attr, context, regionId, region= Id2, chr, chr1)); - } else if (dataname =3D=3D QLatin1String("LineContinue")) { - tmpItem =3D (new KateHlLineContinue(attr, context, regionId, regio= nId2, chr)); - } else if (dataname =3D=3D QLatin1String("StringDetect")) { - tmpItem =3D (new KateHlStringDetect(attr, context, regionId, regio= nId2, stringdata, insensitive)); - } else if (dataname =3D=3D QLatin1String("WordDetect")) { - tmpItem =3D (new KateHlWordDetect(attr, context, regionId, regionI= d2, stringdata, insensitive)); - } else if (dataname =3D=3D QLatin1String("AnyChar")) { - tmpItem =3D (new KateHlAnyChar(attr, context, regionId, regionId2,= stringdata)); - } else if (dataname =3D=3D QLatin1String("RegExpr")) { - tmpItem =3D (new KateHlRegExpr(attr, context, regionId, regionId2,= stringdata, insensitive, minimal)); - } else if (dataname =3D=3D QLatin1String("HlCChar")) { - tmpItem =3D (new KateHlCChar(attr, context, regionId, regionId2)); - } else if (dataname =3D=3D QLatin1String("HlCHex")) { - tmpItem =3D (new KateHlCHex(attr, context, regionId, regionId2)); - } else if (dataname =3D=3D QLatin1String("HlCOct")) { - tmpItem =3D (new KateHlCOct(attr, context, regionId, regionId2)); - } else if (dataname =3D=3D QLatin1String("HlCFloat")) { - tmpItem =3D (new KateHlCFloat(attr, context, regionId, regionId2)); - } else if (dataname =3D=3D QLatin1String("HlCStringChar")) { - tmpItem =3D (new KateHlCStringChar(attr, context, regionId, region= Id2)); - } else if (dataname =3D=3D QLatin1String("DetectSpaces")) { - tmpItem =3D (new KateHlDetectSpaces(attr, context, regionId, regio= nId2)); - } else if (dataname =3D=3D QLatin1String("DetectIdentifier")) { - tmpItem =3D (new KateHlDetectIdentifier(attr, context, regionId, r= egionId2)); - } else { - // oops, unknown type. Perhaps a spelling error in the xml file - return nullptr; - } - - // set lookAhead & dynamic properties - tmpItem->lookAhead =3D lookAhead; - tmpItem->dynamic =3D dynamic; - tmpItem->firstNonSpace =3D firstNonSpace; - tmpItem->column =3D column; - tmpItem->onlyConsume =3D onlyConsume; - - if (!unresolvedContext.isEmpty()) { - unresolvedContextReferences.insert(&(tmpItem->ctx), unresolvedCont= ext); - } - - // 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 &KateHighlighting::charac= terEncodings(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 =3D KateHlManager::self()->syntax.getGroup= Info(QStringLiteral("general"), QStringLiteral("comment")); - - QString cmlStart, cmlEnd, cmlRegion, cslStart; - CSLPos cslPosition =3D CSLPosColumn0; - - if (data) { - while (KateHlManager::self()->syntax.nextGroup(data)) { - if (KateHlManager::self()->syntax.groupData(data, QStringLiter= al("name")) =3D=3D QLatin1String("singleLine")) { - cslStart =3D KateHlManager::self()->syntax.groupData(data,= QStringLiteral("start")); - QString cslpos =3D KateHlManager::self()->syntax.groupData= (data, QStringLiteral("position")); - if (cslpos =3D=3D QLatin1String("afterwhitespace")) { - cslPosition =3D CSLPosAfterWhitespace; - } else { - cslPosition =3D CSLPosColumn0; - } - } else if (KateHlManager::self()->syntax.groupData(data, QStri= ngLiteral("name")) =3D=3D QLatin1String("multiLine")) { - cmlStart =3D KateHlManager::self()->syntax.groupData(data,= QStringLiteral("start")); - cmlEnd =3D KateHlManager::self()->syntax.groupData(data, Q= StringLiteral("end")); - cmlRegion =3D KateHlManager::self()->syntax.groupData(data= , QStringLiteral("region")); - } - } - - KateHlManager::self()->syntax.freeGroupInfo(data); - } - - m_additionalData[buildIdentifier]->singleLineCommentMarker =3D cslStar= t; - m_additionalData[buildIdentifier]->singleLineCommentPosition =3D cslPo= sition; - m_additionalData[buildIdentifier]->multiLineCommentStart =3D cmlStart; - m_additionalData[buildIdentifier]->multiLineCommentEnd =3D cmlEnd; - m_additionalData[buildIdentifier]->multiLineRegion =3D cmlRegion; -} - -void KateHighlighting::readEmptyLineConfig() -{ - KateHlManager::self()->syntax.setIdentifier(buildIdentifier); - KateSyntaxContextData *data =3D KateHlManager::self()->syntax.getGroup= Info(QStringLiteral("general"), QStringLiteral("emptyLine")); - - QLinkedList exprList; - - if (data) { - while (KateHlManager::self()->syntax.nextGroup(data)) { -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "creating an empty line regular expression= "; -#endif - - QString regexprline =3D KateHlManager::self()->syntax.groupDat= a(data, QStringLiteral("regexpr")); - bool regexprcase =3D isTrue(KateHlManager::self()->syntax.grou= pData(data, QStringLiteral("casesensitive"))); - exprList.append(QRegularExpression(regexprline, !regexprcase ?= QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternO= ption)); - } - KateHlManager::self()->syntax.freeGroupInfo(data); - } - - m_additionalData[buildIdentifier]->emptyLines =3D 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 delim= iniators - */ -void KateHighlighting::readGlobalKeywordConfig() -{ - deliminator =3D 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 =3D KateHlManager::self()->syntax.getConfi= g(QStringLiteral("general"), QStringLiteral("keywords")); - - if (data) { -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "Found global keyword config"; -#endif - - casesensitive =3D isTrue(KateHlManager::self()->syntax.groupItemDa= ta(data, QStringLiteral("casesensitive"))); - - //get the weak deliminators - weakDeliminator =3D (KateHlManager::self()->syntax.groupItemData(d= ata, QStringLiteral("weakDeliminator"))); - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "weak delimiters are: " << weakDeliminator; -#endif - - // remove any weakDelimitars (if any) from the default list and st= ore this list. - for (int s =3D 0; s < weakDeliminator.length(); s++) { - int f =3D deliminator.indexOf(weakDeliminator[s]); - - if (f > -1) { - deliminator.remove(f, 1); - } - } - - QString addDelim =3D (KateHlManager::self()->syntax.groupItemData(= data, QStringLiteral("additionalDeliminator"))); - - if (!addDelim.isEmpty()) { - deliminator =3D deliminator + addDelim; - } - - KateHlManager::self()->syntax.freeGroupInfo(data); - } else { - //Default values - casesensitive =3D true; - weakDeliminator =3D QString(); - } - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "readGlobalKeywordConfig:END"; - qCDebug(LOG_KTE) << "delimiterCharacters are: " << deliminator; -#endif - - m_additionalData[buildIdentifier]->deliminator =3D deliminator; -} - -/** - * Helper for makeContextList. It parses the xml file for any wordwrap - * deliminators, characters * at which line can be broken. In case no keyw= ord - * tag is found in the xml file, the wordwrap deliminators list defaults t= o the - * standard denominators. In case a keyword tag is defined, but no - * wordWrapDeliminator attribute is specified, the deliminator list as com= puted - * 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 =3D KateHlManager::self()->syntax.getConfi= g(QStringLiteral("general"), QStringLiteral("keywords")); - - QString wordWrapDeliminator =3D stdDeliminator(); - if (data) { -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "Found global keyword config"; -#endif - - wordWrapDeliminator =3D (KateHlManager::self()->syntax.groupItemDa= ta(data, QStringLiteral("wordWrapDeliminator"))); - //when no wordWrapDeliminator is defined use the deliminator list - if (wordWrapDeliminator.length() =3D=3D 0) { - wordWrapDeliminator =3D deliminator; - } - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "word wrap deliminators are " << wordWrapDelim= inator; -#endif - - KateHlManager::self()->syntax.freeGroupInfo(data); - } - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "readWordWrapConfig:END"; -#endif - - m_additionalData[buildIdentifier]->wordWrapDeliminator =3D wordWrapDel= iminator; -} - -void KateHighlighting::readIndentationConfig() -{ - m_indentation =3D QString(); - - KateHlManager::self()->syntax.setIdentifier(buildIdentifier); - KateSyntaxContextData *data =3D KateHlManager::self()->syntax.getConfi= g(QStringLiteral("general"), QStringLiteral("indentation")); - - if (data) { - m_indentation =3D (KateHlManager::self()->syntax.groupItemData(dat= a, 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 =3D KateHlManager::self()->syntax.getConfi= g(QStringLiteral("general"), QStringLiteral("folding")); - - if (data) { -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "Found global keyword config"; -#endif - - m_foldingIndentationSensitive =3D isTrue(KateHlManager::self()->sy= ntax.groupItemData(data, QStringLiteral("indentationsensitive"))); - - KateHlManager::self()->syntax.freeGroupInfo(data); - } else { - //Default values - m_foldingIndentationSensitive =3D 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 =3D KateHlManager::self()->syntax.getGroup= Info(QStringLiteral("spellchecking"), QStringLiteral("encoding")); - - if (data) { - while (KateHlManager::self()->syntax.nextGroup(data)) { - QString encoding =3D KateHlManager::self()->syntax.groupData(d= ata, QStringLiteral("string")); - QString character =3D KateHlManager::self()->syntax.groupData(= data, QStringLiteral("char")); - QString ignored =3D KateHlManager::self()->syntax.groupData(da= ta, QStringLiteral("ignored")); - - const bool ignoredIsTrue =3D isTrue(ignored); - if (encoding.isEmpty() || (character.isEmpty() && !ignoredIsTr= ue)) { - continue; - } - QRegularExpression newLineRegExp(QStringLiteral("\\r|\\n")); - if (encoding.indexOf(newLineRegExp) >=3D 0) { - encoding.replace(newLineRegExp, QStringLiteral("<\\n|\\r>"= )); - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "Encoding" << encoding - << "contains new-line characters. Ignore= d."; -#endif - } - QChar c =3D (character.isEmpty() || ignoredIsTrue) ? QChar() := character[0]; - addCharacterEncoding(buildIdentifier, encoding, c); - } - - KateHlManager::self()->syntax.freeGroupInfo(data); - } - - data =3D KateHlManager::self()->syntax.getConfig(QStringLiteral("spell= checking"), QStringLiteral("configuration")); - if (data) { - QString policy =3D KateHlManager::self()->syntax.groupItemData(dat= a, QStringLiteral("encodingReplacementPolicy")); - QString policyLowerCase =3D policy.toLower(); - int p; - - if (policyLowerCase =3D=3D QLatin1String("encodewhenpresent")) { - p =3D KTextEditor::DocumentPrivate::EncodeWhenPresent; - } else if (policyLowerCase =3D=3D QLatin1String("encodealways")) { - p =3D KTextEditor::DocumentPrivate::EncodeAlways; - } else { - p =3D KTextEditor::DocumentPrivate::EncodeNever; - } - - m_additionalData[buildIdentifier]->encodedCharactersInsertionPolic= y =3D p; - - KateHlManager::self()->syntax.freeGroupInfo(data); - } -} - -void KateHighlighting::createContextNameList(QStringList *ContextNameList= , int ctx0) -{ -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "creatingContextNameList:BEGIN"; -#endif - - if (ctx0 =3D=3D 0) { - ContextNameList->clear(); - } - - KateHlManager::self()->syntax.setIdentifier(buildIdentifier); - - KateSyntaxContextData *data =3D KateHlManager::self()->syntax.getGroup= Info(QStringLiteral("highlighting"), QStringLiteral("context")); - - int id =3D ctx0; - - if (data) { - while (KateHlManager::self()->syntax.nextGroup(data)) { - QString tmpAttr =3D KateHlManager::self()->syntax.groupData(da= ta, QStringLiteral("name")).simplified(); - if (tmpAttr.isEmpty()) { - tmpAttr =3D QStringLiteral("!KATE_INTERNAL_DUMMY! %1").arg= (id); - errorsAndWarnings +=3D i18n("%1: Deprecated syntax.= Context %2 has no symbolic name
", buildIdentifier, id - ctx0); - } else { - tmpAttr =3D buildPrefix + tmpAttr; - } - (*ContextNameList) << tmpAttr; - id++; - } - KateHlManager::self()->syntax.freeGroupInfo(data); - } - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "creatingContextNameList:END"; -#endif -} - -KateHlContextModification KateHighlighting::getContextModificationFromStri= ng(QStringList *ContextNameList, QString tmpLineEndContext, /*NO CONST*/ QS= tring &unres) -{ - // nothing unresolved - unres =3D QString(); - - // context to push on stack - int context =3D -1; - - // number of contexts to pop - int pops =3D 0; - - // we allow arbitrary #stay and #pop at the start - bool anyFound =3D 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 =3D true; - } - - /** - * we want a ! if we have found any pop or push and still have stuff i= n 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 =3D tmpLineEndContext.indexOf(QLatin1String("##")); - // FIXME at least with 'foo##bar'-style contexts the rules are pic= ked up - // but the default attribute is not - QString tmp =3D tmpLineEndContext.mid(o + 2); - if (!embeddedHls.contains(tmp)) { - embeddedHls.insert(tmp, KateEmbeddedHlInfo()); - } - unres =3D tmp + QLatin1Char(':') + tmpLineEndContext.left(o); - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "unres =3D " << unres; -#endif - - context =3D 0; - } - - else { - context =3D ContextNameList->indexOf(buildPrefix + tmpLineEndConte= xt); - if (context =3D=3D -1) { - context =3D tmpLineEndContext.toInt(); - errorsAndWarnings +=3D i18n( - "%1:Deprecated syntax. Context= %2 not addressed by a symbolic name" - , buildIdentifier, tmpLineEndContext); - } -//#warning restructure this the name list storage. -// context=3Dcontext+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)<<"=3D=3D=3D Adding hl with ident '"<syntax.setIdentifier(ident)) { - noHl =3D true; - KMessageBox::information(QApplication::activeWindow(), i18n( - "Since there has been an error parsin= g the highlighting description, " - "this highlighting will be disabled")= ); - return 0; - } - - // only read for the own stuff - if (identifier =3D=3D ident) { - readIndentationConfig(); - } - - RegionList << QStringLiteral("!KateInternal_TopLevel!"); - - m_hlIndex[internalIDList.count()] =3D ident; - m_ctxIndex[ctx0] =3D ident; - - // clear and reuse or create new - if (m_additionalData[ident]) { - *m_additionalData[ident] =3D HighlightPropertyBag(); - } else { - m_additionalData.insert(ident, new HighlightPropertyBag); - } - - // fill out the propertybag - readCommentConfig(); - readEmptyLineConfig(); - readGlobalKeywordConfig(); - readWordWrapConfig(); - - // only read for ourself - if (identifier =3D=3D 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 iDl =3D internalIDList; - - createContextNameList(&ContextNameList, ctx0); - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "Parsing Context structure"; -#endif - - //start the real work - uint i =3D buildContext0Offset; - KateSyntaxContextData *data =3D KateHlManager::self()->syntax.getGroup= Info(QStringLiteral("highlighting"), QStringLiteral("context")); - if (data) { - while (KateHlManager::self()->syntax.nextGroup(data)) { -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "Found a context in file, building structu= re now"; -#endif - - //BEGIN - Translation of the attribute parameter - QString tmpAttr =3D KateHlManager::self()->syntax.groupData(da= ta, QStringLiteral("attribute")).simplified(); - int attr; - if (QStringLiteral("%1").arg(tmpAttr.toInt()) =3D=3D tmpAttr) { - attr =3D tmpAttr.toInt(); - } else { - attr =3D lookupAttrName(tmpAttr, iDl); - } - //END - Translation of the attribute parameter - - QString tmpLineEndContext =3D KateHlManager::self()->syntax.gr= oupData(data, QStringLiteral("lineEndContext")).simplified(); - KateHlContextModification context; - - context =3D getContextModificationFromString(&ContextNameList,= tmpLineEndContext, dummy); - - QString tmpNIBF =3D KateHlManager::self()->syntax.groupData(da= ta, QStringLiteral("noIndentationBasedFolding")); - bool noIndentationBasedFolding =3D isTrue(tmpNIBF); - - //BEGIN get fallthrough props - KateHlContextModification ftc =3D 0; // fallthrough context - QString tmpFt =3D KateHlManager::self()->syntax.groupData(data= , QStringLiteral("fallthrough")); - const bool ft =3D isTrue(tmpFt); - if (ft) { - QString tmpFtc =3D KateHlManager::self()->syntax.groupData= (data, QStringLiteral("fallthroughContext")); - - ftc =3D getContextModificationFromString(&ContextNameList,= tmpFtc, dummy); - - // stay is not allowed, we need to #pop or push some conte= xt... - if (ftc.type =3D=3D KateHlContextModification::doNothing) { - ftc =3D 0; - } - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "Setting fall through context (context= " << i << "): " << ftc.newContext; -#endif - } - //END fallthrough props - - // empty line context - QString emptyLineContext =3D KateHlManager::self()->syntax.gro= upData(data, QStringLiteral("lineEmptyContext")); - KateHlContextModification emptyLineContextModification; - if (!emptyLineContext.isEmpty()) { - emptyLineContextModification =3D getContextModificationFro= mString(&ContextNameList, emptyLineContext, dummy); - } - - QString tmpDynamic =3D KateHlManager::self()->syntax.groupData= (data, QStringLiteral("dynamic")); - bool dynamic =3D isTrue(tmpDynamic); - - KateHlContext *ctxNew =3D 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 =3D KateHlManager::self()->syntax.groupItemDat= a(data, QString()); - if (tag =3D=3D QLatin1String("IncludeRules")) { //if the n= ew item is an Include rule, we have to take special care - QString incCtx =3D KateHlManager::self()->syntax.group= ItemData(data, QStringLiteral("context")); - QString incAttrib =3D KateHlManager::self()->syntax.gr= oupItemData(data, QStringLiteral("includeAttrib")); - bool includeAttrib =3D isTrue(incAttrib); - - // only context refernces of type Name, ##Name, and Su= bname##Name are allowed - if (incCtx.startsWith(QLatin1String("##")) || (!incCtx= .startsWith(QLatin1Char('#')))) { - int incCtxi =3D incCtx.indexOf(QLatin1String("##")= ); - //#stay, #pop is not interesting here - if (incCtxi >=3D 0) { - QString incSet =3D incCtx.mid(incCtxi + 2); - QString incCtxN =3D incSet + QLatin1Char(':') = + incCtx.left(incCtxi); - - //a cross highlighting reference -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "Cross highlight reference= , context " << incCtxN; -#endif - - KateHlIncludeRule *ir =3D new KateHlIncludeRul= e(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, KateEmbeddedHlI= nfo()); - } -#ifdef HIGHLIGHTING_DEBUG - else { - qCDebug(LOG_KTE) << "Skipping embeddedHls.= insert for " << incCtxN; - } -#endif - - unresolvedContextReferences.insert(&(ir->incCt= x), incCtxN); - - includeRules.append(ir); - } else { - // a local reference -> just initialize the in= clude rule structure - incCtx =3D 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 =3D KateHlManager::self()->syntax.groupKateExt= endedAttribute(data, QString()); - if (tag =3D=3D "IncludeRules") { - // attrib context: the index (jowenn, i think using na= mes here - // would be a cool feat, goes for mentioning the conte= xt in - // any item. a map or dict?) - int ctxId =3D getIdFromString(&ContextNameList, - KateHlManager::self()->syn= tax.groupKateExtendedAttribute(data, QString("context")), dummy); // the in= dex 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 =3D m_contexts[ctxId]->items.first(); c= ; c =3D m_contexts[ctxId]->items.next()) { - m_contexts[i]->items.append(c); - } - } else { - qCDebug(LOG_KTE) << "Context " << ctxId << "no= t defined. You can not include the rules of an undefined context"; - } - } - continue; // while nextItem - } -#endif - KateHlItem *c =3D createKateHlItem(data, iDl, &RegionList,= &ContextNameList); - if (c) { - m_contexts[i]->items.append(c); - - // Not supported completely atm and only one level. Su= bitems.(all have - // to be matched to at once) - KateSyntaxContextData *datasub =3D KateHlManager::self= ()->syntax.getSubItems(data); - for (bool tmpbool =3D KateHlManager::self()->syntax.ne= xtItem(datasub); - tmpbool; - tmpbool =3D KateHlManager::self()->syntax.next= Item(datasub)) { - c->subItems.resize(c->subItems.size() + 1); - c->subItems[c->subItems.size() - 1] =3D createKate= HlItem(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 =3D true; - qCWarning(LOG_KTE) << "There is no \"context\" in the highlighting= file:" << buildIdentifier; - } - - if (RegionList.count() !=3D 1) { - folding =3D true; - } - - folding =3D folding || m_foldingIndentationSensitive; - - //BEGIN Resolve multiline region if possible - if (!m_additionalData[ ident ]->multiLineRegion.isEmpty()) { - long commentregionid =3D RegionList.indexOf(m_additionalData[ iden= t ]->multiLineRegion); - if (-1 =3D=3D commentregionid) { - errorsAndWarnings +=3D i18n( - "%1: Specified multiline comme= nt region (%2) could not be resolved
" - , 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 =3D QString::number= (commentregionid + 1); - -#ifdef HIGHLIGHTING_DEBUG - qCDebug(LOG_KTE) << "comment region resolved to:" << m_additio= nalData[ 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 &l= ist); - void readGlobalKeywordConfig(); - void readWordWrapConfig(); - void readCommentConfig(); - void readEmptyLineConfig(); - void readIndentationConfig(); - void readFoldingConfig(); - void readSpellCheckingConfig(); - - KateHlItem *createKateHlItem(KateSyntaxContextData *data, QList &iDl, QStringList *RegionList, QStringList *ContextL= ist); - int lookupAttrName(const QString &name, QList &iDl); = - void createContextNameList(QStringList *ContextNameList, int ctx0); - KateHlContextModification getContextModificationFromString(QStringList= *ContextNameList, QString tmpLineEndContext,/*NO CONST*/ QString &unres); + int lookupAttrName(const QString &name, QList &iDl); = QList internalIDList; = diff --git a/src/syntax/katesyntaxmanager.cpp b/src/syntax/katesyntaxmanage= r.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 =3D 0; - lastCtxsReset.start(); - - return true; -} - void KateHlManager::reload() { - // clear syntax document cache - syntax.clearCache(); - - resetDynamicCtxs(); - for(int i =3D 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 #include @@ -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 =3D b; - } - - // be carefull: all documents hl should be invalidated after having su= ccessfully called this method! - bool resetDynamicCtxs(); - void reload(); = Q_SIGNALS: @@ -160,12 +142,6 @@ private: = KConfig m_config; QStringList commonSuffixes; - - KateSyntaxDocument syntax; - - int dynamicCtxsCount =3D 0; - QTime lastCtxsReset; - bool forceNoDCReset =3D false; }; = #endif