diff --git a/cmake/QtCreatorAPIInternal.cmake b/cmake/QtCreatorAPIInternal.cmake index ac84459e1a7..6a8dc4c39cf 100644 --- a/cmake/QtCreatorAPIInternal.cmake +++ b/cmake/QtCreatorAPIInternal.cmake @@ -324,12 +324,14 @@ function(enable_pch target) set_target_properties(${pch_target} PROPERTIES PRECOMPILE_HEADERS ${pch_file} CXX_VISIBILITY_PRESET hidden - VISIBILITY_INLINES_HIDDEN ON) + VISIBILITY_INLINES_HIDDEN ON + CXX_EXTENSIONS OFF + ) target_link_libraries(${pch_target} PRIVATE ${pch_dependency}) endif() endfunction() - if (NOT TARGET QtCreatorPchGui AND NOT TARGET QtCreatorPchConsole) + if (NOT TARGET ${PROJECT_NAME}PchGui AND NOT TARGET ${PROJECT_NAME}PchConsole) file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c CONTENT "/*empty file*/") @@ -341,17 +343,17 @@ function(enable_pch target) ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.cpp PROPERTIES GENERATED TRUE) - _add_pch_target(QtCreatorPchGui - "${PROJECT_SOURCE_DIR}/src/shared/qtcreator_gui_pch.h" Qt5::Widgets) - _add_pch_target(QtCreatorPchConsole - "${PROJECT_SOURCE_DIR}/src/shared/qtcreator_pch.h" Qt5::Core) + _add_pch_target(${PROJECT_NAME}PchGui + "${QtCreator_SOURCE_DIR}/src/shared/qtcreator_gui_pch.h" Qt5::Widgets) + _add_pch_target(${PROJECT_NAME}PchConsole + "${QtCreator_SOURCE_DIR}/src/shared/qtcreator_pch.h" Qt5::Core) endif() unset(PCH_TARGET) if ("Qt5::Widgets" IN_LIST dependencies) - set(PCH_TARGET QtCreatorPchGui) + set(PCH_TARGET ${PROJECT_NAME}PchGui) elseif ("Qt5::Core" IN_LIST dependencies) - set(PCH_TARGET QtCreatorPchConsole) + set(PCH_TARGET ${PROJECT_NAME}PchConsole) endif() if (TARGET "${PCH_TARGET}") diff --git a/doc/qtcreator/images/qtcreator-run-failed-tests.png b/doc/qtcreator/images/qtcreator-run-failed-tests.png new file mode 100644 index 00000000000..eb58129dbe1 Binary files /dev/null and b/doc/qtcreator/images/qtcreator-run-failed-tests.png differ diff --git a/doc/qtcreator/src/howto/creator-only/creator-autotest.qdoc b/doc/qtcreator/src/howto/creator-only/creator-autotest.qdoc index 78c7ffb680e..3a7c21cf2fb 100644 --- a/doc/qtcreator/src/howto/creator-only/creator-autotest.qdoc +++ b/doc/qtcreator/src/howto/creator-only/creator-autotest.qdoc @@ -278,6 +278,11 @@ (\uicontrol {Run All Tests}) to run all tests. \li \inlineimage qtcreator-run-selected-tests.png (\uicontrol {Run Selected Tests}) to run the selected tests. + \li \inlineimage qtcreator-run-failed-tests.png + (\uicontrol {Run Failed Tests}) to re-run the tests which failed + in the last run. + Depending on the framework this may select additional tests if it + is impossible to distinguish or to fully address the test. \li \inlineimage qtcreator-run-tests-in-current-file.png (\uicontrol {Run Tests for Current File}) to run the tests in the file currently open in the code editor. diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml index bb7f96f787c..28f39d89f31 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/InternalConstants.qml @@ -90,48 +90,51 @@ QtObject { readonly property string distributeSpacingVertical: "\u0053" readonly property string distributeTop: "\u0054" readonly property string edit: "\u0055" - readonly property string fontStyleBold: "\u0056" - readonly property string fontStyleItalic: "\u0057" - readonly property string fontStyleStrikethrough: "\u0058" - readonly property string fontStyleUnderline: "\u0059" - readonly property string gridView: "\u005A" - readonly property string idAliasOff: "\u005B" - readonly property string idAliasOn: "\u005C" - readonly property string listView: "\u005D" - readonly property string lockOff: "\u005E" - readonly property string lockOn: "\u005F" - readonly property string mergeCells: "\u0060" - readonly property string minus: "\u0061" - readonly property string pin: "\u0062" - readonly property string plus: "\u0063" - readonly property string redo: "\u0064" - readonly property string rotation: "\u0065" - readonly property string splitColumns: "\u0066" - readonly property string splitRows: "\u0067" - readonly property string startNode: "\u0068" - readonly property string testIcon: "\u0069" - readonly property string textAlignBottom: "\u006A" - readonly property string textAlignCenter: "\u006B" - readonly property string textAlignLeft: "\u006C" - readonly property string textAlignMiddle: "\u006D" - readonly property string textAlignRight: "\u006E" - readonly property string textAlignTop: "\u006F" - readonly property string textBulletList: "\u0070" - readonly property string textFullJustification: "\u0071" - readonly property string textNumberedList: "\u0072" - readonly property string tickIcon: "\u0073" - readonly property string triState: "\u0074" - readonly property string undo: "\u0075" - readonly property string unpin: "\u0076" - readonly property string upDownIcon: "\u0077" - readonly property string upDownSquare2: "\u0078" - readonly property string visibilityOff: "\u0079" - readonly property string visibilityOn: "\u007A" - readonly property string wildcard: "\u007B" - readonly property string zoomAll: "\u007C" - readonly property string zoomIn: "\u007D" - readonly property string zoomOut: "\u007E" - readonly property string zoomSelection: "\u007F" + readonly property string flowAction: "\u0056" + readonly property string flowTransition: "\u0057" + readonly property string fontStyleBold: "\u0058" + readonly property string fontStyleItalic: "\u0059" + readonly property string fontStyleStrikethrough: "\u005A" + readonly property string fontStyleUnderline: "\u005B" + readonly property string gridView: "\u005C" + readonly property string idAliasOff: "\u005D" + readonly property string idAliasOn: "\u005E" + readonly property string listView: "\u005F" + readonly property string lockOff: "\u0060" + readonly property string lockOn: "\u0061" + readonly property string mergeCells: "\u0062" + readonly property string minus: "\u0063" + readonly property string pin: "\u0064" + readonly property string plus: "\u0065" + readonly property string redo: "\u0066" + readonly property string rotation: "\u0067" + readonly property string search: "\u0068" + readonly property string splitColumns: "\u0069" + readonly property string splitRows: "\u006A" + readonly property string startNode: "\u006B" + readonly property string testIcon: "\u006C" + readonly property string textAlignBottom: "\u006D" + readonly property string textAlignCenter: "\u006E" + readonly property string textAlignLeft: "\u006F" + readonly property string textAlignMiddle: "\u0070" + readonly property string textAlignRight: "\u0071" + readonly property string textAlignTop: "\u0072" + readonly property string textBulletList: "\u0073" + readonly property string textFullJustification: "\u0074" + readonly property string textNumberedList: "\u0075" + readonly property string tickIcon: "\u0076" + readonly property string triState: "\u0077" + readonly property string undo: "\u0078" + readonly property string unpin: "\u0079" + readonly property string upDownIcon: "\u007A" + readonly property string upDownSquare2: "\u007B" + readonly property string visibilityOff: "\u007C" + readonly property string visibilityOn: "\u007D" + readonly property string wildcard: "\u007E" + readonly property string zoomAll: "\u007F" + readonly property string zoomIn: "\u0080" + readonly property string zoomOut: "\u0081" + readonly property string zoomSelection: "\u0082" readonly property font iconFont: Qt.font({ "family": controlIcons.name, diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf index 0c4d237c0e2..baa995bb5c5 100644 Binary files a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf and b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf differ diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt b/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt index 214dcfc2212..d9a268a634d 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.10) # Remove when sharing with others. list(APPEND CMAKE_PREFIX_PATH "%{QtCreatorBuild}") diff --git a/src/libs/3rdparty/syntax-highlighting/CMakeLists.txt b/src/libs/3rdparty/syntax-highlighting/CMakeLists.txt index e451df24d83..8c37bf1731a 100644 --- a/src/libs/3rdparty/syntax-highlighting/CMakeLists.txt +++ b/src/libs/3rdparty/syntax-highlighting/CMakeLists.txt @@ -32,6 +32,7 @@ add_qtc_library(KSyntaxHighlighting SHARED src/lib/theme.cpp src/lib/theme.h src/lib/themedata.cpp src/lib/themedata_p.h src/lib/wildcardmatcher.cpp src/lib/wildcardmatcher_p.h + src/lib/worddelimiters.cpp src/lib/worddelimiters_p.h src/lib/xml_p.h ) qtc_add_public_header(autogenerated/src/lib/State) diff --git a/src/libs/3rdparty/syntax-highlighting/README.md b/src/libs/3rdparty/syntax-highlighting/README.md index c1b82c63d13..c090d061635 100644 --- a/src/libs/3rdparty/syntax-highlighting/README.md +++ b/src/libs/3rdparty/syntax-highlighting/README.md @@ -2,6 +2,17 @@ Syntax highlighting engine for Kate syntax definitions +## Table of contents + +1. [Introduction](#introduction) +2. [Out of scope](#out-of-scope) +3. [Syntax Definition Files](#syntax-definition-files) +4. [Build it](#build-it) +5. [How to contribute](#how-to-contribute) +6. [Adding unit tests for a syntax definition](#adding-unit-tests-for-a-syntax-definition) +7. [Report bug or help to fix them](#report-bug-or-help-to-fix-them) +8. [Updating the kate-editor.org/syntax website](#updating-the-kate-editororgsyntax-website) + ## Introduction This is a stand-alone implementation of the Kate syntax highlighting engine. @@ -9,15 +20,6 @@ It's meant as a building block for text editors as well as for simple highlighte text rendering (e.g. as HTML), supporting both integration with a custom editor as well as a ready-to-use QSyntaxHighlighter sub-class. -## Syntax Definition Files - -This library uses Kate syntax definition files for the actual highlighting, -the file format is documented [here](https://docs.kde.org/stable5/en/applications/katepart/highlight.html). - -More than 250 syntax definition files are included, additional ones are -picked up from the file system if present, so you can easily extend this -by application-specific syntax definitions for example. - ## Out of scope To not turn this into yet another text editor, the following things are considered @@ -31,19 +33,170 @@ out of scope: If you need any of this, check out [KTextEditor](https://api.kde.org/frameworks/ktexteditor/html/). +## Syntax Definition Files + +This library uses Kate syntax definition files for the actual highlighting, +the file format is documented [here](https://docs.kde.org/?application=katepart&branch=trunk5&path=highlight.html). + +More than 300 syntax definition files are included, that are located +in **data/syntax/** and have the **.xml** extension. Additional ones are +picked up from the file system if present, so you can easily extend this +by application-specific syntax definitions for example. + +To install or test a syntax definiton file locally, place it in +**org.kde.syntax-highlighting/syntax/**, which is located in your user directory. +Usually it is: + +
| For local user | +$HOME/.local/share/org.kde.syntax-highlighting/syntax/ | +
| For Kate's Flatpak package | +$HOME/.var/app/org.kde.kate/data/org.kde.syntax-highlighting/syntax/ | +
| For Kate's Snap package | +$HOME/snap/kate/current/.local/share/org.kde.syntax-highlighting/syntax/ | +
| On Windows® | +%USERPROFILE%\AppData\Local\org.kde.syntax-highlighting\syntax\ | +
\n";
+ *d->out << ";color:" << QColor(theme().textColor(Theme::Normal)).name();
+ *d->out << "\">\n";
QTextStream in(dev);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/htmlhighlighter.h b/src/libs/3rdparty/syntax-highlighting/src/lib/htmlhighlighter.h
index 7479ee2b633..8754057345d 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/htmlhighlighter.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/htmlhighlighter.h
@@ -1,24 +1,7 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause
- 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-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_HTMLHIGHLIGHTER_H
@@ -32,11 +15,6 @@
#include
-QT_BEGIN_NAMESPACE
-class QFile;
-class QTextStream;
-QT_END_NAMESPACE
-
namespace KSyntaxHighlighting
{
class HtmlHighlighterPrivate;
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/keywordlist.cpp b/src/libs/3rdparty/syntax-highlighting/src/lib/keywordlist.cpp
index d82408d8019..b599ce29a18 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/keywordlist.cpp
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/keywordlist.cpp
@@ -1,24 +1,8 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause
+ SPDX-FileCopyrightText: 2020 Jonathan Poelen
- 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-License-Identifier: MIT
*/
#include "definition_p.h"
@@ -42,12 +26,7 @@ bool KeywordList::contains(const QStringView &str, Qt::CaseSensitivity caseSensi
/**
* search with right predicate
*/
- return std::binary_search(vectorToSearch.begin(),
- vectorToSearch.end(),
- str,
- [caseSensitive](const QStringView &a, const QStringView &b) {
- return a.compare(b, caseSensitive) < 0;
- });
+ return std::binary_search(vectorToSearch.begin(), vectorToSearch.end(), QStringView(str), [caseSensitive](const QStringView &a, const QStringView &b) { return a.compare(b, caseSensitive) < 0; });
}
void KeywordList::load(QXmlStreamReader &reader)
@@ -55,7 +34,7 @@ void KeywordList::load(QXmlStreamReader &reader)
Q_ASSERT(reader.name() == QLatin1String("list"));
Q_ASSERT(reader.tokenType() == QXmlStreamReader::StartElement);
- m_name = reader.attributes().value(QStringLiteral("name")).toString();
+ m_name = reader.attributes().value(QLatin1String("name")).toString();
while (!reader.atEnd()) {
switch (reader.tokenType()) {
@@ -105,17 +84,13 @@ void KeywordList::initLookupForCaseSensitivity(Qt::CaseSensitivity caseSensitive
*/
vectorToSort.reserve(m_keywords.size());
for (const auto &keyword : qAsConst(m_keywords)) {
- vectorToSort.emplace_back(keyword);
+ vectorToSort.push_back(keyword);
}
/**
* sort with right predicate
*/
- std::sort(vectorToSort.begin(),
- vectorToSort.end(),
- [caseSensitive](const QStringView &a, const QStringView &b) {
- return a.compare(b, caseSensitive) < 0;
- });
+ std::sort(vectorToSort.begin(), vectorToSort.end(), [caseSensitive](const QStringView &a, const QStringView &b) { return a.compare(b, caseSensitive) < 0; });
}
void KeywordList::resolveIncludeKeywords(DefinitionData &def)
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/keywordlist_p.h b/src/libs/3rdparty/syntax-highlighting/src/lib/keywordlist_p.h
index de39a8731ba..68b1ec6290e 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/keywordlist_p.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/keywordlist_p.h
@@ -1,30 +1,15 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause
+ SPDX-FileCopyrightText: 2020 Jonathan Poelen
- 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-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_KEYWORDLIST_P_H
#define KSYNTAXHIGHLIGHTING_KEYWORDLIST_P_H
#include
+#include
#include
#include
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/matchresult_p.h b/src/libs/3rdparty/syntax-highlighting/src/lib/matchresult_p.h
index c79801dd3df..1e0f7c61027 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/matchresult_p.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/matchresult_p.h
@@ -1,24 +1,7 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause
- 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-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_MATCHRESULT_P_H
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/repository.cpp b/src/libs/3rdparty/syntax-highlighting/src/lib/repository.cpp
index c45dfa7d3cf..2252bc67d24 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/repository.cpp
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/repository.cpp
@@ -1,24 +1,7 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause
- 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-License-Identifier: MIT
*/
#include "repository.h"
@@ -92,8 +75,9 @@ QVector Repository::definitionsForFileName(const QString &fileName)
QFileInfo fi(fileName);
const auto name = fi.fileName();
+ // use d->m_defs, sorted map by highlighting name, to be deterministic and independent of translations
QVector candidates;
- for (const Definition &def : qAsConst(d->m_sortedDefs)) {
+ for (const Definition &def : qAsConst(d->m_defs)) {
for (const auto &pattern : def.extensions()) {
if (WildcardMatcher::exactMatch(name, pattern)) {
candidates.push_back(def);
@@ -113,8 +97,9 @@ Definition Repository::definitionForMimeType(const QString &mimeType) const
QVector Repository::definitionsForMimeType(const QString &mimeType) const
{
+ // use d->m_defs, sorted map by highlighting name, to be deterministic and independent of translations
QVector candidates;
- for (const Definition &def : qAsConst(d->m_sortedDefs)) {
+ for (const Definition &def : qAsConst(d->m_defs)) {
for (const auto &matchType : def.mimeTypes()) {
if (mimeType == matchType) {
candidates.push_back(def);
@@ -152,7 +137,7 @@ Theme Repository::defaultTheme(Repository::DefaultTheme t)
{
if (t == DarkTheme)
return theme(QLatin1String("Breeze Dark"));
- return theme(QLatin1String("Default"));
+ return theme(QLatin1String("Breeze Light"));
}
void RepositoryPrivate::load(Repository *repo)
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/repository.h b/src/libs/3rdparty/syntax-highlighting/src/lib/repository.h
index 555dbe983e9..9da44746852 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/repository.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/repository.h
@@ -1,24 +1,7 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause
- 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-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_REPOSITORY_H
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/repository_p.h b/src/libs/3rdparty/syntax-highlighting/src/lib/repository_p.h
index 81cba479429..447cfae6990 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/repository_p.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/repository_p.h
@@ -1,24 +1,7 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause
- 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-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_REPOSITORY_P_H
@@ -58,7 +41,10 @@ public:
QVector m_customSearchPaths;
- QHash m_defs;
+ // sorted map to have deterministic iteration order for e.g. definitionsForFileName
+ QMap m_defs;
+
+ // this vector is sorted by translated sections/names
QVector m_sortedDefs;
QVector m_themes;
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/rule.cpp b/src/libs/3rdparty/syntax-highlighting/src/lib/rule.cpp
index ad741469549..22f59e02114 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/rule.cpp
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/rule.cpp
@@ -1,25 +1,9 @@
/*
- Copyright (C) 2016 Volker Krause
- Copyright (C) 2018 Christoph Cullmann
+ SPDX-FileCopyrightText: 2016 Volker Krause
+ SPDX-FileCopyrightText: 2018 Christoph Cullmann
+ SPDX-FileCopyrightText: 2020 Jonathan Poelen
- 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-License-Identifier: MIT
*/
#include "context_p.h"
@@ -27,21 +11,29 @@
#include "ksyntaxhighlighting_logging.h"
#include "rule_p.h"
#include "xml_p.h"
+#include "worddelimiters_p.h"
#include
#include
using namespace KSyntaxHighlighting;
+// QChar::isDigit() match any digit in unicode (romain numeral, etc)
+static bool isDigit(QChar c)
+{
+ return (c <= QLatin1Char('9') && QLatin1Char('0') <= c);
+}
+
static bool isOctalChar(QChar c)
{
- return c.isNumber() && c != QLatin1Char('9') && c != QLatin1Char('8');
+ return (c <= QLatin1Char('7') && QLatin1Char('0') <= c);
}
static bool isHexChar(QChar c)
{
- return c.isNumber() || c == QLatin1Char('a') || c == QLatin1Char('A') || c == QLatin1Char('b') || c == QLatin1Char('B') || c == QLatin1Char('c') || c == QLatin1Char('C') || c == QLatin1Char('d') || c == QLatin1Char('D') ||
- c == QLatin1Char('e') || c == QLatin1Char('E') || c == QLatin1Char('f') || c == QLatin1Char('F');
+ return isDigit(c)
+ || (c <= QLatin1Char('f') && QLatin1Char('a') <= c)
+ || (c <= QLatin1Char('F') && QLatin1Char('A') <= c);
}
static int matchEscapedChar(const QString &text, int offset)
@@ -50,30 +42,31 @@ static int matchEscapedChar(const QString &text, int offset)
return offset;
const auto c = text.at(offset + 1);
- static const auto controlChars = QStringLiteral("abefnrtv\"'?\\");
- if (controlChars.contains(c))
+ switch (c.unicode()) {
+ // control chars
+ case 'a': case 'b': case 'e': case 'f':
+ case 'n': case 'r': case 't': case 'v':
+ case '"': case '\'': case '?': case '\\':
return offset + 2;
// hex encoded character
- if (c == QLatin1Char('x')) {
- auto newOffset = offset + 2;
- for (int i = 0; i < 2 && newOffset + i < text.size(); ++i, ++newOffset) {
- if (!isHexChar(text.at(newOffset)))
- break;
+ case 'x':
+ if (offset + 2 < text.size() && isHexChar(text.at(offset + 2))) {
+ if (offset + 3 < text.size() && isHexChar(text.at(offset + 3)))
+ return offset + 4;
+ return offset + 3;
}
- if (newOffset == offset + 2)
- return offset;
- return newOffset;
- }
+ return offset;
// octal encoding, simple \0 is OK, too, unlike simple \x above
- if (isOctalChar(c)) {
- auto newOffset = offset + 2;
- for (int i = 0; i < 2 && newOffset + i < text.size(); ++i, ++newOffset) {
- if (!isOctalChar(text.at(newOffset)))
- break;
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ if (offset + 2 < text.size() && isOctalChar(text.at(offset + 2))) {
+ if (offset + 3 < text.size() && isOctalChar(text.at(offset + 3)))
+ return offset + 4;
+ return offset + 3;
}
- return newOffset;
+ return offset + 2;
}
return offset;
@@ -102,13 +95,13 @@ bool Rule::load(QXmlStreamReader &reader)
{
Q_ASSERT(reader.tokenType() == QXmlStreamReader::StartElement);
- m_attribute = reader.attributes().value(QStringLiteral("attribute")).toString();
+ m_attribute = reader.attributes().value(QLatin1String("attribute")).toString();
if (reader.name() != QLatin1String("IncludeRules")) // IncludeRules uses this with a different semantic
- m_context.parse(reader.attributes().value(QStringLiteral("context")));
- m_firstNonSpace = Xml::attrToBool(reader.attributes().value(QStringLiteral("firstNonSpace")));
- m_lookAhead = Xml::attrToBool(reader.attributes().value(QStringLiteral("lookAhead")));
+ m_context.parse(reader.attributes().value(QLatin1String("context")));
+ m_firstNonSpace = Xml::attrToBool(reader.attributes().value(QLatin1String("firstNonSpace")));
+ m_lookAhead = Xml::attrToBool(reader.attributes().value(QLatin1String("lookAhead")));
bool colOk = false;
- m_column = reader.attributes().value(QStringLiteral("column")).toInt(&colOk);
+ m_column = reader.attributes().value(QLatin1String("column")).toInt(&colOk);
if (!colOk)
m_column = -1;
@@ -131,10 +124,12 @@ bool Rule::load(QXmlStreamReader &reader)
void Rule::resolveContext()
{
- m_context.resolve(m_def.definition());
+ auto const& def = m_def.definition();
+
+ m_context.resolve(def);
// cache for DefinitionData::wordDelimiters, is accessed VERY often
- m_wordDelimiter = DefinitionData::get(m_def.definition())->wordDelimiters;
+ m_wordDelimiters = &DefinitionData::get(def)->wordDelimiters;
}
void Rule::resolveAttributeFormat(Context *lookupContext)
@@ -158,58 +153,55 @@ bool Rule::doLoad(QXmlStreamReader &reader)
Rule::Ptr Rule::create(const QStringView &name)
{
- Rule *rule = nullptr;
if (name == QLatin1String("AnyChar"))
- rule = new AnyChar;
- else if (name == QLatin1String("DetectChar"))
- rule = new DetectChar;
- else if (name == QLatin1String("Detect2Chars"))
- rule = new Detect2Char;
- else if (name == QLatin1String("DetectIdentifier"))
- rule = new DetectIdentifier;
- else if (name == QLatin1String("DetectSpaces"))
- rule = new DetectSpaces;
- else if (name == QLatin1String("Float"))
- rule = new Float;
- else if (name == QLatin1String("Int"))
- rule = new Int;
- else if (name == QLatin1String("HlCChar"))
- rule = new HlCChar;
- else if (name == QLatin1String("HlCHex"))
- rule = new HlCHex;
- else if (name == QLatin1String("HlCOct"))
- rule = new HlCOct;
- else if (name == QLatin1String("HlCStringChar"))
- rule = new HlCStringChar;
- else if (name == QLatin1String("IncludeRules"))
- rule = new IncludeRules;
- else if (name == QLatin1String("keyword"))
- rule = new KeywordListRule;
- else if (name == QLatin1String("LineContinue"))
- rule = new LineContinue;
- else if (name == QLatin1String("RangeDetect"))
- rule = new RangeDetect;
- else if (name == QLatin1String("RegExpr"))
- rule = new RegExpr;
- else if (name == QLatin1String("StringDetect"))
- rule = new StringDetect;
- else if (name == QLatin1String("WordDetect"))
- rule = new WordDetect;
- else
- qCWarning(Log) << "Unknown rule type:" << name;
+ return std::make_shared();
+ if (name == QLatin1String("DetectChar"))
+ return std::make_shared();
+ if (name == QLatin1String("Detect2Chars"))
+ return std::make_shared();
+ if (name == QLatin1String("DetectIdentifier"))
+ return std::make_shared();
+ if (name == QLatin1String("DetectSpaces"))
+ return std::make_shared();
+ if (name == QLatin1String("Float"))
+ return std::make_shared();
+ if (name == QLatin1String("Int"))
+ return std::make_shared();
+ if (name == QLatin1String("HlCChar"))
+ return std::make_shared();
+ if (name == QLatin1String("HlCHex"))
+ return std::make_shared();
+ if (name == QLatin1String("HlCOct"))
+ return std::make_shared();
+ if (name == QLatin1String("HlCStringChar"))
+ return std::make_shared();
+ if (name == QLatin1String("IncludeRules"))
+ return std::make_shared();
+ if (name == QLatin1String("keyword"))
+ return std::make_shared();
+ if (name == QLatin1String("LineContinue"))
+ return std::make_shared();
+ if (name == QLatin1String("RangeDetect"))
+ return std::make_shared();
+ if (name == QLatin1String("RegExpr"))
+ return std::make_shared();
+ if (name == QLatin1String("StringDetect"))
+ return std::make_shared();
+ if (name == QLatin1String("WordDetect"))
+ return std::make_shared();
- return Ptr(rule);
+ qCWarning(Log) << "Unknown rule type:" << name;
+ return Ptr(nullptr);
}
bool Rule::isWordDelimiter(QChar c) const
{
- // perf tells contains is MUCH faster than binary search here, very short array
- return m_wordDelimiter.contains(c);
+ return m_wordDelimiters->contains(c);
}
bool AnyChar::doLoad(QXmlStreamReader &reader)
{
- m_chars = reader.attributes().value(QStringLiteral("String")).toString();
+ m_chars = reader.attributes().value(QLatin1String("String")).toString();
if (m_chars.size() == 1)
qCDebug(Log) << "AnyChar rule with just one char: use DetectChar instead.";
return !m_chars.isEmpty();
@@ -224,11 +216,11 @@ MatchResult AnyChar::doMatch(const QString &text, int offset, const QStringList
bool DetectChar::doLoad(QXmlStreamReader &reader)
{
- const auto s = reader.attributes().value(QStringLiteral("char"));
+ const auto s = reader.attributes().value(QLatin1String("char"));
if (s.isEmpty())
return false;
m_char = s.at(0);
- m_dynamic = Xml::attrToBool(reader.attributes().value(QStringLiteral("dynamic")));
+ m_dynamic = Xml::attrToBool(reader.attributes().value(QLatin1String("dynamic")));
if (m_dynamic) {
m_captureIndex = m_char.digitValue();
}
@@ -252,8 +244,8 @@ MatchResult DetectChar::doMatch(const QString &text, int offset, const QStringLi
bool Detect2Char::doLoad(QXmlStreamReader &reader)
{
- const auto s1 = reader.attributes().value(QStringLiteral("char"));
- const auto s2 = reader.attributes().value(QStringLiteral("char1"));
+ const auto s1 = reader.attributes().value(QLatin1String("char"));
+ const auto s2 = reader.attributes().value(QLatin1String("char1"));
if (s1.isEmpty() || s2.isEmpty())
return false;
m_char1 = s1.at(0);
@@ -297,14 +289,14 @@ MatchResult Float::doMatch(const QString &text, int offset, const QStringList &)
return offset;
auto newOffset = offset;
- while (newOffset < text.size() && text.at(newOffset).isDigit())
+ while (newOffset < text.size() && isDigit(text.at(newOffset)))
++newOffset;
if (newOffset >= text.size() || text.at(newOffset) != QLatin1Char('.'))
return offset;
++newOffset;
- while (newOffset < text.size() && text.at(newOffset).isDigit())
+ while (newOffset < text.size() && isDigit(text.at(newOffset)))
++newOffset;
if (newOffset == offset + 1) // we only found a decimal point
@@ -318,7 +310,7 @@ MatchResult Float::doMatch(const QString &text, int offset, const QStringList &)
if (expOffset < text.size() && (text.at(expOffset) == QLatin1Char('+') || text.at(expOffset) == QLatin1Char('-')))
++expOffset;
bool foundExpDigit = false;
- while (expOffset < text.size() && text.at(expOffset).isDigit()) {
+ while (expOffset < text.size() && isDigit(text.at(expOffset))) {
++expOffset;
foundExpDigit = true;
}
@@ -446,7 +438,7 @@ MatchResult Int::doMatch(const QString &text, int offset, const QStringList &) c
if (offset > 0 && !isWordDelimiter(text.at(offset - 1)))
return offset;
- while (offset < text.size() && text.at(offset).isDigit())
+ while (offset < text.size() && isDigit(text.at(offset)))
++offset;
return offset;
}
@@ -500,7 +492,7 @@ MatchResult KeywordListRule::doMatch(const QString &text, int offset, const QStr
bool LineContinue::doLoad(QXmlStreamReader &reader)
{
- const auto s = reader.attributes().value(QStringLiteral("char"));
+ const auto s = reader.attributes().value(QLatin1String("char"));
if (s.isEmpty())
m_char = QLatin1Char('\\');
else
@@ -517,8 +509,8 @@ MatchResult LineContinue::doMatch(const QString &text, int offset, const QString
bool RangeDetect::doLoad(QXmlStreamReader &reader)
{
- const auto s1 = reader.attributes().value(QStringLiteral("char"));
- const auto s2 = reader.attributes().value(QStringLiteral("char1"));
+ const auto s1 = reader.attributes().value(QLatin1String("char"));
+ const auto s2 = reader.attributes().value(QLatin1String("char1"));
if (s1.isEmpty() || s2.isEmpty())
return false;
m_begin = s1.at(0);
@@ -544,14 +536,14 @@ MatchResult RangeDetect::doMatch(const QString &text, int offset, const QStringL
bool RegExpr::doLoad(QXmlStreamReader &reader)
{
- m_regexp.setPattern(reader.attributes().value(QStringLiteral("String")).toString());
+ m_regexp.setPattern(reader.attributes().value(QLatin1String("String")).toString());
- const auto isMinimal = Xml::attrToBool(reader.attributes().value(QStringLiteral("minimal")));
- const auto isCaseInsensitive = Xml::attrToBool(reader.attributes().value(QStringLiteral("insensitive")));
+ const auto isMinimal = Xml::attrToBool(reader.attributes().value(QLatin1String("minimal")));
+ const auto isCaseInsensitive = Xml::attrToBool(reader.attributes().value(QLatin1String("insensitive")));
m_regexp.setPatternOptions((isMinimal ? QRegularExpression::InvertedGreedinessOption : QRegularExpression::NoPatternOption) | (isCaseInsensitive ? QRegularExpression::CaseInsensitiveOption : QRegularExpression::NoPatternOption));
// optimize the pattern for the non-dynamic case, we use them OFTEN
- m_dynamic = Xml::attrToBool(reader.attributes().value(QStringLiteral("dynamic")));
+ m_dynamic = Xml::attrToBool(reader.attributes().value(QLatin1String("dynamic")));
if (!m_dynamic) {
m_regexp.optimize();
}
@@ -601,9 +593,9 @@ MatchResult RegExpr::doMatch(const QString &text, int offset, const QStringList
bool StringDetect::doLoad(QXmlStreamReader &reader)
{
- m_string = reader.attributes().value(QStringLiteral("String")).toString();
- m_caseSensitivity = Xml::attrToBool(reader.attributes().value(QStringLiteral("insensitive"))) ? Qt::CaseInsensitive : Qt::CaseSensitive;
- m_dynamic = Xml::attrToBool(reader.attributes().value(QStringLiteral("dynamic")));
+ m_string = reader.attributes().value(QLatin1String("String")).toString();
+ m_caseSensitivity = Xml::attrToBool(reader.attributes().value(QLatin1String("insensitive"))) ? Qt::CaseInsensitive : Qt::CaseSensitive;
+ m_dynamic = Xml::attrToBool(reader.attributes().value(QLatin1String("dynamic")));
return !m_string.isEmpty();
}
@@ -622,8 +614,8 @@ MatchResult StringDetect::doMatch(const QString &text, int offset, const QString
bool WordDetect::doLoad(QXmlStreamReader &reader)
{
- m_word = reader.attributes().value(QStringLiteral("String")).toString();
- m_caseSensitivity = Xml::attrToBool(reader.attributes().value(QStringLiteral("insensitive"))) ? Qt::CaseInsensitive : Qt::CaseSensitive;
+ m_word = reader.attributes().value(QLatin1String("String")).toString();
+ m_caseSensitivity = Xml::attrToBool(reader.attributes().value(QLatin1String("insensitive"))) ? Qt::CaseInsensitive : Qt::CaseSensitive;
return !m_word.isEmpty();
}
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/rule_p.h b/src/libs/3rdparty/syntax-highlighting/src/lib/rule_p.h
index 484687bc0a0..788aecdad3f 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/rule_p.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/rule_p.h
@@ -1,24 +1,8 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause
+ SPDX-FileCopyrightText: 2020 Jonathan Poelen
- 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-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_RULE_P_H
@@ -43,6 +27,8 @@ QT_END_NAMESPACE
namespace KSyntaxHighlighting
{
+class WordDelimiters;
+
class Rule
{
public:
@@ -121,7 +107,7 @@ private:
bool m_lookAhead = false;
// cache for DefinitionData::wordDelimiters, is accessed VERY often
- QStringView m_wordDelimiter;
+ WordDelimiters* m_wordDelimiters = nullptr;
protected:
bool m_dynamic = false;
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/state.cpp b/src/libs/3rdparty/syntax-highlighting/src/lib/state.cpp
index dfb4d0c24ad..f9b4f4b4ab0 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/state.cpp
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/state.cpp
@@ -1,25 +1,8 @@
/*
- Copyright (C) 2016 Volker Krause
- Copyright (C) 2018 Christoph Cullmann
+ SPDX-FileCopyrightText: 2016 Volker Krause
+ SPDX-FileCopyrightText: 2018 Christoph Cullmann
- 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-License-Identifier: MIT
*/
#include "state.h"
@@ -33,7 +16,12 @@ using namespace KSyntaxHighlighting;
StateData *StateData::get(State &state)
{
- state.d.detach();
+ // create state data on demand, to make default state construction cheap
+ if (!state.d) {
+ state.d = new StateData();
+ } else {
+ state.d.detach();
+ }
return state.d.data();
}
@@ -85,7 +73,6 @@ const QStringList &StateData::topCaptures() const
}
State::State()
- : d(new StateData)
{
}
@@ -107,7 +94,7 @@ State &State::operator=(const State &other)
bool State::operator==(const State &other) const
{
// use pointer equal as shortcut for shared states
- return (d == other.d) || (d->m_contextStack == other.d->m_contextStack && d->m_defRef == other.d->m_defRef);
+ return (d == other.d) || (d && other.d && d->m_contextStack == other.d->m_contextStack && d->m_defRef == other.d->m_defRef);
}
bool State::operator!=(const State &other) const
@@ -117,7 +104,7 @@ bool State::operator!=(const State &other) const
bool State::indentationBasedFoldingEnabled() const
{
- if (d->m_contextStack.isEmpty())
+ if (!d || d->m_contextStack.isEmpty())
return false;
return d->m_contextStack.last().first->indentationBasedFoldingEnabled();
}
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/state.h b/src/libs/3rdparty/syntax-highlighting/src/lib/state.h
index ed632746958..726ff32a884 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/state.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/state.h
@@ -1,24 +1,7 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause
- 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-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_STATE_H
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/state_p.h b/src/libs/3rdparty/syntax-highlighting/src/lib/state_p.h
index 1156ce981a0..d76f84c93bb 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/state_p.h
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/state_p.h
@@ -1,25 +1,8 @@
/*
- Copyright (C) 2016 Volker Krause
- Copyright (C) 2018 Christoph Cullmann
+ SPDX-FileCopyrightText: 2016 Volker Krause
+ SPDX-FileCopyrightText: 2018 Christoph Cullmann
- 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-License-Identifier: MIT
*/
#ifndef KSYNTAXHIGHLIGHTING_STATE_P_H
diff --git a/src/libs/3rdparty/syntax-highlighting/src/lib/syntaxhighlighter.cpp b/src/libs/3rdparty/syntax-highlighting/src/lib/syntaxhighlighter.cpp
index a6bccffdd42..d0c4ee98ae8 100644
--- a/src/libs/3rdparty/syntax-highlighting/src/lib/syntaxhighlighter.cpp
+++ b/src/libs/3rdparty/syntax-highlighting/src/lib/syntaxhighlighter.cpp
@@ -1,24 +1,7 @@
/*
- Copyright (C) 2016 Volker Krause
+ SPDX-FileCopyrightText: 2016 Volker Krause