diff --git a/src/libs/clangsupport/lineprefixer.cpp b/src/libs/clangsupport/lineprefixer.cpp index b11f98e7a76..bdd8df4667b 100644 --- a/src/libs/clangsupport/lineprefixer.cpp +++ b/src/libs/clangsupport/lineprefixer.cpp @@ -50,7 +50,7 @@ QByteArray LinePrefixer::prefix(const QByteArray &text) m_previousIsEndingWithNewLine = false; } - output.replace("\n", "\n" + m_prefix); + output.replace("\n", QByteArray("\n" + m_prefix)); if (m_previousIsEndingWithNewLine) output.append('\n'); diff --git a/src/libs/clangsupport/messageenvelop.h b/src/libs/clangsupport/messageenvelop.h index 1010ad72fa1..07c2cf46244 100644 --- a/src/libs/clangsupport/messageenvelop.h +++ b/src/libs/clangsupport/messageenvelop.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace ClangBackEnd { diff --git a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp index 24ad1b9b2d2..5dbfd4e94d8 100644 --- a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp +++ b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp @@ -55,8 +55,9 @@ #include #include #include -#include +#include #include +#include #include #include @@ -450,9 +451,9 @@ bool ClangCompletionAssistProcessor::accepts() const && tokens.at(1).kind() == T_IDENTIFIER) { const QString &line = tc.block().text(); const Token &idToken = tokens.at(1); - const QStringRef &identifier = - line.midRef(idToken.bytesBegin(), - idToken.bytesEnd() - idToken.bytesBegin()); + const QStringView &identifier = Utils::midView(line, + idToken.utf16charsBegin(), + idToken.utf16chars()); if (identifier == QLatin1String("include") || identifier == QLatin1String("include_next") || (m_interface->objcEnabled() && identifier == QLatin1String("import"))) { diff --git a/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.h b/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.h index 6469a0ff5f5..c5f8bb607ee 100644 --- a/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.h +++ b/src/plugins/clangcodemodel/clangdiagnostictooltipwidget.h @@ -29,6 +29,7 @@ QT_BEGIN_NAMESPACE class QLayout; +class QWidget; QT_END_NAMESPACE namespace ClangCodeModel { diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index 6efcb8501ea..c29359a531d 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -172,7 +172,7 @@ bool ClangEditorDocumentProcessor::isParserRunning() const bool ClangEditorDocumentProcessor::hasProjectPart() const { - return m_projectPart; + return !m_projectPart.isNull(); } CppTools::ProjectPart::Ptr ClangEditorDocumentProcessor::projectPart() const diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp index 57f0170faab..f46b455197d 100644 --- a/src/plugins/clangcodemodel/clangutils.cpp +++ b/src/plugins/clangcodemodel/clangutils.cpp @@ -129,7 +129,7 @@ ProjectPart::Ptr projectPartForFileBasedOnProcessor(const QString &filePath) bool isProjectPartLoaded(const ProjectPart::Ptr projectPart) { if (projectPart) - return CppModelManager::instance()->projectPartForId(projectPart->id()); + return !CppModelManager::instance()->projectPartForId(projectPart->id()).isNull(); return false; } diff --git a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp index 3c3c8f361ea..7014c57bede 100644 --- a/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp +++ b/src/plugins/cppeditor/cppdocumentationcommenthelper.cpp @@ -162,13 +162,15 @@ bool handleDoxygenCppStyleContinuation(QTextCursor &cursor) // If the line does not start with the comment we don't // consider it as a continuation. Handles situations like: // void d(); /// - const QStringRef commentMarker = text.midRef(offset, 3); + if (offset + 3 > text.size()) + return false; + const QStringView commentMarker = QStringView(text).mid(offset, 3); if (commentMarker != QLatin1String("///") && commentMarker != QLatin1String("//!")) return false; QString newLine(QLatin1Char('\n')); - newLine.append(text.leftRef(offset)); // indent correctly - newLine.append(commentMarker); + newLine.append(text.left(offset)); // indent correctly + newLine.append(commentMarker.toString()); newLine.append(QLatin1Char(' ')); cursor.insertText(newLine); diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index 51aa17eed40..ecdfbf56d18 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -33,6 +33,8 @@ #include #include +#include + #include using namespace CppEditor; @@ -150,11 +152,10 @@ void CppHighlighter::highlightBlock(const QString &text) setFormatWithSpaces(text, tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_PREPROCESSOR)); expectPreprocessorKeyword = true; - } else if (highlightCurrentWordAsPreprocessor - && (tk.isKeyword() || tk.is(T_IDENTIFIER)) - && isPPKeyword(text.midRef(tk.utf16charsBegin(), tk.utf16chars()))) { + } else if (highlightCurrentWordAsPreprocessor && (tk.isKeyword() || tk.is(T_IDENTIFIER)) + && isPPKeyword(Utils::midView(text, tk.utf16charsBegin(), tk.utf16chars()))) { setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_PREPROCESSOR)); - const QStringRef ppKeyword = text.midRef(tk.utf16charsBegin(), tk.utf16chars()); + const QStringView ppKeyword = Utils::midView(text, tk.utf16charsBegin(), tk.utf16chars()); if (ppKeyword == QLatin1String("error") || ppKeyword == QLatin1String("warning") || ppKeyword == QLatin1String("pragma")) { @@ -198,7 +199,8 @@ void CppHighlighter::highlightBlock(const QString &text) } else if (tk.isKeyword() || (m_languageFeatures.qtKeywordsEnabled - && CppTools::isQtKeyword(QStringView{text}.mid(tk.utf16charsBegin(), tk.utf16chars()))) + && CppTools::isQtKeyword( + QStringView{text}.mid(tk.utf16charsBegin(), tk.utf16chars()))) || (m_languageFeatures.objCEnabled && tk.isObjCAtKeyword())) { setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_KEYWORD)); } else if (tk.isPrimitiveType()) { @@ -211,7 +213,8 @@ void CppHighlighter::highlightBlock(const QString &text) } else if (i == 0 && tokens.size() > 1 && tk.is(T_IDENTIFIER) && tokens.at(1).is(T_COLON)) { setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_LABEL)); } else if (tk.is(T_IDENTIFIER)) { - highlightWord(text.midRef(tk.utf16charsBegin(), tk.utf16chars()), tk.utf16charsBegin(), + highlightWord(Utils::midView(text, tk.utf16charsBegin(), tk.utf16chars()), + tk.utf16charsBegin(), tk.utf16chars()); } } @@ -274,7 +277,7 @@ void CppHighlighter::setLanguageFeatures(const LanguageFeatures &languageFeature } } -bool CppHighlighter::isPPKeyword(const QStringRef &text) const +bool CppHighlighter::isPPKeyword(const QStringView &text) const { switch (text.length()) { @@ -348,7 +351,7 @@ bool CppHighlighter::isPPKeyword(const QStringRef &text) const return false; } -void CppHighlighter::highlightWord(QStringRef word, int position, int length) +void CppHighlighter::highlightWord(QStringView word, int position, int length) { // try to highlight Qt 'identifiers' like QObject and Q_PROPERTY diff --git a/src/plugins/cppeditor/cpphighlighter.h b/src/plugins/cppeditor/cpphighlighter.h index eb7f861a7ac..7e55fa4ad88 100644 --- a/src/plugins/cppeditor/cpphighlighter.h +++ b/src/plugins/cppeditor/cpphighlighter.h @@ -46,13 +46,13 @@ public: void highlightBlock(const QString &text) override; private: - void highlightWord(QStringRef word, int position, int length); + void highlightWord(QStringView word, int position, int length); bool highlightRawStringLiteral(const QStringView &text, const CPlusPlus::Token &tk); void highlightDoxygenComment(const QString &text, int position, int length); - bool isPPKeyword(const QStringRef &text) const; + bool isPPKeyword(const QStringView &text) const; private: CPlusPlus::LanguageFeatures m_languageFeatures = CPlusPlus::LanguageFeatures::defaultFeatures(); diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 942d13b5c5a..0853a46d93e 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -1807,7 +1807,7 @@ void ConvertNumericLiteral::match(const CppQuickFixInterface &interface, QuickFi ulong value = 0; const QString x = QString::fromUtf8(spell).left(numberLength); if (x.startsWith("0b", Qt::CaseInsensitive)) - value = x.midRef(2).toULong(&valid, 2); + value = x.mid(2).toULong(&valid, 2); else value = x.toULong(&valid, 0);