diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog-parser b/core/org.eclipse.cdt.core/parser/ChangeLog-parser index b7a1ee690ce..27f7a49e5ef 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog-parser +++ b/core/org.eclipse.cdt.core/parser/ChangeLog-parser @@ -1,3 +1,9 @@ +2004-01-28 John Camelon + Updated Scanner to add ANSI built-in defined macros for C and C++. + Updated GCCScannerExtension to add GCC specific defined macros for C++. + Added factory infrastructure to allow for C/C++ dialect extensions to be added and contained. + Added IASTExpressionExtension w/implementation to allow for GCC specific leniency on evaluating expressions. + 2004-01-28 Andrew Niefer Fixed bug#50729: Visibility is incorrectly decided in inheritance diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IMacroDescriptor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IMacroDescriptor.java index 4a40460fa9b..47327ca0714 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IMacroDescriptor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IMacroDescriptor.java @@ -27,6 +27,8 @@ public interface IMacroDescriptor { // function like - #define SYMBOL( parm1, parm2 ) TOKENS USING parms public static final MacroType FUNCTION_LIKE = new MacroType( 2 ); + // built in internal macro who's value is dynamic + public static final MacroType INTERNAL_LIKE = new MacroType(3); /** * @param enumValue */ 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 ae56ccd7f7f..f27948e0ece 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 @@ -10,6 +10,15 @@ import org.eclipse.cdt.core.parser.ast.IASTFactory; */ public interface IScanner { + public static final String __CPLUSPLUS = "__cplusplus"; + public static final String __STDC_VERSION__ = "__STDC_VERSION__"; + public static final String __STDC_HOSTED__ = "__STDC_HOSTED__"; + public static final String __STDC__ = "__STDC__"; + public static final String __FILE__ = "__FILE__"; + public static final String __TIME__ = "__TIME__"; + public static final String __DATE__ = "__DATE__"; + public static final String __LINE__ = "__LINE__"; + public static final int tPOUNDPOUND = -6; public static final int tPOUND = -7; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java index 526f15bfa9e..cc707860395 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java @@ -13,12 +13,15 @@ package org.eclipse.cdt.core.parser; import java.io.Reader; import org.eclipse.cdt.core.parser.ast.IASTFactory; +import org.eclipse.cdt.core.parser.extension.ExtensionDialect; +import org.eclipse.cdt.core.parser.extension.IParserExtensionFactory; import org.eclipse.cdt.internal.core.parser.CompleteParser; import org.eclipse.cdt.internal.core.parser.ContextualParser; +import org.eclipse.cdt.internal.core.parser.ParserExtensionFactory; import org.eclipse.cdt.internal.core.parser.QuickParseCallback; import org.eclipse.cdt.internal.core.parser.QuickParser; -import org.eclipse.cdt.internal.core.parser.StructuralParser; import org.eclipse.cdt.internal.core.parser.StructuralParseCallback; +import org.eclipse.cdt.internal.core.parser.StructuralParser; import org.eclipse.cdt.internal.core.parser.ast.complete.CompleteParseASTFactory; import org.eclipse.cdt.internal.core.parser.ast.quick.QuickParseASTFactory; import org.eclipse.cdt.internal.core.parser.scanner.LineOffsetReconciler; @@ -32,12 +35,14 @@ import org.eclipse.cdt.internal.core.parser.scanner.Scanner; */ public class ParserFactory { + private static IParserExtensionFactory extensionFactory = new ParserExtensionFactory( ExtensionDialect.GCC ); + public static IASTFactory createASTFactory( ParserMode mode, ParserLanguage language ) { if( mode == ParserMode.QUICK_PARSE ) - return new QuickParseASTFactory(); + return new QuickParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.QUICK_PARSE ) ); else - return new CompleteParseASTFactory( language, mode ); + return new CompleteParseASTFactory( language, mode, extensionFactory.createASTExtensionFactory( ParserMode.COMPLETE_PARSE ) ); } public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IParserLogService log ) throws ParserFactoryError @@ -68,7 +73,7 @@ public class ParserFactory { IParserLogService logService = ( log == null ) ? createDefaultLogService() : log; ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode ); ISourceElementRequestor ourRequestor = (( requestor == null) ? new NullSourceElementRequestor() : requestor ); - IScanner s = new Scanner( input, fileName, config, ourRequestor, ourMode, language, logService ); + IScanner s = new Scanner( input, fileName, config, ourRequestor, ourMode, language, logService, extensionFactory.createScannerExtension() ); return s; } @@ -81,7 +86,7 @@ public class ParserFactory { IParserLogService log = ( logService == null ) ? createDefaultLogService() : logService; ParserMode ourMode = ( (mode == null )? ParserMode.COMPLETE_PARSE : mode ); ISourceElementRequestor ourRequestor = (( requestor == null) ? new NullSourceElementRequestor() : requestor ); - IPreprocessor s = new Preprocessor( input, fileName, info, ourRequestor, ourMode, language, log ); + IPreprocessor s = new Preprocessor( input, fileName, info, ourRequestor, ourMode, language, log, extensionFactory.createScannerExtension() ); return s; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactoryError.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactoryError.java index 1c5c1fea306..b1baca735ed 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactoryError.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactoryError.java @@ -23,6 +23,7 @@ public class ParserFactoryError extends Error { public static final Kind NULL_CONFIG = new Kind( 3 ); public static final Kind NULL_LANGUAGE = new Kind( 4 ); public static final Kind NULL_SCANNER = new Kind( 5 ); + public static final Kind BAD_DIALECT = new Kind( 6 ); protected Kind( int arg ) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/extension/IASTExpressionExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/extension/IASTExpressionExtension.java new file mode 100644 index 00000000000..20738baa73b --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/extension/IASTExpressionExtension.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.parser.ast.extension; + +import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException; +import org.eclipse.cdt.core.parser.ast.IASTExpression; + +/** + * @author jcamelon + */ +public interface IASTExpressionExtension { + + public void setExpression(IASTExpression expression ); + public int evaluateExpression() throws ASTExpressionEvaluationException; +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/extension/IASTExtensionFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/extension/IASTExtensionFactory.java new file mode 100644 index 00000000000..a2daca9c6fa --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/extension/IASTExtensionFactory.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.parser.ast.extension; + +import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException; + +/** + * @author jcamelon + */ +public interface IASTExtensionFactory { + + public IASTExpressionExtension createExpressionExtension( ) throws ASTNotImplementedException; +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/ExtensionDialect.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/ExtensionDialect.java new file mode 100644 index 00000000000..808b19ffc2f --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/ExtensionDialect.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.parser.extension; + +import org.eclipse.cdt.core.parser.Enum; + +/** + * @author jcamelon + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class ExtensionDialect extends Enum { + + public static final ExtensionDialect GCC = new ExtensionDialect( 1 ); + /** + * @param enumValue + */ + public ExtensionDialect(int enumValue) { + super(enumValue); + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IParserExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IParserExtension.java new file mode 100644 index 00000000000..2af4b13fe5c --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IParserExtension.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.parser.extension; + +/** + * @author jcamelon + */ +public interface IParserExtension { + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IParserExtensionFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IParserExtensionFactory.java new file mode 100644 index 00000000000..ff506074841 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IParserExtensionFactory.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.parser.extension; + +import org.eclipse.cdt.core.parser.ParserFactoryError; +import org.eclipse.cdt.core.parser.ParserMode; +import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory; + + +/** + * @author jcamelon + */ +public interface IParserExtensionFactory { + + public IScannerExtension createScannerExtension() throws ParserFactoryError; + public IASTExtensionFactory createASTExtensionFactory(ParserMode mode) throws ParserFactoryError; + public IParserExtension createParserExtension() throws ParserFactoryError; +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScannerExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IScannerExtension.java similarity index 64% rename from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScannerExtension.java rename to core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IScannerExtension.java index 17fd43aae13..edb36d41c88 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScannerExtension.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/extension/IScannerExtension.java @@ -8,12 +8,23 @@ * Contributors: * IBM Rational Software - Initial API and implementation ***********************************************************************/ -package org.eclipse.cdt.core.parser; +package org.eclipse.cdt.core.parser.extension; + +import org.eclipse.cdt.core.parser.IScanner; +import org.eclipse.cdt.core.parser.ParserLanguage; /** * @author jcamelon */ -public interface IScannerExtension { +public interface IScannerExtension extends Cloneable { + + public void setScanner( IScanner scanner ); + public Object clone( ); public String initializeMacroValue( String original ); + + /** + * + */ + public void setupBuiltInMacros(ParserLanguage language); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserExtensionFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserExtensionFactory.java new file mode 100644 index 00000000000..7c2ea9701ab --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserExtensionFactory.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.parser; + +import org.eclipse.cdt.core.parser.ParserFactoryError; +import org.eclipse.cdt.core.parser.ParserMode; +import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory; +import org.eclipse.cdt.core.parser.extension.ExtensionDialect; +import org.eclipse.cdt.core.parser.extension.IParserExtension; +import org.eclipse.cdt.core.parser.extension.IParserExtensionFactory; +import org.eclipse.cdt.core.parser.extension.IScannerExtension; +import org.eclipse.cdt.internal.core.parser.ast.complete.extension.CompleteParseASTExtensionFactory; +import org.eclipse.cdt.internal.core.parser.ast.quick.extension.QuickParseASTExtensionFactory; +import org.eclipse.cdt.internal.core.parser.scanner.GCCScannerExtension; + +/** + * @author jcamelon + */ +public class ParserExtensionFactory implements IParserExtensionFactory { + + + private final ExtensionDialect dialect; + + /** + * @param dialect + */ + public ParserExtensionFactory(ExtensionDialect dialect) { + this.dialect = dialect; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.extension.IParserExtensionFactory#createScannerExtension() + */ + public IScannerExtension createScannerExtension() throws ParserFactoryError { + if( dialect == ExtensionDialect.GCC ) + return new GCCScannerExtension(); + throw new ParserFactoryError( ParserFactoryError.Kind.BAD_DIALECT ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.extension.IParserExtensionFactory#createASTExtensionFactory() + */ + public IASTExtensionFactory createASTExtensionFactory(ParserMode mode) throws ParserFactoryError { + if( dialect == ExtensionDialect.GCC ) + { + if( mode == ParserMode.QUICK_PARSE ) + return new QuickParseASTExtensionFactory(); + return new CompleteParseASTExtensionFactory(); + } + throw new ParserFactoryError( ParserFactoryError.Kind.BAD_DIALECT ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.extension.IParserExtensionFactory#createParserExtension() + */ + public IParserExtension createParserExtension() throws ParserFactoryError + { // TODO Auto-generated method stub + return null; + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java index ce614c3e7c7..efeb1cae197 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java @@ -68,6 +68,7 @@ import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescripto import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type; import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind; +import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory; import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory; import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension; import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol; @@ -99,6 +100,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto */ private final static List SUBSCRIPT; + private final IASTExtensionFactory extensionFactory; + static { SUBSCRIPT = new ArrayList(); @@ -117,11 +120,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto } } - public CompleteParseASTFactory( ParserLanguage language, ParserMode mode ) + public CompleteParseASTFactory( ParserLanguage language, ParserMode mode, IASTExtensionFactory factory ) { super(); - pst = new ParserSymbolTable( language, mode ); + extensionFactory = factory; } /* diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/extension/CompleteParseASTExtensionFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/extension/CompleteParseASTExtensionFactory.java new file mode 100644 index 00000000000..767bee0f2ce --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/extension/CompleteParseASTExtensionFactory.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.parser.ast.complete.extension; + +import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException; +import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension; +import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory; + +/** + * @author jcamelon + */ +public class CompleteParseASTExtensionFactory implements IASTExtensionFactory { + + /** + * + */ + public CompleteParseASTExtensionFactory() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory#createExpressionExtension(org.eclipse.cdt.core.parser.ast.IASTExpression) + */ + public IASTExpressionExtension createExpressionExtension() + throws ASTNotImplementedException { + throw new ASTNotImplementedException(); + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java index f58b9f850f7..f98072e15fa 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTExpression.java @@ -7,18 +7,16 @@ package org.eclipse.cdt.internal.core.parser.ast.quick; import org.eclipse.cdt.core.parser.ISourceElementRequestor; -import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException; import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException; +import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException; import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTTypeId; +import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension; /** * @author jcamelon - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments */ public class ASTExpression implements IASTExpression { @@ -27,6 +25,7 @@ public class ASTExpression implements IASTExpression { private final IASTTypeId typeId; private final String literal, idExpression; private final IASTNewExpressionDescriptor newDescriptor; + private final IASTExpressionExtension extension; /** * @param kind @@ -36,7 +35,7 @@ public class ASTExpression implements IASTExpression { * @param typeId * @param literal */ - public ASTExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression third, IASTTypeId typeId, String idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) { + public ASTExpression(Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression third, IASTTypeId typeId, String idExpression, String literal, IASTNewExpressionDescriptor newDescriptor, IASTExpressionExtension extension) { this.kind = kind; this.lhs =lhs; this.rhs = rhs; @@ -45,6 +44,8 @@ public class ASTExpression implements IASTExpression { this.literal = literal; this.newDescriptor = newDescriptor; this.idExpression = idExpression; + this.extension = extension; + this.extension.setExpression(this); } /* (non-Javadoc) @@ -118,6 +119,7 @@ public class ASTExpression implements IASTExpression { throw new ASTExpressionEvaluationException(); } } + if( getExpressionKind() == IASTExpression.Kind.PRIMARY_BRACKETED_EXPRESSION ) return getLHSExpression().evaluateExpression(); // unary not @@ -171,7 +173,7 @@ public class ASTExpression implements IASTExpression { if( getExpressionKind() == IASTExpression.Kind.LOGICALOREXPRESSION ) return( ( getLHSExpression().evaluateExpression() != 0 ) || ( getRHSExpression().evaluateExpression() != 0 ) ) ? 1 : 0 ; - throw new ASTExpressionEvaluationException(); + return extension.evaluateExpression(); } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java index b5fc96569a5..30d80da36f9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java @@ -15,6 +15,8 @@ import java.util.List; import org.eclipse.cdt.core.parser.ITokenDuple; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.parser.ast.ASTClassKind; +import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException; +import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException; import org.eclipse.cdt.core.parser.ast.ASTPointerOperator; import org.eclipse.cdt.core.parser.ast.IASTASMDefinition; import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration; @@ -56,6 +58,8 @@ import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType; import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor; import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind; import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type; +import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension; +import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory; import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory; /** @@ -65,6 +69,14 @@ import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory; */ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory { + private final IASTExtensionFactory extensionFactory; + + public QuickParseASTFactory( IASTExtensionFactory extensionFactory ) + { + super(); + this.extensionFactory = extensionFactory; + } + /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createUsingDirective(org.eclipse.cdt.internal.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.TokenDuple) */ @@ -147,7 +159,18 @@ public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createExpression(org.eclipse.cdt.core.parser.ast.IASTExpression.ExpressionKind, org.eclipse.cdt.core.parser.ast.IASTExpression, org.eclipse.cdt.core.parser.ast.IASTExpression, java.lang.String, java.lang.String, java.lang.String) */ public IASTExpression createExpression(IASTScope scope, Kind kind, IASTExpression lhs, IASTExpression rhs, IASTExpression thirdExpression, IASTTypeId typeId, ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) { - return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor ); + try { + return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor, extensionFactory.createExpressionExtension() ); + } catch (ASTNotImplementedException e) { + return new ASTExpression( kind, lhs, rhs, thirdExpression, typeId, idExpression == null ? "" : idExpression.toString(), literal, newDescriptor, new IASTExpressionExtension() { + + public void setExpression(IASTExpression expression) { + } + + public int evaluateExpression() throws ASTExpressionEvaluationException { + throw new ASTExpressionEvaluationException(); + } } ); + } } /* (non-Javadoc) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/extension/ASTExpressionExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/extension/ASTExpressionExtension.java new file mode 100644 index 00000000000..21f15841dbe --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/extension/ASTExpressionExtension.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.parser.ast.quick.extension; + +import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException; +import org.eclipse.cdt.core.parser.ast.IASTExpression; +import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind; +import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension; + + +public final class ASTExpressionExtension implements IASTExpressionExtension { + private IASTExpression expression; + + /** + * @param ASTExpression + */ + public ASTExpressionExtension() { + } + + public int evaluateExpression() throws ASTExpressionEvaluationException { + if( this.expression.getExpressionKind() == Kind.ID_EXPRESSION ) + return 0; + throw new ASTExpressionEvaluationException(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension#setExpression(org.eclipse.cdt.core.parser.ast.IASTExpression) + */ + public void setExpression(IASTExpression expression) { + this.expression = expression; + } +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/extension/QuickParseASTExtensionFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/extension/QuickParseASTExtensionFactory.java new file mode 100644 index 00000000000..179c62d229d --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/extension/QuickParseASTExtensionFactory.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.parser.ast.quick.extension; + +import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension; +import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory; + +/** + * @author jcamelon + */ +public class QuickParseASTExtensionFactory implements IASTExtensionFactory { + + /** + * + */ + public QuickParseASTExtensionFactory() { + super(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory#createExpressionExtension(org.eclipse.cdt.core.parser.ast.IASTExpression) + */ + public IASTExpressionExtension createExpressionExtension() { + return new ASTExpressionExtension(); + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/DynamicMacroDescriptor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/DynamicMacroDescriptor.java new file mode 100644 index 00000000000..b0037062136 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/DynamicMacroDescriptor.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.parser.scanner; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.cdt.core.parser.IMacroDescriptor; + +/** + * @author jcamelon + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class DynamicMacroDescriptor implements IMacroDescriptor { + + private final List EMPTY_LIST = new ArrayList(); + private final String name; + private final DynamicMacroEvaluator proxy; + + public DynamicMacroDescriptor( String name, DynamicMacroEvaluator proxy ) + { + this.proxy = proxy; + this.name = name; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IMacroDescriptor#getMacroType() + */ + public MacroType getMacroType() { + return MacroType.INTERNAL_LIKE; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IMacroDescriptor#getParameters() + */ + public List getParameters() { + return EMPTY_LIST; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IMacroDescriptor#getTokenizedExpansion() + */ + public List getTokenizedExpansion() { + return EMPTY_LIST; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IMacroDescriptor#getName() + */ + public String getName() { + return name; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IMacroDescriptor#getCompleteSignature() + */ + public String getCompleteSignature() { + return ""; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IMacroDescriptor#getExpansionSignature() + */ + public String getExpansionSignature() { + return proxy.execute(); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IMacroDescriptor#compatible(org.eclipse.cdt.core.parser.IMacroDescriptor) + */ + public boolean compatible(IMacroDescriptor descriptor) { + if( getMacroType() != descriptor.getMacroType() ) return false; + if( !name.equals( descriptor.getName() )) return false; + return true; + } + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/DynamicMacroEvaluator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/DynamicMacroEvaluator.java new file mode 100644 index 00000000000..b2148a7a41a --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/DynamicMacroEvaluator.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2000 - 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.parser.scanner; + +/** + * @author jcamelon + */ +abstract class DynamicMacroEvaluator { + + /** + * @return + */ + abstract String execute(); + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/GCCScannerExtension.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/GCCScannerExtension.java index 72b183e0e08..f4de06b6697 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/GCCScannerExtension.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/GCCScannerExtension.java @@ -10,20 +10,51 @@ ***********************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner; -import org.eclipse.cdt.core.parser.IScannerExtension; +import org.eclipse.cdt.core.parser.IScanner; +import org.eclipse.cdt.core.parser.ParserLanguage; +import org.eclipse.cdt.core.parser.extension.IScannerExtension; /** * @author jcamelon */ public class GCCScannerExtension implements IScannerExtension { + private IScanner scanner; + /* (non-Javadoc) * @see org.eclipse.cdt.core.parser.IScannerExtension#initializeMacroValue(java.lang.String) */ public String initializeMacroValue(String original) { - if( original == null || original.equals( "") ) + if( original == null || original.trim().equals( "") ) return "1"; return original; } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.IScannerExtension#setupBuiltInMacros() + */ + public void setupBuiltInMacros(ParserLanguage language) { + if( language == ParserLanguage.CPP ) + if( scanner.getDefinition( IScanner.__CPLUSPLUS ) == null ) + scanner.addDefinition( IScanner.__CPLUSPLUS, new ObjectMacroDescriptor( IScanner.__CPLUSPLUS, "1")); + if( scanner.getDefinition(IScanner.__STDC_HOSTED__) == null ) + scanner.addDefinition(IScanner.__STDC_HOSTED__, new ObjectMacroDescriptor( IScanner.__STDC_HOSTED__, "0")); + if( scanner.getDefinition( IScanner.__STDC_VERSION__) == null ) + scanner.addDefinition( IScanner.__STDC_VERSION__, new ObjectMacroDescriptor( IScanner.__STDC_VERSION__, "199001L")); + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.parser.extension.IScannerExtension#setScanner(org.eclipse.cdt.core.parser.IScanner) + */ + public void setScanner(IScanner scanner) { + this.scanner = scanner; + } + + public Object clone( ) { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + return null; + } + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ObjectMacroDescriptor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ObjectMacroDescriptor.java index 4c92efd8ae1..c39744a044e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ObjectMacroDescriptor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ObjectMacroDescriptor.java @@ -25,6 +25,14 @@ public class ObjectMacroDescriptor implements IMacroDescriptor { private final String name; private final List tokenizedExpansion; + public ObjectMacroDescriptor( String name, String expansionSignature ) + { + this.name = name; + this.expansionSignature = expansionSignature; + fullSignature = "#define " + name + " " + expansionSignature; + tokenizedExpansion = EMPTY_LIST; + } + public ObjectMacroDescriptor( String name, String signature, List tokenizedExpansion, String expansionSignature ) { this.name = name; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Preprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Preprocessor.java index ed58f0577bf..c2db0ca6d17 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Preprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Preprocessor.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.ParserMode; import org.eclipse.cdt.core.parser.ScannerException; +import org.eclipse.cdt.core.parser.extension.IScannerExtension; /** @@ -33,8 +34,8 @@ public class Preprocessor extends Scanner implements IPreprocessor { * @param filename * @param defns */ - public Preprocessor(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode mode, ParserLanguage language, IParserLogService logService ) { - super(reader, filename, info, requestor, mode, language, logService ); + public Preprocessor(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode mode, ParserLanguage language, IParserLogService logService, IScannerExtension scannerExtension ) { + super(reader, filename, info, requestor, mode, language, logService, scannerExtension ); } public void process() diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java index 0d41a7a7f56..1e409053661 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.util.ArrayList; +import java.util.Calendar; import java.util.EmptyStackException; import java.util.HashMap; import java.util.Hashtable; @@ -33,7 +34,6 @@ import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.IParserLogService; import org.eclipse.cdt.core.parser.IProblem; import org.eclipse.cdt.core.parser.IScanner; -import org.eclipse.cdt.core.parser.IScannerExtension; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.ISourceElementRequestor; import org.eclipse.cdt.core.parser.IToken; @@ -52,6 +52,7 @@ import org.eclipse.cdt.core.parser.ast.ASTExpressionEvaluationException; import org.eclipse.cdt.core.parser.ast.IASTExpression; import org.eclipse.cdt.core.parser.ast.IASTFactory; import org.eclipse.cdt.core.parser.ast.IASTInclusion; +import org.eclipse.cdt.core.parser.extension.IScannerExtension; import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory; import org.eclipse.cdt.internal.core.parser.token.Token; @@ -96,7 +97,7 @@ public class Scanner implements IScanner { throw new ScannerException( problem ); } - public Scanner(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode parserMode, ParserLanguage language, IParserLogService log ) { + public Scanner(Reader reader, String filename, IScannerInfo info, ISourceElementRequestor requestor, ParserMode parserMode, ParserLanguage language, IParserLogService log, IScannerExtension extension ) { this.log = log; this.requestor = requestor; this.mode = parserMode; @@ -104,8 +105,9 @@ public class Scanner implements IScanner { this.reader = reader; this.language = language; - //support GNU by default for now - scannerExtension = new GCCScannerExtension(); + + scannerExtension = extension; + scannerExtension.setScanner( this ); astFactory = ParserFactory.createASTFactory( mode, language ); contextStack = new ContextStack( log ); try { @@ -162,10 +164,111 @@ public class Scanner implements IScanner { else log.traceLog("\t\tNo include paths specified."); - + setupBuiltInMacros(); } - private void setupInitialContext() + /** + * + */ + protected void setupBuiltInMacros() { + + scannerExtension.setupBuiltInMacros(language); + if( getDefinition(__STDC__) == null ) + addDefinition( __STDC__, new ObjectMacroDescriptor( __STDC__, "1") ); + + if( language == ParserLanguage.C ) + { + if( getDefinition(__STDC_HOSTED__) == null ) + addDefinition( __STDC_HOSTED__, new ObjectMacroDescriptor( __STDC_HOSTED__, "0")); + if( getDefinition( __STDC_VERSION__) == null ) + addDefinition( __STDC_VERSION__, new ObjectMacroDescriptor( __STDC_VERSION__, "199001L")); + } + else + if( getDefinition( __CPLUSPLUS ) == null ) + addDefinition( __CPLUSPLUS, new ObjectMacroDescriptor( __CPLUSPLUS, "199711L")); + + if( getDefinition(__FILE__) == null ) + addDefinition( __FILE__, + new DynamicMacroDescriptor( __FILE__, new DynamicMacroEvaluator() { + public String execute() { + return contextStack.getMostRelevantFileContext().getFilename(); + } + } ) ); + + if( getDefinition( __LINE__) == null ) + addDefinition( __LINE__, + new DynamicMacroDescriptor( __LINE__, new DynamicMacroEvaluator() { + public String execute() { + return new Integer( contextStack.getCurrentLineNumber() ).toString(); + } + } ) ); + + + if( getDefinition( __DATE__ ) == null ) + addDefinition( __DATE__, + new DynamicMacroDescriptor( __DATE__, new DynamicMacroEvaluator() { + + public String getMonth() + { + if( Calendar.MONTH == Calendar.JANUARY ) return "Jan" ; + if( Calendar.MONTH == Calendar.FEBRUARY) return "Feb"; + if( Calendar.MONTH == Calendar.MARCH) return "Mar"; + if( Calendar.MONTH == Calendar.APRIL) return "Apr"; + if( Calendar.MONTH == Calendar.MAY) return "May"; + if( Calendar.MONTH == Calendar.JUNE) return "Jun"; + if( Calendar.MONTH == Calendar.JULY) return "Jul"; + if( Calendar.MONTH == Calendar.AUGUST) return "Aug"; + if( Calendar.MONTH == Calendar.SEPTEMBER) return "Sep"; + if( Calendar.MONTH == Calendar.OCTOBER) return "Oct"; + if( Calendar.MONTH == Calendar.NOVEMBER) return "Nov"; + if( Calendar.MONTH == Calendar.DECEMBER) return "Dec"; + return ""; + } + + public String execute() { + StringBuffer result = new StringBuffer(); + result.append( getMonth() ); + result.append(" "); + if( Calendar.DAY_OF_MONTH < 10 ) + result.append(" "); + result.append(Calendar.DAY_OF_MONTH); + result.append(" "); + result.append( Calendar.YEAR ); + return result.toString(); + } + } ) ); + + if( getDefinition( __TIME__) == null ) + addDefinition( __TIME__, + new DynamicMacroDescriptor( __TIME__, new DynamicMacroEvaluator() { + + + public String execute() { + StringBuffer result = new StringBuffer(); + if( Calendar.AM_PM == Calendar.PM ) + result.append( Calendar.HOUR + 12 ); + else + { + if( Calendar.HOUR < 10 ) + result.append( '0'); + result.append(Calendar.HOUR); + } + result.append(':'); + if( Calendar.MINUTE < 10 ) + result.append( '0'); + result.append(Calendar.MINUTE); + result.append(':'); + if( Calendar.SECOND < 10 ) + result.append( '0'); + result.append(Calendar.SECOND); + return result.toString(); + } + } ) ); + + + } + + private void setupInitialContext() { String resolvedFilename = filename == null ? TEXT : filename; IScannerContext context = null; @@ -2158,7 +2261,7 @@ public class Scanner implements IScanner { new ScannerInfo(definitions, originalConfig.getIncludePaths()), new NullSourceElementRequestor(), mode, - language, nullLogService ); + language, nullLogService, (IScannerExtension)(scannerExtension.clone()) ); helperScanner.setForInclusion( true ); IToken t = null; @@ -2563,7 +2666,7 @@ public class Scanner implements IScanner { protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException { - Scanner tokenizer = new Scanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), new NullSourceElementRequestor(), mode, language, nullLogService ); + Scanner tokenizer = new Scanner(new StringReader(params), TEXT, new ScannerInfo( definitions, originalConfig.getIncludePaths() ), new NullSourceElementRequestor(), mode, language, nullLogService, (IScannerExtension)scannerExtension.clone() ); tokenizer.setThrowExceptionOnBadCharacterRead(false); Vector parameterValues = new Vector(); Token t = null; @@ -2646,7 +2749,7 @@ public class Scanner implements IScanner { { // All the tokens generated by the macro expansion // will have dimensions (offset and length) equal to the expanding symbol. - if ( expansion.getMacroType() == MacroType.OBJECT_LIKE ) { + if ( expansion.getMacroType() == MacroType.OBJECT_LIKE || expansion.getMacroType() == MacroType.INTERNAL_LIKE ) { String replacementValue = expansion.getExpansionSignature(); try { @@ -2814,7 +2917,8 @@ public class Scanner implements IScanner { return; } - } else { + } + else { StringBuffer logMessage = new StringBuffer( "Unexpected type of MacroDescriptor stored in definitions table: " ); logMessage.append( expansion.getMacroType() ); log.traceLog( logMessage.toString() ); diff --git a/core/org.eclipse.cdt.ui.tests/ChangeLog b/core/org.eclipse.cdt.ui.tests/ChangeLog index 45bc107c976..7e267bae4bd 100644 --- a/core/org.eclipse.cdt.ui.tests/ChangeLog +++ b/core/org.eclipse.cdt.ui.tests/ChangeLog @@ -1,3 +1,6 @@ +2004-01-28 John Camelon + Updated CompletionTest_SingleName_NoPrefix to include internal macro definitions. + 2004-01-27 John Camelon Updated COMPLETION_PARSE clients to use SINGLE_NAME_REFERENCE rather than STATEMENT_START. Renamed and updated CompletionTest_StatementStart_NoPrefix to CompletionTest_SingleName_Method_NoPrefix. diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/CompletionTest_SingleName_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/CompletionTest_SingleName_NoPrefix.java index 6510ab95748..958fd9edb1c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/CompletionTest_SingleName_NoPrefix.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/CompletionTest_SingleName_NoPrefix.java @@ -54,6 +54,14 @@ public class CompletionTest_SingleName_NoPrefix extends CompletionProposalsBase "xFirstEnum", "xSecondEnum", "xThirdEnum", + "__cplusplus", + "__DATE__", + "__FILE__", + "__LINE__", + "__STDC__", + "__STDC_HOSTED__", + "__STDC_VERSION__", + "__TIME__", "AMacro(x)", "DEBUG", "XMacro(x,y)"