From 941c4355443073413136c99e14fa8898effd1bbe Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 6 Jun 2016 15:55:42 -0700 Subject: [PATCH] Cosmetics. --- .../parser/scanner/IncludeGuardDetection.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeGuardDetection.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeGuardDetection.java index 55012b602ee..9882694e637 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeGuardDetection.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeGuardDetection.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; import static org.eclipse.cdt.core.parser.OffsetLimitReachedException.ORIGIN_PREPROCESSOR_DIRECTIVE; @@ -20,10 +20,11 @@ import org.eclipse.cdt.core.parser.util.CharArrayIntMap; import org.eclipse.cdt.core.parser.util.CharArrayUtils; /** - * Helper class for detecting include guards + * Helper class for detecting include guards. */ 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); char[] guard= findIncludeGuard(l, ppKeywords); if (guard != null && currentIfSpansFile(l, ppKeywords)) { @@ -34,7 +35,7 @@ public class IncludeGuardDetection { private static char[] findIncludeGuard(Lexer l, CharArrayIntMap ppKeywords) { try { - if (skipAll(l, Lexer.tNEWLINE).getType() == IToken.tPOUND) { + if (skipAll(l, Lexer.tNEWLINE).getType() == IToken.tPOUND) { Token t = l.nextToken(); if (t.getType() == IToken.tIDENTIFIER) { char[] guard= null; @@ -49,7 +50,7 @@ public class IncludeGuardDetection { case IPreprocessorDirective.ppIf: // #if !defined GUARD // #if ((!((defined (GUARD))))) - guard = findNotDefined(l); + guard = findNotDefined(l); break; } if (guard != null) { @@ -73,7 +74,7 @@ public class IncludeGuardDetection { Token t; if (skipAll(l, IToken.tLPAREN).getType() == IToken.tNOT && 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) t= l.nextToken(); if (t.getType() == IToken.tIDENTIFIER) { @@ -88,9 +89,9 @@ public class IncludeGuardDetection { private static boolean checkToken(Token t, char[] image) throws OffsetLimitReachedException { return CharArrayUtils.equals(t.getCharImage(), image); } - + 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 { int nesting= 1; while (nesting > 0) { @@ -114,9 +115,9 @@ public class IncludeGuardDetection { } return true; } - + private static Token skipAll(Lexer l, int kind) throws OffsetLimitReachedException { - // Skip empty lines + // Skip empty lines. Token t= l.nextToken(); while (t.getType() == kind) t= l.nextToken(); @@ -144,7 +145,7 @@ public class IncludeGuardDetection { return false; if (!checkToken(l.nextToken(), Keywords.cENDIF)) return false; - + return true; }