1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Breaking precedence for binary expressions.

This commit is contained in:
Sergey Prigogin 2011-03-04 17:57:24 +00:00
parent 6ad4ad176a
commit 5bfffca532
3 changed files with 37 additions and 7 deletions

View file

@ -2539,9 +2539,11 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
if (isAssignment(node)) {
return formatAssignment(node);
}
Alignment expressionAlignment= scribe.createAlignment(
Alignment.BINARY_EXPRESSION,
preferences.alignment_for_binary_expression,
Alignment.R_OUTERMOST,
2,
scribe.scanner.getCurrentPosition());
@ -2549,12 +2551,11 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
boolean ok = false;
do {
try {
scribe.alignFragment(expressionAlignment, 0);
final IASTExpression op1= node.getOperand1();
// operand 1
// Left operand
op1.accept(this);
scribe.printTrailingComment();
scribe.alignFragment(expressionAlignment, 1);
// In case of macros we may have already passed the operator position.
@ -2577,7 +2578,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
}
// operand 2
// Right operand
final IASTExpression op2= node.getOperand2();
op2.accept(this);

View file

@ -46,9 +46,9 @@ void bug183220() {
if (((rtc_hdw_cr_sync_next != rtc_hdw_cr_sync) || rtc_hdw_cr_resync_enable)
&& !rtc_s2000_src_pending && !rtc_s2000_cr_sync_pending) {
if (!identify_hdw_fvr_master() || !rtc_hdw_current_clock->external
|| !rtc_hdw_cr_sync_next || ((rtc_hdw_current_clock->external
&& rtc_hdw_cr_sync_next && rtc_s2000_clock_source_state
!= RTC_CLOCK_PLL))) {
|| !rtc_hdw_cr_sync_next
|| ((rtc_hdw_current_clock->external && rtc_hdw_cr_sync_next
&& rtc_s2000_clock_source_state != RTC_CLOCK_PLL))) {
}
}
}

View file

@ -1870,6 +1870,35 @@ public class CodeFormatterTest extends BaseUITestCase {
assertFormatterResult();
}
//class Stream {
//Stream& operator <<(const char*);
//Stream& operator <<(int);
//};
//
//Stream stream;
//
//void test() {
// // Breaking at << is preferred to breaking at +.
//stream << "text text text text text text text text text" << 1000000 + 2000000;
//}
//class Stream {
// Stream& operator <<(const char*);
// Stream& operator <<(int);
//};
//
//Stream stream;
//
//void test() {
// // Breaking at << is preferred to breaking at +.
// stream << "text text text text text text text text text"
// << 1000000 + 2000000;
//}
public void testBreakingPrecedence() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
assertFormatterResult();
}
//#define m() f()
//void f() {
//if (1) f();