forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.8'
Conflicts: tests/unit/unittest/unittest.pro Change-Id: I4f0ab05f96ee60900a3a35fad4c7331238367593
This commit is contained in:
@@ -184,8 +184,9 @@ private:
|
||||
{
|
||||
CursorInfo result;
|
||||
|
||||
// findLocalUses operates with 1-based line and 0-based column
|
||||
const CppTools::SemanticInfo::LocalUseMap localUses
|
||||
= BuiltinCursorInfo::findLocalUses(m_document, m_line, m_column);
|
||||
= BuiltinCursorInfo::findLocalUses(m_document, m_line, m_column - 1);
|
||||
result.localUses = localUses;
|
||||
splitLocalUses(localUses, &result.useRanges, &result.unusedVariablesRanges);
|
||||
|
||||
@@ -216,8 +217,7 @@ private:
|
||||
bool good = false;
|
||||
foreach (const CppTools::SemanticInfo::Use &use, uses) {
|
||||
unsigned l = static_cast<unsigned>(m_line);
|
||||
// convertCursorPosition() returns a 0-based column number.
|
||||
unsigned c = static_cast<unsigned>(m_column + 1);
|
||||
unsigned c = static_cast<unsigned>(m_column);
|
||||
if (l == use.line && c >= use.column && c <= (use.column + use.length)) {
|
||||
good = true;
|
||||
break;
|
||||
|
||||
@@ -112,7 +112,6 @@ CppTools::CheckSymbols *createHighlighter(const CPlusPlus::Document::Ptr &doc,
|
||||
int line, column;
|
||||
convertPosition(textDocument, macro.utf16CharOffset(), &line, &column);
|
||||
|
||||
++column; //Highlighting starts at (column-1) --> compensate here
|
||||
Result use(line, column, macro.nameToQString().size(), SemanticHighlighter::MacroUse);
|
||||
macroUses.append(use);
|
||||
}
|
||||
|
||||
@@ -126,6 +126,9 @@ void ClangDiagnosticConfigsSelectionWidget::connectToClangDiagnosticConfigsDialo
|
||||
= settings->clangCustomDiagnosticConfigs();
|
||||
const ClangDiagnosticConfigs currentDiagnosticConfigs = widget->customConfigs();
|
||||
if (oldDiagnosticConfigs != currentDiagnosticConfigs) {
|
||||
const ClangDiagnosticConfigsModel configsModel(currentDiagnosticConfigs);
|
||||
if (!configsModel.hasConfigWithId(settings->clangDiagnosticConfigId()))
|
||||
settings->resetClangDiagnosticConfigId();
|
||||
settings->setClangCustomDiagnosticConfigs(currentDiagnosticConfigs);
|
||||
settings->toSettings(Core::ICore::settings());
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ Scope *CanonicalSymbol::getScopeAndExpression(const QTextCursor &cursor, QString
|
||||
QTextCursor tc = cursor;
|
||||
int line, column;
|
||||
Utils::Text::convertPosition(cursor.document(), tc.position(), &line, &column);
|
||||
++column; // 1-based line and 1-based column
|
||||
|
||||
int pos = tc.position();
|
||||
QTextDocument *textDocument = cursor.document();
|
||||
@@ -74,7 +73,7 @@ Scope *CanonicalSymbol::getScopeAndExpression(const QTextCursor &cursor, QString
|
||||
|
||||
ExpressionUnderCursor expressionUnderCursor(m_document->languageFeatures());
|
||||
*code = expressionUnderCursor(tc);
|
||||
return m_document->scopeAt(line, column);
|
||||
return m_document->scopeAt(line, column - 1);
|
||||
}
|
||||
|
||||
Symbol *CanonicalSymbol::operator()(const QTextCursor &cursor)
|
||||
|
||||
@@ -118,6 +118,12 @@ void CppCodeModelSettings::fromSettings(QSettings *s)
|
||||
setClangCustomDiagnosticConfigs(customDiagnosticConfigsFromSettings(s));
|
||||
setClangDiagnosticConfigId(clangDiagnosticConfigIdFromSettings(s));
|
||||
|
||||
{ // Before Qt Creator 4.8, inconsistent settings might have been written.
|
||||
const ClangDiagnosticConfigsModel model(m_clangCustomDiagnosticConfigs);
|
||||
if (!model.hasConfigWithId(m_clangDiagnosticConfigId))
|
||||
setClangDiagnosticConfigId(initialClangDiagnosticConfigId());
|
||||
}
|
||||
|
||||
const QVariant pchUsageVariant = s->value(pchUsageKey(), initialPchUsage());
|
||||
setPCHUsage(static_cast<PCHUsage>(pchUsageVariant.toInt()));
|
||||
|
||||
@@ -189,6 +195,11 @@ void CppCodeModelSettings::setClangDiagnosticConfigId(const Core::Id &configId)
|
||||
m_clangDiagnosticConfigId = configId;
|
||||
}
|
||||
|
||||
void CppCodeModelSettings::resetClangDiagnosticConfigId()
|
||||
{
|
||||
m_clangDiagnosticConfigId = initialClangDiagnosticConfigId();
|
||||
}
|
||||
|
||||
const ClangDiagnosticConfig CppCodeModelSettings::clangDiagnosticConfig() const
|
||||
{
|
||||
const ClangDiagnosticConfigsModel configsModel(m_clangCustomDiagnosticConfigs);
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
public:
|
||||
Core::Id clangDiagnosticConfigId() const;
|
||||
void setClangDiagnosticConfigId(const Core::Id &configId);
|
||||
void resetClangDiagnosticConfigId();
|
||||
const ClangDiagnosticConfig clangDiagnosticConfig() const;
|
||||
|
||||
ClangDiagnosticConfigs clangCustomDiagnosticConfigs() const;
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
|
||||
#include <texteditor/tabsettings.h>
|
||||
|
||||
#include <cplusplus/Overview.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -226,6 +228,31 @@ CppCodeStyleSettings CppCodeStyleSettings::currentGlobalCodeStyle()
|
||||
return cppCodeStylePreferences->currentCodeStyleSettings();
|
||||
}
|
||||
|
||||
TextEditor::TabSettings CppCodeStyleSettings::currentProjectTabSettings()
|
||||
{
|
||||
ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
|
||||
if (!project)
|
||||
return currentGlobalTabSettings();
|
||||
|
||||
ProjectExplorer::EditorConfiguration *editorConfiguration = project->editorConfiguration();
|
||||
QTC_ASSERT(editorConfiguration, return currentGlobalTabSettings());
|
||||
|
||||
TextEditor::ICodeStylePreferences *codeStylePreferences
|
||||
= editorConfiguration->codeStyle(CppTools::Constants::CPP_SETTINGS_ID);
|
||||
QTC_ASSERT(codeStylePreferences, return currentGlobalTabSettings());
|
||||
return codeStylePreferences->tabSettings();
|
||||
}
|
||||
|
||||
TextEditor::TabSettings CppCodeStyleSettings::currentGlobalTabSettings()
|
||||
{
|
||||
CppTools::CppCodeStylePreferences *cppCodeStylePreferences
|
||||
= CppTools::CppToolsSettings::instance()->cppCodeStyle();
|
||||
QTC_ASSERT(cppCodeStylePreferences, return TextEditor::TabSettings());
|
||||
|
||||
return cppCodeStylePreferences->tabSettings();
|
||||
}
|
||||
|
||||
|
||||
static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview,
|
||||
const CppCodeStyleSettings &settings)
|
||||
{
|
||||
|
||||
@@ -34,6 +34,7 @@ class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace CPlusPlus { class Overview; }
|
||||
namespace TextEditor { class TabSettings; }
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
@@ -94,6 +95,8 @@ public:
|
||||
|
||||
static CppCodeStyleSettings currentProjectCodeStyle();
|
||||
static CppCodeStyleSettings currentGlobalCodeStyle();
|
||||
static TextEditor::TabSettings currentProjectTabSettings();
|
||||
static TextEditor::TabSettings currentGlobalTabSettings();
|
||||
|
||||
/*! Returns an Overview configured by the current project's code style.
|
||||
|
||||
|
||||
@@ -1092,7 +1092,7 @@ int InternalCppCompletionAssistProcessor::startCompletionHelper()
|
||||
int line = 0, column = 0;
|
||||
Utils::Text::convertPosition(m_interface->textDocument(), startOfExpression, &line, &column);
|
||||
const QString fileName = m_interface->fileName();
|
||||
return startCompletionInternal(fileName, line, column, expression, endOfExpression);
|
||||
return startCompletionInternal(fileName, line, column - 1, expression, endOfExpression);
|
||||
}
|
||||
|
||||
bool InternalCppCompletionAssistProcessor::tryObjCCompletion()
|
||||
@@ -1125,7 +1125,7 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion()
|
||||
int line = 0, column = 0;
|
||||
Utils::Text::convertPosition(m_interface->textDocument(), m_interface->position(), &line,
|
||||
&column);
|
||||
Scope *scope = thisDocument->scopeAt(line, column);
|
||||
Scope *scope = thisDocument->scopeAt(line, column - 1);
|
||||
if (!scope)
|
||||
return false;
|
||||
|
||||
@@ -1319,7 +1319,8 @@ bool InternalCppCompletionAssistProcessor::objcKeywordsWanted() const
|
||||
}
|
||||
|
||||
int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString &fileName,
|
||||
unsigned line, unsigned column,
|
||||
unsigned line,
|
||||
unsigned positionInBlock,
|
||||
const QString &expr,
|
||||
int endOfExpression)
|
||||
{
|
||||
@@ -1331,7 +1332,7 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString
|
||||
|
||||
m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot());
|
||||
|
||||
Scope *scope = thisDocument->scopeAt(line, column);
|
||||
Scope *scope = thisDocument->scopeAt(line, positionInBlock);
|
||||
QTC_ASSERT(scope != 0, return -1);
|
||||
|
||||
if (expression.isEmpty()) {
|
||||
@@ -2016,7 +2017,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
||||
int lineSigned = 0, columnSigned = 0;
|
||||
Utils::Text::convertPosition(m_interface->textDocument(), m_interface->position(),
|
||||
&lineSigned, &columnSigned);
|
||||
unsigned line = lineSigned, column = columnSigned;
|
||||
unsigned line = lineSigned, column = columnSigned - 1;
|
||||
|
||||
// find a scope that encloses the current location, starting from the lastVisibileSymbol
|
||||
// and moving outwards
|
||||
|
||||
@@ -113,7 +113,7 @@ private:
|
||||
bool tryObjCCompletion();
|
||||
bool objcKeywordsWanted() const;
|
||||
int startCompletionInternal(const QString &fileName,
|
||||
unsigned line, unsigned column,
|
||||
unsigned line, unsigned positionInBlock,
|
||||
const QString &expression,
|
||||
int endOfExpression);
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ void CppElementEvaluator::execute()
|
||||
// Fetch the expression's code
|
||||
ExpressionUnderCursor expressionUnderCursor(doc->languageFeatures());
|
||||
const QString &expression = expressionUnderCursor(m_tc);
|
||||
Scope *scope = doc->scopeAt(line, column);
|
||||
Scope *scope = doc->scopeAt(line, column - 1);
|
||||
|
||||
TypeOfExpression typeOfExpression;
|
||||
typeOfExpression.init(doc, snapshot);
|
||||
|
||||
@@ -491,12 +491,12 @@ void FollowSymbolUnderCursor::findLink(
|
||||
{
|
||||
Link link;
|
||||
|
||||
int lineNumber = 0, positionInBlock = 0;
|
||||
int line = 0;
|
||||
int column = 0;
|
||||
QTextCursor cursor = data.cursor();
|
||||
QTextDocument *document = cursor.document();
|
||||
Utils::Text::convertPosition(document, cursor.position(), &lineNumber, &positionInBlock);
|
||||
const unsigned line = lineNumber;
|
||||
const unsigned column = positionInBlock + 1;
|
||||
Utils::Text::convertPosition(document, cursor.position(), &line, &column);
|
||||
const int positionInBlock = column - 1;
|
||||
|
||||
Snapshot snapshot = theSnapshot;
|
||||
|
||||
@@ -541,8 +541,8 @@ void FollowSymbolUnderCursor::findLink(
|
||||
for (int i = 0; i < tokens.size(); ++i) {
|
||||
const Token &tk = tokens.at(i);
|
||||
|
||||
if (((unsigned) positionInBlock) >= tk.utf16charsBegin()
|
||||
&& ((unsigned) positionInBlock) < tk.utf16charsEnd()) {
|
||||
if (static_cast<unsigned>(positionInBlock) >= tk.utf16charsBegin()
|
||||
&& static_cast<unsigned>(positionInBlock) < tk.utf16charsEnd()) {
|
||||
int closingParenthesisPos = tokens.size();
|
||||
if (i >= 2 && tokens.at(i).is(T_IDENTIFIER) && tokens.at(i - 1).is(T_LPAREN)
|
||||
&& (tokens.at(i - 2).is(T_SIGNAL) || tokens.at(i - 2).is(T_SLOT))) {
|
||||
@@ -584,8 +584,8 @@ void FollowSymbolUnderCursor::findLink(
|
||||
|
||||
// In this case we want to look at one token before the current position to recognize
|
||||
// an operator if the cursor is inside the actual operator: operator[$]
|
||||
if (unsigned(positionInBlock) >= tk.utf16charsBegin()
|
||||
&& unsigned(positionInBlock) <= tk.utf16charsEnd()) {
|
||||
if (static_cast<unsigned>(positionInBlock) >= tk.utf16charsBegin()
|
||||
&& static_cast<unsigned>(positionInBlock) <= tk.utf16charsEnd()) {
|
||||
cursorRegionReached = true;
|
||||
if (tk.is(T_OPERATOR)) {
|
||||
link = attemptFuncDeclDef(cursor, theSnapshot,
|
||||
@@ -675,7 +675,7 @@ void FollowSymbolUnderCursor::findLink(
|
||||
}
|
||||
|
||||
// Find the last symbol up to the cursor position
|
||||
Scope *scope = doc->scopeAt(line, column);
|
||||
Scope *scope = doc->scopeAt(line, positionInBlock);
|
||||
if (!scope)
|
||||
return processLinkCallback(link);
|
||||
|
||||
@@ -698,19 +698,21 @@ void FollowSymbolUnderCursor::findLink(
|
||||
if (d->isDeclaration() || d->isFunction()) {
|
||||
const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength());
|
||||
if (data.filePath().toString() == fileName) {
|
||||
if (unsigned(lineNumber) == d->line()
|
||||
&& unsigned(positionInBlock) >= d->column()) { // TODO: check the end
|
||||
if (static_cast<unsigned>(line) == d->line()
|
||||
&& static_cast<unsigned>(positionInBlock) >= d->column()) {
|
||||
// TODO: check the end
|
||||
result = r; // take the symbol under cursor.
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (d->isUsingDeclaration()) {
|
||||
int tokenBeginLineNumber = 0, tokenBeginColumnNumber = 0;
|
||||
int tokenBeginLineNumber = 0;
|
||||
int tokenBeginColumnNumber = 0;
|
||||
Utils::Text::convertPosition(document, beginOfToken, &tokenBeginLineNumber,
|
||||
&tokenBeginColumnNumber);
|
||||
if (unsigned(tokenBeginLineNumber) > d->line()
|
||||
|| (unsigned(tokenBeginLineNumber) == d->line()
|
||||
&& unsigned(tokenBeginColumnNumber) > d->column())) {
|
||||
if (static_cast<unsigned>(tokenBeginLineNumber) > d->line()
|
||||
|| (static_cast<unsigned>(tokenBeginLineNumber) == d->line()
|
||||
&& static_cast<unsigned>(tokenBeginColumnNumber) >= d->column())) {
|
||||
result = r; // take the symbol under cursor.
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user