diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeaderRuleTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeaderRuleTest.java index adffef85916..34111bda563 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeaderRuleTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CHeaderRuleTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM Corporation. + * Copyright (c) 2006, 2007 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.ui.tests.text; @@ -54,7 +55,11 @@ public class CHeaderRuleTest extends TestCase { public void testHeader2() { assertHeader("#include ", "", 9); } - + + public void testHeaderNoSpaceBetween() { + assertHeader("#include", "", 8); + } + public void testHeaderExtraSpacesBetween() { assertHeader("#include ", "", 12); } @@ -62,7 +67,11 @@ public class CHeaderRuleTest extends TestCase { public void testHeaderExtraSpacesBefore() { assertHeader(" #include ", "", 11); } - + + public void testHeaderIncludeNext() { + assertHeader("#include_next", "", 13); + } + public void testBooleanLogic() { assertNotHeader("if (x < 10 && x > 20) return false;", 6); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java index f2729a4bd8b..652591691c1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeaderRule.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM Corporation. + * Copyright (c) 2006, 2007 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 @@ -114,11 +114,12 @@ public class CHeaderRule implements IRule { current = unread(scanner); lookBehind++; } while (Character.isWhitespace((char) current)); - scanner.read(); - --lookBehind; - if (searchBackwards(scanner, "include")) { //$NON-NLS-1$ - result = true; - } + } + scanner.read(); + --lookBehind; + if (current == 'e' && searchBackwards(scanner, "include") || //$NON-NLS-1$ + current == 't' && searchBackwards(scanner, "include_next")) { //$NON-NLS-1$ + result = true; } seek(scanner, lookBehind);