mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Fix for 240564: Improve handling of parsing problems in conditional expressions
Fix for 241058: Code Style Formatter for C++ invalidates code for nested templated argument with namespace.
This commit is contained in:
parent
6cffe3d338
commit
2d53d1dd31
3 changed files with 44 additions and 4 deletions
|
@ -2382,7 +2382,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
scribe.space();
|
||||
}
|
||||
IASTExpression condExpr= node.getConditionExpression();
|
||||
if (condExpr instanceof IASTProblemExpression) {
|
||||
if (condExpr == null || condExpr instanceof IASTProblemExpression) {
|
||||
scribe.skipToToken(Token.tRPAREN);
|
||||
} else {
|
||||
condExpr.accept(this);
|
||||
|
@ -2500,7 +2500,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
// destructor
|
||||
scribe.printNextToken(Token.tCOMPL, false);
|
||||
}
|
||||
scribe.printNextToken(Token.tIDENTIFIER, false);
|
||||
names[names.length-1].accept(this);
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
|
||||
|
@ -2519,10 +2519,10 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
|
|||
formatList(Arrays.asList(templateArguments), align, false, false);
|
||||
}
|
||||
scribe.printNextToken(Token.tGT, preferences.insert_space_before_closing_angle_bracket_in_template_arguments);
|
||||
if (node.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME) {
|
||||
int nextToken= peekNextToken();
|
||||
if (node.getPropertyInParent() != ICPPASTQualifiedName.SEGMENT_NAME || nextToken == Token.tGT) {
|
||||
if (preferences.insert_space_after_closing_angle_bracket_in_template_arguments) {
|
||||
// avoid explicit space if followed by pointer operator
|
||||
int nextToken= peekNextToken();
|
||||
if (nextToken != Token.tSTAR && nextToken != Token.tAMPER) {
|
||||
scribe.space();
|
||||
}
|
||||
|
|
|
@ -1618,6 +1618,14 @@ public class Scribe {
|
|||
}
|
||||
int braceLevel= 0;
|
||||
int parenLevel= 0;
|
||||
switch (expectedTokenType) {
|
||||
case Token.tRBRACE:
|
||||
++braceLevel;
|
||||
break;
|
||||
case Token.tRPAREN:
|
||||
++parenLevel;
|
||||
break;
|
||||
}
|
||||
while ((currentToken= scanner.nextToken()) != null) {
|
||||
switch (currentToken.type) {
|
||||
case Token.tLBRACE:
|
||||
|
|
|
@ -760,4 +760,36 @@ public class CodeFormatterTest extends BaseUITestCase {
|
|||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//void A::a(C e) { if (D::iterator it = m.find (e)) m.erase(it);}
|
||||
//T* A::b(T* t) { S::iterator it = m.find(t); if (!it) return NULL; else return *it; }
|
||||
//M* A::c(M* tm) { N::iterator it = myN.find(tm); if (!it) return NULL; else return *it; }
|
||||
|
||||
//void A::a(C e) {
|
||||
// if (D::iterator it = m.find (e))
|
||||
// m.erase(it);
|
||||
//}
|
||||
//T* A::b(T* t) {
|
||||
// S::iterator it = m.find(t);
|
||||
// if (!it)
|
||||
// return NULL;
|
||||
// else
|
||||
// return *it;
|
||||
//}
|
||||
//M* A::c(M* tm) {
|
||||
// N::iterator it = myN.find(tm);
|
||||
// if (!it)
|
||||
// return NULL;
|
||||
// else
|
||||
// return *it;
|
||||
//}
|
||||
public void testHandleParsingProblemsInIfCondition_Bug240564() throws Exception {
|
||||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//TestType1<TESTNS::TestType2<3> > test_variable;
|
||||
|
||||
//TestType1<TESTNS::TestType2<3> > test_variable;
|
||||
public void testNestedTemplatedArgument_Bug241058() throws Exception {
|
||||
assertFormatterResult();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue