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
|
e->setType(control()->integerType(IntegerType::Int)); // ### introduce IntegerType::Enumerator
|
||||||
|
|
||||||
if (ExpressionAST *expr = ast->expression)
|
if (ExpressionAST *expr = ast->expression)
|
||||||
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken(), false));
|
e->setConstantValue(asStringLiteral(expr->firstToken(), expr->lastToken()));
|
||||||
|
|
||||||
symbol->addMember(e);
|
symbol->addMember(e);
|
||||||
}
|
}
|
||||||
@@ -1137,13 +1137,12 @@ FullySpecifiedType Bind::trailingReturnType(TrailingReturnTypeAST *ast, const Fu
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
const StringLiteral *Bind::asStringLiteral(unsigned firstToken, unsigned lastToken,
|
const StringLiteral *Bind::asStringLiteral(unsigned firstToken, unsigned lastToken)
|
||||||
bool addWhitespace)
|
|
||||||
{
|
{
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
for (unsigned index = firstToken; index != lastToken; ++index) {
|
for (unsigned index = firstToken; index != lastToken; ++index) {
|
||||||
const Token &tk = tokenAt(index);
|
const Token &tk = tokenAt(index);
|
||||||
if (addWhitespace && (tk.whitespace() || tk.newline()))
|
if (index != firstToken && (tk.whitespace() || tk.newline()))
|
||||||
buffer += ' ';
|
buffer += ' ';
|
||||||
buffer += tk.spell();
|
buffer += tk.spell();
|
||||||
}
|
}
|
||||||
|
3
src/libs/3rdparty/cplusplus/Bind.h
vendored
3
src/libs/3rdparty/cplusplus/Bind.h
vendored
@@ -105,8 +105,7 @@ protected:
|
|||||||
void capture(CaptureAST *ast);
|
void capture(CaptureAST *ast);
|
||||||
void lambdaDeclarator(LambdaDeclaratorAST *ast);
|
void lambdaDeclarator(LambdaDeclaratorAST *ast);
|
||||||
FullySpecifiedType trailingReturnType(TrailingReturnTypeAST *ast, const FullySpecifiedType &init);
|
FullySpecifiedType trailingReturnType(TrailingReturnTypeAST *ast, const FullySpecifiedType &init);
|
||||||
const StringLiteral *asStringLiteral(unsigned firstToken, unsigned lastToken,
|
const StringLiteral *asStringLiteral(unsigned firstToken, unsigned lastToken);
|
||||||
bool addWhitespace = true);
|
|
||||||
|
|
||||||
virtual bool preVisit(AST *);
|
virtual bool preVisit(AST *);
|
||||||
virtual void postVisit(AST *);
|
virtual void postVisit(AST *);
|
||||||
|
Reference in New Issue
Block a user