forked from qt-creator/qt-creator
Standardize on int for line and column values
Recently tons of warnings show up for presumably "problematic" singned <-> unsigned and size conversions. The Qt side uses 'int', and that's the biggest 'integration surface' for us, so instead of establishing some internal boundary between signed and unsigned areas, push that boundary out of creator core code, and use 'int' everywhere. Because it reduces friction further, also do it in libcplusplus. Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -55,26 +55,24 @@ CursorInfo::Range toRange(const SemanticInfo::Use &use)
|
||||
|
||||
CursorInfo::Range toRange(int tokenIndex, TranslationUnit *translationUnit)
|
||||
{
|
||||
unsigned line, column;
|
||||
translationUnit->getTokenPosition(static_cast<unsigned>(tokenIndex), &line, &column);
|
||||
int line, column;
|
||||
translationUnit->getTokenPosition(tokenIndex, &line, &column);
|
||||
if (column)
|
||||
--column; // adjust the column position.
|
||||
|
||||
return {line,
|
||||
column + 1,
|
||||
translationUnit->tokenAt(static_cast<unsigned>(tokenIndex)).utf16chars()};
|
||||
translationUnit->tokenAt(tokenIndex).utf16chars()};
|
||||
}
|
||||
|
||||
CursorInfo::Range toRange(const QTextCursor &textCursor,
|
||||
unsigned utf16offset,
|
||||
unsigned length)
|
||||
CursorInfo::Range toRange(const QTextCursor &textCursor, int utf16offset, int length)
|
||||
{
|
||||
QTextCursor cursor(textCursor.document());
|
||||
cursor.setPosition(static_cast<int>(utf16offset));
|
||||
cursor.setPosition(utf16offset);
|
||||
const QTextBlock textBlock = cursor.block();
|
||||
|
||||
return {static_cast<unsigned>(textBlock.blockNumber() + 1),
|
||||
static_cast<unsigned>(cursor.position() - textBlock.position() + 1),
|
||||
return {textBlock.blockNumber() + 1,
|
||||
cursor.position() - textBlock.position() + 1,
|
||||
length};
|
||||
}
|
||||
|
||||
@@ -102,8 +100,8 @@ CursorInfo::Ranges toRanges(const QList<int> &tokenIndices, TranslationUnit *tra
|
||||
|
||||
class FunctionDefinitionUnderCursor: protected ASTVisitor
|
||||
{
|
||||
unsigned m_line = 0;
|
||||
unsigned m_column = 0;
|
||||
int m_line = 0;
|
||||
int m_column = 0;
|
||||
DeclarationAST *m_functionDefinition = nullptr;
|
||||
|
||||
public:
|
||||
@@ -111,7 +109,7 @@ public:
|
||||
: ASTVisitor(translationUnit)
|
||||
{ }
|
||||
|
||||
DeclarationAST *operator()(AST *ast, unsigned line, unsigned column)
|
||||
DeclarationAST *operator()(AST *ast, int line, int column)
|
||||
{
|
||||
m_functionDefinition = nullptr;
|
||||
m_line = line;
|
||||
@@ -140,8 +138,8 @@ protected:
|
||||
private:
|
||||
bool checkDeclaration(DeclarationAST *ast)
|
||||
{
|
||||
unsigned startLine, startColumn;
|
||||
unsigned endLine, endColumn;
|
||||
int startLine, startColumn;
|
||||
int endLine, endColumn;
|
||||
getTokenStartPosition(ast->firstToken(), &startLine, &startColumn);
|
||||
getTokenEndPosition(ast->lastToken() - 1, &endLine, &endColumn);
|
||||
|
||||
@@ -214,9 +212,8 @@ private:
|
||||
|
||||
bool good = false;
|
||||
foreach (const CppTools::SemanticInfo::Use &use, uses) {
|
||||
const auto l = static_cast<unsigned>(m_line);
|
||||
const auto c = static_cast<unsigned>(m_column);
|
||||
if (l == use.line && c >= use.column && c <= (use.column + use.length)) {
|
||||
if (m_line == use.line && m_column >= use.column
|
||||
&& m_column <= static_cast<int>(use.column + use.length)) {
|
||||
good = true;
|
||||
break;
|
||||
}
|
||||
@@ -293,7 +290,7 @@ bool handleMacroCase(const Document::Ptr document,
|
||||
if (!macro)
|
||||
return false;
|
||||
|
||||
const unsigned length = static_cast<unsigned>(macro->nameToQString().size());
|
||||
const int length = macro->nameToQString().size();
|
||||
|
||||
// Macro definition
|
||||
if (macro->fileName() == document->fileName())
|
||||
@@ -359,9 +356,7 @@ BuiltinCursorInfo::findLocalUses(const Document::Ptr &document, int line, int co
|
||||
|
||||
AST *ast = document->translationUnit()->ast();
|
||||
FunctionDefinitionUnderCursor functionDefinitionUnderCursor(document->translationUnit());
|
||||
DeclarationAST *declaration = functionDefinitionUnderCursor(ast,
|
||||
static_cast<unsigned>(line),
|
||||
static_cast<unsigned>(column));
|
||||
DeclarationAST *declaration = functionDefinitionUnderCursor(ast, line, column);
|
||||
return CppTools::LocalSymbols(document, declaration).uses;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ QList<QTextEdit::ExtraSelection> toTextEditorSelections(
|
||||
QTextCursor c(textDocument->findBlockByNumber(m.line() - 1));
|
||||
const QString text = c.block().text();
|
||||
const int startPos = m.column() > 0 ? m.column() - 1 : 0;
|
||||
if (m.length() > 0 && startPos + m.length() <= (unsigned)text.size()) {
|
||||
if (m.length() > 0 && startPos + m.length() <= text.size()) {
|
||||
c.setPosition(c.position() + startPos);
|
||||
c.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, m.length());
|
||||
} else {
|
||||
|
||||
@@ -314,9 +314,9 @@ CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context, cons
|
||||
: ASTVisitor(doc->translationUnit()), _doc(doc), _context(context)
|
||||
, _lineOfLastUsage(0), _macroUses(macroUses)
|
||||
{
|
||||
unsigned line = 0;
|
||||
int line = 0;
|
||||
getTokenEndPosition(translationUnit()->ast()->lastToken(), &line, nullptr);
|
||||
_chunkSize = qMax(50U, line / 200);
|
||||
_chunkSize = qMax(50, line / 200);
|
||||
_usages.reserve(_chunkSize);
|
||||
|
||||
_astStack.reserve(200);
|
||||
@@ -365,7 +365,7 @@ bool CheckSymbols::warning(AST *ast, const QString &text)
|
||||
const Token &lastToken = tokenAt(ast->lastToken() - 1);
|
||||
|
||||
const unsigned length = lastToken.utf16charsEnd() - firstToken.utf16charsBegin();
|
||||
unsigned line = 1, column = 1;
|
||||
int line = 1, column = 1;
|
||||
getTokenStartPosition(ast->firstToken(), &line, &column);
|
||||
|
||||
warning(line, column, text, length);
|
||||
@@ -478,7 +478,7 @@ bool CheckSymbols::visit(NamespaceAST *ast)
|
||||
if (ast->identifier_token) {
|
||||
const Token &tok = tokenAt(ast->identifier_token);
|
||||
if (!tok.generated()) {
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
getTokenStartPosition(ast->identifier_token, &line, &column);
|
||||
Result use(line, column, tok.utf16chars(), SemanticHighlighter::TypeUse);
|
||||
addUse(use);
|
||||
@@ -786,7 +786,7 @@ void CheckSymbols::checkNamespace(NameAST *name)
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
getTokenStartPosition(name->firstToken(), &line, &column);
|
||||
|
||||
if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) {
|
||||
@@ -1184,7 +1184,7 @@ void CheckSymbols::addUse(unsigned tokenIndex, Kind kind)
|
||||
if (tok.generated())
|
||||
return;
|
||||
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
getTokenStartPosition(tokenIndex, &line, &column);
|
||||
const unsigned length = tok.utf16chars();
|
||||
|
||||
@@ -1221,7 +1221,7 @@ void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast)
|
||||
if (tok.generated())
|
||||
return;
|
||||
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.utf16chars();
|
||||
const Result use(line, column, length, SemanticHighlighter::TypeUse);
|
||||
@@ -1263,7 +1263,7 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
|
||||
c->isClass() || c->isEnum() || isTemplateClass(c) ||
|
||||
c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum() != nullptr) {
|
||||
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.utf16chars();
|
||||
|
||||
@@ -1305,7 +1305,7 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
|
||||
else if (c->isTypedef() || (c->type() && c->type()->isFunctionType()))
|
||||
return false; // shadowed
|
||||
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.utf16chars();
|
||||
|
||||
@@ -1319,9 +1319,9 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
|
||||
}
|
||||
|
||||
bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST *ast,
|
||||
unsigned argumentCount, FunctionKind functionKind)
|
||||
int argumentCount, FunctionKind functionKind)
|
||||
{
|
||||
unsigned startToken = ast->firstToken();
|
||||
int startToken = ast->firstToken();
|
||||
bool isDestructor = false;
|
||||
bool isConstructor = false;
|
||||
if (DestructorNameAST *dtor = ast->asDestructorName()) {
|
||||
@@ -1399,7 +1399,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
getTokenStartPosition(startToken, &line, &column);
|
||||
const unsigned length = tok.utf16chars();
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ protected:
|
||||
bool maybeAddField(const QList<CPlusPlus::LookupItem> &candidates,
|
||||
CPlusPlus::NameAST *ast);
|
||||
bool maybeAddFunction(const QList<CPlusPlus::LookupItem> &candidates,
|
||||
CPlusPlus::NameAST *ast, unsigned argumentCount,
|
||||
CPlusPlus::NameAST *ast, int argumentCount,
|
||||
FunctionKind functionKind);
|
||||
|
||||
bool isTemplateClass(CPlusPlus::Symbol *s) const;
|
||||
@@ -201,7 +201,7 @@ private:
|
||||
QVector<Result> _usages;
|
||||
QList<CPlusPlus::Document::DiagnosticMessage> _diagMsgs;
|
||||
int _chunkSize;
|
||||
unsigned _lineOfLastUsage;
|
||||
int _lineOfLastUsage;
|
||||
QList<Result> _macroUses;
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ using namespace CppTools::Internal;
|
||||
namespace {
|
||||
|
||||
Document::Ptr createDocument(const QString &filePath, const QByteArray &text,
|
||||
unsigned expectedGlobalSymbolCount)
|
||||
int expectedGlobalSymbolCount)
|
||||
{
|
||||
Document::Ptr document = Document::create(filePath);
|
||||
document->setUtf8Source(text);
|
||||
@@ -59,7 +59,7 @@ Document::Ptr createDocument(const QString &filePath, const QByteArray &text,
|
||||
Document::Ptr createDocumentAndFile(Tests::TemporaryDir *temporaryDir,
|
||||
const QByteArray relativeFilePath,
|
||||
const QByteArray text,
|
||||
unsigned expectedGlobalSymbolCount)
|
||||
int expectedGlobalSymbolCount)
|
||||
{
|
||||
QTC_ASSERT(temporaryDir, return Document::Ptr());
|
||||
const QString absoluteFilePath = temporaryDir->createFile(relativeFilePath, text);
|
||||
@@ -80,13 +80,13 @@ void CppToolsPlugin::test_codegen_public_in_empty_class()
|
||||
"{\n"
|
||||
"};\n"
|
||||
"\n";
|
||||
Document::Ptr doc = createDocument(QLatin1String("public_in_empty_class"), src, 1U);
|
||||
Document::Ptr doc = createDocument(QLatin1String("public_in_empty_class"), src, 1);
|
||||
QVERIFY(doc);
|
||||
|
||||
Class *foo = doc->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
@@ -99,8 +99,8 @@ void CppToolsPlugin::test_codegen_public_in_empty_class()
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("public:\n"));
|
||||
QVERIFY(loc.suffix().isEmpty());
|
||||
QCOMPARE(loc.line(), 3U);
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 3);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -114,13 +114,13 @@ void CppToolsPlugin::test_codegen_public_in_nonempty_class()
|
||||
"public:\n" // line 3
|
||||
"};\n" // line 4
|
||||
"\n";
|
||||
Document::Ptr doc = createDocument(QLatin1String("public_in_nonempty_class"), src, 1U);
|
||||
Document::Ptr doc = createDocument(QLatin1String("public_in_nonempty_class"), src, 1);
|
||||
QVERIFY(doc);
|
||||
|
||||
Class *foo = doc->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
@@ -133,8 +133,8 @@ void CppToolsPlugin::test_codegen_public_in_nonempty_class()
|
||||
QVERIFY(loc.isValid());
|
||||
QVERIFY(loc.prefix().isEmpty());
|
||||
QVERIFY(loc.suffix().isEmpty());
|
||||
QCOMPARE(loc.line(), 4U);
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 4);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -148,13 +148,13 @@ void CppToolsPlugin::test_codegen_public_before_protected()
|
||||
"protected:\n" // line 3
|
||||
"};\n"
|
||||
"\n";
|
||||
Document::Ptr doc = createDocument(QLatin1String("public_before_protected"), src, 1U);
|
||||
Document::Ptr doc = createDocument(QLatin1String("public_before_protected"), src, 1);
|
||||
QVERIFY(doc);
|
||||
|
||||
Class *foo = doc->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
@@ -167,8 +167,8 @@ void CppToolsPlugin::test_codegen_public_before_protected()
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("public:\n"));
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n"));
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 3U);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
QCOMPARE(loc.line(), 3);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -183,13 +183,13 @@ void CppToolsPlugin::test_codegen_private_after_protected()
|
||||
"protected:\n" // line 3
|
||||
"};\n"
|
||||
"\n";
|
||||
Document::Ptr doc = createDocument(QLatin1String("private_after_protected"), src, 1U);
|
||||
Document::Ptr doc = createDocument(QLatin1String("private_after_protected"), src, 1);
|
||||
QVERIFY(doc);
|
||||
|
||||
Class *foo = doc->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
@@ -202,8 +202,8 @@ void CppToolsPlugin::test_codegen_private_after_protected()
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("private:\n"));
|
||||
QVERIFY(loc.suffix().isEmpty());
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 4U);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
QCOMPARE(loc.line(), 4);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -218,13 +218,13 @@ void CppToolsPlugin::test_codegen_protected_in_nonempty_class()
|
||||
"public:\n" // line 3
|
||||
"};\n" // line 4
|
||||
"\n";
|
||||
Document::Ptr doc = createDocument(QLatin1String("protected_in_nonempty_class"), src, 1U);
|
||||
Document::Ptr doc = createDocument(QLatin1String("protected_in_nonempty_class"), src, 1);
|
||||
QVERIFY(doc);
|
||||
|
||||
Class *foo = doc->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
@@ -237,8 +237,8 @@ void CppToolsPlugin::test_codegen_protected_in_nonempty_class()
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("protected:\n"));
|
||||
QVERIFY(loc.suffix().isEmpty());
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 4U);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
QCOMPARE(loc.line(), 4);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -253,13 +253,13 @@ void CppToolsPlugin::test_codegen_protected_between_public_and_private()
|
||||
"private:\n" // line 4
|
||||
"};\n" // line 5
|
||||
"\n";
|
||||
Document::Ptr doc = createDocument(QLatin1String("protected_betwee_public_and_private"), src, 1U);
|
||||
Document::Ptr doc = createDocument(QLatin1String("protected_betwee_public_and_private"), src, 1);
|
||||
QVERIFY(doc);
|
||||
|
||||
Class *foo = doc->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
@@ -272,8 +272,8 @@ void CppToolsPlugin::test_codegen_protected_between_public_and_private()
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("protected:\n"));
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n"));
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 4U);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
QCOMPARE(loc.line(), 4);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -309,13 +309,13 @@ void CppToolsPlugin::test_codegen_qtdesigner_integration()
|
||||
"\n"
|
||||
"#endif // MAINWINDOW_H\n";
|
||||
|
||||
Document::Ptr doc = createDocument(QLatin1String("qtdesigner_integration"), src, 2U);
|
||||
Document::Ptr doc = createDocument(QLatin1String("qtdesigner_integration"), src, 2);
|
||||
QVERIFY(doc);
|
||||
|
||||
Class *foo = doc->globalSymbolAt(1)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 10U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->line(), 10);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
|
||||
Snapshot snapshot;
|
||||
snapshot.insert(doc);
|
||||
@@ -328,8 +328,8 @@ void CppToolsPlugin::test_codegen_qtdesigner_integration()
|
||||
QVERIFY(loc.isValid());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("private slots:\n"));
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n"));
|
||||
QCOMPARE(loc.line(), 18U);
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 18);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_codegen_definition_empty_class()
|
||||
@@ -343,13 +343,13 @@ void CppToolsPlugin::test_codegen_definition_empty_class()
|
||||
"void foo();\n" // line 3
|
||||
"};\n"
|
||||
"\n";
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1U);
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1);
|
||||
QVERIFY(headerDocument);
|
||||
|
||||
const QByteArray sourceText = "\n"
|
||||
"int x;\n" // line 1
|
||||
"\n";
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 1U);
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 1);
|
||||
QVERIFY(sourceDocument);
|
||||
|
||||
Snapshot snapshot;
|
||||
@@ -358,13 +358,13 @@ void CppToolsPlugin::test_codegen_definition_empty_class()
|
||||
|
||||
Class *foo = headerDocument->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->memberCount(), 1U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
QCOMPARE(foo->memberCount(), 1);
|
||||
Declaration *decl = foo->memberAt(0)->asDeclaration();
|
||||
QVERIFY(decl);
|
||||
QCOMPARE(decl->line(), 3U);
|
||||
QCOMPARE(decl->column(), 6U);
|
||||
QCOMPARE(decl->line(), 3);
|
||||
QCOMPARE(decl->column(), 6);
|
||||
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
@@ -374,8 +374,8 @@ void CppToolsPlugin::test_codegen_definition_empty_class()
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
|
||||
QCOMPARE(loc.suffix(), QString());
|
||||
QCOMPARE(loc.line(), 3U);
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 3);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_codegen_definition_first_member()
|
||||
@@ -390,7 +390,7 @@ void CppToolsPlugin::test_codegen_definition_first_member()
|
||||
"void bar();\n" // line 4
|
||||
"};\n"
|
||||
"\n";
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1U);
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1);
|
||||
QVERIFY(headerDocument);
|
||||
|
||||
const QByteArray sourceText = QString::fromLatin1(
|
||||
@@ -404,7 +404,7 @@ void CppToolsPlugin::test_codegen_definition_first_member()
|
||||
"}\n"
|
||||
"\n"
|
||||
"int y;\n").arg(temporaryDir.path()).toLatin1();
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3U);
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
@@ -416,13 +416,13 @@ void CppToolsPlugin::test_codegen_definition_first_member()
|
||||
|
||||
Class *foo = headerDocument->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->memberCount(), 2U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
QCOMPARE(foo->memberCount(), 2);
|
||||
Declaration *decl = foo->memberAt(0)->asDeclaration();
|
||||
QVERIFY(decl);
|
||||
QCOMPARE(decl->line(), 3U);
|
||||
QCOMPARE(decl->column(), 6U);
|
||||
QCOMPARE(decl->line(), 3);
|
||||
QCOMPARE(decl->column(), 6);
|
||||
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
@@ -430,8 +430,8 @@ void CppToolsPlugin::test_codegen_definition_first_member()
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.line(), 4U);
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 4);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n\n"));
|
||||
QCOMPARE(loc.prefix(), QString());
|
||||
}
|
||||
@@ -448,7 +448,7 @@ void CppToolsPlugin::test_codegen_definition_last_member()
|
||||
"void bar();\n" // line 4
|
||||
"};\n"
|
||||
"\n";
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1U);
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1);
|
||||
QVERIFY(headerDocument);
|
||||
|
||||
const QByteArray sourceText = QString::fromLatin1(
|
||||
@@ -463,7 +463,7 @@ void CppToolsPlugin::test_codegen_definition_last_member()
|
||||
"\n"
|
||||
"int y;\n").arg(temporaryDir.path()).toLatin1();
|
||||
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3U);
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
@@ -475,13 +475,13 @@ void CppToolsPlugin::test_codegen_definition_last_member()
|
||||
|
||||
Class *foo = headerDocument->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->memberCount(), 2U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
QCOMPARE(foo->memberCount(), 2);
|
||||
Declaration *decl = foo->memberAt(1)->asDeclaration();
|
||||
QVERIFY(decl);
|
||||
QCOMPARE(decl->line(), 4U);
|
||||
QCOMPARE(decl->column(), 6U);
|
||||
QCOMPARE(decl->line(), 4);
|
||||
QCOMPARE(decl->column(), 6);
|
||||
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
@@ -489,8 +489,8 @@ void CppToolsPlugin::test_codegen_definition_last_member()
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.line(), 7U);
|
||||
QCOMPARE(loc.column(), 2U);
|
||||
QCOMPARE(loc.line(), 7);
|
||||
QCOMPARE(loc.column(), 2);
|
||||
QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
|
||||
QCOMPARE(loc.suffix(), QString());
|
||||
}
|
||||
@@ -509,7 +509,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
|
||||
"};\n"
|
||||
"\n";
|
||||
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1U);
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1);
|
||||
QVERIFY(headerDocument);
|
||||
|
||||
const QByteArray sourceText = QString::fromLatin1(
|
||||
@@ -529,7 +529,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
|
||||
"\n"
|
||||
"int y;\n").arg(Utils::TemporaryDirectory::masterDirectoryPath()).toLatin1();
|
||||
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 4U);
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 4);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
@@ -541,13 +541,13 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
|
||||
|
||||
Class *foo = headerDocument->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->memberCount(), 3U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
QCOMPARE(foo->memberCount(), 3);
|
||||
Declaration *decl = foo->memberAt(1)->asDeclaration();
|
||||
QVERIFY(decl);
|
||||
QCOMPARE(decl->line(), 4U);
|
||||
QCOMPARE(decl->column(), 6U);
|
||||
QCOMPARE(decl->line(), 4);
|
||||
QCOMPARE(decl->column(), 6);
|
||||
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
@@ -555,8 +555,8 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.line(), 7U);
|
||||
QCOMPARE(loc.column(), 2U);
|
||||
QCOMPARE(loc.line(), 7);
|
||||
QCOMPARE(loc.column(), 2);
|
||||
QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
|
||||
QCOMPARE(loc.suffix(), QString());
|
||||
}
|
||||
@@ -575,7 +575,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member_surrounded_by_undefin
|
||||
"void car();\n" // line 6
|
||||
"};\n"
|
||||
"\n";
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1U);
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 1);
|
||||
QVERIFY(headerDocument);
|
||||
|
||||
const QByteArray sourceText = QString::fromLatin1(
|
||||
@@ -589,7 +589,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member_surrounded_by_undefin
|
||||
"}\n"
|
||||
"\n"
|
||||
"int y;\n").arg(temporaryDir.path()).toLatin1();
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3U);
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
@@ -601,13 +601,13 @@ void CppToolsPlugin::test_codegen_definition_middle_member_surrounded_by_undefin
|
||||
|
||||
Class *foo = headerDocument->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->memberCount(), 4U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
QCOMPARE(foo->memberCount(), 4);
|
||||
Declaration *decl = foo->memberAt(1)->asDeclaration();
|
||||
QVERIFY(decl);
|
||||
QCOMPARE(decl->line(), 4U);
|
||||
QCOMPARE(decl->column(), 6U);
|
||||
QCOMPARE(decl->line(), 4);
|
||||
QCOMPARE(decl->column(), 6);
|
||||
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
@@ -615,8 +615,8 @@ void CppToolsPlugin::test_codegen_definition_middle_member_surrounded_by_undefin
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.line(), 4U);
|
||||
QCOMPARE(loc.column(), 1U);
|
||||
QCOMPARE(loc.line(), 4);
|
||||
QCOMPARE(loc.column(), 1);
|
||||
QCOMPARE(loc.prefix(), QString());
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n\n"));
|
||||
}
|
||||
@@ -638,7 +638,7 @@ void CppToolsPlugin::test_codegen_definition_member_specific_file()
|
||||
"{\n"
|
||||
"\n"
|
||||
"}\n";
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 2U);
|
||||
Document::Ptr headerDocument = createDocumentAndFile(&temporaryDir, "file.h", headerText, 2);
|
||||
QVERIFY(headerDocument);
|
||||
|
||||
const QByteArray sourceText = QString::fromLatin1(
|
||||
@@ -652,7 +652,7 @@ void CppToolsPlugin::test_codegen_definition_member_specific_file()
|
||||
"}\n" // line 7
|
||||
"\n"
|
||||
"int y;\n").arg(temporaryDir.path()).toLatin1();
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3U);
|
||||
Document::Ptr sourceDocument = createDocumentAndFile(&temporaryDir, "file.cpp", sourceText, 3);
|
||||
QVERIFY(sourceDocument);
|
||||
sourceDocument->addIncludeFile(Document::Include(QLatin1String("file.h"),
|
||||
headerDocument->fileName(), 1,
|
||||
@@ -664,13 +664,13 @@ void CppToolsPlugin::test_codegen_definition_member_specific_file()
|
||||
|
||||
Class *foo = headerDocument->globalSymbolAt(0)->asClass();
|
||||
QVERIFY(foo);
|
||||
QCOMPARE(foo->line(), 1U);
|
||||
QCOMPARE(foo->column(), 7U);
|
||||
QCOMPARE(foo->memberCount(), 3U);
|
||||
QCOMPARE(foo->line(), 1);
|
||||
QCOMPARE(foo->column(), 7);
|
||||
QCOMPARE(foo->memberCount(), 3);
|
||||
Declaration *decl = foo->memberAt(2)->asDeclaration();
|
||||
QVERIFY(decl);
|
||||
QCOMPARE(decl->line(), 5U);
|
||||
QCOMPARE(decl->column(), 6U);
|
||||
QCOMPARE(decl->line(), 5);
|
||||
QCOMPARE(decl->column(), 6);
|
||||
|
||||
CppRefactoringChanges changes(snapshot);
|
||||
InsertionPointLocator find(changes);
|
||||
@@ -678,8 +678,8 @@ void CppToolsPlugin::test_codegen_definition_member_specific_file()
|
||||
QVERIFY(locList.size() == 1);
|
||||
InsertionLocation loc = locList.first();
|
||||
QCOMPARE(loc.fileName(), sourceDocument->fileName());
|
||||
QCOMPARE(loc.line(), 7U);
|
||||
QCOMPARE(loc.column(), 2U);
|
||||
QCOMPARE(loc.line(), 7);
|
||||
QCOMPARE(loc.column(), 2);
|
||||
QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
|
||||
QCOMPARE(loc.suffix(), QString());
|
||||
}
|
||||
|
||||
@@ -53,6 +53,11 @@ QString Utils::toString(bool value)
|
||||
return value ? QLatin1String("Yes") : QLatin1String("No");
|
||||
}
|
||||
|
||||
QString Utils::toString(int value)
|
||||
{
|
||||
return QString::number(value);
|
||||
}
|
||||
|
||||
QString Utils::toString(unsigned value)
|
||||
{
|
||||
return QString::number(value);
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace CppCodeModelInspector {
|
||||
struct CPPTOOLS_EXPORT Utils
|
||||
{
|
||||
static QString toString(bool value);
|
||||
static QString toString(int value);
|
||||
static QString toString(unsigned value);
|
||||
static QString toString(const QDateTime &dateTime);
|
||||
static QString toString(CPlusPlus::Document::CheckMode checkMode);
|
||||
|
||||
@@ -1203,7 +1203,7 @@ void InternalCppCompletionAssistProcessor::completeObjCMsgSend(ClassOrNamespace
|
||||
}
|
||||
|
||||
foreach (Scope *scope, memberScopes) {
|
||||
for (unsigned i = 0; i < scope->memberCount(); ++i) {
|
||||
for (int i = 0; i < scope->memberCount(); ++i) {
|
||||
Symbol *symbol = scope->memberAt(i);
|
||||
|
||||
if (ObjCMethod *method = symbol->type()->asObjCMethodType()) {
|
||||
@@ -1214,7 +1214,7 @@ void InternalCppCompletionAssistProcessor::completeObjCMsgSend(ClassOrNamespace
|
||||
QString text;
|
||||
QString data;
|
||||
if (selectorName->hasArguments()) {
|
||||
for (unsigned i = 0; i < selectorName->nameCount(); ++i) {
|
||||
for (int i = 0; i < selectorName->nameCount(); ++i) {
|
||||
if (i > 0)
|
||||
text += QLatin1Char(' ');
|
||||
Symbol *arg = method->argumentAt(i);
|
||||
@@ -1320,8 +1320,8 @@ bool InternalCppCompletionAssistProcessor::objcKeywordsWanted() const
|
||||
}
|
||||
|
||||
int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString &fileName,
|
||||
unsigned line,
|
||||
unsigned positionInBlock,
|
||||
int line,
|
||||
int positionInBlock,
|
||||
const QString &expr,
|
||||
int endOfExpression)
|
||||
{
|
||||
@@ -1467,7 +1467,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
|
||||
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
|
||||
if (Block *block = scope->asBlock()) {
|
||||
if (ClassOrNamespace *binding = context.lookupType(scope)) {
|
||||
for (unsigned i = 0; i < scope->memberCount(); ++i) {
|
||||
for (int i = 0; i < scope->memberCount(); ++i) {
|
||||
Symbol *member = scope->memberAt(i);
|
||||
if (member->isEnum()) {
|
||||
if (ClassOrNamespace *b = binding->findBlock(block))
|
||||
@@ -1494,13 +1494,13 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
|
||||
|
||||
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
|
||||
if (scope->isBlock()) {
|
||||
for (unsigned i = 0; i < scope->memberCount(); ++i)
|
||||
for (int i = 0; i < scope->memberCount(); ++i)
|
||||
addCompletionItem(scope->memberAt(i), FunctionLocalsOrder);
|
||||
} else if (Function *fun = scope->asFunction()) {
|
||||
for (unsigned i = 0, argc = fun->argumentCount(); i < argc; ++i)
|
||||
for (int i = 0, argc = fun->argumentCount(); i < argc; ++i)
|
||||
addCompletionItem(fun->argumentAt(i), FunctionArgumentsOrder);
|
||||
} else if (Template *templ = scope->asTemplate()) {
|
||||
for (unsigned i = 0, argc = templ->templateParameterCount(); i < argc; ++i)
|
||||
for (int i = 0, argc = templ->templateParameterCount(); i < argc; ++i)
|
||||
addCompletionItem(templ->templateParameterAt(i), FunctionArgumentsOrder);
|
||||
break;
|
||||
}
|
||||
@@ -1799,7 +1799,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
|
||||
if (!klass)
|
||||
continue;
|
||||
|
||||
for (unsigned i = 0; i < scope->memberCount(); ++i) {
|
||||
for (int i = 0; i < scope->memberCount(); ++i) {
|
||||
Symbol *member = scope->memberAt(i);
|
||||
Function *fun = member->type()->asFunctionType();
|
||||
if (!fun || fun->isGenerated())
|
||||
@@ -1809,7 +1809,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
|
||||
else if (!wantSignals && type == CompleteQt4Slots && !fun->isSlot())
|
||||
continue;
|
||||
|
||||
unsigned count = fun->argumentCount();
|
||||
int count = fun->argumentCount();
|
||||
while (true) {
|
||||
const QString completionText = wantQt5SignalOrSlot
|
||||
? createQt5SignalOrSlot(fun, o)
|
||||
@@ -1937,7 +1937,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
||||
if (!className)
|
||||
continue; // nothing to do for anonymous classes.
|
||||
|
||||
for (unsigned i = 0; i < klass->memberCount(); ++i) {
|
||||
for (int i = 0; i < klass->memberCount(); ++i) {
|
||||
Symbol *member = klass->memberAt(i);
|
||||
const Name *memberName = member->name();
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
bool tryObjCCompletion();
|
||||
bool objcKeywordsWanted() const;
|
||||
int startCompletionInternal(const QString &fileName,
|
||||
unsigned line, unsigned positionInBlock,
|
||||
int line, int positionInBlock,
|
||||
const QString &expression,
|
||||
int endOfExpression);
|
||||
|
||||
|
||||
@@ -46,16 +46,16 @@ class CPPTOOLS_EXPORT CursorInfo
|
||||
public:
|
||||
struct Range {
|
||||
Range() = default;
|
||||
Range(unsigned line, unsigned column, unsigned length)
|
||||
Range(int line, int column, int length)
|
||||
: line(line)
|
||||
, column(column)
|
||||
, length(length)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned line = 0; // 1-based
|
||||
unsigned column = 0; // 1-based
|
||||
unsigned length = 0;
|
||||
int line = 0; // 1-based
|
||||
int column = 0; // 1-based
|
||||
int length = 0;
|
||||
};
|
||||
using Ranges = QVector<Range>;
|
||||
|
||||
|
||||
@@ -397,7 +397,7 @@ void CppElementEvaluator::checkDiagnosticMessage(int pos)
|
||||
}
|
||||
}
|
||||
|
||||
bool CppElementEvaluator::matchIncludeFile(const Document::Ptr &document, unsigned line)
|
||||
bool CppElementEvaluator::matchIncludeFile(const Document::Ptr &document, int line)
|
||||
{
|
||||
foreach (const Document::Include &includeFile, document->resolvedIncludes()) {
|
||||
if (includeFile.line() == line) {
|
||||
@@ -408,11 +408,11 @@ bool CppElementEvaluator::matchIncludeFile(const Document::Ptr &document, unsign
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CppElementEvaluator::matchMacroInUse(const Document::Ptr &document, unsigned pos)
|
||||
bool CppElementEvaluator::matchMacroInUse(const Document::Ptr &document, int pos)
|
||||
{
|
||||
foreach (const Document::MacroUse &use, document->macroUses()) {
|
||||
if (use.containsUtf16charOffset(pos)) {
|
||||
const unsigned begin = use.utf16charsBegin();
|
||||
const int begin = use.utf16charsBegin();
|
||||
if (pos < begin + use.macro().nameToQString().size()) {
|
||||
m_element = QSharedPointer<CppElement>(new CppMacro(use.macro()));
|
||||
return true;
|
||||
|
||||
@@ -65,8 +65,8 @@ public:
|
||||
private:
|
||||
void clear();
|
||||
void checkDiagnosticMessage(int pos);
|
||||
bool matchIncludeFile(const CPlusPlus::Document::Ptr &document, unsigned line);
|
||||
bool matchMacroInUse(const CPlusPlus::Document::Ptr &document, unsigned pos);
|
||||
bool matchIncludeFile(const CPlusPlus::Document::Ptr &document, int line);
|
||||
bool matchMacroInUse(const CPlusPlus::Document::Ptr &document, int pos);
|
||||
void handleLookupItemMatch(const CPlusPlus::Snapshot &snapshot,
|
||||
const CPlusPlus::LookupItem &lookupItem,
|
||||
const CPlusPlus::LookupContext &lookupContext,
|
||||
|
||||
@@ -353,7 +353,7 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
|
||||
if (target) {
|
||||
result = target->toLink();
|
||||
|
||||
unsigned startLine, startColumn, endLine, endColumn;
|
||||
int startLine, startColumn, endLine, endColumn;
|
||||
document->translationUnit()->getTokenStartPosition(name->firstToken(), &startLine,
|
||||
&startColumn);
|
||||
document->translationUnit()->getTokenEndPosition(name->lastToken() - 1, &endLine,
|
||||
@@ -540,8 +540,7 @@ void FollowSymbolUnderCursor::findLink(
|
||||
for (int i = 0; i < tokens.size(); ++i) {
|
||||
const Token &tk = tokens.at(i);
|
||||
|
||||
if (static_cast<unsigned>(positionInBlock) >= tk.utf16charsBegin()
|
||||
&& static_cast<unsigned>(positionInBlock) < tk.utf16charsEnd()) {
|
||||
if (positionInBlock >= tk.utf16charsBegin() && 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))) {
|
||||
@@ -583,8 +582,7 @@ 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 (static_cast<unsigned>(positionInBlock) >= tk.utf16charsBegin()
|
||||
&& static_cast<unsigned>(positionInBlock) <= tk.utf16charsEnd()) {
|
||||
if (positionInBlock >= tk.utf16charsBegin() && positionInBlock <= tk.utf16charsEnd()) {
|
||||
cursorRegionReached = true;
|
||||
if (tk.is(T_OPERATOR)) {
|
||||
link = attemptFuncDeclDef(cursor, theSnapshot,
|
||||
@@ -633,7 +631,7 @@ void FollowSymbolUnderCursor::findLink(
|
||||
|
||||
// Handle include directives
|
||||
if (tk.is(T_STRING_LITERAL) || tk.is(T_ANGLE_STRING_LITERAL)) {
|
||||
const unsigned lineno = cursor.blockNumber() + 1;
|
||||
const int lineno = cursor.blockNumber() + 1;
|
||||
foreach (const Document::Include &incl, doc->resolvedIncludes()) {
|
||||
if (incl.line() == lineno) {
|
||||
link.targetFileName = incl.resolvedFileName();
|
||||
@@ -697,8 +695,7 @@ void FollowSymbolUnderCursor::findLink(
|
||||
if (d->isDeclaration() || d->isFunction()) {
|
||||
const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength());
|
||||
if (data.filePath().toString() == fileName) {
|
||||
if (static_cast<unsigned>(line) == d->line()
|
||||
&& static_cast<unsigned>(positionInBlock) >= d->column()) {
|
||||
if (line == d->line() && positionInBlock >= d->column()) {
|
||||
// TODO: check the end
|
||||
result = r; // take the symbol under cursor.
|
||||
break;
|
||||
@@ -709,9 +706,9 @@ void FollowSymbolUnderCursor::findLink(
|
||||
int tokenBeginColumnNumber = 0;
|
||||
Utils::Text::convertPosition(document, beginOfToken, &tokenBeginLineNumber,
|
||||
&tokenBeginColumnNumber);
|
||||
if (static_cast<unsigned>(tokenBeginLineNumber) > d->line()
|
||||
|| (static_cast<unsigned>(tokenBeginLineNumber) == d->line()
|
||||
&& static_cast<unsigned>(tokenBeginColumnNumber) >= d->column())) {
|
||||
if (tokenBeginLineNumber > d->line()
|
||||
|| (tokenBeginLineNumber == d->line()
|
||||
&& tokenBeginColumnNumber >= d->column())) {
|
||||
result = r; // take the symbol under cursor.
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -71,14 +71,14 @@ protected:
|
||||
{
|
||||
_scopeStack.append(scope);
|
||||
|
||||
for (unsigned i = 0; i < scope->memberCount(); ++i) {
|
||||
for (int i = 0; i < scope->memberCount(); ++i) {
|
||||
if (Symbol *member = scope->memberAt(i)) {
|
||||
if (member->isTypedef())
|
||||
continue;
|
||||
if (!member->isGenerated() && (member->isDeclaration() || member->isArgument())) {
|
||||
if (member->name() && member->name()->isNameId()) {
|
||||
const Token token = tokenAt(member->sourceLocation());
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
getPosition(token.utf16charsBegin(), &line, &column);
|
||||
localUses[member].append(
|
||||
HighlightingResult(line, column, token.utf16chars(),
|
||||
@@ -89,7 +89,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
bool checkLocalUse(NameAST *nameAst, unsigned firstToken)
|
||||
bool checkLocalUse(NameAST *nameAst, int firstToken)
|
||||
{
|
||||
if (SimpleNameAST *simpleName = nameAst->asSimpleName()) {
|
||||
const Token token = tokenAt(simpleName->identifier_token);
|
||||
@@ -102,7 +102,7 @@ protected:
|
||||
continue;
|
||||
if (!member->isGenerated() && (member->sourceLocation() < firstToken
|
||||
|| member->enclosingScope()->isFunction())) {
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
getTokenStartPosition(simpleName->identifier_token, &line, &column);
|
||||
localUses[member].append(
|
||||
HighlightingResult(line, column, token.utf16chars(),
|
||||
|
||||
@@ -498,7 +498,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
|
||||
|
||||
document = snapshot.document(fileToChange);
|
||||
const QDateTime lastModifiedBefore = document->lastModified();
|
||||
QCOMPARE(document->globalSymbolCount(), 1U);
|
||||
QCOMPARE(document->globalSymbolCount(), 1);
|
||||
QCOMPARE(document->globalSymbolAt(0)->name()->identifier()->chars(), "someGlobal");
|
||||
|
||||
// Modify the file
|
||||
@@ -527,7 +527,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
|
||||
document = snapshot.document(fileToChange);
|
||||
const QDateTime lastModifiedAfter = document->lastModified();
|
||||
QVERIFY(lastModifiedAfter > lastModifiedBefore);
|
||||
QCOMPARE(document->globalSymbolCount(), 2U);
|
||||
QCOMPARE(document->globalSymbolCount(), 2);
|
||||
QCOMPARE(document->globalSymbolAt(0)->name()->identifier()->chars(), "someGlobal");
|
||||
QCOMPARE(document->globalSymbolAt(1)->name()->identifier()->chars(), "addedOtherGlobal");
|
||||
}
|
||||
|
||||
@@ -82,8 +82,8 @@ QVariant SymbolItem::data(int /*column*/, int role) const
|
||||
if (Template *t = symbl->asTemplate())
|
||||
if (Symbol *templateDeclaration = t->declaration()) {
|
||||
QStringList parameters;
|
||||
parameters.reserve(static_cast<int>(t->templateParameterCount()));
|
||||
for (unsigned i = 0; i < t->templateParameterCount(); ++i) {
|
||||
parameters.reserve(t->templateParameterCount());
|
||||
for (int i = 0; i < t->templateParameterCount(); ++i) {
|
||||
parameters.append(overviewModel->_overview.prettyName(
|
||||
t->templateParameterAt(i)->name()));
|
||||
}
|
||||
@@ -119,7 +119,7 @@ QVariant SymbolItem::data(int /*column*/, int role) const
|
||||
return Icons::iconForSymbol(symbol);
|
||||
|
||||
case AbstractOverviewModel::FileNameRole:
|
||||
return QString::fromUtf8(symbol->fileName(), static_cast<int>(symbol->fileNameLength()));
|
||||
return QString::fromUtf8(symbol->fileName(), symbol->fileNameLength());
|
||||
|
||||
case AbstractOverviewModel::LineNumberRole:
|
||||
return symbol->line();
|
||||
@@ -135,15 +135,15 @@ bool OverviewModel::hasDocument() const
|
||||
return _cppDocument;
|
||||
}
|
||||
|
||||
unsigned OverviewModel::globalSymbolCount() const
|
||||
int OverviewModel::globalSymbolCount() const
|
||||
{
|
||||
unsigned count = 0;
|
||||
int count = 0;
|
||||
if (_cppDocument)
|
||||
count += _cppDocument->globalSymbolCount();
|
||||
return count;
|
||||
}
|
||||
|
||||
Symbol *OverviewModel::globalSymbolAt(unsigned index) const
|
||||
Symbol *OverviewModel::globalSymbolAt(int index) const
|
||||
{ return _cppDocument->globalSymbolAt(index); }
|
||||
|
||||
Symbol *OverviewModel::symbolFromIndex(const QModelIndex &index) const
|
||||
@@ -185,8 +185,8 @@ Utils::LineColumn OverviewModel::lineColumnFromIndex(const QModelIndex &sourceIn
|
||||
CPlusPlus::Symbol *symbol = symbolFromIndex(sourceIndex);
|
||||
if (!symbol)
|
||||
return lineColumn;
|
||||
lineColumn.line = static_cast<int>(symbol->line());
|
||||
lineColumn.column = static_cast<int>(symbol->column());
|
||||
lineColumn.line = symbol->line();
|
||||
lineColumn.column = symbol->column();
|
||||
return lineColumn;
|
||||
}
|
||||
|
||||
@@ -202,8 +202,8 @@ void OverviewModel::buildTree(SymbolItem *root, bool isRoot)
|
||||
return;
|
||||
|
||||
if (isRoot) {
|
||||
unsigned rows = globalSymbolCount();
|
||||
for (unsigned row = 0; row < rows; ++row) {
|
||||
int rows = globalSymbolCount();
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
Symbol *symbol = globalSymbolAt(row);
|
||||
auto currentItem = new SymbolItem(symbol);
|
||||
buildTree(currentItem, false);
|
||||
|
||||
@@ -59,8 +59,8 @@ public:
|
||||
private:
|
||||
CPlusPlus::Symbol *symbolFromIndex(const QModelIndex &index) const;
|
||||
bool hasDocument() const;
|
||||
unsigned globalSymbolCount() const;
|
||||
CPlusPlus::Symbol *globalSymbolAt(unsigned index) const;
|
||||
int globalSymbolCount() const;
|
||||
CPlusPlus::Symbol *globalSymbolAt(int index) const;
|
||||
void buildTree(SymbolItem *root, bool isRoot);
|
||||
|
||||
private:
|
||||
|
||||
@@ -377,7 +377,7 @@ void PointerDeclarationFormatter::checkAndRewrite(DeclaratorAST *declarator,
|
||||
CHECK_R(symbol, "No symbol");
|
||||
|
||||
// Check for expanded tokens
|
||||
for (unsigned token = tokenRange.start; token <= tokenRange.end; ++token)
|
||||
for (int token = tokenRange.start; token <= tokenRange.end; ++token)
|
||||
CHECK_R(!tokenAt(token).expanded(), "Token is expanded");
|
||||
|
||||
Utils::ChangeSet::Range range(m_cppRefactoringFile->startOf(tokenRange.start),
|
||||
@@ -455,7 +455,7 @@ void PointerDeclarationFormatter::printCandidate(AST *ast)
|
||||
{
|
||||
#if DEBUG_OUTPUT
|
||||
QString tokens;
|
||||
for (unsigned token = ast->firstToken(); token < ast->lastToken(); token++)
|
||||
for (int token = ast->firstToken(); token < ast->lastToken(); token++)
|
||||
tokens += QString::fromLatin1(tokenAt(token).spell()) + QLatin1Char(' ');
|
||||
|
||||
# ifdef __GNUC__
|
||||
|
||||
@@ -101,9 +101,9 @@ private:
|
||||
class TokenRange {
|
||||
public:
|
||||
TokenRange() = default;
|
||||
TokenRange(unsigned start, unsigned end) : start(start), end(end) {}
|
||||
unsigned start = 0;
|
||||
unsigned end = 0;
|
||||
TokenRange(int start, int end) : start(start), end(end) {}
|
||||
int start = 0;
|
||||
int end = 0;
|
||||
};
|
||||
|
||||
void processIfWhileForStatement(ExpressionAST *expression, Symbol *symbol);
|
||||
|
||||
@@ -159,7 +159,7 @@ void CppRefactoringFile::setCppDocument(Document::Ptr document)
|
||||
|
||||
Scope *CppRefactoringFile::scopeAt(unsigned index) const
|
||||
{
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
cppDocument()->translationUnit()->getTokenStartPosition(index, &line, &column);
|
||||
return cppDocument()->scopeAt(line, column);
|
||||
}
|
||||
@@ -195,10 +195,10 @@ bool CppRefactoringFile::isCursorOn(const AST *ast) const
|
||||
Utils::ChangeSet::Range CppRefactoringFile::range(unsigned tokenIndex) const
|
||||
{
|
||||
const Token &token = tokenAt(tokenIndex);
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
cppDocument()->translationUnit()->getPosition(token.utf16charsBegin(), &line, &column);
|
||||
const int start = document()->findBlockByNumber(line - 1).position() + column - 1;
|
||||
return {start, static_cast<int>(start + token.utf16chars())};
|
||||
return {start, start + token.utf16chars()};
|
||||
}
|
||||
|
||||
Utils::ChangeSet::Range CppRefactoringFile::range(AST *ast) const
|
||||
@@ -208,7 +208,7 @@ Utils::ChangeSet::Range CppRefactoringFile::range(AST *ast) const
|
||||
|
||||
int CppRefactoringFile::startOf(unsigned index) const
|
||||
{
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
cppDocument()->translationUnit()->getPosition(tokenAt(index).utf16charsBegin(), &line, &column);
|
||||
return document()->findBlockByNumber(line - 1).position() + column - 1;
|
||||
}
|
||||
@@ -220,21 +220,21 @@ int CppRefactoringFile::startOf(const AST *ast) const
|
||||
|
||||
int CppRefactoringFile::endOf(unsigned index) const
|
||||
{
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
cppDocument()->translationUnit()->getPosition(tokenAt(index).utf16charsEnd(), &line, &column);
|
||||
return document()->findBlockByNumber(line - 1).position() + column - 1;
|
||||
}
|
||||
|
||||
int CppRefactoringFile::endOf(const AST *ast) const
|
||||
{
|
||||
unsigned end = ast->lastToken();
|
||||
int end = ast->lastToken();
|
||||
QTC_ASSERT(end > 0, return -1);
|
||||
return endOf(end - 1);
|
||||
}
|
||||
|
||||
void CppRefactoringFile::startAndEndOf(unsigned index, int *start, int *end) const
|
||||
{
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
Token token(tokenAt(index));
|
||||
cppDocument()->translationUnit()->getPosition(token.utf16charsBegin(), &line, &column);
|
||||
*start = document()->findBlockByNumber(line - 1).position() + column - 1;
|
||||
|
||||
@@ -136,13 +136,12 @@ int CppSelectionChanger::getTokenStartCursorPosition(
|
||||
unsigned tokenIndex,
|
||||
const QTextCursor &cursor) const
|
||||
{
|
||||
unsigned startLine, startColumn;
|
||||
int startLine, startColumn;
|
||||
m_unit->getTokenStartPosition(tokenIndex, &startLine, &startColumn);
|
||||
|
||||
const QTextDocument *document = cursor.document();
|
||||
const int startPosition =
|
||||
document->findBlockByNumber(static_cast<int>(startLine) - 1).position()
|
||||
+ static_cast<int>(startColumn) - 1;
|
||||
const int startPosition = document->findBlockByNumber(startLine - 1).position()
|
||||
+ startColumn - 1;
|
||||
|
||||
return startPosition;
|
||||
}
|
||||
@@ -151,13 +150,12 @@ int CppSelectionChanger::getTokenEndCursorPosition(
|
||||
unsigned tokenIndex,
|
||||
const QTextCursor &cursor) const
|
||||
{
|
||||
unsigned endLine, endColumn;
|
||||
int endLine, endColumn;
|
||||
m_unit->getTokenEndPosition(tokenIndex, &endLine, &endColumn);
|
||||
|
||||
const QTextDocument *document = cursor.document();
|
||||
const int endPosition =
|
||||
document->findBlockByNumber(static_cast<int>(endLine) - 1).position()
|
||||
+ static_cast<int>(endColumn) - 1;
|
||||
const int endPosition = document->findBlockByNumber(endLine - 1).position()
|
||||
+ endColumn - 1;
|
||||
|
||||
return endPosition;
|
||||
}
|
||||
@@ -167,7 +165,7 @@ void CppSelectionChanger::printTokenDebugInfo(
|
||||
const QTextCursor &cursor,
|
||||
QString prefix) const
|
||||
{
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
const Token token = m_unit->tokenAt(tokenIndex);
|
||||
m_unit->getTokenStartPosition(tokenIndex, &line, &column);
|
||||
const int startPos = getTokenStartCursorPosition(tokenIndex, cursor);
|
||||
@@ -571,7 +569,7 @@ void CppSelectionChanger::fineTuneASTNodePositions(ASTNodePositions &positions)
|
||||
|
||||
// Start position will be the end position minus the size of the actual contents of the
|
||||
// literal.
|
||||
int newPosStart = newPosEnd - static_cast<int>(firstToken.string->size());
|
||||
int newPosStart = newPosEnd - firstToken.string->size();
|
||||
|
||||
// Skip raw literal parentheses.
|
||||
if (isRawLiteral)
|
||||
@@ -591,7 +589,7 @@ void CppSelectionChanger::fineTuneASTNodePositions(ASTNodePositions &positions)
|
||||
qDebug() << "Selecting inner contents of char literal.";
|
||||
|
||||
positions.astPosEnd = positions.astPosEnd - 1;
|
||||
positions.astPosStart = positions.astPosEnd - int(firstToken.literal->size());
|
||||
positions.astPosStart = positions.astPosEnd - firstToken.literal->size();
|
||||
}
|
||||
}
|
||||
} else if (ForStatementAST *forStatementAST = ast->asForStatement()) {
|
||||
|
||||
@@ -324,8 +324,8 @@ void CppSourceProcessor::macroAdded(const CPlusPlus::Macro ¯o)
|
||||
m_currentDoc->appendMacro(macro);
|
||||
}
|
||||
|
||||
void CppSourceProcessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset,
|
||||
unsigned line, const CPlusPlus::Macro ¯o)
|
||||
void CppSourceProcessor::passedMacroDefinitionCheck(int bytesOffset, int utf16charsOffset,
|
||||
int line, const CPlusPlus::Macro ¯o)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
@@ -336,7 +336,7 @@ void CppSourceProcessor::passedMacroDefinitionCheck(unsigned bytesOffset, unsign
|
||||
line, QVector<MacroArgumentReference>());
|
||||
}
|
||||
|
||||
void CppSourceProcessor::failedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
void CppSourceProcessor::failedMacroDefinitionCheck(int bytesOffset, int utf16charOffset,
|
||||
const ByteArrayRef &name)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
@@ -346,8 +346,8 @@ void CppSourceProcessor::failedMacroDefinitionCheck(unsigned bytesOffset, unsign
|
||||
bytesOffset, utf16charOffset);
|
||||
}
|
||||
|
||||
void CppSourceProcessor::notifyMacroReference(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
unsigned line, const CPlusPlus::Macro ¯o)
|
||||
void CppSourceProcessor::notifyMacroReference(int bytesOffset, int utf16charOffset,
|
||||
int line, const CPlusPlus::Macro ¯o)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
@@ -358,8 +358,8 @@ void CppSourceProcessor::notifyMacroReference(unsigned bytesOffset, unsigned utf
|
||||
line, QVector<MacroArgumentReference>());
|
||||
}
|
||||
|
||||
void CppSourceProcessor::startExpandingMacro(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
unsigned line, const CPlusPlus::Macro ¯o,
|
||||
void CppSourceProcessor::startExpandingMacro(int bytesOffset, int utf16charOffset,
|
||||
int line, const CPlusPlus::Macro ¯o,
|
||||
const QVector<MacroArgumentReference> &actuals)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
@@ -371,7 +371,7 @@ void CppSourceProcessor::startExpandingMacro(unsigned bytesOffset, unsigned utf1
|
||||
line, actuals);
|
||||
}
|
||||
|
||||
void CppSourceProcessor::stopExpandingMacro(unsigned, const CPlusPlus::Macro &)
|
||||
void CppSourceProcessor::stopExpandingMacro(int, const CPlusPlus::Macro &)
|
||||
{
|
||||
if (!m_currentDoc)
|
||||
return;
|
||||
@@ -409,19 +409,19 @@ void CppSourceProcessor::mergeEnvironment(Document::Ptr doc)
|
||||
m_env.addMacros(doc->definedMacros());
|
||||
}
|
||||
|
||||
void CppSourceProcessor::startSkippingBlocks(unsigned utf16charsOffset)
|
||||
void CppSourceProcessor::startSkippingBlocks(int utf16charsOffset)
|
||||
{
|
||||
if (m_currentDoc)
|
||||
m_currentDoc->startSkippingBlocks(utf16charsOffset);
|
||||
}
|
||||
|
||||
void CppSourceProcessor::stopSkippingBlocks(unsigned utf16charsOffset)
|
||||
void CppSourceProcessor::stopSkippingBlocks(int utf16charsOffset)
|
||||
{
|
||||
if (m_currentDoc)
|
||||
m_currentDoc->stopSkippingBlocks(utf16charsOffset);
|
||||
}
|
||||
|
||||
void CppSourceProcessor::sourceNeeded(unsigned line, const QString &fileName, IncludeType type,
|
||||
void CppSourceProcessor::sourceNeeded(int line, const QString &fileName, IncludeType type,
|
||||
const QStringList &initialIncludes)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
|
||||
@@ -93,20 +93,20 @@ private:
|
||||
|
||||
// Client interface
|
||||
void macroAdded(const CPlusPlus::Macro ¯o) override;
|
||||
void passedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charsOffset,
|
||||
unsigned line, const CPlusPlus::Macro ¯o) override;
|
||||
void failedMacroDefinitionCheck(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
void passedMacroDefinitionCheck(int bytesOffset, int utf16charsOffset,
|
||||
int line, const CPlusPlus::Macro ¯o) override;
|
||||
void failedMacroDefinitionCheck(int bytesOffset, int utf16charOffset,
|
||||
const CPlusPlus::ByteArrayRef &name) override;
|
||||
void notifyMacroReference(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
unsigned line, const CPlusPlus::Macro ¯o) override;
|
||||
void startExpandingMacro(unsigned bytesOffset, unsigned utf16charOffset,
|
||||
unsigned line, const CPlusPlus::Macro ¯o,
|
||||
void notifyMacroReference(int bytesOffset, int utf16charOffset,
|
||||
int line, const CPlusPlus::Macro ¯o) override;
|
||||
void startExpandingMacro(int bytesOffset, int utf16charOffset,
|
||||
int line, const CPlusPlus::Macro ¯o,
|
||||
const QVector<CPlusPlus::MacroArgumentReference> &actuals) override;
|
||||
void stopExpandingMacro(unsigned bytesOffset, const CPlusPlus::Macro ¯o) override;
|
||||
void stopExpandingMacro(int bytesOffset, const CPlusPlus::Macro ¯o) override;
|
||||
void markAsIncludeGuard(const QByteArray ¯oName) override;
|
||||
void startSkippingBlocks(unsigned utf16charsOffset) override;
|
||||
void stopSkippingBlocks(unsigned utf16charsOffset) override;
|
||||
void sourceNeeded(unsigned line, const QString &fileName, IncludeType type,
|
||||
void startSkippingBlocks(int utf16charsOffset) override;
|
||||
void stopSkippingBlocks(int utf16charsOffset) override;
|
||||
void sourceNeeded(int line, const QString &fileName, IncludeType type,
|
||||
const QStringList &initialIncludes) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -179,11 +179,11 @@ void CppToolsPlugin::test_cppsourceprocessor_macroUses()
|
||||
const QList<Document::MacroUse> macroUses = document->macroUses();
|
||||
QCOMPARE(macroUses.size(), 1);
|
||||
const Document::MacroUse macroUse = macroUses.at(0);
|
||||
QCOMPARE(macroUse.bytesBegin(), 25U);
|
||||
QCOMPARE(macroUse.bytesEnd(), 35U);
|
||||
QCOMPARE(macroUse.utf16charsBegin(), 25U);
|
||||
QCOMPARE(macroUse.utf16charsEnd(), 35U);
|
||||
QCOMPARE(macroUse.beginLine(), 2U);
|
||||
QCOMPARE(macroUse.bytesBegin(), 25);
|
||||
QCOMPARE(macroUse.bytesEnd(), 35);
|
||||
QCOMPARE(macroUse.utf16charsBegin(), 25);
|
||||
QCOMPARE(macroUse.utf16charsEnd(), 35);
|
||||
QCOMPARE(macroUse.beginLine(), 2);
|
||||
}
|
||||
|
||||
static bool isMacroDefinedInDocument(const QByteArray ¯oName, const Document::Ptr &document)
|
||||
|
||||
@@ -319,7 +319,7 @@ QList<IncludeGroup> IncludeGroup::detectIncludeGroupsByNewLines(QList<Document::
|
||||
{
|
||||
// Create groups
|
||||
QList<IncludeGroup> result;
|
||||
unsigned lastLine = 0;
|
||||
int lastLine = 0;
|
||||
QList<Include> currentIncludes;
|
||||
bool isFirst = true;
|
||||
foreach (const Include &include, includes) {
|
||||
|
||||
@@ -58,7 +58,7 @@ static int ordering(InsertionPointLocator::AccessSpec xsSpec)
|
||||
|
||||
struct AccessRange
|
||||
{
|
||||
unsigned start = 0;
|
||||
int start = 0;
|
||||
unsigned end = 0;
|
||||
InsertionPointLocator::AccessSpec xsSpec = InsertionPointLocator::Invalid;
|
||||
unsigned colonToken = 0;
|
||||
@@ -119,7 +119,7 @@ protected:
|
||||
bool needsSuffix = false;
|
||||
findMatch(ranges, _xsSpec, beforeToken, needsLeadingEmptyLine, needsPrefix, needsSuffix);
|
||||
|
||||
unsigned line = 0, column = 0;
|
||||
int line = 0, column = 0;
|
||||
getTokenStartPosition(beforeToken, &line, &column);
|
||||
|
||||
QString prefix;
|
||||
@@ -253,7 +253,7 @@ InsertionLocation::InsertionLocation() = default;
|
||||
InsertionLocation::InsertionLocation(const QString &fileName,
|
||||
const QString &prefix,
|
||||
const QString &suffix,
|
||||
unsigned line, unsigned column)
|
||||
int line, int column)
|
||||
: m_fileName(fileName)
|
||||
, m_prefix(prefix)
|
||||
, m_suffix(suffix)
|
||||
@@ -350,7 +350,7 @@ public:
|
||||
: ASTVisitor(translationUnit)
|
||||
{}
|
||||
|
||||
void operator()(Symbol *decl, unsigned *line, unsigned *column)
|
||||
void operator()(Symbol *decl, int *line, int *column)
|
||||
{
|
||||
// default to end of file
|
||||
const unsigned lastToken = translationUnit()->ast()->lastToken();
|
||||
@@ -408,15 +408,15 @@ protected:
|
||||
class FindFunctionDefinition : protected ASTVisitor
|
||||
{
|
||||
FunctionDefinitionAST *_result = nullptr;
|
||||
unsigned _line = 0;
|
||||
unsigned _column = 0;
|
||||
int _line = 0;
|
||||
int _column = 0;
|
||||
public:
|
||||
explicit FindFunctionDefinition(TranslationUnit *translationUnit)
|
||||
: ASTVisitor(translationUnit)
|
||||
{
|
||||
}
|
||||
|
||||
FunctionDefinitionAST *operator()(unsigned line, unsigned column)
|
||||
FunctionDefinitionAST *operator()(int line, int column)
|
||||
{
|
||||
_result = nullptr;
|
||||
_line = line;
|
||||
@@ -430,7 +430,7 @@ protected:
|
||||
{
|
||||
if (_result)
|
||||
return false;
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
translationUnit()->getTokenStartPosition(ast->firstToken(), &line, &column);
|
||||
if (line > _line || (line == _line && column > _column))
|
||||
return false;
|
||||
@@ -473,7 +473,7 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
|
||||
|
||||
// find the index of declaration
|
||||
int declIndex = -1;
|
||||
for (unsigned i = 0; i < klass->memberCount(); ++i) {
|
||||
for (int i = 0; i < klass->memberCount(); ++i) {
|
||||
Symbol *s = klass->memberAt(i);
|
||||
if (s == declaration) {
|
||||
declIndex = i;
|
||||
@@ -505,7 +505,7 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
|
||||
}
|
||||
if (!definitionFunction) {
|
||||
// try to find one below
|
||||
for (unsigned i = declIndex + 1; i < klass->memberCount(); ++i) {
|
||||
for (int i = declIndex + 1; i < klass->memberCount(); ++i) {
|
||||
Symbol *s = klass->memberAt(i);
|
||||
surroundingFunctionDecl = isNonVirtualFunctionDeclaration(s);
|
||||
if (!surroundingFunctionDecl)
|
||||
@@ -526,7 +526,7 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
|
||||
if (!definitionFunction)
|
||||
return noResult;
|
||||
|
||||
unsigned line, column;
|
||||
int line, column;
|
||||
if (suffix.isEmpty()) {
|
||||
Document::Ptr targetDoc = changes.snapshot().document(QString::fromUtf8(definitionFunction->fileName()));
|
||||
if (!targetDoc)
|
||||
@@ -586,7 +586,7 @@ QList<InsertionLocation> InsertionPointLocator::methodDefinition(Symbol *declara
|
||||
if (doc.isNull())
|
||||
return result;
|
||||
|
||||
unsigned line = 0, column = 0;
|
||||
int line = 0, column = 0;
|
||||
FindMethodDefinitionInsertPoint finder(doc->translationUnit());
|
||||
finder(declaration, &line, &column);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class CPPTOOLS_EXPORT InsertionLocation
|
||||
public:
|
||||
InsertionLocation();
|
||||
InsertionLocation(const QString &fileName, const QString &prefix,
|
||||
const QString &suffix, unsigned line, unsigned column);
|
||||
const QString &suffix, int line, int column);
|
||||
|
||||
QString fileName() const
|
||||
{ return m_fileName; }
|
||||
@@ -49,11 +49,11 @@ public:
|
||||
{ return m_suffix; }
|
||||
|
||||
/// \returns The line where to insert. The line number is 1-based.
|
||||
unsigned line() const
|
||||
int line() const
|
||||
{ return m_line; }
|
||||
|
||||
/// \returns The column where to insert. The column number is 1-based.
|
||||
unsigned column() const
|
||||
int column() const
|
||||
{ return m_column; }
|
||||
|
||||
bool isValid() const
|
||||
@@ -63,8 +63,8 @@ private:
|
||||
QString m_fileName;
|
||||
QString m_prefix;
|
||||
QString m_suffix;
|
||||
unsigned m_line = 0;
|
||||
unsigned m_column = 0;
|
||||
int m_line = 0;
|
||||
int m_column = 0;
|
||||
};
|
||||
|
||||
class CPPTOOLS_EXPORT InsertionPointLocator
|
||||
|
||||
@@ -70,7 +70,7 @@ IndexItem::Ptr SearchSymbols::operator()(Document::Ptr doc, const QString &scope
|
||||
QTC_ASSERT(_parent->fileName() == Internal::StringTable::insert(doc->fileName()),
|
||||
return IndexItem::Ptr());
|
||||
|
||||
for (unsigned i = 0, ei = doc->globalSymbolCount(); i != ei; ++i)
|
||||
for (int i = 0, ei = doc->globalSymbolCount(); i != ei; ++i)
|
||||
accept(doc->globalSymbolAt(i));
|
||||
|
||||
Internal::StringTable::scheduleGC();
|
||||
@@ -95,7 +95,7 @@ bool SearchSymbols::visit(Enum *symbol)
|
||||
QString newScope = scopedSymbolName(name, symbol);
|
||||
ScopedScope scopeRaii(_scope, newScope);
|
||||
|
||||
for (unsigned i = 0, ei = symbol->memberCount(); i != ei; ++i)
|
||||
for (int i = 0, ei = symbol->memberCount(); i != ei; ++i)
|
||||
accept(symbol->memberAt(i));
|
||||
|
||||
return false;
|
||||
@@ -112,7 +112,7 @@ bool SearchSymbols::visit(Namespace *symbol)
|
||||
QString name = scopedSymbolName(symbol);
|
||||
QString newScope = name;
|
||||
ScopedScope raii(_scope, newScope);
|
||||
for (unsigned i = 0; i < symbol->memberCount(); ++i) {
|
||||
for (int i = 0; i < symbol->memberCount(); ++i) {
|
||||
accept(symbol->memberAt(i));
|
||||
}
|
||||
return false;
|
||||
@@ -321,7 +321,7 @@ void SearchSymbols::processClass(T *clazz)
|
||||
|
||||
QString newScope = scopedSymbolName(name, clazz);
|
||||
ScopedScope scopeRaii(_scope, newScope);
|
||||
for (unsigned i = 0, ei = clazz->memberCount(); i != ei; ++i)
|
||||
for (int i = 0, ei = clazz->memberCount(); i != ei; ++i)
|
||||
accept(clazz->memberAt(i));
|
||||
}
|
||||
|
||||
|
||||
@@ -71,13 +71,13 @@ void DerivedHierarchyVisitor::execute(const CPlusPlus::Document::Ptr &doc,
|
||||
_otherBases.clear();
|
||||
_context = CPlusPlus::LookupContext(doc, snapshot);
|
||||
|
||||
for (unsigned i = 0; i < doc->globalSymbolCount(); ++i)
|
||||
for (int i = 0; i < doc->globalSymbolCount(); ++i)
|
||||
accept(doc->globalSymbolAt(i));
|
||||
}
|
||||
|
||||
bool DerivedHierarchyVisitor::visit(CPlusPlus::Class *symbol)
|
||||
{
|
||||
for (unsigned i = 0; i < symbol->baseClassCount(); ++i) {
|
||||
for (int i = 0; i < symbol->baseClassCount(); ++i) {
|
||||
CPlusPlus::BaseClass *baseSymbol = symbol->baseClassAt(i);
|
||||
|
||||
QString baseName = _actualBases.value(baseSymbol);
|
||||
|
||||
Reference in New Issue
Block a user