Commit c287d906 authored by Leandro Melo's avatar Leandro Melo

C++: Rename source/setSource to utf8Source/setUtf8Source

Continuinng a previous commit... This is in order to make
the interface clearer.

Change-Id: Ic1b05217f878578bc84a064927507b75981c47d6
Reviewed-by: default avatarRoberto Raggi <roberto.raggi@nokia.com>
parent 40810e75
......@@ -494,10 +494,10 @@ Document::Ptr Document::create(const QString &fileName)
return doc;
}
QByteArray Document::source() const
QByteArray Document::utf8Source() const
{ return _source; }
void Document::setSource(const QByteArray &source)
void Document::setUtf8Source(const QByteArray &source)
{
_source = source;
_translationUnit->setSource(_source.constBegin(), _source.size());
......@@ -686,7 +686,7 @@ Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode,
newDoc->_macroUses = thisDocument->_macroUses;
}
newDoc->setSource(preprocessedCode);
newDoc->setUtf8Source(preprocessedCode);
return newDoc;
}
......
......@@ -99,8 +99,8 @@ public:
Symbol *lastVisibleSymbolAt(unsigned line, unsigned column = 0) const;
Scope *scopeAt(unsigned line, unsigned column = 0);
QByteArray source() const;
void setSource(const QByteArray &source);
QByteArray utf8Source() const;
void setUtf8Source(const QByteArray &utf8Source);
void startSkippingBlocks(unsigned offset);
void stopSkippingBlocks(unsigned offset);
......
......@@ -79,7 +79,7 @@ FindUsages::FindUsages(const QByteArray &originalSource, Document::Ptr doc, cons
_snapshot(snapshot),
_context(doc, snapshot),
_originalSource(originalSource),
_source(_doc->source()),
_source(_doc->utf8Source()),
_currentScope(0)
{
_snapshot.insert(_doc);
......@@ -93,8 +93,8 @@ FindUsages::FindUsages(const LookupContext &context)
_doc(context.thisDocument()),
_snapshot(context.snapshot()),
_context(context),
_originalSource(_doc->source()),
_source(_doc->source()),
_originalSource(_doc->utf8Source()),
_source(_doc->utf8Source()),
_currentScope(0)
{
typeofExpression.init(_doc, _snapshot, _context.bindings());
......
......@@ -177,7 +177,7 @@ Document::Ptr TypeOfExpression::documentForExpression(const QByteArray &utf8code
{
// create the expression's AST.
Document::Ptr doc = Document::create(QLatin1String("<completion>"));
doc->setSource(utf8code);
doc->setUtf8Source(utf8code);
doc->parse(Document::ParseExpression);
return doc;
}
......
......@@ -505,7 +505,7 @@ bool CheckSymbols::visit(MemberAccessAST *ast)
if (_potentialMembers.contains(id)) {
const Token start = tokenAt(ast->firstToken());
const Token end = tokenAt(ast->lastToken() - 1);
const QByteArray expression = _doc->source().mid(start.begin(), end.end() - start.begin());
const QByteArray expression = _doc->utf8Source().mid(start.begin(), end.end() - start.begin());
const QList<LookupItem> candidates =
typeOfExpression(expression, enclosingScope(), TypeOfExpression::Preprocess);
......@@ -568,7 +568,7 @@ QByteArray CheckSymbols::textOf(AST *ast) const
{
const Token start = tokenAt(ast->firstToken());
const Token end = tokenAt(ast->lastToken() - 1);
const QByteArray text = _doc->source().mid(start.begin(), end.end() - start.begin());
const QByteArray text = _doc->utf8Source().mid(start.begin(), end.end() - start.begin());
return text;
}
......
......@@ -579,7 +579,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
QString::fromUtf8(typeOfExpression.preprocess(newDeclText.toUtf8()));
Document::Ptr newDeclDoc = Document::create(QLatin1String("<decl>"));
newDeclDoc->setSource(newDeclTextPreprocessed.toUtf8());
newDeclDoc->setUtf8Source(newDeclTextPreprocessed.toUtf8());
newDeclDoc->parse(Document::ParseDeclaration);
newDeclDoc->check();
......@@ -810,7 +810,7 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
// don't change the name if it's in a comment
if (hasCommentedName(targetFile->cppDocument()->translationUnit(),
QLatin1String(targetFile->cppDocument()->source()),
QLatin1String(targetFile->cppDocument()->utf8Source()),
targetFunctionDeclarator, existingParamIndex))
replacementName = 0;
......
......@@ -72,7 +72,7 @@ void CppToolsPlugin::test_codegen_public_in_empty_class()
"\n";
Document::Ptr doc = Document::create("public_in_empty_class");
doc->setSource(src);
doc->setUtf8Source(src);
doc->parse();
doc->check();
......@@ -112,7 +112,7 @@ void CppToolsPlugin::test_codegen_public_in_nonempty_class()
"\n";
Document::Ptr doc = Document::create("public_in_nonempty_class");
doc->setSource(src);
doc->setUtf8Source(src);
doc->parse();
doc->check();
......@@ -152,7 +152,7 @@ void CppToolsPlugin::test_codegen_public_before_protected()
"\n";
Document::Ptr doc = Document::create("public_before_protected");
doc->setSource(src);
doc->setUtf8Source(src);
doc->parse();
doc->check();
......@@ -193,7 +193,7 @@ void CppToolsPlugin::test_codegen_private_after_protected()
"\n";
Document::Ptr doc = Document::create("private_after_protected");
doc->setSource(src);
doc->setUtf8Source(src);
doc->parse();
doc->check();
......@@ -234,7 +234,7 @@ void CppToolsPlugin::test_codegen_protected_in_nonempty_class()
"\n";
Document::Ptr doc = Document::create("protected_in_nonempty_class");
doc->setSource(src);
doc->setUtf8Source(src);
doc->parse();
doc->check();
......@@ -275,7 +275,7 @@ void CppToolsPlugin::test_codegen_protected_between_public_and_private()
"\n";
Document::Ptr doc = Document::create("protected_betwee_public_and_private");
doc->setSource(src);
doc->setUtf8Source(src);
doc->parse();
doc->check();
......@@ -336,7 +336,7 @@ void CppToolsPlugin::test_codegen_qtdesigner_integration()
"#endif // MAINWINDOW_H\n";
Document::Ptr doc = Document::create("qtdesigner_integration");
doc->setSource(src);
doc->setUtf8Source(src);
doc->parse();
doc->check();
......@@ -380,7 +380,7 @@ void CppToolsPlugin::test_codegen_definition_empty_class()
Utils::FileSaver srcSaver(src->fileName());
srcSaver.write(srcText);
srcSaver.finalize();
src->setSource(srcText);
src->setUtf8Source(srcText);
src->parse();
src->check();
QCOMPARE(src->diagnosticMessages().size(), 0);
......@@ -390,7 +390,7 @@ void CppToolsPlugin::test_codegen_definition_empty_class()
Utils::FileSaver dstSaver(dst->fileName());
dstSaver.write(dstText);
dstSaver.finalize();
dst->setSource(dstText);
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
QCOMPARE(dst->diagnosticMessages().size(), 0);
......@@ -448,7 +448,7 @@ void CppToolsPlugin::test_codegen_definition_first_member()
Utils::FileSaver srcSaver(src->fileName());
srcSaver.write(srcText);
srcSaver.finalize();
src->setSource(srcText);
src->setUtf8Source(srcText);
src->parse();
src->check();
QCOMPARE(src->diagnosticMessages().size(), 0);
......@@ -459,7 +459,7 @@ void CppToolsPlugin::test_codegen_definition_first_member()
Utils::FileSaver dstSaver(dst->fileName());
dstSaver.write(dstText);
dstSaver.finalize();
dst->setSource(dstText);
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
QCOMPARE(dst->diagnosticMessages().size(), 0);
......@@ -517,7 +517,7 @@ void CppToolsPlugin::test_codegen_definition_last_member()
Utils::FileSaver srcSaver(src->fileName());
srcSaver.write(srcText);
srcSaver.finalize();
src->setSource(srcText);
src->setUtf8Source(srcText);
src->parse();
src->check();
QCOMPARE(src->diagnosticMessages().size(), 0);
......@@ -528,7 +528,7 @@ void CppToolsPlugin::test_codegen_definition_last_member()
Utils::FileSaver dstSaver(dst->fileName());
dstSaver.write(dstText);
dstSaver.finalize();
dst->setSource(dstText);
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
QCOMPARE(dst->diagnosticMessages().size(), 0);
......@@ -592,7 +592,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
Utils::FileSaver srcSaver(src->fileName());
srcSaver.write(srcText);
srcSaver.finalize();
src->setSource(srcText);
src->setUtf8Source(srcText);
src->parse();
src->check();
QCOMPARE(src->diagnosticMessages().size(), 0);
......@@ -603,7 +603,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
Utils::FileSaver dstSaver(dst->fileName());
dstSaver.write(dstText);
dstSaver.finalize();
dst->setSource(dstText);
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
QCOMPARE(dst->diagnosticMessages().size(), 0);
......
......@@ -1844,7 +1844,7 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
QString possibleDecl = bs.mid(lineStartToken).trimmed().append("();");
Document::Ptr doc = Document::create(QLatin1String("<completion>"));
doc->setSource(possibleDecl.toLatin1());
doc->setUtf8Source(possibleDecl.toLatin1());
if (doc->parse(Document::ParseDeclaration)) {
doc->check();
if (SimpleDeclarationAST *sd = doc->translationUnit()->ast()->asSimpleDeclaration()) {
......
......@@ -589,7 +589,7 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type, unsigned
const QByteArray preprocessedCode = preprocess(fileName, contents);
doc->setSource(preprocessedCode);
doc->setUtf8Source(preprocessedCode);
doc->keepSourceAndAST();
doc->tokenize();
......
......@@ -82,7 +82,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor)
declCandidate.append(QLatin1Char('}'));
Document::Ptr doc = Document::create(QLatin1String("<doxygen>"));
doc->setSource(declCandidate.toUtf8());
doc->setUtf8Source(declCandidate.toUtf8());
doc->parse(Document::ParseDeclaration);
doc->check(Document::FastCheck);
......
......@@ -264,7 +264,7 @@ protected:
// and the expression
const Token begin = translationUnit()->tokenAt(typeId->firstToken());
const Token last = translationUnit()->tokenAt(typeId->lastToken() - 1);
exportedType.typeExpression = _doc->source().mid(begin.begin(), last.end() - begin.begin());
exportedType.typeExpression = _doc->utf8Source().mid(begin.begin(), last.end() - begin.begin());
_exportedTypes += exportedType;
......@@ -392,12 +392,12 @@ private:
{
const Token firstToken = translationUnit()->tokenAt(first);
const Token lastToken = translationUnit()->tokenAt(last);
return _doc->source().mid(firstToken.begin(), lastToken.end() - firstToken.begin());
return _doc->utf8Source().mid(firstToken.begin(), lastToken.end() - firstToken.begin());
}
QString stringOf(const Token &token)
{
return _doc->source().mid(token.begin(), token.length());
return _doc->utf8Source().mid(token.begin(), token.length());
}
ExpressionAST *skipStringCall(ExpressionAST *exp)
......@@ -689,7 +689,7 @@ void FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &document)
// this check only guards against some input errors, if document's source and AST has not
// been guarded properly the source and AST may still become empty/null while this function is running
if (document->source().isEmpty()
if (document->utf8Source().isEmpty()
|| !document->translationUnit()->ast())
return;
......@@ -710,7 +710,7 @@ void FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &document)
// context properties need lookup inside function scope, and thus require a full check
Document::Ptr localDoc = document;
if (document->checkMode() != Document::FullCheck && !contextPropertyDescriptions.isEmpty()) {
localDoc = m_snapshot.documentFromSource(document->source(), document->fileName());
localDoc = m_snapshot.documentFromSource(document->utf8Source(), document->fileName());
localDoc->check();
}
......
......@@ -710,7 +710,7 @@ void ModelManager::maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &do
{
// avoid scanning documents without source code available
doc->keepSourceAndAST();
if (doc->source().isEmpty()) {
if (doc->utf8Source().isEmpty()) {
doc->releaseSourceAndAST();
return;
}
......
......@@ -1069,7 +1069,7 @@ void generateAST_cpp(const Snapshot &snapshot, const QDir &cplusplusDir)
Document::Ptr AST_cpp_document = Document::create(fileName);
const QByteArray preprocessedCode = snapshot.preprocessedCode(source, fileName);
AST_cpp_document->setSource(preprocessedCode);
AST_cpp_document->setUtf8Source(preprocessedCode);
AST_cpp_document->check();
Overview oo;
......@@ -1373,7 +1373,7 @@ QStringList generateAST_H(const Snapshot &snapshot, const QDir &cplusplusDir, co
AST_h_document = Document::create(fileName);
const QByteArray preprocessedCode = snapshot.preprocessedCode(source, fileName);
AST_h_document->setSource(preprocessedCode);
AST_h_document->setUtf8Source(preprocessedCode);
AST_h_document->check();
FindASTNodes process(AST_h_document, &document);
......@@ -1520,7 +1520,7 @@ void generateASTFwd_h(const Snapshot &snapshot, const QDir &cplusplusDir, const
Document::Ptr doc = Document::create(fileName);
const QByteArray preprocessedCode = snapshot.preprocessedCode(source, fileName);
doc->setSource(preprocessedCode);
doc->setUtf8Source(preprocessedCode);
doc->check();
FindASTForwards process(doc, &document);
......
......@@ -100,7 +100,7 @@ void tst_FindUsages::inlineMethod()
" }\n"
"};\n";
Document::Ptr doc = Document::create("inlineMethod");
doc->setSource(src);
doc->setUtf8Source(src);
doc->parse();
doc->check();
......@@ -143,7 +143,7 @@ const QByteArray objcSource = "\n"
void tst_FindUsages::objc_args()
{
Document::Ptr doc = Document::create("objc_args");
doc->setSource(objcSource);
doc->setUtf8Source(objcSource);
doc->parse();
doc->check();
......@@ -199,7 +199,7 @@ void tst_FindUsages::qproperty_1()
" int _x;\n"
"};\n";
Document::Ptr doc = Document::create("qproperty_1");
doc->setSource(src);
doc->setUtf8Source(src);
doc->parse();
doc->check();
......
......@@ -114,7 +114,7 @@ void tst_Lookup::base_class_defined_1()
"class derived: public base {};\n";
Document::Ptr doc = Document::create("base_class_defined_1");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......@@ -163,7 +163,7 @@ void tst_Lookup::simple_class_1()
"@implementation Zoo +(id)alloc{} -(id)init{} -(void)dealloc{} @end\n";
Document::Ptr doc = Document::create("simple_class_1");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......@@ -226,7 +226,7 @@ void tst_Lookup::class_with_baseclass()
"@implementation Zoo +(id)alloc{} -(id)init{} -(void)dealloc{} @end\n";
Document::Ptr doc = Document::create("class_with_baseclass");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......@@ -287,7 +287,7 @@ void tst_Lookup::class_with_protocol_with_protocol()
"@implementation Zoo +(id)alloc{} -(id)init{} -(void)dealloc{} @end\n";
Document::Ptr doc = Document::create("class_with_protocol_with_protocol");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......@@ -341,7 +341,7 @@ void tst_Lookup::iface_impl_scoping()
"@implementation Scooping-(int)method1:(int)arg{return arg;}@end\n";
Document::Ptr doc = Document::create("class_with_protocol_with_protocol");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......@@ -431,7 +431,7 @@ void tst_Lookup::templates_1()
" l.end(); // std::_List_iterator<Point>\n"
"}\n";
Document::Ptr doc = Document::create("templates_1");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......@@ -462,7 +462,7 @@ void tst_Lookup::templates_2()
"}\n"
;
Document::Ptr doc = Document::create("templates_2");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......@@ -487,7 +487,7 @@ void tst_Lookup::templates_3()
" l.at(0); // const Point &\n"
"}\n";
Document::Ptr doc = Document::create("templates_3");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......@@ -528,7 +528,7 @@ void tst_Lookup::templates_4()
" (*l); // Point &\n"
"}\n";
Document::Ptr doc = Document::create("templates_4");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......@@ -558,7 +558,7 @@ void tst_Lookup::templates_5()
" a.get(); // const Point &\n"
"}\n";
Document::Ptr doc = Document::create("templates_5");
doc->setSource(source);
doc->setUtf8Source(source);
doc->parse();
doc->check();
......
......@@ -59,7 +59,7 @@ void tst_Misc::diagnosticClient_error()
);
Document::Ptr doc = Document::create("diagnosticClient_error");
QVERIFY(!doc.isNull());
doc->setSource(src);
doc->setUtf8Source(src);
bool success = doc->parse(Document::ParseTranlationUnit);
QVERIFY(success);
......@@ -79,7 +79,7 @@ void tst_Misc::diagnosticClient_warning()
);
Document::Ptr doc = Document::create("diagnosticClient_warning");
QVERIFY(!doc.isNull());
doc->setSource(src);
doc->setUtf8Source(src);
bool success = doc->parse(Document::ParseTranlationUnit);
QVERIFY(success);
......@@ -132,7 +132,7 @@ void tst_Misc::findBreakpoints()
);
Document::Ptr doc = Document::create("findContstructorBreakpoint");
QVERIFY(!doc.isNull());
doc->setSource(src);
doc->setUtf8Source(src);
bool success = doc->parse();
QVERIFY(success);
QCOMPARE(doc->diagnosticMessages().size(), 0);
......@@ -161,7 +161,7 @@ void tst_Misc::findBreakpoints2()
);
Document::Ptr doc = Document::create("findContstructorBreakpoint");
QVERIFY(!doc.isNull());
doc->setSource(src);
doc->setUtf8Source(src);
bool success = doc->parse();
QVERIFY(success);
QCOMPARE(doc->diagnosticMessages().size(), 0);
......
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