mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
org.eclipse.cdt.core
Added some trace statements to CompleteParseASTFactory. Cleaned up usage of Enum.getValue() wrt encapsulation of enumerator value. Refactored CompleteParseASTFactory for correctness and abstraction. Added preliminary IProblem support to CompleteParseASTFactory. Added (commented out unfortunately) assertions into CompleteParseASTFactory. Updated IASTUsingDeclaration to return an Iterator for declarations mapped rather than just a single declaration. org.eclipse.cdt.core.tests Updated tests to deal with IASTUsingDeclaration interface changes. org.eclipse.cdt.ui Cleaned up usage of Enum.getValue() wrt encapsulation of enumerator value.
This commit is contained in:
parent
ba12f674af
commit
fc37d2f92c
35 changed files with 1469 additions and 1202 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
2004-03-03 John Camelon
|
||||||
|
Updated tests to deal with IASTUsingDeclaration interface changes.
|
||||||
|
|
||||||
2004-03-02 Sean Evoy
|
2004-03-02 Sean Evoy
|
||||||
Added tests to verify that the tool command canbe set through the
|
Added tests to verify that the tool command canbe set through the
|
||||||
IConfiguration interface in the testConfigurations() method, and
|
IConfiguration interface in the testConfigurations() method, and
|
||||||
|
|
|
@ -196,11 +196,11 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
||||||
assertEquals( directive.getNamespaceDefinition(), namespaceB );
|
assertEquals( directive.getNamespaceDefinition(), namespaceB );
|
||||||
assertEquals( directive.getNamespaceName(), "A::B" );
|
assertEquals( directive.getNamespaceName(), "A::B" );
|
||||||
IASTUsingDeclaration declaration = (IASTUsingDeclaration)declarations.next();
|
IASTUsingDeclaration declaration = (IASTUsingDeclaration)declarations.next();
|
||||||
assertEquals( declaration.getUsingType(), variableX );
|
assertEquals( declaration.getUsingTypes().next(), variableX );
|
||||||
declaration = (IASTUsingDeclaration)declarations.next();
|
declaration = (IASTUsingDeclaration)declarations.next();
|
||||||
assertEquals( declaration.getUsingType(), classC );
|
assertEquals( declaration.getUsingTypes().next(), classC );
|
||||||
declaration = (IASTUsingDeclaration)declarations.next();
|
declaration = (IASTUsingDeclaration)declarations.next();
|
||||||
assertEquals( declaration.getUsingType(), fieldY );
|
assertEquals( declaration.getUsingTypes().next(), fieldY );
|
||||||
assertEquals( callback.getReferences().size(), 12 );
|
assertEquals( callback.getReferences().size(), 12 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class Enum
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getEnumValue()
|
protected int getEnumValue()
|
||||||
{
|
{
|
||||||
return enumValue;
|
return enumValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2003 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corp. - Rational Software - initial implementation
|
||||||
|
******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.parser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*/
|
||||||
|
public interface IFilenameProvider {
|
||||||
|
|
||||||
|
public char [] getCurrentFilename();
|
||||||
|
|
||||||
|
}
|
|
@ -13,8 +13,11 @@ package org.eclipse.cdt.core.parser;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of a C/C++ problem, as detected by the translation or some of the underlying
|
* @author jcamelon
|
||||||
* technology reusing it.
|
*
|
||||||
|
* Description of a C/C++ parse/compilation problem, as detected by the parser or some of the underlying
|
||||||
|
* clients of the parser.
|
||||||
|
*
|
||||||
* A problem provides access to:
|
* A problem provides access to:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li> its location (originating source file name, source position, line number), </li>
|
* <li> its location (originating source file name, source position, line number), </li>
|
||||||
|
@ -26,6 +29,8 @@ import java.util.Map;
|
||||||
public interface IProblem
|
public interface IProblem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the problem id
|
* Returns the problem id
|
||||||
*
|
*
|
||||||
|
@ -205,6 +210,21 @@ public interface IProblem
|
||||||
*/
|
*/
|
||||||
public static final String A_SCANNER_BADCHAR = null;
|
public static final String A_SCANNER_BADCHAR = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A_SYMBOL_NAME - symbol name
|
||||||
|
*/
|
||||||
|
public static final String A_SYMBOL_NAME = "symbol name";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A_NAMESPACE_NAME = namespace name
|
||||||
|
*/
|
||||||
|
public static final String A_NAMESPACE_NAME = "namespace name";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A_TYPE_NAME - type name
|
||||||
|
*/
|
||||||
|
public static final String A_TYPE_NAME = "type name";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Below are listed all available problem IDs. Note that this list could be augmented in the future,
|
* Below are listed all available problem IDs. Note that this list could be augmented in the future,
|
||||||
* as new features are added to the C/C++ core implementation.
|
* as new features are added to the C/C++ core implementation.
|
||||||
|
@ -320,14 +340,14 @@ public interface IProblem
|
||||||
public final static int PREPROCESSOR_MACRO_USAGE_ERROR = PREPROCESSOR_RELATED | 0x009;
|
public final static int PREPROCESSOR_MACRO_USAGE_ERROR = PREPROCESSOR_RELATED | 0x009;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalid Macro Pasting encountered by Preprocessor.
|
* Invalid Macro Pasting encountered by Preprocessor.
|
||||||
* Required attributes: A_PREPROC_MACRO_NAME
|
* Required attributes: A_PREPROC_MACRO_NAME
|
||||||
* @see #A_PREPROC_MACRO_NAME
|
* @see #A_PREPROC_MACRO_NAME
|
||||||
*/
|
*/
|
||||||
public final static int PREPROCESSOR_MACRO_PASTING_ERROR = PREPROCESSOR_RELATED | 0x00A;
|
public final static int PREPROCESSOR_MACRO_PASTING_ERROR = PREPROCESSOR_RELATED | 0x00A;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Circular inclusion encountered by Preprocessor.
|
* Circular inclusion encountered by Preprocessor.
|
||||||
* Required attributes: A_PREPROC_INCLUDE_FILENAME
|
* Required attributes: A_PREPROC_INCLUDE_FILENAME
|
||||||
* @see #A_PREPROC_INCLUDE_FILENAME
|
* @see #A_PREPROC_INCLUDE_FILENAME
|
||||||
*/
|
*/
|
||||||
|
@ -340,10 +360,72 @@ public interface IProblem
|
||||||
/*
|
/*
|
||||||
* Parser Semantic Problems
|
* Parser Semantic Problems
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to add a unique symbol, yet the value was already defined.
|
||||||
|
* Require attributes: A_SYMBOL_NAME
|
||||||
|
* @see #A_SYMBOL_NAME
|
||||||
|
*/
|
||||||
|
public final static int SEMANTIC_UNIQUE_NAME_PREDEFINED = SEMANTICS_RELATED | 0x001;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to use a symbol that was not found.
|
||||||
|
* Require attributes: A_SYMBOL_NAME
|
||||||
|
* @see #A_SYMBOL_NAME
|
||||||
|
*/
|
||||||
|
public final static int SEMANTIC_NAME_NOT_FOUND = SEMANTICS_RELATED | 0x002;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID reserved for referencing an internal error inside the CCorePlugin implementation which
|
* Name not provided in context that it was required.
|
||||||
* may be surfaced as a problem associated with the translation unit which caused it to occur.
|
* Require attributes: none
|
||||||
*/
|
*/
|
||||||
public final static int UNCLASSIFIED_ERROR = 0;
|
public final static int SEMANTIC_NAME_NOT_PROVIDED = SEMANTICS_RELATED | 0x003;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalid overload of a particular name.
|
||||||
|
* Required attributes: A_SYMBOL_NAME
|
||||||
|
* @see #A_SYMBOL_NAME
|
||||||
|
*/
|
||||||
|
public static final int SEMANTIC_INVALID_OVERLOAD = SEMANTICS_RELATED | 0x004;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalid using directive.
|
||||||
|
* Required attributes: A_NAMESPACE_NAME
|
||||||
|
* @see #A_NAMESPACE_NAME
|
||||||
|
*/
|
||||||
|
public static final int SEMANTIC_INVALID_USING = SEMANTICS_RELATED | 0x005;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ambiguous lookup for given name.
|
||||||
|
* Required attributes: A_SYMBOL_NAME
|
||||||
|
* @see #A_SYMBOL_NAME
|
||||||
|
*/
|
||||||
|
public static final int SEMANTIC_AMBIGUOUS_LOOKUP = SEMANTICS_RELATED | 0x006;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalid type provided
|
||||||
|
* Required attribugtes: A_TYPE_NAME
|
||||||
|
* @see #A_TYPE_NAME
|
||||||
|
*/
|
||||||
|
public static final int SEMANTIC_INVALID_TYPE = SEMANTICS_RELATED | 0x007;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_CIRCULAR_INHERITANCE = SEMANTICS_RELATED | 0x008;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_INVALID_TEMPLATE = SEMANTICS_RELATED | 0x009;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_BAD_VISIBILITY = SEMANTICS_RELATED | 0x00A;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION = SEMANTICS_RELATED | 0x00B;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_INVALID_TEMPLATE_ARGUMENT = SEMANTICS_RELATED | 0x00C;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_INVALID_TEMPLATE_PARAMETER = SEMANTICS_RELATED | 0x00D;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_REDECLARED_TEMPLATE_PARAMETER = SEMANTICS_RELATED | 0x00E;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_INVALID_CONVERSION_TYPE = SEMANTICS_RELATED | 0x00F;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_MALFORMED_EXPRESSION = SEMANTICS_RELATED | 0x010;
|
||||||
|
|
||||||
|
public static final int SEMANTIC_ILLFORMED_FRIEND = SEMANTICS_RELATED | 0x011;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IScanner {
|
public interface IScanner extends IFilenameProvider {
|
||||||
|
|
||||||
public static final String __CPLUSPLUS = "__cplusplus"; //$NON-NLS-1$
|
public static final String __CPLUSPLUS = "__cplusplus"; //$NON-NLS-1$
|
||||||
public static final String __STDC_VERSION__ = "__STDC_VERSION__"; //$NON-NLS-1$
|
public static final String __STDC_VERSION__ = "__STDC_VERSION__"; //$NON-NLS-1$
|
||||||
|
|
|
@ -42,4 +42,7 @@ public interface ITokenDuple {
|
||||||
public int findLastTokenType( int type );
|
public int findLastTokenType( int type );
|
||||||
|
|
||||||
public IASTNode lookup( IASTFactory factory, IASTScope scope );
|
public IASTNode lookup( IASTFactory factory, IASTScope scope );
|
||||||
|
public int getStartOffset();
|
||||||
|
public int getEndOffset();
|
||||||
|
public int getLineNumber();
|
||||||
}
|
}
|
|
@ -39,14 +39,14 @@ public class ParserFactory {
|
||||||
|
|
||||||
private static IParserExtensionFactory extensionFactory = new ParserExtensionFactory( ExtensionDialect.GCC );
|
private static IParserExtensionFactory extensionFactory = new ParserExtensionFactory( ExtensionDialect.GCC );
|
||||||
|
|
||||||
public static IASTFactory createASTFactory( ParserMode mode, ParserLanguage language )
|
public static IASTFactory createASTFactory( IFilenameProvider provider, ParserMode mode, ParserLanguage language )
|
||||||
{
|
{
|
||||||
if( mode == ParserMode.QUICK_PARSE )
|
if( mode == ParserMode.QUICK_PARSE )
|
||||||
return new QuickParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.QUICK_PARSE ) );
|
return new QuickParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.QUICK_PARSE ) );
|
||||||
else if( mode == ParserMode.EXPRESSION_PARSE )
|
else if( mode == ParserMode.EXPRESSION_PARSE )
|
||||||
return new ExpressionParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.EXPRESSION_PARSE ) );
|
return new ExpressionParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.EXPRESSION_PARSE ) );
|
||||||
else
|
else
|
||||||
return new CompleteParseASTFactory( language, mode, extensionFactory.createASTExtensionFactory( ParserMode.COMPLETE_PARSE ) );
|
return new CompleteParseASTFactory( provider, language, mode, extensionFactory.createASTExtensionFactory( ParserMode.COMPLETE_PARSE ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IParserLogService log ) throws ParserFactoryError
|
public static IParser createParser( IScanner scanner, ISourceElementRequestor callback, ParserMode mode, ParserLanguage language, IParserLogService log ) throws ParserFactoryError
|
||||||
|
|
|
@ -26,5 +26,17 @@ public class ASTAccessVisibility extends Enum {
|
||||||
{
|
{
|
||||||
super( constant );
|
super( constant );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLessThan( ASTAccessVisibility other )
|
||||||
|
{
|
||||||
|
return getEnumValue() < other.getEnumValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGreaterThan( ASTAccessVisibility other )
|
||||||
|
{
|
||||||
|
return getEnumValue() > other.getEnumValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,6 @@ public class ASTSemanticException extends Exception
|
||||||
{
|
{
|
||||||
private final IProblem theProblem;
|
private final IProblem theProblem;
|
||||||
|
|
||||||
public ASTSemanticException()
|
|
||||||
{
|
|
||||||
theProblem = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -37,6 +31,14 @@ public class ASTSemanticException extends Exception
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
public ASTSemanticException(ASTSemanticException e) {
|
||||||
|
theProblem = e.getProblem();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public IProblem getProblem()
|
public IProblem getProblem()
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.ast;
|
package org.eclipse.cdt.core.parser.ast;
|
||||||
|
|
||||||
|
import java.util.Hashtable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.Enum;
|
import org.eclipse.cdt.core.parser.Enum;
|
||||||
|
@ -118,6 +119,119 @@ public interface IASTExpression extends ISourceElementCallbackDelegate
|
||||||
{
|
{
|
||||||
super(enumValue);
|
super(enumValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Hashtable names;
|
||||||
|
static
|
||||||
|
{
|
||||||
|
names = new Hashtable();
|
||||||
|
names.put( PRIMARY_EMPTY, "PRIMARY_EMPTY" );
|
||||||
|
names.put( PRIMARY_INTEGER_LITERAL , "PRIMARY_INTEGER_LITERAL" );
|
||||||
|
names.put( PRIMARY_CHAR_LITERAL , "PRIMARY_CHAR_LITERAL" );
|
||||||
|
names.put( PRIMARY_FLOAT_LITERAL , "PRIMARY_FLOAT_LITERAL" );
|
||||||
|
names.put( PRIMARY_STRING_LITERAL , "PRIMARY_STRING_LITERAL" );
|
||||||
|
names.put( PRIMARY_BOOLEAN_LITERAL , "PRIMARY_BOOLEAN_LITERAL" );
|
||||||
|
names.put( PRIMARY_THIS , "PRIMARY_THIS");
|
||||||
|
names.put( PRIMARY_BRACKETED_EXPRESSION , "PRIMARY_BRACKETED_EXPRESSION");
|
||||||
|
names.put( ID_EXPRESSION , "ID_EXPRESSION");
|
||||||
|
names.put( POSTFIX_SUBSCRIPT , "POSTFIX_SUBSCRIPT");
|
||||||
|
names.put( POSTFIX_FUNCTIONCALL , "POSTFIX_FUNCTIONCALL");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_INT , "POSTFIX_SIMPLETYPE_INT");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_SHORT , "POSTFIX_SIMPLETYPE_SHORT");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_DOUBLE , "POSTFIX_SIMPLETYPE_DOUBLE");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_FLOAT , "POSTFIX_SIMPLETYPE_FLOAT");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_CHAR , "POSTFIX_SIMPLETYPE_CHAR");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_WCHART , "POSTFIX_SIMPLETYPE_WCHART");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_SIGNED , "POSTFIX_SIMPLETYPE_SIGNED");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_UNSIGNED , "POSTFIX_SIMPLETYPE_UNSIGNED");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_BOOL , "POSTFIX_SIMPLETYPE_BOOL");
|
||||||
|
names.put( POSTFIX_SIMPLETYPE_LONG , "POSTFIX_SIMPLETYPE_LONG");
|
||||||
|
names.put( POSTFIX_TYPENAME_IDENTIFIER , "POSTFIX_TYPENAME_IDENTIFIER");
|
||||||
|
names.put( POSTFIX_TYPENAME_TEMPLATEID, "POSTFIX_TYPENAME_TEMPLATEID" );
|
||||||
|
names.put( POSTFIX_DOT_IDEXPRESSION , "POSTFIX_DOT_IDEXPRESSION");
|
||||||
|
names.put( POSTFIX_ARROW_IDEXPRESSION , "POSTFIX_ARROW_IDEXPRESSION");
|
||||||
|
names.put( POSTFIX_DOT_TEMPL_IDEXPRESS , "POSTFIX_DOT_TEMPL_IDEXPRESS");
|
||||||
|
names.put( POSTFIX_ARROW_TEMPL_IDEXP , "POSTFIX_ARROW_TEMPL_IDEXP");
|
||||||
|
names.put( POSTFIX_DOT_DESTRUCTOR , "POSTFIX_DOT_DESTRUCTOR");
|
||||||
|
names.put( POSTFIX_ARROW_DESTRUCTOR , "POSTFIX_ARROW_DESTRUCTOR");
|
||||||
|
names.put( POSTFIX_INCREMENT , "POSTFIX_INCREMENT");
|
||||||
|
names.put( POSTFIX_DECREMENT , "POSTFIX_DECREMENT");
|
||||||
|
names.put( POSTFIX_DYNAMIC_CAST , "POSTFIX_DYNAMIC_CAST");
|
||||||
|
names.put( POSTFIX_REINTERPRET_CAST , "POSTFIX_REINTERPRET_CAST");
|
||||||
|
names.put( POSTFIX_STATIC_CAST , "POSTFIX_STATIC_CAST");
|
||||||
|
names.put( POSTFIX_CONST_CAST , "POSTFIX_CONST_CAST");
|
||||||
|
names.put( POSTFIX_TYPEID_EXPRESSION , "POSTFIX_TYPEID_EXPRESSION");
|
||||||
|
names.put( POSTFIX_TYPEID_TYPEID , "POSTFIX_TYPEID_TYPEID");
|
||||||
|
names.put( UNARY_INCREMENT , "UNARY_INCREMENT");
|
||||||
|
names.put( UNARY_DECREMENT , "UNARY_DECREMENT");
|
||||||
|
names.put( UNARY_STAR_CASTEXPRESSION , "UNARY_STAR_CASTEXPRESSION");
|
||||||
|
names.put( UNARY_AMPSND_CASTEXPRESSION , "UNARY_AMPSND_CASTEXPRESSION");
|
||||||
|
names.put( UNARY_PLUS_CASTEXPRESSION , "UNARY_PLUS_CASTEXPRESSION");
|
||||||
|
names.put( UNARY_MINUS_CASTEXPRESSION , "UNARY_MINUS_CASTEXPRESSION");
|
||||||
|
names.put( UNARY_NOT_CASTEXPRESSION , "UNARY_NOT_CASTEXPRESSION");
|
||||||
|
names.put( UNARY_TILDE_CASTEXPRESSION , "UNARY_TILDE_CASTEXPRESSION");
|
||||||
|
names.put( UNARY_SIZEOF_UNARYEXPRESSION , "UNARY_SIZEOF_UNARYEXPRESSION");
|
||||||
|
names.put( UNARY_SIZEOF_TYPEID , "UNARY_SIZEOF_TYPEID");
|
||||||
|
names.put( NEW_NEWTYPEID , "NEW_NEWTYPEID");
|
||||||
|
names.put( NEW_TYPEID , "NEW_TYPEID");
|
||||||
|
names.put( DELETE_CASTEXPRESSION , "DELETE_CASTEXPRESSION");
|
||||||
|
names.put( DELETE_VECTORCASTEXPRESSION , "DELETE_VECTORCASTEXPRESSION");
|
||||||
|
names.put( CASTEXPRESSION , "CASTEXPRESSION");
|
||||||
|
names.put( PM_DOTSTAR , "PM_DOTSTAR");
|
||||||
|
names.put( PM_ARROWSTAR , "PM_ARROWSTAR");
|
||||||
|
names.put( MULTIPLICATIVE_MULTIPLY , "MULTIPLICATIVE_MULTIPLY");
|
||||||
|
names.put( MULTIPLICATIVE_DIVIDE , "MULTIPLICATIVE_DIVIDE");
|
||||||
|
names.put( MULTIPLICATIVE_MODULUS , "MULTIPLICATIVE_MODULUS");
|
||||||
|
names.put( ADDITIVE_PLUS , "ADDITIVE_PLUS");
|
||||||
|
names.put( ADDITIVE_MINUS , "ADDITIVE_MINUS");
|
||||||
|
names.put( SHIFT_LEFT , "SHIFT_LEFT");
|
||||||
|
names.put( SHIFT_RIGHT , "SHIFT_RIGHT");
|
||||||
|
names.put( RELATIONAL_LESSTHAN , "RELATIONAL_LESSTHAN");
|
||||||
|
names.put( RELATIONAL_GREATERTHAN , "RELATIONAL_GREATERTHAN");
|
||||||
|
names.put( RELATIONAL_LESSTHANEQUALTO , "RELATIONAL_LESSTHANEQUALTO");
|
||||||
|
names.put( RELATIONAL_GREATERTHANEQUALTO, "RELATIONAL_GREATERTHANEQUALTO" );
|
||||||
|
names.put( EQUALITY_EQUALS , "EQUALITY_EQUALS");
|
||||||
|
names.put( EQUALITY_NOTEQUALS , "EQUALITY_NOTEQUALS");
|
||||||
|
names.put( ANDEXPRESSION , "ANDEXPRESSION");
|
||||||
|
names.put( EXCLUSIVEOREXPRESSION , "EXCLUSIVEOREXPRESSION");
|
||||||
|
names.put( INCLUSIVEOREXPRESSION , "INCLUSIVEOREXPRESSION");
|
||||||
|
names.put( LOGICALANDEXPRESSION , "LOGICALANDEXPRESSION");
|
||||||
|
names.put( LOGICALOREXPRESSION , "LOGICALOREXPRESSION");
|
||||||
|
names.put( CONDITIONALEXPRESSION , "CONDITIONALEXPRESSION");
|
||||||
|
names.put( THROWEXPRESSION , "THROWEXPRESSION");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_NORMAL , "ASSIGNMENTEXPRESSION_NORMAL");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_PLUS , "ASSIGNMENTEXPRESSION_PLUS");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_MINUS , "ASSIGNMENTEXPRESSION_MINUS");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_MULT , "ASSIGNMENTEXPRESSION_MULT");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_DIV , "ASSIGNMENTEXPRESSION_DIV");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_MOD , "ASSIGNMENTEXPRESSION_MOD");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_LSHIFT , "ASSIGNMENTEXPRESSION_LSHIFT");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_RSHIFT , "ASSIGNMENTEXPRESSION_RSHIFT");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_AND , "ASSIGNMENTEXPRESSION_AND");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_OR , "ASSIGNMENTEXPRESSION_OR");
|
||||||
|
names.put( ASSIGNMENTEXPRESSION_XOR , "ASSIGNMENTEXPRESSION_XOR");
|
||||||
|
names.put( EXPRESSIONLIST , "EXPRESSIONLIST");
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getKindName() {
|
||||||
|
return (String) names.get(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPostfixMemberReference()
|
||||||
|
{
|
||||||
|
if( this == IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION ||
|
||||||
|
this == IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION ||
|
||||||
|
this == IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS ||
|
||||||
|
this == IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP ||
|
||||||
|
this == IASTExpression.Kind.PM_DOTSTAR ||
|
||||||
|
this == IASTExpression.Kind.PM_ARROWSTAR )
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core.parser.ast;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||||
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier.ClassNameType;
|
||||||
|
@ -243,4 +244,9 @@ public interface IASTFactory
|
||||||
public IASTNode getCompletionContext(Kind kind, IASTExpression expression);
|
public IASTNode getCompletionContext(Kind kind, IASTExpression expression);
|
||||||
|
|
||||||
public IASTNode lookupSymbolInContext( IASTScope scope, ITokenDuple duple ) throws ASTNotImplementedException;
|
public IASTNode lookupSymbolInContext( IASTScope scope, ITokenDuple duple ) throws ASTNotImplementedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param log
|
||||||
|
*/
|
||||||
|
public void setLogger(IParserLogService log);
|
||||||
}
|
}
|
|
@ -10,6 +10,8 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.parser.ast;
|
package org.eclipse.cdt.core.parser.ast;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*
|
*
|
||||||
|
@ -17,7 +19,7 @@ package org.eclipse.cdt.core.parser.ast;
|
||||||
public interface IASTUsingDeclaration extends IASTDeclaration, IASTOffsetableElement {
|
public interface IASTUsingDeclaration extends IASTDeclaration, IASTOffsetableElement {
|
||||||
|
|
||||||
public boolean isTypename();
|
public boolean isTypename();
|
||||||
public String usingTypeName();
|
public String usingTypeName();
|
||||||
public IASTDeclaration getUsingType() throws ASTNotImplementedException;
|
public Iterator getUsingTypes() throws ASTNotImplementedException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,9 @@ public class CompleteParser extends Parser {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
|
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
|
||||||
*/
|
*/
|
||||||
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
||||||
astFactory = ParserFactory.createASTFactory( ParserMode.COMPLETE_PARSE, language);
|
astFactory = ParserFactory.createASTFactory( this, ParserMode.COMPLETE_PARSE, language);
|
||||||
scanner.setASTFactory(astFactory);
|
scanner.setASTFactory(astFactory);
|
||||||
|
astFactory.setLogger(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,8 +160,9 @@ public class CompletionParser extends ContextualParser implements IParser {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
|
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
|
||||||
*/
|
*/
|
||||||
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
||||||
astFactory = ParserFactory.createASTFactory( ParserMode.COMPLETION_PARSE, language);
|
astFactory = ParserFactory.createASTFactory( this, ParserMode.COMPLETION_PARSE, language);
|
||||||
scanner.setASTFactory(astFactory);
|
scanner.setASTFactory(astFactory);
|
||||||
|
astFactory.setLogger(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
|
||||||
|
@ -307,7 +308,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
/**
|
/**
|
||||||
* @param requestor
|
* @param requestor
|
||||||
*/
|
*/
|
||||||
public List createASTNodes(IASTFactory astFactory) throws ASTSemanticException
|
public List createASTNodes(IASTFactory astFactory) throws ASTSemanticException, BacktrackException
|
||||||
{
|
{
|
||||||
this.astFactory = astFactory;
|
this.astFactory = astFactory;
|
||||||
Iterator i = declarators.iterator();
|
Iterator i = declarators.iterator();
|
||||||
|
@ -319,7 +320,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
*/
|
*/
|
||||||
private IASTDeclaration createASTNode(Declarator declarator) throws ASTSemanticException
|
private IASTDeclaration createASTNode(Declarator declarator) throws ASTSemanticException, BacktrackException
|
||||||
{
|
{
|
||||||
boolean isWithinClass = (getScope() instanceof IASTClassSpecifier); //TODO fix this for COMPLETE_PARSE
|
boolean isWithinClass = (getScope() instanceof IASTClassSpecifier); //TODO fix this for COMPLETE_PARSE
|
||||||
boolean isFunction = declarator.isFunction();
|
boolean isFunction = declarator.isFunction();
|
||||||
|
@ -350,7 +351,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
* @param declarator
|
* @param declarator
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IASTDeclaration createIndirectDeclaration(Declarator declarator) throws ASTSemanticException
|
private IASTDeclaration createIndirectDeclaration(Declarator declarator) throws BacktrackException, ASTSemanticException
|
||||||
{
|
{
|
||||||
if( declarator.getOwnedDeclarator().getOwnedDeclarator() == null )
|
if( declarator.getOwnedDeclarator().getOwnedDeclarator() == null )
|
||||||
{
|
{
|
||||||
|
@ -383,9 +384,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
|
|
||||||
List convertedParms = createParameterList( declarator.getParameters() );
|
List convertedParms = createParameterList( declarator.getParameters() );
|
||||||
IASTAbstractDeclaration abs = null;
|
IASTAbstractDeclaration abs = null;
|
||||||
try
|
abs =
|
||||||
{
|
|
||||||
abs =
|
|
||||||
astFactory.createAbstractDeclaration(
|
astFactory.createAbstractDeclaration(
|
||||||
constt,
|
constt,
|
||||||
volatil,
|
volatil,
|
||||||
|
@ -394,44 +393,20 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
declarator.getArrayModifiers(),
|
declarator.getArrayModifiers(),
|
||||||
convertedParms,
|
convertedParms,
|
||||||
(ASTPointerOperator)i.next());
|
(ASTPointerOperator)i.next());
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
String name = ( d.getPointerOperatorNameDuple() != null ) ? d.getPointerOperatorNameDuple().toString() + d.getName() : d.getName();
|
String name = ( d.getPointerOperatorNameDuple() != null ) ? d.getPointerOperatorNameDuple().toString() + d.getName() : d.getName();
|
||||||
if( typedef )
|
if( typedef )
|
||||||
try
|
return astFactory.createTypedef(scope, name, abs,
|
||||||
{
|
getStartingOffset(), getStartingLine(), d
|
||||||
return astFactory.createTypedef(
|
.getNameStartOffset(), d.getNameEndOffset(), d
|
||||||
scope,
|
.getNameLine());
|
||||||
name,
|
|
||||||
abs, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine() );
|
|
||||||
}
|
|
||||||
catch (ASTSemanticException e1)
|
|
||||||
{
|
|
||||||
throw e1;
|
|
||||||
}
|
|
||||||
catch (Exception e1)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
try
|
return astFactory.createVariable( scope, name, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression() );
|
||||||
{
|
|
||||||
return astFactory.createVariable( scope, name, auto, d.getInitializerClause(), d.getBitFieldExpression(), abs, mutable, extern, register, staticc, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine(), d.getConstructorExpression() );
|
|
||||||
}
|
|
||||||
catch (Exception e2)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ASTSemanticException();
|
throw new BacktrackException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,25 +415,14 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
*/
|
*/
|
||||||
private IASTTypedefDeclaration createTypedef(Declarator declarator, boolean nested ) throws ASTSemanticException
|
private IASTTypedefDeclaration createTypedef(Declarator declarator, boolean nested ) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
try
|
return astFactory.createTypedef(scope, nested ? declarator
|
||||||
{
|
.getOwnedDeclarator().getName() : declarator.getName(),
|
||||||
return astFactory.createTypedef(
|
astFactory.createAbstractDeclaration(constt, volatil,
|
||||||
scope,
|
getTypeSpecifier(), declarator.getPointerOperators(),
|
||||||
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
|
declarator.getArrayModifiers(), null, null),
|
||||||
astFactory.createAbstractDeclaration(
|
startingOffset, getStartingLine(), declarator
|
||||||
constt,
|
.getNameStartOffset(), declarator.getNameEndOffset(),
|
||||||
volatil,
|
declarator.getNameLine());
|
||||||
getTypeSpecifier(),
|
|
||||||
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null), startingOffset, getStartingLine(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine());
|
|
||||||
}
|
|
||||||
catch (ASTSemanticException e)
|
|
||||||
{
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
|
@ -466,41 +430,24 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
*/
|
*/
|
||||||
private IASTMethod createMethodASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
|
private IASTMethod createMethodASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
try
|
return astFactory.createMethod(scope, nested ? declarator
|
||||||
{
|
.getOwnedDeclarator().getNameDuple() : declarator
|
||||||
return astFactory
|
.getNameDuple(),
|
||||||
.createMethod(
|
createParameterList(declarator.getParameters()), astFactory
|
||||||
scope,
|
.createAbstractDeclaration(constt, volatil,
|
||||||
nested ? declarator.getOwnedDeclarator().getNameDuple() : declarator.getNameDuple(),
|
getTypeSpecifier(), declarator
|
||||||
createParameterList(declarator.getParameters()),
|
.getPointerOperators(), declarator
|
||||||
astFactory.createAbstractDeclaration(
|
.getArrayModifiers(), null, null),
|
||||||
constt,
|
declarator.getExceptionSpecification(), inline, friend,
|
||||||
volatil,
|
staticc, startingOffset, getStartingLine(), declarator
|
||||||
getTypeSpecifier(),
|
.getNameStartOffset(), declarator.getNameEndOffset(),
|
||||||
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
|
declarator.getNameLine(), templateDeclaration, declarator
|
||||||
declarator.getExceptionSpecification(),
|
.isConst(), declarator.isVolatile(), virtual, explicit,
|
||||||
inline,
|
declarator.isPureVirtual(), ((IASTClassSpecifier) scope)
|
||||||
friend,
|
.getCurrentVisibilityMode(), declarator
|
||||||
staticc,
|
.getConstructorMemberInitializers(), declarator
|
||||||
startingOffset,
|
.hasFunctionBody(), declarator.hasFunctionTryBlock(),
|
||||||
getStartingLine(),
|
declarator.isVarArgs());
|
||||||
declarator.getNameStartOffset(),
|
|
||||||
declarator.getNameEndOffset(),
|
|
||||||
declarator.getNameLine(),
|
|
||||||
templateDeclaration,
|
|
||||||
declarator.isConst(),
|
|
||||||
declarator.isVolatile(),
|
|
||||||
virtual, explicit,
|
|
||||||
declarator.isPureVirtual(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode(), declarator.getConstructorMemberInitializers(), declarator.hasFunctionBody(), declarator.hasFunctionTryBlock(), declarator.isVarArgs());
|
|
||||||
}
|
|
||||||
catch (ASTSemanticException e)
|
|
||||||
{
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
|
@ -508,41 +455,23 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
*/
|
*/
|
||||||
private IASTFunction createFunctionASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
|
private IASTFunction createFunctionASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
try
|
return astFactory.createFunction(scope, nested ? declarator
|
||||||
{
|
.getOwnedDeclarator().getNameDuple() : declarator
|
||||||
return astFactory.createFunction(
|
.getNameDuple(),
|
||||||
scope,
|
createParameterList(declarator.getParameters()), astFactory
|
||||||
nested ? declarator.getOwnedDeclarator().getNameDuple() : declarator.getNameDuple(),
|
.createAbstractDeclaration(constt, volatil,
|
||||||
createParameterList(declarator.getParameters()),
|
getTypeSpecifier(), declarator
|
||||||
astFactory.createAbstractDeclaration(
|
.getPointerOperators(), declarator
|
||||||
constt,
|
.getArrayModifiers(), null, null),
|
||||||
volatil,
|
declarator.getExceptionSpecification(), inline, friend,
|
||||||
getTypeSpecifier(),
|
staticc, startingOffset, getStartingLine(), declarator
|
||||||
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
|
.getNameStartOffset(), declarator.getNameEndOffset(),
|
||||||
declarator.getExceptionSpecification(),
|
declarator.getNameLine(), templateDeclaration, declarator
|
||||||
inline,
|
.isConst(), declarator.isVolatile(), virtual, explicit,
|
||||||
friend,
|
declarator.isPureVirtual(), declarator
|
||||||
staticc,
|
.getConstructorMemberInitializers(), declarator
|
||||||
startingOffset,
|
.hasFunctionBody(), declarator.hasFunctionTryBlock(),
|
||||||
getStartingLine(),
|
declarator.isVarArgs());
|
||||||
declarator.getNameStartOffset(),
|
|
||||||
declarator.getNameEndOffset(),
|
|
||||||
declarator.getNameLine(),
|
|
||||||
templateDeclaration,
|
|
||||||
declarator.isConst(),
|
|
||||||
declarator.isVolatile(),
|
|
||||||
virtual,
|
|
||||||
explicit, declarator.isPureVirtual(), declarator.getConstructorMemberInitializers(),
|
|
||||||
declarator.hasFunctionBody(), declarator.hasFunctionTryBlock(), declarator.isVarArgs() );
|
|
||||||
}
|
|
||||||
catch (ASTSemanticException e)
|
|
||||||
{
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param declarator
|
* @param declarator
|
||||||
|
@ -550,9 +479,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
*/
|
*/
|
||||||
private IASTField createFieldASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
|
private IASTField createFieldASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
try
|
return astFactory.createField(
|
||||||
{
|
|
||||||
return astFactory.createField(
|
|
||||||
scope,
|
scope,
|
||||||
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
|
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
|
||||||
auto,
|
auto,
|
||||||
|
@ -570,16 +497,8 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
startingOffset,
|
startingOffset,
|
||||||
getStartingLine(),
|
getStartingLine(),
|
||||||
declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), declarator.getConstructorExpression(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode());
|
declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), declarator.getConstructorExpression(), ((IASTClassSpecifier)scope).getCurrentVisibilityMode());
|
||||||
}
|
|
||||||
catch (ASTSemanticException e)
|
|
||||||
{
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List createParameterList(List currentParameters) throws ASTSemanticException
|
private List createParameterList(List currentParameters) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
List result = new ArrayList();
|
List result = new ArrayList();
|
||||||
|
@ -591,23 +510,17 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
while (j.hasNext())
|
while (j.hasNext())
|
||||||
{
|
{
|
||||||
Declarator declarator = (Declarator)j.next();
|
Declarator declarator = (Declarator)j.next();
|
||||||
try
|
|
||||||
{
|
result.add(
|
||||||
result.add(
|
astFactory.createParameterDeclaration(
|
||||||
astFactory.createParameterDeclaration(
|
wrapper.isConst(),
|
||||||
wrapper.isConst(),
|
wrapper.isVolatile(),
|
||||||
wrapper.isVolatile(),
|
wrapper.getTypeSpecifier(),
|
||||||
wrapper.getTypeSpecifier(),
|
declarator.getPointerOperators(),
|
||||||
declarator.getPointerOperators(),
|
declarator.getArrayModifiers(),
|
||||||
declarator.getArrayModifiers(),
|
null, null, declarator.getName() == null
|
||||||
null, null, declarator.getName() == null
|
? "" //$NON-NLS-1$
|
||||||
? "" //$NON-NLS-1$
|
: declarator.getName(), declarator.getInitializerClause(), wrapper.getStartingOffset(), getStartingLine(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), wrapper.getEndOffset(), getEndLine()));
|
||||||
: declarator.getName(), declarator.getInitializerClause(), wrapper.getStartingOffset(), getStartingLine(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), wrapper.getEndOffset(), getEndLine()));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -618,34 +531,24 @@ public class DeclarationWrapper implements IDeclaratorOwner
|
||||||
*/
|
*/
|
||||||
private IASTVariable createVariableASTNode(Declarator declarator, boolean nested ) throws ASTSemanticException
|
private IASTVariable createVariableASTNode(Declarator declarator, boolean nested ) throws ASTSemanticException
|
||||||
{
|
{
|
||||||
try
|
return astFactory.createVariable(
|
||||||
{
|
scope,
|
||||||
return astFactory.createVariable(
|
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
|
||||||
scope,
|
isAuto(),
|
||||||
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
|
declarator.getInitializerClause(),
|
||||||
isAuto(),
|
declarator.getBitFieldExpression(),
|
||||||
declarator.getInitializerClause(),
|
astFactory.createAbstractDeclaration(
|
||||||
declarator.getBitFieldExpression(),
|
constt,
|
||||||
astFactory.createAbstractDeclaration(
|
volatil,
|
||||||
constt,
|
getTypeSpecifier(),
|
||||||
volatil,
|
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
|
||||||
getTypeSpecifier(),
|
mutable,
|
||||||
declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
|
extern,
|
||||||
mutable,
|
register,
|
||||||
extern,
|
staticc,
|
||||||
register,
|
getStartingOffset(),
|
||||||
staticc,
|
getStartingLine(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), declarator.getConstructorExpression());
|
||||||
getStartingOffset(),
|
|
||||||
getStartingLine(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), declarator.getConstructorExpression());
|
|
||||||
}
|
|
||||||
catch (ASTSemanticException e)
|
|
||||||
{
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ASTSemanticException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -71,8 +71,9 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
* @param language
|
* @param language
|
||||||
*/
|
*/
|
||||||
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
||||||
astFactory = ParserFactory.createASTFactory( ParserMode.EXPRESSION_PARSE, language);
|
astFactory = ParserFactory.createASTFactory( this, ParserMode.EXPRESSION_PARSE, language);
|
||||||
scanner.setASTFactory(astFactory);
|
scanner.setASTFactory(astFactory);
|
||||||
|
astFactory.setLogger(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2508,4 +2509,8 @@ public class ExpressionParser implements IExpressionParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public char[] getCurrentFilename() {
|
||||||
|
return scanner.getCurrentFilename();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,13 +12,14 @@ package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.BacktrackException;
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
|
import org.eclipse.cdt.core.parser.IFilenameProvider;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
import org.eclipse.cdt.core.parser.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public interface IExpressionParser {
|
public interface IExpressionParser extends IFilenameProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request a parse from a pre-configured parser to parse an expression.
|
* Request a parse from a pre-configured parser to parse an expression.
|
||||||
|
|
|
@ -123,7 +123,6 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
*/
|
*/
|
||||||
protected void translationUnit()
|
protected void translationUnit()
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
compilationUnit = astFactory.createCompilationUnit();
|
compilationUnit = astFactory.createCompilationUnit();
|
||||||
|
@ -1649,7 +1648,8 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
eck = ASTClassKind.ENUM;
|
eck = ASTClassKind.ENUM;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
break;
|
backup( t );
|
||||||
|
throw backtrack;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITokenDuple d = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE);
|
ITokenDuple d = name(sdw.getScope(), CompletionKind.TYPE_REFERENCE);
|
||||||
|
@ -2991,5 +2991,4 @@ public abstract class Parser extends ExpressionParser implements IParser
|
||||||
*/
|
*/
|
||||||
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,9 @@ public class QuickParser extends Parser {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
|
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
|
||||||
*/
|
*/
|
||||||
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
||||||
astFactory = ParserFactory.createASTFactory( ParserMode.QUICK_PARSE, language);
|
astFactory = ParserFactory.createASTFactory( this, ParserMode.QUICK_PARSE, language);
|
||||||
scanner.setASTFactory(astFactory);
|
scanner.setASTFactory(astFactory);
|
||||||
|
astFactory.setLogger(log);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,7 @@ public class StructuralParser extends Parser implements IParser {
|
||||||
*/
|
*/
|
||||||
public StructuralParser(IScanner scanner, ISourceElementRequestor ourCallback, ParserLanguage language, IParserLogService logService) {
|
public StructuralParser(IScanner scanner, ISourceElementRequestor ourCallback, ParserLanguage language, IParserLogService logService) {
|
||||||
super(scanner, ourCallback, language, logService);
|
super(scanner, ourCallback, language, logService);
|
||||||
astFactory = ParserFactory.createASTFactory( ParserMode.COMPLETE_PARSE, language);
|
setupASTFactory(scanner, language );
|
||||||
scanner.setASTFactory(astFactory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -74,6 +73,13 @@ public class StructuralParser extends Parser implements IParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.ExpressionParser#setupASTFactory(org.eclipse.cdt.core.parser.IScanner, org.eclipse.cdt.core.parser.ParserLanguage)
|
||||||
|
*/
|
||||||
|
protected void setupASTFactory(IScanner scanner, ParserLanguage language) {
|
||||||
|
astFactory = ParserFactory.createASTFactory( this, ParserMode.COMPLETE_PARSE, language);
|
||||||
|
scanner.setASTFactory(astFactory);
|
||||||
|
astFactory.setLogger(log);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser.ast;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||||
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IToken;
|
import org.eclipse.cdt.core.parser.IToken;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
|
||||||
|
@ -31,6 +32,8 @@ import org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind;
|
||||||
*/
|
*/
|
||||||
public class BaseASTFactory {
|
public class BaseASTFactory {
|
||||||
|
|
||||||
|
protected IParserLogService logService;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createMacro(java.lang.String, int, int, int)
|
* @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createMacro(java.lang.String, int, int, int)
|
||||||
*/
|
*/
|
||||||
|
@ -64,5 +67,9 @@ public class BaseASTFactory {
|
||||||
fieldIdentifier == null ? -1 : fieldIdentifier.getOffset() );
|
fieldIdentifier == null ? -1 : fieldIdentifier.getOffset() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLogger(IParserLogService log) {
|
||||||
|
logService = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,12 @@ public class ASTNamespaceReference
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param offset
|
* @param offset
|
||||||
* @param string
|
* @param referencedElementName
|
||||||
* @param definition
|
* @param definition
|
||||||
*/
|
*/
|
||||||
public ASTNamespaceReference(int offset, String string, IASTNamespaceDefinition definition)
|
public ASTNamespaceReference(int offset, String referencedElementName, IASTNamespaceDefinition definition)
|
||||||
{
|
{
|
||||||
super(offset, string);
|
super(offset, referencedElementName);
|
||||||
reference = definition;
|
reference = definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,119 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2001 Rational Software Corp. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Rational Software - initial implementation
|
||||||
|
******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.problem.BaseProblemFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author jcamelon
|
||||||
|
*
|
||||||
|
* To change the template for this generated type comment go to
|
||||||
|
* Window - Preferences - Java - Code Generation - Code and Comments
|
||||||
|
*/
|
||||||
|
public class ASTProblemFactory extends BaseProblemFactory implements IProblemFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
protected static final Map errorMessages;
|
||||||
|
static {
|
||||||
|
errorMessages = new HashMap();
|
||||||
|
errorMessages.put( new Integer( IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED),"Attempt to introduce unique symbol failed : ");
|
||||||
|
errorMessages.put( new Integer( IProblem.SEMANTIC_NAME_NOT_FOUND), "Attempt to use symbol failed : ");
|
||||||
|
errorMessages.put( new Integer( IProblem.SEMANTIC_NAME_NOT_PROVIDED), "Name not provided.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.problem.BaseProblemFactory#createMessage(int, java.util.Map, int, char[])
|
||||||
|
*/
|
||||||
|
public String createMessage(int id, Map arguments, int lineNumber,
|
||||||
|
char[] fileName) {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
|
buffer.append(PROBLEM);
|
||||||
|
buffer.append(errorMessages.get(new Integer(id)));
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED:
|
||||||
|
case IProblem.SEMANTIC_NAME_NOT_FOUND:
|
||||||
|
buffer.append(arguments.get(IProblem.A_SYMBOL_NAME));
|
||||||
|
break;
|
||||||
|
case IProblem.SEMANTIC_NAME_NOT_PROVIDED:
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( fileName != null )
|
||||||
|
{
|
||||||
|
buffer.append( IN_FILE );
|
||||||
|
buffer.append(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( lineNumber > 0 )
|
||||||
|
{
|
||||||
|
buffer.append( ON_LINE );
|
||||||
|
buffer.append(lineNumber);
|
||||||
|
}
|
||||||
|
return buffer.toString();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.problem.IProblemFactory#createProblem(int, int, int, int, char[], java.util.Map, boolean, boolean)
|
||||||
|
*/
|
||||||
|
public IProblem createProblem(int id, int start, int end, int line,
|
||||||
|
char[] file, Map arguments, boolean warn, boolean error) {
|
||||||
|
|
||||||
|
if( checkBitmask( id, IProblem.INTERNAL_RELATED ) )
|
||||||
|
return createInternalProblem( id, start, end, line, file, arguments, warn, error );
|
||||||
|
|
||||||
|
if ( checkBitmask( id, IProblem.SEMANTICS_RELATED ) )
|
||||||
|
return super.createProblem(
|
||||||
|
id,
|
||||||
|
start,
|
||||||
|
end,
|
||||||
|
line,
|
||||||
|
file,
|
||||||
|
createMessage(id, arguments, line, file),
|
||||||
|
arguments,
|
||||||
|
warn,
|
||||||
|
error);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.problem.IProblemFactory#getRequiredAttributesForId(int)
|
||||||
|
*/
|
||||||
|
public String[] getRequiredAttributesForId(int id) {
|
||||||
|
String [] result = new String[1];
|
||||||
|
switch (id)
|
||||||
|
{
|
||||||
|
case IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED :
|
||||||
|
case IProblem.SEMANTIC_NAME_NOT_FOUND:
|
||||||
|
case IProblem.SEMANTIC_AMBIGUOUS_LOOKUP:
|
||||||
|
result[0] = IProblem.A_SYMBOL_NAME;
|
||||||
|
break;
|
||||||
|
case IProblem.SEMANTIC_INVALID_TYPE:
|
||||||
|
result[0] = IProblem.A_TYPE_NAME;
|
||||||
|
break;
|
||||||
|
case IProblem.SEMANTIC_INVALID_USING:
|
||||||
|
result[0] = IProblem.A_NAMESPACE_NAME;
|
||||||
|
break;
|
||||||
|
case IProblem.SEMANTIC_NAME_NOT_PROVIDED:
|
||||||
|
result = new String[0];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,14 +10,15 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
package org.eclipse.cdt.internal.core.parser.ast.complete;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.SymbolIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -27,18 +28,20 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
|
||||||
{
|
{
|
||||||
private final IASTScope ownerScope;
|
private final IASTScope ownerScope;
|
||||||
private final boolean isTypeName;
|
private final boolean isTypeName;
|
||||||
private final IASTDeclaration declaration;
|
private final List declarations = new ArrayList();
|
||||||
private Offsets offsets = new Offsets();
|
private Offsets offsets = new Offsets();
|
||||||
private final ASTReferenceStore delegate;
|
private final ASTReferenceStore delegate;
|
||||||
|
private String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public ASTUsingDeclaration( IASTScope ownerScope, IASTDeclaration declaration, boolean isTypeName, int startingOffset, int startingLine, int endingOffset, int endingLine, List references )
|
public ASTUsingDeclaration( IASTScope ownerScope, String name, List declarations, boolean isTypeName, int startingOffset, int startingLine, int endingOffset, int endingLine, List references )
|
||||||
{
|
{
|
||||||
this.ownerScope = ownerScope;
|
this.ownerScope = ownerScope;
|
||||||
this.isTypeName = isTypeName;
|
this.isTypeName = isTypeName;
|
||||||
this.declaration = declaration;
|
this.name = name;
|
||||||
|
this.declarations.addAll( declarations );
|
||||||
setStartingOffsetAndLineNumber(startingOffset, startingLine);
|
setStartingOffsetAndLineNumber(startingOffset, startingLine);
|
||||||
setEndingOffsetAndLineNumber(endingOffset, endingLine);
|
setEndingOffsetAndLineNumber(endingOffset, endingLine);
|
||||||
delegate = new ASTReferenceStore( references );
|
delegate = new ASTReferenceStore( references );
|
||||||
|
@ -55,7 +58,7 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
|
||||||
*/
|
*/
|
||||||
public String usingTypeName()
|
public String usingTypeName()
|
||||||
{
|
{
|
||||||
return ((IASTOffsetableNamedElement)declaration).getName();
|
return name;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
|
||||||
|
@ -122,9 +125,9 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#getUsingType()
|
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#getUsingType()
|
||||||
*/
|
*/
|
||||||
public IASTDeclaration getUsingType()
|
public Iterator getUsingTypes()
|
||||||
{
|
{
|
||||||
return declaration;
|
return new SymbolIterator( declarations.iterator() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -67,11 +67,12 @@ 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.IASTTemplateParameter.ParamKind;
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
|
import org.eclipse.cdt.core.parser.ast.extension.IASTExpressionExtension;
|
||||||
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
public class ExpressionParseASTFactory implements IASTFactory {
|
public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFactory {
|
||||||
|
|
||||||
private final IASTExtensionFactory extensionFactory;
|
private final IASTExtensionFactory extensionFactory;
|
||||||
|
|
||||||
|
@ -914,4 +915,5 @@ public class ExpressionParseASTFactory implements IASTFactory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
package org.eclipse.cdt.internal.core.parser.ast.quick;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
import org.eclipse.cdt.core.parser.ast.IASTScope;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
|
||||||
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
|
||||||
|
@ -108,7 +109,7 @@ public class ASTUsingDeclaration
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#getUsingType()
|
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#getUsingType()
|
||||||
*/
|
*/
|
||||||
public IASTDeclaration getUsingType() throws ASTNotImplementedException
|
public Iterator getUsingTypes() throws ASTNotImplementedException
|
||||||
{
|
{
|
||||||
throw new ASTNotImplementedException();
|
throw new ASTNotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2205,7 +2205,7 @@ public class ParserSymbolTable {
|
||||||
parentAccess = parent.getAccess();
|
parentAccess = parent.getAccess();
|
||||||
symbolAccess = ((IASTMember)symbol.getASTExtension().getPrimaryDeclaration()).getVisiblity();
|
symbolAccess = ((IASTMember)symbol.getASTExtension().getPrimaryDeclaration()).getVisiblity();
|
||||||
|
|
||||||
return ( parentAccess.getEnumValue() > symbolAccess.getEnumValue() ) ? parentAccess : symbolAccess;
|
return ( parentAccess.isGreaterThan( symbolAccess ) )? parentAccess : symbolAccess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2221,10 +2221,10 @@ public class ParserSymbolTable {
|
||||||
symbolAccess = getVisibility( symbol, (IContainerSymbol) parent.getParent() );
|
symbolAccess = getVisibility( symbol, (IContainerSymbol) parent.getParent() );
|
||||||
|
|
||||||
if( symbolAccess != null ){
|
if( symbolAccess != null ){
|
||||||
symbolAccess = ( parentAccess.getEnumValue() > symbolAccess.getEnumValue() ) ? parentAccess : symbolAccess;
|
symbolAccess = ( parentAccess.isGreaterThan( symbolAccess ) ) ? parentAccess : symbolAccess;
|
||||||
if( checkAllPaths ){
|
if( checkAllPaths ){
|
||||||
if( resultingAccess != null )
|
if( resultingAccess != null )
|
||||||
resultingAccess = ( resultingAccess.getEnumValue() > symbolAccess.getEnumValue() ) ? symbolAccess : resultingAccess;
|
resultingAccess = resultingAccess.isGreaterThan( symbolAccess ) ? symbolAccess : resultingAccess;
|
||||||
else
|
else
|
||||||
resultingAccess = symbolAccess;
|
resultingAccess = symbolAccess;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.parser.pst;
|
package org.eclipse.cdt.internal.core.parser.pst;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
*/
|
*/
|
||||||
|
@ -44,5 +46,38 @@ public class ParserSymbolTableException extends Exception {
|
||||||
public static final int r_BadTemplateParameter = 9;
|
public static final int r_BadTemplateParameter = 9;
|
||||||
public static final int r_RedeclaredTemplateParam = 10;
|
public static final int r_RedeclaredTemplateParam = 10;
|
||||||
public int reason = -1;
|
public int reason = -1;
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int createProblemID() {
|
||||||
|
switch( reason )
|
||||||
|
{
|
||||||
|
case r_Ambiguous:
|
||||||
|
return IProblem.SEMANTIC_AMBIGUOUS_LOOKUP;
|
||||||
|
case r_BadTypeInfo:
|
||||||
|
return IProblem.SEMANTIC_INVALID_TYPE;
|
||||||
|
case r_CircularInheritance:
|
||||||
|
return IProblem.SEMANTIC_CIRCULAR_INHERITANCE;
|
||||||
|
case r_InvalidOverload:
|
||||||
|
return IProblem.SEMANTIC_INVALID_OVERLOAD;
|
||||||
|
case r_BadTemplate:
|
||||||
|
return IProblem.SEMANTIC_INVALID_TEMPLATE;
|
||||||
|
case r_InvalidUsing:
|
||||||
|
return IProblem.SEMANTIC_INVALID_USING;
|
||||||
|
case r_BadVisibility:
|
||||||
|
return IProblem.SEMANTIC_BAD_VISIBILITY;
|
||||||
|
case r_UnableToResolveFunction:
|
||||||
|
return IProblem.SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION;
|
||||||
|
case r_BadTemplateArgument:
|
||||||
|
return IProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT;
|
||||||
|
case r_BadTemplateParameter:
|
||||||
|
return IProblem.SEMANTIC_INVALID_TEMPLATE_PARAMETER;
|
||||||
|
case r_RedeclaredTemplateParam:
|
||||||
|
return IProblem.SEMANTIC_REDECLARED_TEMPLATE_PARAMETER;
|
||||||
|
default:
|
||||||
|
// assert false : this;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -11,6 +11,8 @@
|
||||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
@ -26,7 +28,6 @@ import java.util.StringTokenizer;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.BacktrackException;
|
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
|
||||||
import org.eclipse.cdt.core.parser.Directives;
|
import org.eclipse.cdt.core.parser.Directives;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
import org.eclipse.cdt.core.parser.EndOfFileException;
|
||||||
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
import org.eclipse.cdt.core.parser.IMacroDescriptor;
|
||||||
|
@ -66,7 +67,7 @@ import org.eclipse.cdt.internal.core.parser.token.Token;
|
||||||
|
|
||||||
public class Scanner implements IScanner {
|
public class Scanner implements IScanner {
|
||||||
|
|
||||||
private final static String SCRATCH = "<scratch>"; //$NON-NLS-1$
|
private final static String SCRATCH = "<scratch>";
|
||||||
protected final IScannerData scannerData;
|
protected final IScannerData scannerData;
|
||||||
|
|
||||||
private boolean initialContextInitialized = false;
|
private boolean initialContextInitialized = false;
|
||||||
|
@ -94,7 +95,7 @@ public class Scanner implements IScanner {
|
||||||
IProblem problem = scannerData.getProblemFactory().createProblem( problemID, beginningOffset, getCurrentOffset(), scannerData.getContextStack().getCurrentLineNumber(), getCurrentFile().toCharArray(), arguments, warning, error );
|
IProblem problem = scannerData.getProblemFactory().createProblem( problemID, beginningOffset, getCurrentOffset(), scannerData.getContextStack().getCurrentLineNumber(), getCurrentFile().toCharArray(), arguments, warning, error );
|
||||||
|
|
||||||
// trace log
|
// trace log
|
||||||
StringBuffer logMessage = new StringBuffer( "Scanner problem encountered: "); //$NON-NLS-1$
|
StringBuffer logMessage = new StringBuffer( "Scanner problem encountered: ");
|
||||||
logMessage.append( problem.getMessage() );
|
logMessage.append( problem.getMessage() );
|
||||||
scannerData.getLogService().traceLog( logMessage.toString() );
|
scannerData.getLogService().traceLog( logMessage.toString() );
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ public class Scanner implements IScanner {
|
||||||
if( scannerExtension instanceof GCCScannerExtension )
|
if( scannerExtension instanceof GCCScannerExtension )
|
||||||
((GCCScannerExtension)scannerExtension).setScannerData( scannerData );
|
((GCCScannerExtension)scannerExtension).setScannerData( scannerData );
|
||||||
|
|
||||||
scannerData.setASTFactory( ParserFactory.createASTFactory( scannerData.getParserMode(), language ) );
|
scannerData.setASTFactory( ParserFactory.createASTFactory( this, scannerData.getParserMode(), language ) );
|
||||||
try {
|
try {
|
||||||
//this is a hack to get around a sudden EOF experience
|
//this is a hack to get around a sudden EOF experience
|
||||||
scannerData.getContextStack().push(
|
scannerData.getContextStack().push(
|
||||||
|
@ -174,18 +175,18 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
scannerExtension.setupBuiltInMacros(scannerData.getLanguage());
|
scannerExtension.setupBuiltInMacros(scannerData.getLanguage());
|
||||||
if( getDefinition(__STDC__) == null )
|
if( getDefinition(__STDC__) == null )
|
||||||
addDefinition( __STDC__, new ObjectMacroDescriptor( __STDC__, "1") ); //$NON-NLS-1$
|
addDefinition( __STDC__, new ObjectMacroDescriptor( __STDC__, "1") );
|
||||||
|
|
||||||
if( scannerData.getLanguage() == ParserLanguage.C )
|
if( scannerData.getLanguage() == ParserLanguage.C )
|
||||||
{
|
{
|
||||||
if( getDefinition(__STDC_HOSTED__) == null )
|
if( getDefinition(__STDC_HOSTED__) == null )
|
||||||
addDefinition( __STDC_HOSTED__, new ObjectMacroDescriptor( __STDC_HOSTED__, "0")); //$NON-NLS-1$
|
addDefinition( __STDC_HOSTED__, new ObjectMacroDescriptor( __STDC_HOSTED__, "0"));
|
||||||
if( getDefinition( __STDC_VERSION__) == null )
|
if( getDefinition( __STDC_VERSION__) == null )
|
||||||
addDefinition( __STDC_VERSION__, new ObjectMacroDescriptor( __STDC_VERSION__, "199001L")); //$NON-NLS-1$
|
addDefinition( __STDC_VERSION__, new ObjectMacroDescriptor( __STDC_VERSION__, "199001L"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if( getDefinition( __CPLUSPLUS ) == null )
|
if( getDefinition( __CPLUSPLUS ) == null )
|
||||||
addDefinition( __CPLUSPLUS, new ObjectMacroDescriptor( __CPLUSPLUS, "199711L")); //$NON-NLS-1$
|
addDefinition( __CPLUSPLUS, new ObjectMacroDescriptor( __CPLUSPLUS, "199711L"));
|
||||||
|
|
||||||
if( getDefinition(__FILE__) == null )
|
if( getDefinition(__FILE__) == null )
|
||||||
addDefinition( __FILE__,
|
addDefinition( __FILE__,
|
||||||
|
@ -222,17 +223,17 @@ public class Scanner implements IScanner {
|
||||||
if( Calendar.MONTH == Calendar.OCTOBER) return "Oct";
|
if( Calendar.MONTH == Calendar.OCTOBER) return "Oct";
|
||||||
if( Calendar.MONTH == Calendar.NOVEMBER) return "Nov";
|
if( Calendar.MONTH == Calendar.NOVEMBER) return "Nov";
|
||||||
if( Calendar.MONTH == Calendar.DECEMBER) return "Dec";
|
if( Calendar.MONTH == Calendar.DECEMBER) return "Dec";
|
||||||
return ""; //$NON-NLS-1$
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String execute() {
|
public String execute() {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer();
|
||||||
result.append( getMonth() );
|
result.append( getMonth() );
|
||||||
result.append(" "); //$NON-NLS-1$
|
result.append(" ");
|
||||||
if( Calendar.DAY_OF_MONTH < 10 )
|
if( Calendar.DAY_OF_MONTH < 10 )
|
||||||
result.append(" "); //$NON-NLS-1$
|
result.append(" ");
|
||||||
result.append(Calendar.DAY_OF_MONTH);
|
result.append(Calendar.DAY_OF_MONTH);
|
||||||
result.append(" "); //$NON-NLS-1$
|
result.append(" ");
|
||||||
result.append( Calendar.YEAR );
|
result.append( Calendar.YEAR );
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
@ -308,7 +309,6 @@ public class Scanner implements IScanner {
|
||||||
buffer.append( tokenizer.nextToken() );
|
buffer.append( tokenizer.nextToken() );
|
||||||
}
|
}
|
||||||
file = new File( buffer.toString() );
|
file = new File( buffer.toString() );
|
||||||
path = buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( file.exists() && file.isDirectory() )
|
if( file.exists() && file.isDirectory() )
|
||||||
|
@ -496,7 +496,9 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
protected void handleInclusion(String fileName, boolean useIncludePaths, int beginOffset, int startLine, int nameOffset, int nameLine, int endOffset, int endLine ) throws ScannerException {
|
protected void handleInclusion(String fileName, boolean useIncludePaths, int beginOffset, int startLine, int nameOffset, int nameLine, int endOffset, int endLine ) throws ScannerException {
|
||||||
|
|
||||||
CodeReader duple = null;
|
FileReader inclusionReader = null;
|
||||||
|
String newPath = null;
|
||||||
|
|
||||||
totalLoop: for( int i = 0; i < 2; ++i )
|
totalLoop: for( int i = 0; i < 2; ++i )
|
||||||
{
|
{
|
||||||
if( useIncludePaths ) // search include paths for this file
|
if( useIncludePaths ) // search include paths for this file
|
||||||
|
@ -507,33 +509,65 @@ public class Scanner implements IScanner {
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
|
||||||
String path = (String)iter.next();
|
String path = (String)iter.next();
|
||||||
duple = createReaderDuple( path, fileName );
|
File pathFile = new File(path);
|
||||||
if( duple != null )
|
//TODO assert pathFile.isDirectory();
|
||||||
break totalLoop;
|
StringBuffer buffer = new StringBuffer( pathFile.getPath() );
|
||||||
|
buffer.append( File.separatorChar );
|
||||||
|
buffer.append( fileName );
|
||||||
|
newPath = buffer.toString();
|
||||||
|
//TODO remove ".." and "." segments
|
||||||
|
File includeFile = new File(newPath);
|
||||||
|
if (includeFile.exists() && includeFile.isFile()) {
|
||||||
|
try {
|
||||||
|
inclusionReader = new FileReader(includeFile);
|
||||||
|
break totalLoop;
|
||||||
|
} catch (FileNotFoundException fnf) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (duple == null )
|
if (inclusionReader == null )
|
||||||
handleProblem( IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, fileName, beginOffset, false, true );
|
handleProblem( IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, fileName, beginOffset, false, true );
|
||||||
|
|
||||||
}
|
}
|
||||||
else // local inclusion
|
else // local inclusion
|
||||||
{
|
{
|
||||||
duple = createReaderDuple( new File( scannerData.getContextStack().getCurrentContext().getFilename() ).getParentFile().getAbsolutePath(), fileName );
|
String currentFilename = scannerData.getContextStack().getCurrentContext().getFilename();
|
||||||
if( duple != null )
|
File currentIncludeFile = new File( currentFilename );
|
||||||
break totalLoop;
|
String parentDirectory = currentIncludeFile.getParentFile().getAbsolutePath();
|
||||||
useIncludePaths = true;
|
currentIncludeFile = null;
|
||||||
continue totalLoop;
|
|
||||||
|
StringBuffer buffer = new StringBuffer( parentDirectory );
|
||||||
|
buffer.append( File.separatorChar );
|
||||||
|
buffer.append( fileName );
|
||||||
|
newPath = buffer.toString();
|
||||||
|
//TODO remove ".." and "." segments
|
||||||
|
File includeFile = new File( newPath );
|
||||||
|
if (includeFile.exists() && includeFile.isFile()) {
|
||||||
|
try {
|
||||||
|
inclusionReader = new FileReader(includeFile);
|
||||||
|
break totalLoop;
|
||||||
|
} catch (FileNotFoundException fnf) {
|
||||||
|
useIncludePaths = true;
|
||||||
|
continue totalLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
useIncludePaths = true;
|
||||||
|
continue totalLoop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (inclusionReader != null) {
|
||||||
if (duple!= null) {
|
|
||||||
IASTInclusion inclusion = null;
|
IASTInclusion inclusion = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
inclusion =
|
inclusion =
|
||||||
scannerData.getASTFactory().createInclusion(
|
scannerData.getASTFactory().createInclusion(
|
||||||
fileName,
|
fileName,
|
||||||
duple.getFilename(),
|
newPath,
|
||||||
!useIncludePaths,
|
!useIncludePaths,
|
||||||
beginOffset,
|
beginOffset,
|
||||||
startLine,
|
startLine,
|
||||||
|
@ -547,7 +581,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
scannerData.getContextStack().updateContext(duple.getUnderlyingReader(), duple.getFilename(), ScannerContext.ContextKind.INCLUSION, inclusion, scannerData.getClientRequestor() );
|
scannerData.getContextStack().updateContext(inclusionReader, newPath, ScannerContext.ContextKind.INCLUSION, inclusion, scannerData.getClientRequestor() );
|
||||||
}
|
}
|
||||||
catch (ContextException e1)
|
catch (ContextException e1)
|
||||||
{
|
{
|
||||||
|
@ -559,14 +593,14 @@ public class Scanner implements IScanner {
|
||||||
// constants
|
// constants
|
||||||
private static final int NOCHAR = -1;
|
private static final int NOCHAR = -1;
|
||||||
|
|
||||||
private static final String TEXT = "<text>"; //$NON-NLS-1$
|
private static final String TEXT = "<text>";
|
||||||
private static final String START = "<initial reader>"; //$NON-NLS-1$
|
private static final String START = "<initial reader>";
|
||||||
private static final String EXPRESSION = "<expression>"; //$NON-NLS-1$
|
private static final String EXPRESSION = "<expression>";
|
||||||
private static final String PASTING = "<pasting>"; //$NON-NLS-1$
|
private static final String PASTING = "<pasting>";
|
||||||
|
|
||||||
private static final String DEFINED = "defined"; //$NON-NLS-1$
|
private static final String DEFINED = "defined";
|
||||||
private static final String _PRAGMA = "_Pragma"; //$NON-NLS-1$
|
private static final String _PRAGMA = "_Pragma";
|
||||||
private static final String POUND_DEFINE = "#define "; //$NON-NLS-1$
|
private static final String POUND_DEFINE = "#define ";
|
||||||
|
|
||||||
private IScannerContext lastContext = null;
|
private IScannerContext lastContext = null;
|
||||||
|
|
||||||
|
@ -634,39 +668,39 @@ public class Scanner implements IScanner {
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '(':
|
case '(':
|
||||||
expandDefinition("??(", "[", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("??(", "[", baseOffset);
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
break;
|
break;
|
||||||
case ')':
|
case ')':
|
||||||
expandDefinition("??)", "]", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("??)", "]", baseOffset);
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
break;
|
break;
|
||||||
case '<':
|
case '<':
|
||||||
expandDefinition("??<", "{", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("??<", "{", baseOffset);
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
break;
|
break;
|
||||||
case '>':
|
case '>':
|
||||||
expandDefinition("??>", "}", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("??>", "}", baseOffset);
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
break;
|
break;
|
||||||
case '=':
|
case '=':
|
||||||
expandDefinition("??=", "#", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("??=", "#", baseOffset);
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
expandDefinition("??/", "\\", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("??/", "\\", baseOffset);
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
break;
|
break;
|
||||||
case '\'':
|
case '\'':
|
||||||
expandDefinition("??\'", "^", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("??\'", "^", baseOffset);
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
break;
|
break;
|
||||||
case '!':
|
case '!':
|
||||||
expandDefinition("??!", "|", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("??!", "|", baseOffset);
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
expandDefinition("??-", "~", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("??-", "~", baseOffset);
|
||||||
c = getChar(insideString);
|
c = getChar(insideString);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -709,10 +743,10 @@ public class Scanner implements IScanner {
|
||||||
if (c == '<') {
|
if (c == '<') {
|
||||||
c = getChar(false);
|
c = getChar(false);
|
||||||
if (c == '%') {
|
if (c == '%') {
|
||||||
expandDefinition("<%", "{", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("<%", "{", baseOffset);
|
||||||
c = getChar(false);
|
c = getChar(false);
|
||||||
} else if (c == ':') {
|
} else if (c == ':') {
|
||||||
expandDefinition("<:", "[", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("<:", "[", baseOffset);
|
||||||
c = getChar(false);
|
c = getChar(false);
|
||||||
} else {
|
} else {
|
||||||
// Not a digraph
|
// Not a digraph
|
||||||
|
@ -722,7 +756,7 @@ public class Scanner implements IScanner {
|
||||||
} else if (c == ':') {
|
} else if (c == ':') {
|
||||||
c = getChar(false);
|
c = getChar(false);
|
||||||
if (c == '>') {
|
if (c == '>') {
|
||||||
expandDefinition(":>", "]", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition(":>", "]", baseOffset);
|
||||||
c = getChar(false);
|
c = getChar(false);
|
||||||
} else {
|
} else {
|
||||||
// Not a digraph
|
// Not a digraph
|
||||||
|
@ -732,10 +766,10 @@ public class Scanner implements IScanner {
|
||||||
} else if (c == '%') {
|
} else if (c == '%') {
|
||||||
c = getChar(false);
|
c = getChar(false);
|
||||||
if (c == '>') {
|
if (c == '>') {
|
||||||
expandDefinition("%>", "}", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("%>", "}", baseOffset);
|
||||||
c = getChar(false);
|
c = getChar(false);
|
||||||
} else if (c == ':') {
|
} else if (c == ':') {
|
||||||
expandDefinition("%:", "#", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
|
expandDefinition("%:", "#", baseOffset);
|
||||||
c = getChar(false);
|
c = getChar(false);
|
||||||
} else {
|
} else {
|
||||||
// Not a digraph
|
// Not a digraph
|
||||||
|
@ -1081,17 +1115,17 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
if( ! firstCharZero && floatingPoint && !(c >= '0' && c <= '9') ){
|
if( ! firstCharZero && floatingPoint && !(c >= '0' && c <= '9') ){
|
||||||
//if pasting, there could actually be a float here instead of just a .
|
//if pasting, there could actually be a float here instead of just a .
|
||||||
if( buff.toString().equals( "." ) ){ //$NON-NLS-1$
|
if( buff.toString().equals( "." ) ){
|
||||||
if( c == '*' ){
|
if( c == '*' ){
|
||||||
return newToken( IToken.tDOTSTAR, ".*", scannerData.getContextStack().getCurrentContext() ); //$NON-NLS-1$
|
return newToken( IToken.tDOTSTAR, ".*", scannerData.getContextStack().getCurrentContext() );
|
||||||
} else if( c == '.' ){
|
} else if( c == '.' ){
|
||||||
if( getChar() == '.' )
|
if( getChar() == '.' )
|
||||||
return newToken( IToken.tELLIPSIS, "...", scannerData.getContextStack().getCurrentContext() ); //$NON-NLS-1$
|
return newToken( IToken.tELLIPSIS, "...", scannerData.getContextStack().getCurrentContext() );
|
||||||
else
|
else
|
||||||
handleProblem( IProblem.SCANNER_BAD_FLOATING_POINT, null, beginOffset, false, true );
|
handleProblem( IProblem.SCANNER_BAD_FLOATING_POINT, null, beginOffset, false, true );
|
||||||
} else {
|
} else {
|
||||||
ungetChar( c );
|
ungetChar( c );
|
||||||
return newToken( IToken.tDOT, ".", scannerData.getContextStack().getCurrentContext() ); //$NON-NLS-1$
|
return newToken( IToken.tDOT, ".", scannerData.getContextStack().getCurrentContext() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (c == 'x') {
|
} else if (c == 'x') {
|
||||||
|
@ -1212,7 +1246,7 @@ public class Scanner implements IScanner {
|
||||||
int tokenType;
|
int tokenType;
|
||||||
String result = buff.toString();
|
String result = buff.toString();
|
||||||
|
|
||||||
if( floatingPoint && result.equals(".") ) //$NON-NLS-1$
|
if( floatingPoint && result.equals(".") )
|
||||||
tokenType = IToken.tDOT;
|
tokenType = IToken.tDOT;
|
||||||
else
|
else
|
||||||
tokenType = floatingPoint ? IToken.tFLOATINGPT : IToken.tINTEGER;
|
tokenType = floatingPoint ? IToken.tFLOATINGPT : IToken.tINTEGER;
|
||||||
|
@ -1238,12 +1272,12 @@ public class Scanner implements IScanner {
|
||||||
if( c == '#' )
|
if( c == '#' )
|
||||||
{
|
{
|
||||||
if( skipped )
|
if( skipped )
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "# #", beginningOffset, false, true ); //$NON-NLS-1$
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "# #", beginningOffset, false, true );
|
||||||
else
|
else
|
||||||
return newToken( tPOUNDPOUND, "##" ); //$NON-NLS-1$
|
return newToken( tPOUNDPOUND, "##" );
|
||||||
} else if( tokenizingMacroReplacementList ) {
|
} else if( tokenizingMacroReplacementList ) {
|
||||||
ungetChar( c );
|
ungetChar( c );
|
||||||
return newToken( tPOUND, "#" ); //$NON-NLS-1$
|
return newToken( tPOUND, "#" );
|
||||||
}
|
}
|
||||||
|
|
||||||
while (((c >= 'a') && (c <= 'z'))
|
while (((c >= 'a') && (c <= 'z'))
|
||||||
|
@ -1263,7 +1297,7 @@ public class Scanner implements IScanner {
|
||||||
if (directive == null) {
|
if (directive == null) {
|
||||||
if( scannerExtension.canHandlePreprocessorDirective( token ) )
|
if( scannerExtension.canHandlePreprocessorDirective( token ) )
|
||||||
scannerExtension.handlePreprocessorDirective( token, getRestOfPreprocessorLine() );
|
scannerExtension.handlePreprocessorDirective( token, getRestOfPreprocessorLine() );
|
||||||
StringBuffer buffer = new StringBuffer( "#"); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer( "#");
|
||||||
buffer.append( token );
|
buffer.append( token );
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
|
||||||
} else {
|
} else {
|
||||||
|
@ -1320,8 +1354,8 @@ public class Scanner implements IScanner {
|
||||||
if( isLimitReached() )
|
if( isLimitReached() )
|
||||||
handleCompletionOnExpression( expression );
|
handleCompletionOnExpression( expression );
|
||||||
|
|
||||||
if (expression.trim().equals("")) //$NON-NLS-1$
|
if (expression.trim().equals(""))
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#if", beginningOffset, false, true ); //$NON-NLS-1$
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#if", beginningOffset, false, true );
|
||||||
|
|
||||||
boolean expressionEvalResult = false;
|
boolean expressionEvalResult = false;
|
||||||
|
|
||||||
|
@ -1355,9 +1389,9 @@ public class Scanner implements IScanner {
|
||||||
if( isLimitReached() )
|
if( isLimitReached() )
|
||||||
handleInvalidCompletion();
|
handleInvalidCompletion();
|
||||||
|
|
||||||
if( ! restOfLine.equals( "" ) ) //$NON-NLS-1$
|
if( ! restOfLine.equals( "" ) )
|
||||||
{
|
{
|
||||||
StringBuffer buffer = new StringBuffer("#endif "); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer("#endif ");
|
||||||
buffer.append( restOfLine );
|
buffer.append( restOfLine );
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
|
||||||
}
|
}
|
||||||
|
@ -1415,8 +1449,8 @@ public class Scanner implements IScanner {
|
||||||
handleCompletionOnExpression( elifExpression );
|
handleCompletionOnExpression( elifExpression );
|
||||||
|
|
||||||
|
|
||||||
if (elifExpression.equals("")) //$NON-NLS-1$
|
if (elifExpression.equals(""))
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#elif", beginningOffset, false, true ); //$NON-NLS-1$
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#elif", beginningOffset, false, true );
|
||||||
|
|
||||||
boolean elsifResult = false;
|
boolean elsifResult = false;
|
||||||
if( scannerData.getBranchTracker().queryCurrentBranchForElif() )
|
if( scannerData.getBranchTracker().queryCurrentBranchForElif() )
|
||||||
|
@ -1467,15 +1501,15 @@ public class Scanner implements IScanner {
|
||||||
case PreprocessorDirectives.BLANK :
|
case PreprocessorDirectives.BLANK :
|
||||||
String remainderOfLine =
|
String remainderOfLine =
|
||||||
getRestOfPreprocessorLine().trim();
|
getRestOfPreprocessorLine().trim();
|
||||||
if (!remainderOfLine.equals("")) { //$NON-NLS-1$
|
if (!remainderOfLine.equals("")) {
|
||||||
StringBuffer buffer = new StringBuffer( "# "); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer( "# ");
|
||||||
buffer.append( remainderOfLine );
|
buffer.append( remainderOfLine );
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true);
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true);
|
||||||
}
|
}
|
||||||
c = getChar();
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
default :
|
default :
|
||||||
StringBuffer buffer = new StringBuffer( "# "); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer( "# ");
|
||||||
buffer.append( token );
|
buffer.append( token );
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
|
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
|
||||||
}
|
}
|
||||||
|
@ -1490,51 +1524,51 @@ public class Scanner implements IScanner {
|
||||||
case ':' :
|
case ':' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tCOLONCOLON,
|
IToken.tCOLONCOLON,
|
||||||
"::", //$NON-NLS-1$
|
"::",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tCOLON,
|
IToken.tCOLON,
|
||||||
":", //$NON-NLS-1$
|
":",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case ';' :
|
case ';' :
|
||||||
return newToken(IToken.tSEMI, ";", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tSEMI, ";", scannerData.getContextStack().getCurrentContext());
|
||||||
case ',' :
|
case ',' :
|
||||||
return newToken(IToken.tCOMMA, ",", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tCOMMA, ",", scannerData.getContextStack().getCurrentContext());
|
||||||
case '?' :
|
case '?' :
|
||||||
return newToken(IToken.tQUESTION, "?", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tQUESTION, "?", scannerData.getContextStack().getCurrentContext());
|
||||||
case '(' :
|
case '(' :
|
||||||
return newToken(IToken.tLPAREN, "(", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tLPAREN, "(", scannerData.getContextStack().getCurrentContext());
|
||||||
case ')' :
|
case ')' :
|
||||||
return newToken(IToken.tRPAREN, ")", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tRPAREN, ")", scannerData.getContextStack().getCurrentContext());
|
||||||
case '[' :
|
case '[' :
|
||||||
return newToken(IToken.tLBRACKET, "[", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tLBRACKET, "[", scannerData.getContextStack().getCurrentContext());
|
||||||
case ']' :
|
case ']' :
|
||||||
return newToken(IToken.tRBRACKET, "]", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tRBRACKET, "]", scannerData.getContextStack().getCurrentContext());
|
||||||
case '{' :
|
case '{' :
|
||||||
return newToken(IToken.tLBRACE, "{", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tLBRACE, "{", scannerData.getContextStack().getCurrentContext());
|
||||||
case '}' :
|
case '}' :
|
||||||
return newToken(IToken.tRBRACE, "}", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tRBRACE, "}", scannerData.getContextStack().getCurrentContext());
|
||||||
case '+' :
|
case '+' :
|
||||||
c = getChar();
|
c = getChar();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tPLUSASSIGN,
|
IToken.tPLUSASSIGN,
|
||||||
"+=", //$NON-NLS-1$
|
"+=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
case '+' :
|
case '+' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tINCR,
|
IToken.tINCR,
|
||||||
"++", //$NON-NLS-1$
|
"++",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tPLUS,
|
IToken.tPLUS,
|
||||||
"+", //$NON-NLS-1$
|
"+",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '-' :
|
case '-' :
|
||||||
|
@ -1543,12 +1577,12 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tMINUSASSIGN,
|
IToken.tMINUSASSIGN,
|
||||||
"-=", //$NON-NLS-1$
|
"-=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
case '-' :
|
case '-' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tDECR,
|
IToken.tDECR,
|
||||||
"--", //$NON-NLS-1$
|
"--",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
case '>' :
|
case '>' :
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
@ -1556,20 +1590,20 @@ public class Scanner implements IScanner {
|
||||||
case '*' :
|
case '*' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tARROWSTAR,
|
IToken.tARROWSTAR,
|
||||||
"->*", //$NON-NLS-1$
|
"->*",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tARROW,
|
IToken.tARROW,
|
||||||
"->", //$NON-NLS-1$
|
"->",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tMINUS,
|
IToken.tMINUS,
|
||||||
"-", //$NON-NLS-1$
|
"-",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '*' :
|
case '*' :
|
||||||
|
@ -1578,13 +1612,13 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tSTARASSIGN,
|
IToken.tSTARASSIGN,
|
||||||
"*=", //$NON-NLS-1$
|
"*=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tSTAR,
|
IToken.tSTAR,
|
||||||
"*", //$NON-NLS-1$
|
"*",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '%' :
|
case '%' :
|
||||||
|
@ -1593,13 +1627,13 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tMODASSIGN,
|
IToken.tMODASSIGN,
|
||||||
"%=", //$NON-NLS-1$
|
"%=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tMOD,
|
IToken.tMOD,
|
||||||
"%", //$NON-NLS-1$
|
"%",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '^' :
|
case '^' :
|
||||||
|
@ -1608,13 +1642,13 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tXORASSIGN,
|
IToken.tXORASSIGN,
|
||||||
"^=", //$NON-NLS-1$
|
"^=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tXOR,
|
IToken.tXOR,
|
||||||
"^", //$NON-NLS-1$
|
"^",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '&' :
|
case '&' :
|
||||||
|
@ -1623,18 +1657,18 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tAMPERASSIGN,
|
IToken.tAMPERASSIGN,
|
||||||
"&=", //$NON-NLS-1$
|
"&=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
case '&' :
|
case '&' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tAND,
|
IToken.tAND,
|
||||||
"&&", //$NON-NLS-1$
|
"&&",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tAMPER,
|
IToken.tAMPER,
|
||||||
"&", //$NON-NLS-1$
|
"&",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '|' :
|
case '|' :
|
||||||
|
@ -1643,35 +1677,35 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tBITORASSIGN,
|
IToken.tBITORASSIGN,
|
||||||
"|=", //$NON-NLS-1$
|
"|=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
case '|' :
|
case '|' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tOR,
|
IToken.tOR,
|
||||||
"||", //$NON-NLS-1$
|
"||",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tBITOR,
|
IToken.tBITOR,
|
||||||
"|", //$NON-NLS-1$
|
"|",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '~' :
|
case '~' :
|
||||||
return newToken(IToken.tCOMPL, "~", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tCOMPL, "~", scannerData.getContextStack().getCurrentContext());
|
||||||
case '!' :
|
case '!' :
|
||||||
c = getChar();
|
c = getChar();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tNOTEQUAL,
|
IToken.tNOTEQUAL,
|
||||||
"!=", //$NON-NLS-1$
|
"!=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tNOT,
|
IToken.tNOT,
|
||||||
"!", //$NON-NLS-1$
|
"!",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '=' :
|
case '=' :
|
||||||
|
@ -1680,13 +1714,13 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tEQUAL,
|
IToken.tEQUAL,
|
||||||
"==", //$NON-NLS-1$
|
"==",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tASSIGN,
|
IToken.tASSIGN,
|
||||||
"=", //$NON-NLS-1$
|
"=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '<' :
|
case '<' :
|
||||||
|
@ -1698,25 +1732,25 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tSHIFTLASSIGN,
|
IToken.tSHIFTLASSIGN,
|
||||||
"<<=", //$NON-NLS-1$
|
"<<=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tSHIFTL,
|
IToken.tSHIFTL,
|
||||||
"<<", //$NON-NLS-1$
|
"<<",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tLTEQUAL,
|
IToken.tLTEQUAL,
|
||||||
"<=", //$NON-NLS-1$
|
"<=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
if( forInclusion )
|
if( forInclusion )
|
||||||
temporarilyReplaceDefinitionsMap();
|
temporarilyReplaceDefinitionsMap();
|
||||||
return newToken(IToken.tLT, "<", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tLT, "<", scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '>' :
|
case '>' :
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
@ -1727,25 +1761,25 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tSHIFTRASSIGN,
|
IToken.tSHIFTRASSIGN,
|
||||||
">>=", //$NON-NLS-1$
|
">>=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tSHIFTR,
|
IToken.tSHIFTR,
|
||||||
">>", //$NON-NLS-1$
|
">>",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tGTEQUAL,
|
IToken.tGTEQUAL,
|
||||||
">=", //$NON-NLS-1$
|
">=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
if( forInclusion )
|
if( forInclusion )
|
||||||
restoreDefinitionsMap();
|
restoreDefinitionsMap();
|
||||||
return newToken(IToken.tGT, ">", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tGT, ">", scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
case '.' :
|
case '.' :
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
@ -1756,7 +1790,7 @@ public class Scanner implements IScanner {
|
||||||
case '.' :
|
case '.' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tELLIPSIS,
|
IToken.tELLIPSIS,
|
||||||
"...", //$NON-NLS-1$
|
"...",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
|
@ -1765,13 +1799,13 @@ public class Scanner implements IScanner {
|
||||||
case '*' :
|
case '*' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tDOTSTAR,
|
IToken.tDOTSTAR,
|
||||||
".*", //$NON-NLS-1$
|
".*",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tDOT,
|
IToken.tDOT,
|
||||||
".", //$NON-NLS-1$
|
".",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1789,13 +1823,13 @@ public class Scanner implements IScanner {
|
||||||
case '=' :
|
case '=' :
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tDIVASSIGN,
|
IToken.tDIVASSIGN,
|
||||||
"/=", //$NON-NLS-1$
|
"/=",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
default :
|
default :
|
||||||
ungetChar(c);
|
ungetChar(c);
|
||||||
return newToken(
|
return newToken(
|
||||||
IToken.tDIV,
|
IToken.tDIV,
|
||||||
"/", //$NON-NLS-1$
|
"/",
|
||||||
scannerData.getContextStack().getCurrentContext());
|
scannerData.getContextStack().getCurrentContext());
|
||||||
}
|
}
|
||||||
default :
|
default :
|
||||||
|
@ -1838,9 +1872,9 @@ public class Scanner implements IScanner {
|
||||||
int completionPoint = expression.length() + 2;
|
int completionPoint = expression.length() + 2;
|
||||||
IASTCompletionNode.CompletionKind kind = IASTCompletionNode.CompletionKind.MACRO_REFERENCE;
|
IASTCompletionNode.CompletionKind kind = IASTCompletionNode.CompletionKind.MACRO_REFERENCE;
|
||||||
|
|
||||||
String prefix = ""; //$NON-NLS-1$
|
String prefix = "";
|
||||||
|
|
||||||
if( ! expression.trim().equals("")) //$NON-NLS-1$
|
if( ! expression.trim().equals(""))
|
||||||
{
|
{
|
||||||
IScanner subScanner = ParserFactory.createScanner( new StringReader(expression), SCRATCH, EMPTY_INFO, ParserMode.QUICK_PARSE, scannerData.getLanguage(), new NullSourceElementRequestor(), new NullLogService());
|
IScanner subScanner = ParserFactory.createScanner( new StringReader(expression), SCRATCH, EMPTY_INFO, ParserMode.QUICK_PARSE, scannerData.getLanguage(), new NullSourceElementRequestor(), new NullLogService());
|
||||||
IToken lastToken = null;
|
IToken lastToken = null;
|
||||||
|
@ -1883,7 +1917,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
protected void handleInvalidCompletion() throws EndOfFileException
|
protected void handleInvalidCompletion() throws EndOfFileException
|
||||||
{
|
{
|
||||||
throwEOF( new ASTCompletionNode( IASTCompletionNode.CompletionKind.UNREACHABLE_CODE, null, null, "", KeywordSets.getKeywords(KeywordSets.Key.EMPTY, scannerData.getLanguage()) )); //$NON-NLS-1$
|
throwEOF( new ASTCompletionNode( IASTCompletionNode.CompletionKind.UNREACHABLE_CODE, null, null, "", KeywordSets.getKeywords(KeywordSets.Key.EMPTY, scannerData.getLanguage()) ));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleCompletionOnPreprocessorDirective( String prefix ) throws EndOfFileException
|
protected void handleCompletionOnPreprocessorDirective( String prefix ) throws EndOfFileException
|
||||||
|
@ -1948,7 +1982,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
protected String getCurrentFile()
|
protected String getCurrentFile()
|
||||||
{
|
{
|
||||||
return scannerData.getContextStack().getMostRelevantFileContext() != null ? scannerData.getContextStack().getMostRelevantFileContext().getFilename() : ""; //$NON-NLS-1$
|
return scannerData.getContextStack().getMostRelevantFileContext() != null ? scannerData.getContextStack().getMostRelevantFileContext().getFilename() : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2009,13 +2043,13 @@ public class Scanner implements IScanner {
|
||||||
return processCharacterLiteral( c, false );
|
return processCharacterLiteral( c, false );
|
||||||
case ',' :
|
case ',' :
|
||||||
if (tokenImage.length() > 0) throw endOfMacroToken;
|
if (tokenImage.length() > 0) throw endOfMacroToken;
|
||||||
return newToken(IToken.tCOMMA, ",", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tCOMMA, ",", scannerData.getContextStack().getCurrentContext());
|
||||||
case '(' :
|
case '(' :
|
||||||
if (tokenImage.length() > 0) throw endOfMacroToken;
|
if (tokenImage.length() > 0) throw endOfMacroToken;
|
||||||
return newToken(IToken.tLPAREN, "(", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tLPAREN, "(", scannerData.getContextStack().getCurrentContext());
|
||||||
case ')' :
|
case ')' :
|
||||||
if (tokenImage.length() > 0) throw endOfMacroToken;
|
if (tokenImage.length() > 0) throw endOfMacroToken;
|
||||||
return newToken(IToken.tRPAREN, ")", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
|
return newToken(IToken.tRPAREN, ")", scannerData.getContextStack().getCurrentContext());
|
||||||
case '/' :
|
case '/' :
|
||||||
if (tokenImage.length() > 0) throw endOfMacroToken;
|
if (tokenImage.length() > 0) throw endOfMacroToken;
|
||||||
c = getChar();
|
c = getChar();
|
||||||
|
@ -2231,7 +2265,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
if( scannerData.getParserMode() == ParserMode.QUICK_PARSE )
|
if( scannerData.getParserMode() == ParserMode.QUICK_PARSE )
|
||||||
{
|
{
|
||||||
if( expression.trim().equals( "0" ) ) //$NON-NLS-1$
|
if( expression.trim().equals( "0" ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -2275,7 +2309,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
protected void skipOverSinglelineComment() throws ScannerException, EndOfFileException {
|
protected void skipOverSinglelineComment() throws ScannerException, EndOfFileException {
|
||||||
|
|
||||||
StringBuffer comment = new StringBuffer("//"); //$NON-NLS-1$
|
StringBuffer comment = new StringBuffer("//");
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
|
@ -2298,7 +2332,7 @@ public class Scanner implements IScanner {
|
||||||
protected boolean skipOverMultilineComment() throws ScannerException, EndOfFileException {
|
protected boolean skipOverMultilineComment() throws ScannerException, EndOfFileException {
|
||||||
int state = 0;
|
int state = 0;
|
||||||
boolean encounteredNewline = false;
|
boolean encounteredNewline = false;
|
||||||
StringBuffer comment = new StringBuffer("/*"); //$NON-NLS-1$
|
StringBuffer comment = new StringBuffer("/*");
|
||||||
// simple state machine to handle multi-line comments
|
// simple state machine to handle multi-line comments
|
||||||
// state 0 == no end of comment in site
|
// state 0 == no end of comment in site
|
||||||
// state 1 == encountered *, expecting /
|
// state 1 == encountered *, expecting /
|
||||||
|
@ -2337,7 +2371,7 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void poundInclude( int beginningOffset, int startLine ) throws ScannerException, EndOfFileException {
|
protected void poundInclude( int beginningOffset, int startLine ) throws ScannerException, EndOfFileException {
|
||||||
StringBuffer potentialErrorLine = new StringBuffer( "#include "); //$NON-NLS-1$
|
StringBuffer potentialErrorLine = new StringBuffer( "#include ");
|
||||||
skipOverWhitespace();
|
skipOverWhitespace();
|
||||||
int baseOffset = lastContext.getOffset() - lastContext.undoStackSize();
|
int baseOffset = lastContext.getOffset() - lastContext.undoStackSize();
|
||||||
int nameLine = scannerData.getContextStack().getCurrentLineNumber();
|
int nameLine = scannerData.getContextStack().getCurrentLineNumber();
|
||||||
|
@ -2348,7 +2382,7 @@ public class Scanner implements IScanner {
|
||||||
int startOffset = baseOffset;
|
int startOffset = baseOffset;
|
||||||
int endOffset = baseOffset;
|
int endOffset = baseOffset;
|
||||||
|
|
||||||
if (! includeLine.equals("")) { //$NON-NLS-1$
|
if (! includeLine.equals("")) {
|
||||||
Scanner helperScanner = new Scanner(
|
Scanner helperScanner = new Scanner(
|
||||||
new StringReader(includeLine),
|
new StringReader(includeLine),
|
||||||
null,
|
null,
|
||||||
|
@ -2429,7 +2463,7 @@ public class Scanner implements IScanner {
|
||||||
i =
|
i =
|
||||||
scannerData.getASTFactory().createInclusion(
|
scannerData.getASTFactory().createInclusion(
|
||||||
f,
|
f,
|
||||||
"", //$NON-NLS-1$
|
"",
|
||||||
!useIncludePath,
|
!useIncludePath,
|
||||||
beginningOffset,
|
beginningOffset,
|
||||||
startLine,
|
startLine,
|
||||||
|
@ -2481,7 +2515,7 @@ public class Scanner implements IScanner {
|
||||||
protected List tokenizeReplacementString( int beginning, String key, String replacementString, List parameterIdentifiers )
|
protected List tokenizeReplacementString( int beginning, String key, String replacementString, List parameterIdentifiers )
|
||||||
{
|
{
|
||||||
List macroReplacementTokens = new ArrayList();
|
List macroReplacementTokens = new ArrayList();
|
||||||
if( replacementString.trim().equals( "" ) ) //$NON-NLS-1$
|
if( replacementString.trim().equals( "" ) )
|
||||||
return macroReplacementTokens;
|
return macroReplacementTokens;
|
||||||
IScanner helperScanner=null;
|
IScanner helperScanner=null;
|
||||||
try {
|
try {
|
||||||
|
@ -2602,7 +2636,7 @@ public class Scanner implements IScanner {
|
||||||
String parameters = buffer.toString();
|
String parameters = buffer.toString();
|
||||||
|
|
||||||
// replace StringTokenizer later -- not performant
|
// replace StringTokenizer later -- not performant
|
||||||
StringTokenizer tokenizer = new StringTokenizer(parameters, ","); //$NON-NLS-1$
|
StringTokenizer tokenizer = new StringTokenizer(parameters, ",");
|
||||||
ArrayList parameterIdentifiers =
|
ArrayList parameterIdentifiers =
|
||||||
new ArrayList(tokenizer.countTokens());
|
new ArrayList(tokenizer.countTokens());
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
|
@ -2615,7 +2649,7 @@ public class Scanner implements IScanner {
|
||||||
String replacementString = getRestOfPreprocessorLine();
|
String replacementString = getRestOfPreprocessorLine();
|
||||||
|
|
||||||
|
|
||||||
macroReplacementTokens = ( ! replacementString.equals( "" ) ) ? //$NON-NLS-1$
|
macroReplacementTokens = ( ! replacementString.equals( "" ) ) ?
|
||||||
tokenizeReplacementString( beginning, key, replacementString, parameterIdentifiers ) :
|
tokenizeReplacementString( beginning, key, replacementString, parameterIdentifiers ) :
|
||||||
EMPTY_LIST;
|
EMPTY_LIST;
|
||||||
|
|
||||||
|
@ -2623,7 +2657,7 @@ public class Scanner implements IScanner {
|
||||||
fullSignature.append( key );
|
fullSignature.append( key );
|
||||||
fullSignature.append( '(');
|
fullSignature.append( '(');
|
||||||
fullSignature.append( parameters );
|
fullSignature.append( parameters );
|
||||||
fullSignature.append( ") "); //$NON-NLS-1$
|
fullSignature.append( ") ");
|
||||||
fullSignature.append( replacementString );
|
fullSignature.append( replacementString );
|
||||||
descriptor = new FunctionMacroDescriptor(
|
descriptor = new FunctionMacroDescriptor(
|
||||||
key,
|
key,
|
||||||
|
@ -2638,8 +2672,8 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
else if ((c == '\n') || (c == '\r'))
|
else if ((c == '\n') || (c == '\r'))
|
||||||
{
|
{
|
||||||
checkValidMacroRedefinition(key, previousDefinition, "", beginning); //$NON-NLS-1$
|
checkValidMacroRedefinition(key, previousDefinition, "", beginning);
|
||||||
addDefinition( key, "" ); //$NON-NLS-1$
|
addDefinition( key, "" );
|
||||||
}
|
}
|
||||||
else if ((c == ' ') || (c == '\t') ) {
|
else if ((c == ' ') || (c == '\t') ) {
|
||||||
// this is a simple definition
|
// this is a simple definition
|
||||||
|
@ -2657,33 +2691,33 @@ public class Scanner implements IScanner {
|
||||||
if (c == '/') // one line comment
|
if (c == '/') // one line comment
|
||||||
{
|
{
|
||||||
skipOverSinglelineComment();
|
skipOverSinglelineComment();
|
||||||
checkValidMacroRedefinition(key, previousDefinition, "", beginning); //$NON-NLS-1$
|
checkValidMacroRedefinition(key, previousDefinition, "", beginning);
|
||||||
addDefinition(key, ""); //$NON-NLS-1$
|
addDefinition(key, "");
|
||||||
} else if (c == '*') // multi-line comment
|
} else if (c == '*') // multi-line comment
|
||||||
{
|
{
|
||||||
if (skipOverMultilineComment()) {
|
if (skipOverMultilineComment()) {
|
||||||
// we have gone over a newline
|
// we have gone over a newline
|
||||||
// therefore, this symbol was defined to an empty string
|
// therefore, this symbol was defined to an empty string
|
||||||
checkValidMacroRedefinition(key, previousDefinition, "", beginning); //$NON-NLS-1$
|
checkValidMacroRedefinition(key, previousDefinition, "", beginning);
|
||||||
addDefinition(key, ""); //$NON-NLS-1$
|
addDefinition(key, "");
|
||||||
} else {
|
} else {
|
||||||
String value = getRestOfPreprocessorLine();
|
String value = getRestOfPreprocessorLine();
|
||||||
|
|
||||||
checkValidMacroRedefinition(key, previousDefinition, "", beginning); //$NON-NLS-1$
|
checkValidMacroRedefinition(key, previousDefinition, "", beginning);
|
||||||
addDefinition(key, value);
|
addDefinition(key, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// this is not a comment
|
// this is not a comment
|
||||||
// it is a bad statement
|
// it is a bad statement
|
||||||
potentialErrorMessage.append( key );
|
potentialErrorMessage.append( key );
|
||||||
potentialErrorMessage.append( " /"); //$NON-NLS-1$
|
potentialErrorMessage.append( " /");
|
||||||
potentialErrorMessage.append( getRestOfPreprocessorLine() );
|
potentialErrorMessage.append( getRestOfPreprocessorLine() );
|
||||||
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, potentialErrorMessage.toString(), beginning, false, true );
|
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, potentialErrorMessage.toString(), beginning, false, true );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
potentialErrorMessage = new StringBuffer();
|
potentialErrorMessage = new StringBuffer();
|
||||||
potentialErrorMessage.append( "#define"); //$NON-NLS-1$
|
potentialErrorMessage.append( "#define");
|
||||||
potentialErrorMessage.append( key );
|
potentialErrorMessage.append( key );
|
||||||
potentialErrorMessage.append( (char)c );
|
potentialErrorMessage.append( (char)c );
|
||||||
potentialErrorMessage.append( getRestOfPreprocessorLine() );
|
potentialErrorMessage.append( getRestOfPreprocessorLine() );
|
||||||
|
@ -2798,7 +2832,7 @@ public class Scanner implements IScanner {
|
||||||
buffer.append('\"');
|
buffer.append('\"');
|
||||||
break;
|
break;
|
||||||
case IToken.tLSTRING :
|
case IToken.tLSTRING :
|
||||||
buffer.append( "L\""); //$NON-NLS-1$
|
buffer.append( "L\"");
|
||||||
buffer.append(t.getImage());
|
buffer.append(t.getImage());
|
||||||
buffer.append('\"');
|
buffer.append('\"');
|
||||||
break;
|
break;
|
||||||
|
@ -2958,7 +2992,7 @@ public class Scanner implements IScanner {
|
||||||
buffer.append('\"');
|
buffer.append('\"');
|
||||||
break;
|
break;
|
||||||
case IToken.tLSTRING:
|
case IToken.tLSTRING:
|
||||||
buffer.append("L\""); //$NON-NLS-1$
|
buffer.append("L\"");
|
||||||
buffer.append(t.getImage());
|
buffer.append(t.getImage());
|
||||||
buffer.append('\"');
|
buffer.append('\"');
|
||||||
break;
|
break;
|
||||||
|
@ -2987,7 +3021,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
if( t.getType() != tPOUNDPOUND && ! pastingNext )
|
if( t.getType() != tPOUNDPOUND && ! pastingNext )
|
||||||
if (i < (numberOfTokens-1)) // Do not append to the last one
|
if (i < (numberOfTokens-1)) // Do not append to the last one
|
||||||
buffer.append( " " ); //$NON-NLS-1$
|
buffer.append( " " );
|
||||||
}
|
}
|
||||||
String finalString = buffer.toString();
|
String finalString = buffer.toString();
|
||||||
try
|
try
|
||||||
|
@ -3013,7 +3047,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
StringBuffer logMessage = new StringBuffer( "Unexpected type of MacroDescriptor stored in definitions table: " ); //$NON-NLS-1$
|
StringBuffer logMessage = new StringBuffer( "Unexpected type of MacroDescriptor stored in definitions table: " );
|
||||||
logMessage.append( expansion.getMacroType() );
|
logMessage.append( expansion.getMacroType() );
|
||||||
scannerData.getLogService().traceLog( logMessage.toString() );
|
scannerData.getLogService().traceLog( logMessage.toString() );
|
||||||
}
|
}
|
||||||
|
@ -3034,8 +3068,8 @@ public class Scanner implements IScanner {
|
||||||
c = getChar();
|
c = getChar();
|
||||||
if (c != ')')
|
if (c != ')')
|
||||||
{
|
{
|
||||||
handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, "defined()", o, false, true ); //$NON-NLS-1$
|
handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, "defined()", o, false, true );
|
||||||
return "0"; //$NON-NLS-1$
|
return "0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3045,9 +3079,9 @@ public class Scanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getDefinition(definitionIdentifier) != null)
|
if (getDefinition(definitionIdentifier) != null)
|
||||||
return "1"; //$NON-NLS-1$
|
return "1";
|
||||||
|
|
||||||
return "0"; //$NON-NLS-1$
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThrowExceptionOnBadCharacterRead( boolean throwOnBad ){
|
public void setThrowExceptionOnBadCharacterRead( boolean throwOnBad ){
|
||||||
|
@ -3093,55 +3127,11 @@ public class Scanner implements IScanner {
|
||||||
*/
|
*/
|
||||||
public boolean isOnTopContext() {
|
public boolean isOnTopContext() {
|
||||||
return ( scannerData.getContextStack().getCurrentContext() == scannerData.getContextStack().getTopContext() );
|
return ( scannerData.getContextStack().getCurrentContext() == scannerData.getContextStack().getTopContext() );
|
||||||
}
|
} /* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.IFilenameProvider#getCurrentFilename()
|
||||||
protected CodeReader createReaderDuple( String path, String fileName )
|
|
||||||
{
|
|
||||||
File pathFile = new File(path);
|
|
||||||
//TODO assert pathFile.isDirectory();
|
|
||||||
StringBuffer newPathBuffer = new StringBuffer( pathFile.getPath() );
|
|
||||||
newPathBuffer.append( File.separatorChar );
|
|
||||||
newPathBuffer.append( fileName );
|
|
||||||
//remove ".." and "." segments
|
|
||||||
String finalPath = reconcilePath( newPathBuffer.toString() );
|
|
||||||
Reader r = scannerData.getClientRequestor().createReader( finalPath );
|
|
||||||
if( r != null )
|
|
||||||
return new CodeReader( finalPath, r );
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private String reconcilePath(String originalPath ) {
|
public char[] getCurrentFilename() {
|
||||||
if( originalPath == null ) return null;
|
return getCurrentFile().toCharArray();
|
||||||
String [] segments = originalPath.split( "[/\\\\]" ); //$NON-NLS-1$
|
|
||||||
if( segments.length == 1 ) return originalPath;
|
|
||||||
Vector results = new Vector();
|
|
||||||
for( int i = 0; i < segments.length; ++i )
|
|
||||||
{
|
|
||||||
String segment = segments[i];
|
|
||||||
if( segment.equals( ".") ) continue; //$NON-NLS-1$
|
|
||||||
if( segment.equals("..") ) //$NON-NLS-1$
|
|
||||||
{
|
|
||||||
if( results.size() > 0 )
|
|
||||||
results.removeElementAt( results.size() - 1 );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
results.add( segment );
|
|
||||||
}
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
|
||||||
Iterator i = results.iterator();
|
|
||||||
while( i.hasNext() )
|
|
||||||
{
|
|
||||||
buffer.append( (String)i.next() );
|
|
||||||
if( i.hasNext() )
|
|
||||||
buffer.append( File.separatorChar );
|
|
||||||
}
|
|
||||||
scannerData.getLogService().traceLog( "Path has been reduced to " + buffer.toString()); //$NON-NLS-1$
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,9 @@ import org.eclipse.cdt.internal.core.parser.problem.*;
|
||||||
*/
|
*/
|
||||||
public class ScannerProblemFactory extends BaseProblemFactory implements IProblemFactory
|
public class ScannerProblemFactory extends BaseProblemFactory implements IProblemFactory
|
||||||
{
|
{
|
||||||
protected static Map errorMessages = new HashMap();
|
protected static final Map errorMessages;
|
||||||
static {
|
static {
|
||||||
|
errorMessages = new HashMap();
|
||||||
errorMessages.put(
|
errorMessages.put(
|
||||||
new Integer(IProblem.PREPROCESSOR_POUND_ERROR),
|
new Integer(IProblem.PREPROCESSOR_POUND_ERROR),
|
||||||
"#error encountered with text: ");
|
"#error encountered with text: ");
|
||||||
|
|
|
@ -28,6 +28,7 @@ public class TokenDuple implements ITokenDuple {
|
||||||
|
|
||||||
public TokenDuple( IToken first, IToken last )
|
public TokenDuple( IToken first, IToken last )
|
||||||
{
|
{
|
||||||
|
// assert ( first != null && last != null ) : this;
|
||||||
firstToken = first;
|
firstToken = first;
|
||||||
lastToken = last;
|
lastToken = last;
|
||||||
}
|
}
|
||||||
|
@ -190,4 +191,22 @@ public class TokenDuple implements ITokenDuple {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getEndOffset()
|
||||||
|
*/
|
||||||
|
public int getEndOffset() {
|
||||||
|
return getLastToken().getEndOffset();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getLineNumber()
|
||||||
|
*/
|
||||||
|
public int getLineNumber() {
|
||||||
|
return getFirstToken().getLineNumber();
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.parser.ITokenDuple#getStartOffset()
|
||||||
|
*/
|
||||||
|
public int getStartOffset() {
|
||||||
|
return getFirstToken().getOffset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
2004-03-03 John Camelon
|
||||||
|
Cleaned up usage of Enum.getValue() wrt encapsulation of enumerator value.
|
||||||
|
|
||||||
2004-03-02 Tanya Wolff
|
2004-03-02 Tanya Wolff
|
||||||
|
|
||||||
Fixed missing key for Working Set name and content on
|
Fixed missing key for Working Set name and content on
|
||||||
|
|
|
@ -189,7 +189,6 @@ public abstract class FindAction extends Action {
|
||||||
}
|
}
|
||||||
catch (ParseError er){
|
catch (ParseError er){
|
||||||
ParseErrorKind per = er.getErrorKind();
|
ParseErrorKind per = er.getErrorKind();
|
||||||
int val = per.getEnumValue();
|
|
||||||
er.printStackTrace();
|
er.printStackTrace();
|
||||||
}
|
}
|
||||||
catch (Exception ex){
|
catch (Exception ex){
|
||||||
|
|
Loading…
Add table
Reference in a new issue