mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 08:45:44 +02:00
Cosmetics.
This commit is contained in:
parent
591f90c6d2
commit
941c435544
1 changed files with 12 additions and 11 deletions
|
@ -20,10 +20,11 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for detecting include guards
|
* Helper class for detecting include guards.
|
||||||
*/
|
*/
|
||||||
public class IncludeGuardDetection {
|
public class IncludeGuardDetection {
|
||||||
public static char[] detectIncludeGuard(AbstractCharArray content, Lexer.LexerOptions lexOptions, CharArrayIntMap ppKeywords) {
|
public static char[] detectIncludeGuard(AbstractCharArray content, Lexer.LexerOptions lexOptions,
|
||||||
|
CharArrayIntMap ppKeywords) {
|
||||||
Lexer l= new Lexer(content, lexOptions, ILexerLog.NULL, null);
|
Lexer l= new Lexer(content, lexOptions, ILexerLog.NULL, null);
|
||||||
char[] guard= findIncludeGuard(l, ppKeywords);
|
char[] guard= findIncludeGuard(l, ppKeywords);
|
||||||
if (guard != null && currentIfSpansFile(l, ppKeywords)) {
|
if (guard != null && currentIfSpansFile(l, ppKeywords)) {
|
||||||
|
@ -73,7 +74,7 @@ public class IncludeGuardDetection {
|
||||||
Token t;
|
Token t;
|
||||||
if (skipAll(l, IToken.tLPAREN).getType() == IToken.tNOT
|
if (skipAll(l, IToken.tLPAREN).getType() == IToken.tNOT
|
||||||
&& checkToken(skipAll(l, IToken.tLPAREN), Keywords.cDEFINED)) {
|
&& checkToken(skipAll(l, IToken.tLPAREN), Keywords.cDEFINED)) {
|
||||||
t= l.nextToken(); // only a single parenthesis is allowed
|
t= l.nextToken(); // Only a single parenthesis is allowed.
|
||||||
if (t.getType() == IToken.tLPAREN)
|
if (t.getType() == IToken.tLPAREN)
|
||||||
t= l.nextToken();
|
t= l.nextToken();
|
||||||
if (t.getType() == IToken.tIDENTIFIER) {
|
if (t.getType() == IToken.tIDENTIFIER) {
|
||||||
|
@ -90,7 +91,7 @@ public class IncludeGuardDetection {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean currentIfSpansFile(Lexer l, CharArrayIntMap ppKeywords) {
|
private static boolean currentIfSpansFile(Lexer l, CharArrayIntMap ppKeywords) {
|
||||||
// Check if the #ifndef spans the entire file
|
// Check if the #ifndef spans the entire file.
|
||||||
try {
|
try {
|
||||||
int nesting= 1;
|
int nesting= 1;
|
||||||
while (nesting > 0) {
|
while (nesting > 0) {
|
||||||
|
@ -116,7 +117,7 @@ public class IncludeGuardDetection {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Token skipAll(Lexer l, int kind) throws OffsetLimitReachedException {
|
private static Token skipAll(Lexer l, int kind) throws OffsetLimitReachedException {
|
||||||
// Skip empty lines
|
// Skip empty lines.
|
||||||
Token t= l.nextToken();
|
Token t= l.nextToken();
|
||||||
while (t.getType() == kind)
|
while (t.getType() == kind)
|
||||||
t= l.nextToken();
|
t= l.nextToken();
|
||||||
|
|
Loading…
Add table
Reference in a new issue