diff --git a/src/shared/cplusplus/CheckDeclaration.cpp b/src/shared/cplusplus/CheckDeclaration.cpp index d3f914a3e8c25cde8e1cadfb2d59482ab4e7a29a..3cf8040e39c8d2a2974a0c9cb5a1c8e7dce54d8a 100644 --- a/src/shared/cplusplus/CheckDeclaration.cpp +++ b/src/shared/cplusplus/CheckDeclaration.cpp @@ -230,8 +230,6 @@ bool CheckDeclaration::visit(SimpleDeclarationAST *ast) } Declaration *symbol = control()->newDeclaration(location, name); - symbol->setStartOffset(tokenAt(ast->firstToken()).offset); - symbol->setEndOffset(tokenAt(ast->lastToken() - 1).end()); symbol->setType(declTy); if (declTy.isDeprecated()) @@ -321,8 +319,6 @@ bool CheckDeclaration::visit(ExceptionDeclarationAST *ast) } Declaration *symbol = control()->newDeclaration(location, name); - symbol->setStartOffset(tokenAt(ast->firstToken()).offset); - symbol->setEndOffset(tokenAt(ast->lastToken() - 1).end()); symbol->setType(declTy); _scope->enterSymbol(symbol); @@ -444,8 +440,6 @@ bool CheckDeclaration::visit(NamespaceAliasDefinitionAST *ast) NamespaceAlias *namespaceAlias = control()->newNamespaceAlias(sourceLocation, name); namespaceAlias->setNamespaceName(namespaceName); - namespaceAlias->setStartOffset(tokenAt(ast->firstToken()).offset); - namespaceAlias->setEndOffset(tokenAt(ast->lastToken() - 1).end()); //ast->symbol = namespaceAlias; _scope->enterSymbol(namespaceAlias); @@ -578,8 +572,6 @@ bool CheckDeclaration::visit(ObjCProtocolForwardDeclarationAST *ast) const Name *protocolName = semantic()->check(it->value, _scope); ObjCForwardProtocolDeclaration *fwdProtocol = control()->newObjCForwardProtocolDeclaration(sourceLocation, protocolName); - fwdProtocol->setStartOffset(tokenAt(ast->firstToken()).offset); - fwdProtocol->setEndOffset(tokenAt(ast->lastToken() - 1).end()); _scope->enterSymbol(fwdProtocol); @@ -639,8 +631,6 @@ bool CheckDeclaration::visit(ObjCClassForwardDeclarationAST *ast) const Name *className = semantic()->check(it->value, _scope); ObjCForwardClassDeclaration *fwdClass = control()->newObjCForwardClassDeclaration(sourceLocation, className); - fwdClass->setStartOffset(tokenAt(ast->firstToken()).offset); - fwdClass->setEndOffset(tokenAt(ast->lastToken() - 1).end()); _scope->enterSymbol(fwdClass); @@ -726,6 +716,8 @@ bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast) Symbol *symbol; if (ast->function_body) { symbol = methodTy; + methodTy->setStartOffset(tokenAt(ast->firstToken()).offset); + methodTy->setEndOffset(tokenAt(ast->lastToken() - 1).end()); } else { Declaration *decl = control()->newDeclaration(selector->firstToken(), methodTy->name()); decl->setType(methodTy); @@ -733,8 +725,6 @@ bool CheckDeclaration::visit(ObjCMethodDeclarationAST *ast) symbol->setStorage(methodTy->storage()); } - symbol->setStartOffset(tokenAt(ast->firstToken()).offset); - symbol->setEndOffset(tokenAt(ast->lastToken() - 1).end()); symbol->setVisibility(semantic()->currentObjCVisibility()); if (ty.isDeprecated()) symbol->setDeprecated(true); diff --git a/src/shared/cplusplus/Scope.cpp b/src/shared/cplusplus/Scope.cpp index 22eddedd415b7e8e3e2395a629c263e1a182617c..de0f147eb3e329346688df6571ee20ba42ca88fa 100644 --- a/src/shared/cplusplus/Scope.cpp +++ b/src/shared/cplusplus/Scope.cpp @@ -61,7 +61,9 @@ Scope::Scope(ScopedSymbol *owner) _allocatedSymbols(0), _symbolCount(-1), _hash(0), - _hashSize(0) + _hashSize(0), + _startOffset(0), + _endOffset(0) { } Scope::~Scope() @@ -333,4 +335,16 @@ Scope::iterator Scope::firstSymbol() const Scope::iterator Scope::lastSymbol() const { return _symbols + _symbolCount + 1; } +unsigned Scope::startOffset() const +{ return _startOffset; } + +void Scope::setStartOffset(unsigned offset) +{ _startOffset = offset; } + +unsigned Scope::endOffset() const +{ return _endOffset; } + +void Scope::setEndOffset(unsigned offset) +{ _endOffset = offset; } + diff --git a/src/shared/cplusplus/Scope.h b/src/shared/cplusplus/Scope.h index 7ad6ecf2324243011478c0a939b64df1a86db6cd..09eded99076bd98753ae5ac9199205a7ffe976a2 100644 --- a/src/shared/cplusplus/Scope.h +++ b/src/shared/cplusplus/Scope.h @@ -142,6 +142,14 @@ public: Symbol *lookat(const Identifier *id) const; Symbol *lookat(int operatorId) const; + /// Set the start offset of the scope + unsigned startOffset() const; + void setStartOffset(unsigned offset); + + /// Set the end offset of the scope + unsigned endOffset() const; + void setEndOffset(unsigned offset); + private: /// Returns the hash value for the given Symbol. unsigned hashValue(Symbol *symbol) const; @@ -160,6 +168,9 @@ private: Symbol **_hash; int _hashSize; + + unsigned _startOffset; + unsigned _endOffset; }; } // end of namespace CPlusPlus diff --git a/src/shared/cplusplus/Symbol.cpp b/src/shared/cplusplus/Symbol.cpp index af168982da423214d74361df3a30a298120a7e52..7262522a11b40d3eaf4ded41e548de9d43ccca4e 100644 --- a/src/shared/cplusplus/Symbol.cpp +++ b/src/shared/cplusplus/Symbol.cpp @@ -111,9 +111,7 @@ private: }; Symbol::Symbol(TranslationUnit *translationUnit, unsigned sourceLocation, const Name *name) - : _startOffset(0), - _endOffset(0), - _name(0), + : _name(0), _hashCode(0), _storage(Symbol::NoStorage), _visibility(Symbol::Public), @@ -201,18 +199,6 @@ const char *Symbol::fileName() const unsigned Symbol::fileNameLength() const { return fileId()->size(); } -unsigned Symbol::startOffset() const -{ return _startOffset; } - -void Symbol::setStartOffset(unsigned offset) -{ _startOffset = offset; } - -unsigned Symbol::endOffset() const -{ return _endOffset; } - -void Symbol::setEndOffset(unsigned offset) -{ _endOffset = offset; } - const Name *Symbol::identity() const { if (! _name) @@ -433,8 +419,6 @@ bool Symbol::isObjCPropertyDeclaration() const void Symbol::copy(Symbol *other) { _sourceLocation = other->_sourceLocation; - _startOffset = other->_startOffset; - _endOffset = other->_endOffset; _name = other->_name; _hashCode = other->_hashCode; _storage = other->_storage; diff --git a/src/shared/cplusplus/Symbol.h b/src/shared/cplusplus/Symbol.h index c6ce1a64023d13339623643a762180befbf8bcf3..ee32779c946c27d0f88c6b1bc156d9b8e873be33 100644 --- a/src/shared/cplusplus/Symbol.h +++ b/src/shared/cplusplus/Symbol.h @@ -105,12 +105,6 @@ public: /// Returns this Symbol's file name length. unsigned fileNameLength() const; - unsigned startOffset() const; - void setStartOffset(unsigned offset); - - unsigned endOffset() const; - void setEndOffset(unsigned offset); - /// Returns this Symbol's name. const Name *name() const; @@ -320,8 +314,6 @@ protected: private: unsigned _sourceLocation; - unsigned _startOffset; - unsigned _endOffset; const Name *_name; unsigned _hashCode; int _storage; diff --git a/src/shared/cplusplus/Symbols.cpp b/src/shared/cplusplus/Symbols.cpp index e82a60ae199e92cd9bd25bf0d388412b67f61d6c..5d64149360ef44f1e96f2be8d556eabe9b7d31cc 100644 --- a/src/shared/cplusplus/Symbols.cpp +++ b/src/shared/cplusplus/Symbols.cpp @@ -427,6 +427,18 @@ Scope *ScopedSymbol::members() const void ScopedSymbol::addMember(Symbol *member) { _members->enterSymbol(member); } +unsigned ScopedSymbol::startOffset() const +{ return _members->startOffset(); } + +void ScopedSymbol::setStartOffset(unsigned offset) +{ _members->setStartOffset(offset); } + +unsigned ScopedSymbol::endOffset() const +{ return _members->endOffset(); } + +void ScopedSymbol::setEndOffset(unsigned offset) +{ _members->setEndOffset(offset); } + Block::Block(TranslationUnit *translationUnit, unsigned sourceLocation) : ScopedSymbol(translationUnit, sourceLocation, /*name = */ 0) { } diff --git a/src/shared/cplusplus/Symbols.h b/src/shared/cplusplus/Symbols.h index 2a90fd0cc0306b5712e4f9385fea450129a1d67b..05a1241ec405d33df726bd9f54880ca21e17425c 100644 --- a/src/shared/cplusplus/Symbols.h +++ b/src/shared/cplusplus/Symbols.h @@ -234,6 +234,14 @@ public: virtual ScopedSymbol *asScopedSymbol() { return this; } + /// Set the start offset of the scope for this symbol + unsigned startOffset() const; + void setStartOffset(unsigned offset); + + /// Set the end offset of the scope for this symbol + unsigned endOffset() const; + void setEndOffset(unsigned offset); + private: Scope *_members; };