From a05892cd10d83930dac0a8e115778960b0203346 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Thu, 14 Jan 2010 13:26:23 +0000 Subject: [PATCH] Bug 298593 - Formatter breaks the code when #defining a placement new --- .../internal/formatter/CodeFormatterVisitor.java | 15 ++------------- .../cdt/ui/tests/text/CodeFormatterTest.java | 14 +++++++++++++- 2 files changed, 15 insertions(+), 14 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 ad4a8ba839a..38cf6282d1c 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2010 Wind River Systems, Inc. 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 @@ -2928,18 +2928,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor { break; } else if (currentOffset == endOffset && i == locations.length - 1) { - if (node instanceof IASTExpressionList) { - IASTNode parent= node.getParent(); - if (parent != null) { - IASTFileLocation parentLocation= parent.getFileLocation(); - int parentEndOffset= parentLocation.getNodeOffset() + parentLocation.getNodeLength(); - if (parentEndOffset == endOffset) { - scribe.skipRange(startOffset, endOffset); - } - } - } else { - scribe.skipRange(startOffset, endOffset); - } + scribe.skipRange(startOffset, endOffset); break; } } 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 5cd9aff921a..eee5cabc619 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 @@ -1307,7 +1307,19 @@ public class CodeFormatterTest extends BaseUITestCase { // // return 0; //} -public void testControlStatementsAsMacro_Bug290630() throws Exception { + public void testControlStatementsAsMacro_Bug290630() throws Exception { assertFormatterResult(); } + + //#define new new(__FILE__, __LINE__) + //void func() {char* a = new char[10];} + + //#define new new(__FILE__, __LINE__) + //void func() { + // char* a = new char[10]; + //} + public void testPlacementNewAsMacro_Bug298593() throws Exception { + assertFormatterResult(); + } + }