Refactored to remove code duplication.

This commit is contained in:
Pete Johns 2011-01-18 20:51:57 +11:00
parent abfd907763
commit 62063aa250
1 changed files with 11 additions and 15 deletions

View File

@ -1233,6 +1233,7 @@ const Token* skipPointers(const Token* tok)
bool SymbolDatabase::SpaceInfo::isVariableDeclaration(const Token* tok, const Token*& vartok, const Token*& typetok) const bool SymbolDatabase::SpaceInfo::isVariableDeclaration(const Token* tok, const Token*& vartok, const Token*& typetok) const
{ {
const Token* localTypeTok = skipScopeIdentifiers(tok); const Token* localTypeTok = skipScopeIdentifiers(tok);
const Token* localVarTok = NULL;
if (Token::Match(localTypeTok, "%type% < ")) if (Token::Match(localTypeTok, "%type% < "))
{ {
@ -1240,30 +1241,25 @@ bool SymbolDatabase::SpaceInfo::isVariableDeclaration(const Token* tok, const To
bool found = findClosingBracket(localTypeTok->next(), closeTok); bool found = findClosingBracket(localTypeTok->next(), closeTok);
if (found) if (found)
{ {
const Token* localVarTok = skipPointers(closeTok->next()); localVarTok = skipPointers(closeTok->next());
if (isSimpleVariable(localVarTok) || isArrayVariable(localVarTok)) if (Token::Match(localVarTok, ":: %type% %var% ;"))
{ {
vartok = localVarTok; localTypeTok = localVarTok->next();
typetok = localTypeTok; localVarTok = localVarTok->tokAt(2);
}
else if (Token::Match(closeTok, "> :: %type% %var% ;"))
{
vartok = closeTok->tokAt(3);
typetok = closeTok->tokAt(2);
} }
} }
} }
else if (Token::Match(localTypeTok, "%type%")) else if (Token::Match(localTypeTok, "%type%"))
{ {
const Token* localVarTok = skipPointers(localTypeTok->next()); localVarTok = skipPointers(localTypeTok->next());
}
if (isSimpleVariable(localVarTok) || isArrayVariable(localVarTok)) if (isSimpleVariable(localVarTok) || isArrayVariable(localVarTok))
{ {
vartok = localVarTok; vartok = localVarTok;
typetok = localTypeTok; typetok = localTypeTok;
} }
}
return NULL != vartok; return NULL != vartok;
} }