diff --git a/codecompletion/context.cpp b/codecompletion/context.cpp --- a/codecompletion/context.cpp +++ b/codecompletion/context.cpp @@ -44,10 +44,10 @@ namespace go { - + CodeCompletionContext::CodeCompletionContext(const KDevelop::DUContextPointer& context, - const QString& text, - const KDevelop::CursorInRevision& position, int depth): + const QString& text, + const KDevelop::CursorInRevision& position, int depth): KDevelop::CodeCompletionContext(context, extractLastExpression(text), position, depth), m_fullText(text) { @@ -66,6 +66,8 @@ QList< CompletionTreeItemPointer > CodeCompletionContext::completionItems(bool& abort, bool fullCompletion) { + Q_UNUSED(abort); + Q_UNUSED(fullCompletion); qCDebug(COMPLETION) << m_text; QList items; @@ -344,14 +346,14 @@ Lexer lexer(iter); bool atEnd=false; ExpressionStackEntry entry; - + entry.startPosition = 0; entry.operatorStart = 0; entry.operatorEnd = 0; entry.commas = 0; - + stack.push(entry); - + qint64 line, lineEnd, column, columnEnd; while(!atEnd) { @@ -382,7 +384,7 @@ break; case Parser::Token_IDENT: //temporary hack to allow completion in variable declarations - //two identifiers in a row is not possible? + //two identifiers in a row is not possible? if(lexer.size() > 1 && lexer.at(lexer.index()-2).kind == Parser::Token_IDENT) { lexer.locationTable()->positionAt(lexer.at(lexer.index()-2).begin, &line, &column); @@ -498,15 +500,15 @@ } else if(inDoubleQuotes) { - if(c != QLatin1Char('\\') && next == QLatin1Char('\"')) + if(c != QLatin1Char('\\') && next == QLatin1Char('"')) { inDoubleQuotes = false; continue; } } else if(inBackQuotes) { - if(c != QLatin1Char('\\') && next == QLatin1Char('\`')) + if(c != QLatin1Char('\\') && next == QLatin1Char('`')) { inBackQuotes = false; continue; @@ -522,7 +524,7 @@ inQuotes = true; if(next == QLatin1Char('\"')) inDoubleQuotes = true; - if(next == QLatin1Char('\`')) + if(next == QLatin1Char('`')) inBackQuotes = true; } } diff --git a/codecompletion/items/completionitem.cpp b/codecompletion/items/completionitem.cpp --- a/codecompletion/items/completionitem.cpp +++ b/codecompletion/items/completionitem.cpp @@ -33,6 +33,8 @@ NormalDeclarationCompletionItem(decl, QExplicitlySharedDataPointer(), 0), m_prefix("") { + Q_UNUSED(context); + Q_UNUSED(inheritanceDepth); DUChainReadLocker lock; if(!decl) return; diff --git a/codecompletion/worker.cpp b/codecompletion/worker.cpp --- a/codecompletion/worker.cpp +++ b/codecompletion/worker.cpp @@ -29,10 +29,11 @@ } KDevelop::CodeCompletionContext* CodeCompletionWorker::createCompletionContext(const KDevelop::DUContextPointer& context, - const QString& contextText, - const QString& followingText, + const QString& contextText, + const QString& followingText, const KDevelop::CursorInRevision& position) const { + Q_UNUSED(followingText); qCDebug(COMPLETION) << "Completion test"; //return go::CodeCompletionWorker::createCompletionContext(context, contextText, followingText, position); return new go::CodeCompletionContext(context, contextText, position); diff --git a/duchain/builders/contextbuilder.cpp b/duchain/builders/contextbuilder.cpp --- a/duchain/builders/contextbuilder.cpp +++ b/duchain/builders/contextbuilder.cpp @@ -86,7 +86,7 @@ TopDUContext* ContextBuilder::newTopContext(const RangeInRevision& range, ParsingEnvironmentFile* file) { - + if (!file) { file = new ParsingEnvironmentFile(m_session->currentDocument()); file->setLanguage(m_session->languageString()); @@ -185,7 +185,6 @@ } if(declaration && declaration->kind() == Declaration::Type) { - const RangeInRevision &range = editorFindRange(primaryExprResolveNode->literalValue, 0); openContext(node->id, editorFindRange(primaryExprResolveNode->literalValue, 0), DUContext::Other, id); visitPrimaryExprResolve(node->primaryExprResolve); closeContext(); diff --git a/duchain/builders/declarationbuilder.cpp b/duchain/builders/declarationbuilder.cpp --- a/duchain/builders/declarationbuilder.cpp +++ b/duchain/builders/declarationbuilder.cpp @@ -404,7 +404,7 @@ QList contexts = m_session->contextForImport(import); if(contexts.empty()) return; - + //usually package name matches directory, so try searching for that first QualifiedIdentifier packageName(import.mid(1, import.length()-2)); bool firstContext = true; @@ -424,7 +424,7 @@ } if(!decl) //contexts belongs to a different package continue; - + DUChainWriteLocker lock; if(firstContext) //only open declarations once per import(others are redundant) { @@ -438,7 +438,7 @@ closeDeclaration(); }else if(node->dot != -1) {//anonymous import - NamespaceAliasDeclaration* decl = openDeclaration(QualifiedIdentifier(globalImportIdentifier()), + NamespaceAliasDeclaration* decl = openDeclaration(QualifiedIdentifier(globalImportIdentifier()), editorFindRange(node->importpath, 0)); decl->setKind(Declaration::NamespaceAlias); decl->setImportIdentifier(packageName); //this needs to be actual package name @@ -463,7 +463,7 @@ Declaration* packageDeclaration = openDeclaration(identifierForNode(node->packageClause->packageName), editorFindRange(node->packageClause->packageName, 0)); packageDeclaration->setKind(Declaration::Namespace); openContext(node, editorFindRange(node, 0), DUContext::Namespace, identifierForNode(node->packageClause->packageName)); - + packageDeclaration->setInternalContext(currentContext()); lock.unlock(); m_thisPackage = identifierForNode(node->packageClause->packageName); @@ -496,7 +496,7 @@ DUChainWriteLocker lock; //TODO Since package names are identical duchain should find declarations without namespace alias, right? - + //NamespaceAliasDeclaration* import = openDeclaration(QualifiedIdentifier(globalImportIdentifier()), RangeInRevision()); //import->setKind(Declaration::NamespaceAlias); //import->setImportIdentifier(packageName); //this needs to be actual package name @@ -678,6 +678,7 @@ go::GoFunctionDeclaration *declaration, const QualifiedIdentifier &identifier) { + Q_UNUSED(declaration); setComment(comment); DUChainWriteLocker lock; auto dec = openDefinition(identifier, editorFindRange(id, 0)); diff --git a/duchain/builders/typebuilder.cpp b/duchain/builders/typebuilder.cpp --- a/duchain/builders/typebuilder.cpp +++ b/duchain/builders/typebuilder.cpp @@ -285,6 +285,7 @@ go::GoFunctionType::Ptr TypeBuilder::parseSignature(go::SignatureAst *node, bool declareParameters, DUContext **parametersContext, DUContext **returnArgsContext, const QualifiedIdentifier &identifier, const QByteArray &comment) { + Q_UNUSED(comment); go::GoFunctionType::Ptr type(new go::GoFunctionType()); openType(type); diff --git a/duchain/expressionvisitor.cpp b/duchain/expressionvisitor.cpp --- a/duchain/expressionvisitor.cpp +++ b/duchain/expressionvisitor.cpp @@ -30,7 +30,7 @@ using namespace KDevelop; -namespace go +namespace go { ExpressionVisitor::ExpressionVisitor(ParseSession* session, DUContext* context, DeclarationBuilder* builder) : @@ -71,7 +71,7 @@ for(const AbstractType::Ptr &type : types) addType(type); } - + //push unknown type if we failed to find anything else if(m_types.size() == 0) pushType(AbstractType::Ptr(new IntegralType(IntegralType::TypeNone))); @@ -120,7 +120,7 @@ if(node->id) { //first try to handle builtin functions, so we can allow identifiers like "make" - if(!handleBuiltinFunction(node)) + if(!handleBuiltinFunction(node)) { QualifiedIdentifier id(identifierForNode(node->id)); DeclarationPointer decl = go::getTypeOrVarDeclaration(id, m_context); @@ -141,7 +141,7 @@ } m_declaration = decl; //qCDebug(DUCHAIN) << "Expression Visitor for "<< id; - + //this handles stuff like mytype{}, mytype() if((node->literalValue || node->callOrBuiltinParam) && decl->kind() == Declaration::Type) { @@ -183,7 +183,7 @@ { pushType(decl->abstractType()); } - } + } } } else if(node->expression) @@ -213,15 +213,15 @@ //note that methods do NOT inherit from type to type //e.g. type mystruct int; type mystruct2 mystruct; func (m mystruct) method() {}; //in this example mystruct2 will NOT have method method() - + //second type is field members of Go structs and interfaces(e.g. struct{ abc int}{10}. or mystruct{10}. // ^ ^ // ^ - we are here - //note that members are inherited(e.g. type mystruct struct { var1 int}; type mystruct2 mystruct; + //note that members are inherited(e.g. type mystruct struct { var1 int}; type mystruct2 mystruct; //in this example mystruct2 will have member named var1 //hope this explanation helps understand this code and some code in completion classes - - + + bool success=false; AbstractType::Ptr type = types.first(); //evaluate pointers @@ -232,7 +232,7 @@ if(ptype->baseType()) type = ptype->baseType(); } - + if(fastCast(type.constData())) {//we have to look for namespace declarations DUChainReadLocker lock; @@ -291,7 +291,7 @@ } else break; - + } while(type && count < 100); //if we descended 100 times and still didn't find anything - something is wrong } } @@ -539,6 +539,7 @@ void ExpressionVisitor::visitBlock(BlockAst* node) { + Q_UNUSED(node); } diff --git a/duchain/helper.cpp b/duchain/helper.cpp --- a/duchain/helper.cpp +++ b/duchain/helper.cpp @@ -160,7 +160,7 @@ for(Declaration* decl : declarations) { if((decl->kind() == Declaration::Import) || (decl->kind() == Declaration::Namespace) || (decl->kind() == Declaration::NamespaceAlias)) - continue; + continue; return DeclarationPointer(decl); } if(searchInParent && context->parentContext()) @@ -180,9 +180,9 @@ for(Declaration* decl : declarations) { //TODO change this to just decl->kind() != Declaration::Type - if((decl->kind() == Declaration::Import) || (decl->kind() == Declaration::Namespace) + if((decl->kind() == Declaration::Import) || (decl->kind() == Declaration::Namespace) || (decl->kind() == Declaration::NamespaceAlias) || (decl->kind() == Declaration::Instance)) - continue; + continue; return DeclarationPointer(decl); } if(searchInParent && context->parentContext()) @@ -195,6 +195,7 @@ QList< Declaration* > getDeclarations(QualifiedIdentifier id, DUContext* context, bool searchInParent) { + Q_UNUSED(searchInParent); DUChainReadLocker lock; if(context) { diff --git a/golangparsejob.cpp b/golangparsejob.cpp --- a/golangparsejob.cpp +++ b/golangparsejob.cpp @@ -47,7 +47,9 @@ void GoParseJob::run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread *thread) { - qCDebug(Go) << "GoParseJob succesfully created for document " << document(); + Q_UNUSED(self); + Q_UNUSED(thread); + qCDebug(Go) << "GoParseJob succesfully created for document " << document(); UrlParseLock urlLock(document()); @@ -66,7 +68,7 @@ //ParseSession session(QString(contents().contents).toUtf8(), priority()); ParseSession session(code, parsePriority()); - + session.setCurrentDocument(document()); session.setFeatures(minimumFeatures()); @@ -79,9 +81,9 @@ DUChainReadLocker lock; context = DUChainUtils::standardContextForUrl(document().toUrl()); } - + //ParsingEnvironmentFilePointer filep = context->parsingEnvironmentFile(); - + if (context) { translateDUChainToRevision(context); context->setRange(RangeInRevision(0, 0, INT_MAX, INT_MAX)); @@ -137,7 +139,7 @@ context = new TopDUContext(document(), RangeInRevision(0, 0, INT_MAX, INT_MAX), file); DUChain::self()->addDocumentChain(context); } - + setDuChain(context); { DUChainWriteLocker lock; diff --git a/parser/parsesession.h b/parser/parsesession.h --- a/parser/parsesession.h +++ b/parser/parsesession.h @@ -45,19 +45,19 @@ class KDEVGOPARSER_EXPORT ParseSession { public: - + ParseSession(const QByteArray& contents, int priority, bool appendWithNewline=true); - + virtual ~ParseSession(); - + static KDevelop::IndexedString languageString(); - + bool startParsing(); - + bool parseExpression(go::ExpressionAst **node); - + go::StartAst* ast(); - + QString symbol(qint64 index); KDevelop::RangeInRevision findRange(go::AstNode* from, go::AstNode* to); @@ -96,10 +96,11 @@ void setCanonicalImports(QHash* imports); + /** * Returns doc comment preceding given token. - * GoDoc comments are multilined /*-style comments - * or several consecutive single-lined //-style comments + * GoDoc comments are multilined dash-star-style comments (/\*) + * or several consecutive single-lined dash-dash-style comments (//) * with no empty line between them. * Comment must start on a new line and end a line before given declaration. **/ @@ -111,23 +112,23 @@ * This only exists, because parser test application uses DebugVisitor, which needs a lexer */ friend go::Lexer* getLexer(const ParseSession& session) { return session.m_lexer; } - + void mapAstUse(go::AstNode* node, const SimpleUse& use) { Q_UNUSED(node); Q_UNUSED(use); } private: - + bool lex(); - + KDevPG::MemoryPool* m_pool; go::Lexer* m_lexer; go::Parser* m_parser; go::StartAst* m_ast; QByteArray m_contents; - + int m_priority; KDevelop::IndexedString m_document; KDevelop::TopDUContext::Features m_features; diff --git a/parser/parsesession.cpp b/parser/parsesession.cpp --- a/parser/parsesession.cpp +++ b/parser/parsesession.cpp @@ -51,12 +51,12 @@ // See more in Go Language Specification http://golang.org/ref/spec#Semicolons if(appendWithNewline) m_contents.append("\n"); - KDevPG::QByteArrayIterator iter(m_contents); + KDevPG::QByteArrayIterator iter(m_contents); m_lexer = new go::Lexer(iter); m_parser->setMemoryPool(m_pool); m_parser->setTokenStream(m_lexer); forExport=false; - + } ParseSession::~ParseSession() @@ -77,13 +77,12 @@ { if(!lex()) return false; - + return m_parser->parseStart(&m_ast); } bool ParseSession::lex() { - KDevPG::Token token; int kind = go::Parser::Token_EOF; while((kind = m_lexer->read().kind) != go::Parser::Token_EOF) { @@ -104,7 +103,7 @@ { if(!lex()) return false; - + return m_parser->parseExpression(node); } @@ -215,7 +214,7 @@ shouldReparse = true; } } - if(shouldReparse) + if(shouldReparse) //reparse this file after its imports are done scheduleForParsing(m_document, priority+1, (TopDUContext::Features)(m_features | TopDUContext::ForceUpdate)); @@ -236,13 +235,13 @@ if(forExport && priority >= BackgroundParser::InitialParsePriority && priority < BackgroundParser::WorstPriority - 2*levels) //if(forExport) return false; - - if (bgparser->isQueued(url)) + + if (bgparser->isQueued(url)) { - if (bgparser->priorityForDocument(url) > priority ) + if (bgparser->priorityForDocument(url) > priority ) // Remove the document and re-queue it with a greater priority bgparser->removeDocument(url); - else + else return true; } bgparser->addDocument(url, features, priority, 0, ParseJob::FullSequentialProcessing); @@ -295,9 +294,9 @@ continue; if(forExport && filename.endsWith("_test.go")) continue; - + IndexedString url(filename); - DUChainReadLocker lock; + DUChainReadLocker lock; ReferencedTopDUContext context = DUChain::self()->chainForDocument(url); lock.unlock(); if(context) @@ -307,7 +306,7 @@ if(scheduleForParsing(url, priority, (TopDUContext::Features)(TopDUContext::ForceUpdate | TopDUContext::AllDeclarationsAndContexts))) shouldReparse=true; } - + } if(shouldReparse) scheduleForParsing(m_document, priority+1, (TopDUContext::Features)(m_features | TopDUContext::ForceUpdate));