mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 07:15:39 +02:00
Fix for 195481: [Editor] Include header not highlighted if no space in between
This commit is contained in:
parent
d4c724562d
commit
4439294790
2 changed files with 19 additions and 9 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests.text;
|
package org.eclipse.cdt.ui.tests.text;
|
||||||
|
@ -55,6 +56,10 @@ public class CHeaderRuleTest extends TestCase {
|
||||||
assertHeader("#include <vector>", "<vector>", 9);
|
assertHeader("#include <vector>", "<vector>", 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testHeaderNoSpaceBetween() {
|
||||||
|
assertHeader("#include<vector>", "<vector>", 8);
|
||||||
|
}
|
||||||
|
|
||||||
public void testHeaderExtraSpacesBetween() {
|
public void testHeaderExtraSpacesBetween() {
|
||||||
assertHeader("#include <foo.h>", "<foo.h>", 12);
|
assertHeader("#include <foo.h>", "<foo.h>", 12);
|
||||||
}
|
}
|
||||||
|
@ -63,6 +68,10 @@ public class CHeaderRuleTest extends TestCase {
|
||||||
assertHeader(" #include <foo.h>", "<foo.h>", 11);
|
assertHeader(" #include <foo.h>", "<foo.h>", 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testHeaderIncludeNext() {
|
||||||
|
assertHeader("#include_next<vector>", "<vector>", 13);
|
||||||
|
}
|
||||||
|
|
||||||
public void testBooleanLogic() {
|
public void testBooleanLogic() {
|
||||||
assertNotHeader("if (x < 10 && x > 20) return false;", 6);
|
assertNotHeader("if (x < 10 && x > 20) return false;", 6);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -114,12 +114,13 @@ public class CHeaderRule implements IRule {
|
||||||
current = unread(scanner);
|
current = unread(scanner);
|
||||||
lookBehind++;
|
lookBehind++;
|
||||||
} while (Character.isWhitespace((char) current));
|
} while (Character.isWhitespace((char) current));
|
||||||
|
}
|
||||||
scanner.read();
|
scanner.read();
|
||||||
--lookBehind;
|
--lookBehind;
|
||||||
if (searchBackwards(scanner, "include")) { //$NON-NLS-1$
|
if (current == 'e' && searchBackwards(scanner, "include") || //$NON-NLS-1$
|
||||||
|
current == 't' && searchBackwards(scanner, "include_next")) { //$NON-NLS-1$
|
||||||
result = true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
seek(scanner, lookBehind);
|
seek(scanner, lookBehind);
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Add table
Reference in a new issue