Commit 38ffd39e authored by Thomas Schöps's avatar Thomas Schöps

Merge branch '5.4'

parents 360bf1b5 54597a6a
Pipeline #11511 failed with stage
in 60 minutes and 2 seconds
......@@ -47,6 +47,8 @@
#include <language/interfaces/editorcontext.h>
#include <language/backgroundparser/backgroundparser.h>
#include <util/foregroundlock.h>
#include "core.h"
#include "mainwindow.h"
#include "uicontroller.h"
......@@ -527,6 +529,7 @@ KTextEditor::Range TextDocument::textSelection() const
QString TextDocument::text(const KTextEditor::Range &range) const
{
VERIFY_FOREGROUND_LOCKED
Q_D(const TextDocument);
if (!d->document) {
......@@ -538,6 +541,7 @@ QString TextDocument::text(const KTextEditor::Range &range) const
QString TextDocument::textLine() const
{
VERIFY_FOREGROUND_LOCKED
Q_D(const TextDocument);
if (!d->document) {
......@@ -555,6 +559,7 @@ QString TextDocument::textLine() const
QString TextDocument::textWord() const
{
VERIFY_FOREGROUND_LOCKED
Q_D(const TextDocument);
if (!d->document) {
......
......@@ -148,7 +148,8 @@ public:
bool KDevelop::ForegroundLock::isLockedForThread()
{
return QThread::currentThread() == holderThread;
return QThread::currentThread() == holderThread ||
QThread::currentThread() == QApplication::instance()->thread();
}
bool KDevelop::ForegroundLock::tryLock()
......
......@@ -25,6 +25,7 @@
#include "util/clangtypes.h"
#include "util/clangdebug.h"
#include "util/clangutils.h"
#include <language/duchain/duchainlock.h>
#include <language/codegen/documentchangeset.h>
......@@ -66,7 +67,7 @@ inline QString prettyDiagnosticSpelling(const QString& str)
return ret;
}
ClangFixits fixitsForDiagnostic(CXDiagnostic diagnostic)
ClangFixits fixitsForDiagnostic(CXDiagnostic diagnostic, CXTranslationUnit unit)
{
ClangFixits fixits;
auto numFixits = clang_getDiagnosticNumFixIts(diagnostic);
......@@ -74,12 +75,8 @@ ClangFixits fixitsForDiagnostic(CXDiagnostic diagnostic)
for (uint i = 0; i < numFixits; ++i) {
CXSourceRange range;
const QString replacementText = ClangString(clang_getDiagnosticFixIt(diagnostic, i, &range)).toString();
const auto docRange = ClangRange(range).toDocumentRange();
auto doc = KDevelop::ICore::self()->documentController()->documentForUrl(docRange.document.toUrl());
const QString original = doc ? doc->text(docRange) : QString{};
fixits << ClangFixit{replacementText, docRange, QString(), original};
QByteArray original = ClangUtils::getRawContents(unit, range);
fixits << ClangFixit{replacementText, ClangRange(range).toDocumentRange(), QString(), QString::fromLocal8Bit(original)};
}
return fixits;
}
......@@ -168,7 +165,7 @@ ClangProblem::ClangProblem(CXDiagnostic diagnostic, CXTranslationUnit unit)
}
}
setFixits(fixitsForDiagnostic(diagnostic));
setFixits(fixitsForDiagnostic(diagnostic, unit));
setFinalLocation(docRange);
setSource(IProblem::SemanticAnalysis);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment