diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/CompletionInPreprocessorException.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/CompletionInPreprocessorException.java deleted file mode 100644 index a8283c6df2c..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/CompletionInPreprocessorException.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.core.parser; - -/** - * The exception is thrown when a completion is requested within one of the following constructs: - *

character-literal, string-literal, comment, preprocessing directive, macro-expansion. - * @since 5.0 - */ -public class CompletionInPreprocessorException extends Exception { - -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java index d838079180a..4bbf89c155c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java @@ -52,6 +52,9 @@ public interface IScanner extends IMacroCollector { public IToken nextToken() throws EndOfFileException; public int getCount(); + /** + * Returns true, whenever we are processing the outermost file of the translation unit. + */ public boolean isOnTopContext(); public CharArrayObjectMap getRealDefinitions(); public void cancel(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java index 7aac95532a3..ed27b812d61 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IToken.java @@ -41,6 +41,8 @@ public interface IToken { // Token types + int FIRST_RESERVED_PREPROCESSOR= -200; + int LAST_RESERVED_PREPROCESSOR= -101; int FIRST_RESERVED_SCANNER= -100; int LAST_RESERVED_SCANNER= -1; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java index b299c751172..99600032cb9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Keywords.java @@ -11,6 +11,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser; +import org.eclipse.cdt.core.parser.util.CharArrayIntMap; + /** * @author jcamelon */ @@ -229,9 +231,9 @@ public class Keywords { public static final char[] cpDOT = ".".toCharArray(); //$NON-NLS-1$ public static final char[] cpDIVASSIGN = "/=".toCharArray(); //$NON-NLS-1$ public static final char[] cpDIV = "/".toCharArray(); //$NON-NLS-1$ - public static final char[] cpBACKSLASH = "\\".toCharArray(); //$NON-NLS-1$ public static final char[] cpPOUND = "#".toCharArray(); //$NON-NLS-1$ public static final char[] cpPOUNDPOUND = "##".toCharArray(); //$NON-NLS-1$ + public static final char[] cpBACKSLASH = "\\".toCharArray(); //$NON-NLS-1$ // gcc extensions public static final char[] cpMIN = " + * {@link #ORIGIN_LEXER}: char-literal, string-literal, number-literal, header-name. + *

+ * {@link #ORIGIN_PREPROCESSOR}: preprocessor-directive. + *

+ * {@link #ORIGIN_INACTIVE_CODE}: within an inactive branch of conditional compilation. + *

+ * {@link #ORIGIN_MACRO_EXPANSION}: within a macro-expansion. */ public class OffsetLimitReachedException extends EndOfFileException { private static final long serialVersionUID= -4315255081891716385L; + + public static final int ORIGIN_UNKNOWN = 0; + public static final int ORIGIN_LEXER = 1; + public static final int ORIGIN_PREPROCESSOR_DIRECTIVE = 2; + public static final int ORIGIN_INACTIVE_CODE = 3; + public static final int ORIGIN_MACRO_EXPANSION = 4; private final IASTCompletionNode node; private final IToken finalToken; + private final int fOrigin; public OffsetLimitReachedException( IASTCompletionNode node ) { this.node = node; finalToken = null; + fOrigin= ORIGIN_UNKNOWN; } - public OffsetLimitReachedException( IToken token ) + public OffsetLimitReachedException( IToken token ) { + fOrigin= ORIGIN_UNKNOWN; finalToken = token; node = null; } + public OffsetLimitReachedException(int origin, IToken lastToken) { + fOrigin= origin; + finalToken= lastToken; + node= null; + } + + /** + * Returns one of ORIGIN_... + */ + public int getOriginator() { + return fOrigin; + } + /** * @return Returns the finalToken. */ @@ -48,9 +79,4 @@ public class OffsetLimitReachedException extends EndOfFileException { { return node; } - - /** - * @author jcamelon - */ - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayIntMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayIntMap.java index 3835e6f35df..0143d6bd921 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayIntMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayIntMap.java @@ -74,11 +74,18 @@ public class CharArrayIntMap extends CharTable { return undefined; } - /** - * @param image - * @return - */ public int get(char[] image) { return get( image, 0, image.length ); } + + /** + * Puts all mappings of map into this map. The keys are not cloned. + * @since 5.0 + */ + public void putAll(CharArrayIntMap map) { + resize(size() + map.size()); + for(int i=0; i-1 + */ + public static int indexOf(final char[] searchFor, final char[][] searchIn) { + for (int i=0; i < searchIn.length; i++) { + if (equals(searchIn[i], searchFor)) { + return i; + } + } + return -1; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/MacroBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/MacroBinding.java index 7d1a1327e11..0d9d534f373 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/MacroBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/MacroBinding.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.internal.core.dom.Linkage; +import org.eclipse.cdt.internal.core.parser.scanner2.LocationMap._FunctionMacroDefinition; import org.eclipse.core.runtime.PlatformObject; public class MacroBinding extends PlatformObject implements IMacroBinding { @@ -53,4 +54,12 @@ public class MacroBinding extends PlatformObject implements IMacroBinding { public ILinkage getLinkage() { return Linkage.NO_LINKAGE; } + + public char[] getExpansion() { + return definition.getExpansion(); + } + + public boolean isFunctionStyle() { + return definition instanceof _FunctionMacroDefinition; + } }