Merge remote-tracking branch 'origin/4.6'

Conflicts:
	src/plugins/coreplugin/locator/locator.cpp
	src/plugins/imageviewer/imageviewerplugin.cpp
	src/plugins/remotelinux/remotelinuxplugin.cpp
	src/tools/clangbackend/source/tokeninfo.cpp
	tests/unit/unittest/data/highlightingmarks.cpp

Change-Id: I74cc3ba3a2836cb9d0e65d3380d8c4f88d720c67
This commit is contained in:
Eike Ziller
2018-02-07 11:58:23 +01:00
119 changed files with 1204 additions and 589 deletions

View File

@@ -558,9 +558,8 @@ ClangCompletionAssistProcessor::extractLineColumn(int position)
int line = -1, column = -1;
::Utils::Text::convertPosition(m_interface->textDocument(), position, &line, &column);
const QTextBlock block = m_interface->textDocument()->findBlock(position);
const QString stringOnTheLeft = block.text().left(column);
column = stringOnTheLeft.toUtf8().size() + 1; // '+ 1' is for 1-based columns
column = Utils::clangColumn(m_interface->textDocument()->findBlock(position), column);
return {line, column};
}

View File

@@ -64,6 +64,9 @@ int positionInText(QTextDocument *textDocument,
{
auto textBlock = textDocument->findBlockByNumber(
static_cast<int>(sourceLocationContainer.line()) - 1);
// 'sourceLocationContainer' already has the CppEditor column converted from
// the utf8 byte offset from the beginning of the line provided by clang.
// - 1 is required for 0-based columns.
const int column = static_cast<int>(sourceLocationContainer.column()) - 1;
return textBlock.position() + column;
}

View File

@@ -356,9 +356,7 @@ ClangEditorDocumentProcessor::cursorInfo(const CppTools::CursorInfoParams &param
if (!isCursorOnIdentifier(params.textCursor))
return defaultCursorInfoFuture();
const QTextBlock block = params.textCursor.document()->findBlockByNumber(line - 1);
const QString stringOnTheLeft = block.text().left(column);
column = stringOnTheLeft.toUtf8().size() + 1; // '+ 1' is for 1-based columns
column = Utils::clangColumn(params.textCursor.document()->findBlockByNumber(line - 1), column);
const CppTools::SemanticInfo::LocalUseMap localUses
= CppTools::BuiltinCursorInfo::findLocalUses(params.semanticInfo.doc, line, column);

View File

@@ -43,6 +43,7 @@
#include <QDir>
#include <QFile>
#include <QStringList>
#include <QTextBlock>
using namespace ClangCodeModel;
using namespace ClangCodeModel::Internal;
@@ -190,5 +191,15 @@ void setLastSentDocumentRevision(const QString &filePath, uint revision)
document->sendTracker().setLastSentRevision(int(revision));
}
int clangColumn(const QTextBlock &line, int cppEditorColumn)
{
// (1) cppEditorColumn is the actual column shown by CppEditor.
// (2) The return value is the column in Clang which is the utf8 byte offset from the beginning
// of the line.
// Here we convert column from (1) to (2).
// '+ 1' is for 1-based columns
return line.text().left(cppEditorColumn).toUtf8().size() + 1;
}
} // namespace Utils
} // namespace Clang

View File

@@ -27,6 +27,10 @@
#include <cpptools/projectpart.h>
QT_BEGIN_NAMESPACE
class QTextBlock;
QT_END_NAMESPACE
namespace CppTools {
class CppEditorDocumentHandle;
}
@@ -46,6 +50,7 @@ CppTools::ProjectPart::Ptr projectPartForFile(const QString &filePath);
CppTools::ProjectPart::Ptr projectPartForFileBasedOnProcessor(const QString &filePath);
bool isProjectPartLoaded(const CppTools::ProjectPart::Ptr projectPart);
QString projectPartIdForFile(const QString &filePath);
int clangColumn(const QTextBlock &lineText, int cppEditorColumn);
} // namespace Utils
} // namespace Clang