Commit 107544bd authored by Christian Kamm's avatar Christian Kamm
Browse files

C++: Set endOffset of Function symbols even if skipping bodies.

Fixes insert-definition-from-declaration when the source file was not
yet opened in an editor.

Change-Id: I4263113390ae4fbe9d4641104b5cb43373ddc5a4
Reviewed-on: http://codereview.qt-project.org/4394

Reviewed-by: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent daf6f5ff
...@@ -2007,6 +2007,7 @@ bool Bind::visit(FunctionDefinitionAST *ast) ...@@ -2007,6 +2007,7 @@ bool Bind::visit(FunctionDefinitionAST *ast)
if (fun) { if (fun) {
setDeclSpecifiers(fun, declSpecifiers); setDeclSpecifiers(fun, declSpecifiers);
fun->setEndOffset(tokenAt(ast->lastToken() - 1).end());
if (_scope->isClass()) { if (_scope->isClass()) {
fun->setVisibility(_visibility); fun->setVisibility(_visibility);
...@@ -2028,12 +2029,6 @@ bool Bind::visit(FunctionDefinitionAST *ast) ...@@ -2028,12 +2029,6 @@ bool Bind::visit(FunctionDefinitionAST *ast)
Scope *previousScope = switchScope(fun); Scope *previousScope = switchScope(fun);
this->statement(ast->function_body); this->statement(ast->function_body);
(void) switchScope(previousScope); (void) switchScope(previousScope);
if (CompoundStatementAST *c = ast->function_body->asCompoundStatement()) {
if (c->symbol) {
fun->setEndOffset(c->symbol->endOffset());
}
}
} }
return false; return false;
......
...@@ -548,7 +548,6 @@ static InsertionLocation nextToSurroundingDefinitions(Declaration *declaration, ...@@ -548,7 +548,6 @@ static InsertionLocation nextToSurroundingDefinitions(Declaration *declaration,
return InsertionLocation(definition->fileName(), prefix, suffix, line, column); return InsertionLocation(definition->fileName(), prefix, suffix, line, column);
} }
/// Currently, we return the end of fileName.cpp
QList<InsertionLocation> InsertionPointLocator::methodDefinition( QList<InsertionLocation> InsertionPointLocator::methodDefinition(
Declaration *declaration) const Declaration *declaration) const
{ {
......
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