forked from qt-creator/qt-creator
Moved startOffset/endOffset from Symbol to Scope.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{ }
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user