diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorMacroDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorMacroDefinition.java index ba51cd823d7..64ab382c073 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorMacroDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTPreprocessorMacroDefinition.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -17,9 +17,7 @@ package org.eclipse.cdt.core.dom.ast; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IASTPreprocessorMacroDefinition extends - IASTPreprocessorStatement, IASTNameOwner { - +public interface IASTPreprocessorMacroDefinition extends IASTPreprocessorStatement, IASTNameOwner { /** * MACRO_NAME describes the relationship between a macro * definition and it's name. @@ -43,7 +41,6 @@ public interface IASTPreprocessorMacroDefinition extends * @since 5.0 */ public IASTFileLocation getExpansionLocation(); - /** * Returns whether this macro definition occurs in active code. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java index 6f3fa1bc4bf..d2725a244c4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacro.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.core.index; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; @@ -23,7 +22,6 @@ import org.eclipse.core.runtime.CoreException; * @noimplement This interface is not intended to be implemented by clients. */ public interface IIndexMacro extends IMacroBinding, IIndexBinding { - IIndexMacro[] EMPTY_INDEX_MACRO_ARRAY = new IIndexMacro[0]; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacroContainer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacroContainer.java index b974ac1e948..1704ba50a59 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacroContainer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndexMacroContainer.java @@ -6,18 +6,17 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.index; /** - * Represents a binding for all macros with the same name. When you try to adapt a macro binding in an index - * you'll get the container as a result. + * Represents a binding for all macros with the same name. When you try to adapt a macro binding + * in an index you'll get the container as a result. * @since 5.0 * * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ public interface IIndexMacroContainer extends IIndexBinding { - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java index a2fe8e155ce..a832728cba2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java @@ -1200,14 +1200,14 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { final int[] nameOffsets= new int[] {header.getOffset(), condEndOffset}; char[] headerName= null; boolean userInclude= true; - + switch (header.getType()) { case Lexer.tSYSTEM_HEADER_NAME: userInclude= false; headerName = extractHeaderName(header.getCharImage(), '<', '>', nameOffsets); condEndOffset= lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); break; - + case Lexer.tQUOTE_HEADER_NAME: headerName = extractHeaderName(header.getCharImage(), '"', '"', nameOffsets); condEndOffset= lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); @@ -1215,7 +1215,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { case IToken.tCOMPLETION: throw new OffsetLimitReachedException(ORIGIN_PREPROCESSOR_DIRECTIVE, header); - + case IToken.tIDENTIFIER: TokenList tl= new TokenList(); condEndOffset= nameOffsets[1]= getTokensWithinPPDirective(false, tl, false); @@ -1245,11 +1245,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } break; - + default: condEndOffset= lexer.consumeLine(ORIGIN_PREPROCESSOR_DIRECTIVE); break; } + if (headerName == null || headerName.length == 0) { if (active) { handleProblem(IProblem.PREPROCESSOR_INVALID_DIRECTIVE, @@ -1288,8 +1289,8 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { fAllIncludedFiles.add(path); ILocationCtx ctx= fLocationMap.pushInclusion(poundOffset, nameOffsets[0], nameOffsets[1], condEndOffset, source, path, headerName, userInclude, isHeuristic, fi.isSource()); - ScannerContext fctx= new ScannerContext(ctx, fCurrentContext, new Lexer(source, - fLexOptions, this, this)); + ScannerContext fctx= new ScannerContext(ctx, fCurrentContext, + new Lexer(source, fLexOptions, this, this)); fctx.setFoundOnPath(fi.getFoundOnPath(), includeDirective); fCurrentContext= fctx; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java index 63d82f34602..b032956b7d8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; @@ -22,14 +22,17 @@ import org.eclipse.cdt.core.parser.OffsetLimitReachedException; final class ScannerContext { enum BranchKind {eIf, eElif, eElse, eEnd} enum CodeState {eActive, eParseInactive, eSkipInactive} + final static class Conditional { private final CodeState fInitialState; private BranchKind fLast; private boolean fTakeElse= true; + Conditional(CodeState state) { fInitialState= state; fLast= BranchKind.eIf; } + boolean canHaveActiveBranch(boolean withinExpansion) { return fTakeElse && isActive(withinExpansion); } @@ -174,12 +177,12 @@ final class ScannerContext { private int getOldNestingLevel(BranchKind kind, int nesting) { switch (kind) { case eIf: - return nesting-1; + return nesting - 1; case eElif: case eElse: return nesting; case eEnd: - return nesting+1; + return nesting + 1; } return nesting; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java index 40c4f3a2fb9..4248cd68207 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/ShortString.java @@ -10,7 +10,6 @@ * Andrew Ferguson (Symbian) * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.core.pdom.db; import org.eclipse.cdt.core.CCorePlugin; @@ -77,7 +76,7 @@ public class ShortString implements IString { Chunk chunk = db.getChunk(record); int length = chunk.getInt(record + LENGTH); char[] chars = new char[length]; - chunk.getCharArray(record+CHARS, chars); + chunk.getCharArray(record + CHARS, chars); return chars; } @@ -259,7 +258,6 @@ public class ShortString implements IString { else return 0; } - public int compareCompatibleWithIgnoreCase(IString string) throws CoreException { if (string instanceof ShortString) @@ -269,7 +267,6 @@ public class ShortString implements IString { else throw new IllegalArgumentException(); } - public int compareCompatibleWithIgnoreCase(ShortString other) throws CoreException { Chunk chunk1 = db.getChunk(record);