From 9f2dc0efc8ec998acef0b4ff77437e242b4c8c2e Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Thu, 20 Jan 2011 12:04:38 +0000 Subject: [PATCH] Bug 334805 - Auto Indentation (CTRL+i) is not correct after function header with pointer return type --- .../eclipse/cdt/ui/tests/text/CIndenterTest.java | 13 ++++++++++++- .../eclipse/cdt/internal/ui/text/CIndenter.java | 4 ++-- .../ui/text/DocumentCharacterIterator.java | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java index e392f0a7e3c..b0be6d945ef 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CIndenterTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2011 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 @@ -968,4 +968,15 @@ public class CIndenterTest extends BaseUITestCase { public void testIndentationAfterEnumValueAssignment_Bug324031() throws Exception { assertIndenterResult(); } + + //int * f() + //{ + //} + + //int * f() + //{ + //} + public void testIndentationAfterFunctionHeaderWithPointerReturnType_Bug334805() throws Exception { + assertIndenterResult(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java index dc40302d0eb..5b955e2c7bb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CIndenter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -2021,7 +2021,7 @@ public final class CIndenter { */ private boolean skipPointerOperators() { if (fToken == Symbols.TokenOTHER) { - CharSequence token= getTokenContent(); + CharSequence token= getTokenContent().toString().trim(); if (token.length() == 1 && token.charAt(0) == '*' || token.charAt(0) == '&') { return true; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java index d0063b1a270..27042e59f4d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -217,4 +217,17 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc throw new IndexOutOfBoundsException(); return new DocumentCharacterIterator(fDocument, getBeginIndex() + start, getBeginIndex() + end); } + + /* + * @see java.lang.CharSequence#toString() + */ + @Override + public String toString() { + int length = length(); + char[] chs = new char[length]; + for (int i=0; i