forked from qt-creator/qt-creator
C++: fix tooltip for constantValue of enumeratorDeclaration
E.g.:
enum E { x = 1 + 2 + 1 };
constantValue for enumeratorDeclaration currently is equal: '1+2+1'
(spaces between are removed).
Fixed version produces "1 + 2 + 1".
Change-Id: I38f7703bd5c856c28aadeecd7f7923aa4a7da422
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
fe39e8e9c3
commit
f068223133
7
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
7
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -476,7 +476,7 @@ void Bind::enumerator(EnumeratorAST *ast, Enum *symbol)
|
||||
e->setType(control()->integerType(IntegerType::Int)); // ### introduce IntegerType::Enumerator
|
||||
|
||||
if (ExpressionAST *expr = ast->expression)
|
||||
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken(), false));
|
||||
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken()));
|
||||
|
||||
symbol->addMember(e);
|
||||
}
|
||||
@@ -1137,13 +1137,12 @@ FullySpecifiedType Bind::trailingReturnType(TrailingReturnTypeAST *ast, const Fu
|
||||
return type;
|
||||
}
|
||||
|
||||
const StringLiteral *Bind::asStringLiteral(unsigned firstToken, unsigned lastToken,
|
||||
bool addWhitespace)
|
||||
const StringLiteral *Bind::asStringLiteral(unsigned firstToken, unsigned lastToken)
|
||||
{
|
||||
std::string buffer;
|
||||
for (unsigned index = firstToken; index != lastToken; ++index) {
|
||||
const Token &tk = tokenAt(index);
|
||||
if (addWhitespace && (tk.whitespace() || tk.newline()))
|
||||
if (index != firstToken && (tk.whitespace() || tk.newline()))
|
||||
buffer += ' ';
|
||||
buffer += tk.spell();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user