Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2009-05-28 04:22:48 -0400
committerAnton Leherbauer2009-05-28 04:22:48 -0400
commit08fe62a2a1b1f1a6505e0da46aac8e2776e93513 (patch)
treecdb93d4524c38a68316ddc9951ce39b295bc2644
parent2bf225f6df74823a94ce16ac241821e28f51b34a (diff)
downloadorg.eclipse.cdt-08fe62a2a1b1f1a6505e0da46aac8e2776e93513.tar.gz
org.eclipse.cdt-08fe62a2a1b1f1a6505e0da46aac8e2776e93513.tar.xz
org.eclipse.cdt-08fe62a2a1b1f1a6505e0da46aac8e2776e93513.zip
Bug 278118 - Code formatter is confused by some arithmetic expressions
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java2
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java7
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java25
3 files changed, 31 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
index 668090c55f3..db4092fe5e5 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
@@ -2139,7 +2139,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
private int visit(IASTLiteralExpression node) {
if (node.getKind() == IASTLiteralExpression.lk_string_literal) {
- // handle concatentation of string literals
+ // handle concatenation of string literals
int token;
boolean needSpace= false;
final int line= scribe.line;
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java
index 2c4eb4e15ed..93280b8646e 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 IBM Corporation and others.
+ * Copyright (c) 2004, 2009 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -248,7 +248,10 @@ public class SimpleScanner {
if (!hex) {
if (c == '*') {
- return newToken(Token.tDOTSTAR);
+ if (floatingPoint && digits == 0) {
+ // encountered .*
+ return newToken(Token.tDOTSTAR);
+ }
} else if (c == '.') {
if (floatingPoint && digits == 0) {
// encountered ..
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
index 8baf9fde4da..630fdb90958 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
@@ -1112,6 +1112,31 @@ public class CodeFormatterTest extends BaseUITestCase {
assertFormatterResult();
}
+ //void f() {
+ // Canvas1->MoveTo((50 + (24* 20 ) +xoff) *Scale,(200+yoff)*ScaleY);
+ // Canvas1->LineTo((67+(24*20) +xoff)*Scale,(200+yoff)*ScaleY);
+ // Canvas1->MoveTo((50+(24*20) +xoff)*Scale,((200+yoff)*ScaleY)-1);
+ // Canvas1->LineTo((67+(24*20) +xoff)*Scale,((200+yoff)*ScaleY)-1);
+ // Canvas1->MoveTo((50+(24*20) +xoff)*Scale,((200+yoff)*ScaleY)+1);
+ // Canvas1->LineTo((67+(24*20) +xoff)*Scale,((200+yoff)*ScaleY)+1);
+ //}
+
+ //void f() {
+ // Canvas1->MoveTo((50 + (24 * 20) + xoff) * Scale, (200 + yoff) * ScaleY);
+ // Canvas1->LineTo((67 + (24 * 20) + xoff) * Scale, (200 + yoff) * ScaleY);
+ // Canvas1->MoveTo((50 + (24 * 20) + xoff) * Scale, ((200 + yoff) * ScaleY)
+ // - 1);
+ // Canvas1->LineTo((67 + (24 * 20) + xoff) * Scale, ((200 + yoff) * ScaleY)
+ // - 1);
+ // Canvas1->MoveTo((50 + (24 * 20) + xoff) * Scale, ((200 + yoff) * ScaleY)
+ // + 1);
+ // Canvas1->LineTo((67 + (24 * 20) + xoff) * Scale, ((200 + yoff) * ScaleY)
+ // + 1);
+ //}
+ public void testScannerErrorWithIntegerFollowedByStar_Bug278118() throws Exception {
+ assertFormatterResult();
+ }
+
//inline typename A foo();
//void bar(const typename A x) ;
//static typename A x ;

Back to the top