diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog
index bb65c144e02..e7629f6896a 100644
--- a/core/org.eclipse.cdt.core.tests/ChangeLog
+++ b/core/org.eclipse.cdt.core.tests/ChangeLog
@@ -1,3 +1,6 @@
+2004-03-03 John Camelon
+ Updated tests to deal with IASTUsingDeclaration interface changes.
+
2004-03-02 Sean Evoy
Added tests to verify that the tool command canbe set through the
IConfiguration interface in the testConfigurations() method, and
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
index a8caf327867..21895a1811a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CompleteParseASTTest.java
@@ -196,11 +196,11 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
assertEquals( directive.getNamespaceDefinition(), namespaceB );
assertEquals( directive.getNamespaceName(), "A::B" );
IASTUsingDeclaration declaration = (IASTUsingDeclaration)declarations.next();
- assertEquals( declaration.getUsingType(), variableX );
+ assertEquals( declaration.getUsingTypes().next(), variableX );
declaration = (IASTUsingDeclaration)declarations.next();
- assertEquals( declaration.getUsingType(), classC );
+ assertEquals( declaration.getUsingTypes().next(), classC );
declaration = (IASTUsingDeclaration)declarations.next();
- assertEquals( declaration.getUsingType(), fieldY );
+ assertEquals( declaration.getUsingTypes().next(), fieldY );
assertEquals( callback.getReferences().size(), 12 );
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Enum.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Enum.java
index a4302365dca..6faaa66db9b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Enum.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/Enum.java
@@ -25,7 +25,7 @@ public class Enum
/**
* @return
*/
- public int getEnumValue()
+ protected int getEnumValue()
{
return enumValue;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IFilenameProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IFilenameProvider.java
new file mode 100644
index 00000000000..f94777eb88b
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IFilenameProvider.java
@@ -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();
+
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java
index f2cfa11ae44..1e1de85e324 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java
@@ -13,8 +13,11 @@ package org.eclipse.cdt.core.parser;
import java.util.Map;
/**
- * Description of a C/C++ problem, as detected by the translation or some of the underlying
- * technology reusing it.
+ * @author jcamelon
+ *
+ * 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:
*
* - its location (originating source file name, source position, line number),
@@ -26,6 +29,8 @@ import java.util.Map;
public interface IProblem
{
+
+
/**
* Returns the problem id
*
@@ -205,6 +210,21 @@ public interface IProblem
*/
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,
* 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;
/**
- * Invalid Macro Pasting encountered by Preprocessor.
+ * Invalid Macro Pasting encountered by Preprocessor.
* Required attributes: A_PREPROC_MACRO_NAME
* @see #A_PREPROC_MACRO_NAME
*/
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
* @see #A_PREPROC_INCLUDE_FILENAME
*/
@@ -340,10 +360,72 @@ public interface IProblem
/*
* 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
- * may be surfaced as a problem associated with the translation unit which caused it to occur.
+ * Name not provided in context that it was required.
+ * 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;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java
index 608fb3db145..fa284cfd0e1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java
@@ -8,7 +8,7 @@ import org.eclipse.cdt.core.parser.ast.IASTFactory;
* @author jcamelon
*
*/
-public interface IScanner {
+public interface IScanner extends IFilenameProvider {
public static final String __CPLUSPLUS = "__cplusplus"; //$NON-NLS-1$
public static final String __STDC_VERSION__ = "__STDC_VERSION__"; //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ITokenDuple.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ITokenDuple.java
index a67867a335d..08a4b3e6aef 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ITokenDuple.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ITokenDuple.java
@@ -42,4 +42,7 @@ public interface ITokenDuple {
public int findLastTokenType( int type );
public IASTNode lookup( IASTFactory factory, IASTScope scope );
+ public int getStartOffset();
+ public int getEndOffset();
+ public int getLineNumber();
}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java
index 094b2f00155..1628ae2c703 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ParserFactory.java
@@ -39,14 +39,14 @@ public class ParserFactory {
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 )
return new QuickParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.QUICK_PARSE ) );
else if( mode == ParserMode.EXPRESSION_PARSE )
return new ExpressionParseASTFactory( extensionFactory.createASTExtensionFactory( ParserMode.EXPRESSION_PARSE ) );
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
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTAccessVisibility.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTAccessVisibility.java
index 7329a5a144a..056f6eebf10 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTAccessVisibility.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTAccessVisibility.java
@@ -26,5 +26,17 @@ public class ASTAccessVisibility extends Enum {
{
super( constant );
}
+
+ public boolean isLessThan( ASTAccessVisibility other )
+ {
+ return getEnumValue() < other.getEnumValue();
+ }
+
+ public boolean isGreaterThan( ASTAccessVisibility other )
+ {
+ return getEnumValue() > other.getEnumValue();
+ }
+
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTSemanticException.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTSemanticException.java
index 431f0ead0d0..a1f49f294b3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTSemanticException.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/ASTSemanticException.java
@@ -20,12 +20,6 @@ public class ASTSemanticException extends Exception
{
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
*/
public IProblem getProblem()
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java
index 3ab2e59c0e0..149daf93268 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTExpression.java
@@ -10,6 +10,7 @@
***********************************************************************/
package org.eclipse.cdt.core.parser.ast;
+import java.util.Hashtable;
import java.util.Iterator;
import org.eclipse.cdt.core.parser.Enum;
@@ -118,6 +119,119 @@ public interface IASTExpression extends ISourceElementCallbackDelegate
{
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;
+
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
index 8d861ed92c7..6b3e7f4af93 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
@@ -12,6 +12,7 @@ package org.eclipse.cdt.core.parser.ast;
import java.util.List;
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.ITokenDuple;
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 lookupSymbolInContext( IASTScope scope, ITokenDuple duple ) throws ASTNotImplementedException;
+
+ /**
+ * @param log
+ */
+ public void setLogger(IParserLogService log);
}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java
index 1a168ed16f2..993757e8ffd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java
@@ -10,6 +10,8 @@
***********************************************************************/
package org.eclipse.cdt.core.parser.ast;
+import java.util.Iterator;
+
/**
* @author jcamelon
*
@@ -17,7 +19,7 @@ package org.eclipse.cdt.core.parser.ast;
public interface IASTUsingDeclaration extends IASTDeclaration, IASTOffsetableElement {
public boolean isTypename();
- public String usingTypeName();
- public IASTDeclaration getUsingType() throws ASTNotImplementedException;
+ public String usingTypeName();
+ public Iterator getUsingTypes() throws ASTNotImplementedException;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompleteParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompleteParser.java
index 18228db8a59..87f3f0b62f7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompleteParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompleteParser.java
@@ -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)
*/
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);
+ astFactory.setLogger(log);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompletionParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompletionParser.java
index 3112240905b..09ed7a494de 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompletionParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/CompletionParser.java
@@ -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)
*/
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);
+ astFactory.setLogger(log);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
index 9611368d9c0..69aacddb95b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/DeclarationWrapper.java
@@ -14,6 +14,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.cdt.core.parser.BacktrackException;
import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.ASTSemanticException;
@@ -307,7 +308,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
/**
* @param requestor
*/
- public List createASTNodes(IASTFactory astFactory) throws ASTSemanticException
+ public List createASTNodes(IASTFactory astFactory) throws ASTSemanticException, BacktrackException
{
this.astFactory = astFactory;
Iterator i = declarators.iterator();
@@ -319,7 +320,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
/**
* @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 isFunction = declarator.isFunction();
@@ -350,7 +351,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
* @param declarator
* @return
*/
- private IASTDeclaration createIndirectDeclaration(Declarator declarator) throws ASTSemanticException
+ private IASTDeclaration createIndirectDeclaration(Declarator declarator) throws BacktrackException, ASTSemanticException
{
if( declarator.getOwnedDeclarator().getOwnedDeclarator() == null )
{
@@ -383,9 +384,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
List convertedParms = createParameterList( declarator.getParameters() );
IASTAbstractDeclaration abs = null;
- try
- {
- abs =
+ abs =
astFactory.createAbstractDeclaration(
constt,
volatil,
@@ -394,44 +393,20 @@ public class DeclarationWrapper implements IDeclaratorOwner
declarator.getArrayModifiers(),
convertedParms,
(ASTPointerOperator)i.next());
- }
- catch (Exception e)
- {
- throw new ASTSemanticException();
- }
String name = ( d.getPointerOperatorNameDuple() != null ) ? d.getPointerOperatorNameDuple().toString() + d.getName() : d.getName();
if( typedef )
- try
- {
- return astFactory.createTypedef(
- scope,
- name,
- abs, getStartingOffset(), getStartingLine(), d.getNameStartOffset(), d.getNameEndOffset(), d.getNameLine() );
- }
- catch (ASTSemanticException e1)
- {
- throw e1;
- }
- catch (Exception e1)
- {
- throw new ASTSemanticException();
- }
+ return astFactory.createTypedef(scope, name, abs,
+ getStartingOffset(), getStartingLine(), d
+ .getNameStartOffset(), d.getNameEndOffset(), d
+ .getNameLine());
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() );
- }
- catch (Exception e2)
- {
- throw new ASTSemanticException();
- }
+ 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() );
}
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
{
- try
- {
- return astFactory.createTypedef(
- scope,
- nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
- astFactory.createAbstractDeclaration(
- constt,
- volatil,
- 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();
- }
+ return astFactory.createTypedef(scope, nested ? declarator
+ .getOwnedDeclarator().getName() : declarator.getName(),
+ astFactory.createAbstractDeclaration(constt, volatil,
+ getTypeSpecifier(), declarator.getPointerOperators(),
+ declarator.getArrayModifiers(), null, null),
+ startingOffset, getStartingLine(), declarator
+ .getNameStartOffset(), declarator.getNameEndOffset(),
+ declarator.getNameLine());
}
/**
* @param declarator
@@ -466,41 +430,24 @@ public class DeclarationWrapper implements IDeclaratorOwner
*/
private IASTMethod createMethodASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
{
- try
- {
- return astFactory
- .createMethod(
- scope,
- nested ? declarator.getOwnedDeclarator().getNameDuple() : declarator.getNameDuple(),
- createParameterList(declarator.getParameters()),
- astFactory.createAbstractDeclaration(
- constt,
- volatil,
- getTypeSpecifier(),
- declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
- declarator.getExceptionSpecification(),
- inline,
- friend,
- staticc,
- startingOffset,
- getStartingLine(),
- 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();
- }
+ return astFactory.createMethod(scope, nested ? declarator
+ .getOwnedDeclarator().getNameDuple() : declarator
+ .getNameDuple(),
+ createParameterList(declarator.getParameters()), astFactory
+ .createAbstractDeclaration(constt, volatil,
+ getTypeSpecifier(), declarator
+ .getPointerOperators(), declarator
+ .getArrayModifiers(), null, null),
+ declarator.getExceptionSpecification(), inline, friend,
+ staticc, startingOffset, getStartingLine(), 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());
}
/**
* @param declarator
@@ -508,41 +455,23 @@ public class DeclarationWrapper implements IDeclaratorOwner
*/
private IASTFunction createFunctionASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
{
- try
- {
- return astFactory.createFunction(
- scope,
- nested ? declarator.getOwnedDeclarator().getNameDuple() : declarator.getNameDuple(),
- createParameterList(declarator.getParameters()),
- astFactory.createAbstractDeclaration(
- constt,
- volatil,
- getTypeSpecifier(),
- declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
- declarator.getExceptionSpecification(),
- inline,
- friend,
- staticc,
- startingOffset,
- getStartingLine(),
- 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();
- }
+ return astFactory.createFunction(scope, nested ? declarator
+ .getOwnedDeclarator().getNameDuple() : declarator
+ .getNameDuple(),
+ createParameterList(declarator.getParameters()), astFactory
+ .createAbstractDeclaration(constt, volatil,
+ getTypeSpecifier(), declarator
+ .getPointerOperators(), declarator
+ .getArrayModifiers(), null, null),
+ declarator.getExceptionSpecification(), inline, friend,
+ staticc, startingOffset, getStartingLine(), declarator
+ .getNameStartOffset(), declarator.getNameEndOffset(),
+ declarator.getNameLine(), templateDeclaration, declarator
+ .isConst(), declarator.isVolatile(), virtual, explicit,
+ declarator.isPureVirtual(), declarator
+ .getConstructorMemberInitializers(), declarator
+ .hasFunctionBody(), declarator.hasFunctionTryBlock(),
+ declarator.isVarArgs());
}
/**
* @param declarator
@@ -550,9 +479,7 @@ public class DeclarationWrapper implements IDeclaratorOwner
*/
private IASTField createFieldASTNode(Declarator declarator, boolean nested) throws ASTSemanticException
{
- try
- {
- return astFactory.createField(
+ return astFactory.createField(
scope,
nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
auto,
@@ -570,16 +497,8 @@ public class DeclarationWrapper implements IDeclaratorOwner
startingOffset,
getStartingLine(),
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
{
List result = new ArrayList();
@@ -591,23 +510,17 @@ public class DeclarationWrapper implements IDeclaratorOwner
while (j.hasNext())
{
Declarator declarator = (Declarator)j.next();
- try
- {
- result.add(
- astFactory.createParameterDeclaration(
- wrapper.isConst(),
- wrapper.isVolatile(),
- wrapper.getTypeSpecifier(),
- declarator.getPointerOperators(),
- declarator.getArrayModifiers(),
- null, null, declarator.getName() == null
- ? "" //$NON-NLS-1$
- : declarator.getName(), declarator.getInitializerClause(), wrapper.getStartingOffset(), getStartingLine(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), wrapper.getEndOffset(), getEndLine()));
- }
- catch (Exception e)
- {
- throw new ASTSemanticException();
- }
+
+ result.add(
+ astFactory.createParameterDeclaration(
+ wrapper.isConst(),
+ wrapper.isVolatile(),
+ wrapper.getTypeSpecifier(),
+ declarator.getPointerOperators(),
+ declarator.getArrayModifiers(),
+ null, null, declarator.getName() == null
+ ? "" //$NON-NLS-1$
+ : declarator.getName(), declarator.getInitializerClause(), wrapper.getStartingOffset(), getStartingLine(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), wrapper.getEndOffset(), getEndLine()));
}
}
return result;
@@ -618,34 +531,24 @@ public class DeclarationWrapper implements IDeclaratorOwner
*/
private IASTVariable createVariableASTNode(Declarator declarator, boolean nested ) throws ASTSemanticException
{
- try
- {
- return astFactory.createVariable(
- scope,
- nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
- isAuto(),
- declarator.getInitializerClause(),
- declarator.getBitFieldExpression(),
- astFactory.createAbstractDeclaration(
- constt,
- volatil,
- getTypeSpecifier(),
- declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
- mutable,
- extern,
- register,
- staticc,
- getStartingOffset(),
- getStartingLine(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), declarator.getConstructorExpression());
- }
- catch (ASTSemanticException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new ASTSemanticException();
- }
+ return astFactory.createVariable(
+ scope,
+ nested ? declarator.getOwnedDeclarator().getName() : declarator.getName(),
+ isAuto(),
+ declarator.getInitializerClause(),
+ declarator.getBitFieldExpression(),
+ astFactory.createAbstractDeclaration(
+ constt,
+ volatil,
+ getTypeSpecifier(),
+ declarator.getPointerOperators(), declarator.getArrayModifiers(), null, null),
+ mutable,
+ extern,
+ register,
+ staticc,
+ getStartingOffset(),
+ getStartingLine(), declarator.getNameStartOffset(), declarator.getNameEndOffset(), declarator.getNameLine(), declarator.getConstructorExpression());
+
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionParser.java
index de75cba72f2..ac1c2894d49 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionParser.java
@@ -71,8 +71,9 @@ public class ExpressionParser implements IExpressionParser {
* @param 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);
+ astFactory.setLogger(log);
}
/**
@@ -2508,4 +2509,8 @@ public class ExpressionParser implements IExpressionParser {
}
}
+ public char[] getCurrentFilename() {
+ return scanner.getCurrentFilename();
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IExpressionParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IExpressionParser.java
index 54e49fc5145..0537fd017cf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IExpressionParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IExpressionParser.java
@@ -12,13 +12,14 @@ package org.eclipse.cdt.internal.core.parser;
import org.eclipse.cdt.core.parser.BacktrackException;
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.IASTScope;
/**
* @author jcamelon
*/
-public interface IExpressionParser {
+public interface IExpressionParser extends IFilenameProvider {
/**
* Request a parse from a pre-configured parser to parse an expression.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
index 87dded66981..7d82b3b0b2f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java
@@ -123,7 +123,6 @@ public abstract class Parser extends ExpressionParser implements IParser
*/
protected void translationUnit()
{
-
try
{
compilationUnit = astFactory.createCompilationUnit();
@@ -1649,7 +1648,8 @@ public abstract class Parser extends ExpressionParser implements IParser
eck = ASTClassKind.ENUM;
break;
default :
- break;
+ backup( t );
+ throw backtrack;
}
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) {
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/QuickParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/QuickParser.java
index d78269e1eca..c0501a7c965 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/QuickParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/QuickParser.java
@@ -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)
*/
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);
+ astFactory.setLogger(log);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/StructuralParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/StructuralParser.java
index 0d7df121124..111793a1763 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/StructuralParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/StructuralParser.java
@@ -38,8 +38,7 @@ public class StructuralParser extends Parser implements IParser {
*/
public StructuralParser(IScanner scanner, ISourceElementRequestor ourCallback, ParserLanguage language, IParserLogService logService) {
super(scanner, ourCallback, language, logService);
- astFactory = ParserFactory.createASTFactory( ParserMode.COMPLETE_PARSE, language);
- scanner.setASTFactory(astFactory);
+ setupASTFactory(scanner, language );
}
/* (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);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
index 465fb6b1181..0d45cc4da2a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
@@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.parser.ast;
import java.util.List;
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.ast.ASTPointerOperator;
import org.eclipse.cdt.core.parser.ast.IASTAbstractDeclaration;
@@ -31,6 +32,8 @@ import org.eclipse.cdt.core.parser.ast.IASTDesignator.DesignatorKind;
*/
public class BaseASTFactory {
+ protected IParserLogService logService;
+
/* (non-Javadoc)
* @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() );
}
+ public void setLogger(IParserLogService log) {
+ logService = log;
+ }
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTNamespaceReference.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTNamespaceReference.java
index d7b87dd24a3..99821946456 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTNamespaceReference.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTNamespaceReference.java
@@ -27,12 +27,12 @@ public class ASTNamespaceReference
/**
* @param offset
- * @param string
+ * @param referencedElementName
* @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;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTProblemFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTProblemFactory.java
new file mode 100644
index 00000000000..173071af755
--- /dev/null
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTProblemFactory.java
@@ -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;
+ }
+}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTUsingDeclaration.java
index 5a563c8fad0..6bf6d89e863 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTUsingDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/ASTUsingDeclaration.java
@@ -10,14 +10,15 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.complete;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
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.IASTUsingDeclaration;
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
+import org.eclipse.cdt.internal.core.parser.ast.SymbolIterator;
/**
* @author jcamelon
@@ -27,18 +28,20 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
{
private final IASTScope ownerScope;
private final boolean isTypeName;
- private final IASTDeclaration declaration;
+ private final List declarations = new ArrayList();
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.isTypeName = isTypeName;
- this.declaration = declaration;
+ this.name = name;
+ this.declarations.addAll( declarations );
setStartingOffsetAndLineNumber(startingOffset, startingLine);
setEndingOffsetAndLineNumber(endingOffset, endingLine);
delegate = new ASTReferenceStore( references );
@@ -55,7 +58,7 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
*/
public String usingTypeName()
{
- return ((IASTOffsetableNamedElement)declaration).getName();
+ return name;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
@@ -122,9 +125,9 @@ public class ASTUsingDeclaration extends ASTNode implements IASTUsingDeclaration
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#getUsingType()
*/
- public IASTDeclaration getUsingType()
+ public Iterator getUsingTypes()
{
- return declaration;
+ return new SymbolIterator( declarations.iterator() );
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
index 1da2bf006ae..33ffd8736ae 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/complete/CompleteParseASTFactory.java
@@ -10,13 +10,18 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.parser.ast.complete;
+
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.parser.Enum;
+import org.eclipse.cdt.core.parser.IFilenameProvider;
+import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ITokenDuple;
import org.eclipse.cdt.core.parser.ParserLanguage;
@@ -70,6 +75,7 @@ import org.eclipse.cdt.core.parser.ast.IASTSimpleTypeSpecifier.Type;
import org.eclipse.cdt.core.parser.ast.IASTTemplateParameter.ParamKind;
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
+import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
import org.eclipse.cdt.internal.core.parser.pst.ForewardDeclaredSymbolExtension;
import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
@@ -77,6 +83,7 @@ import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
import org.eclipse.cdt.internal.core.parser.pst.ISymbolASTExtension;
import org.eclipse.cdt.internal.core.parser.pst.ISymbolOwner;
+import org.eclipse.cdt.internal.core.parser.pst.IUsingDeclarationSymbol;
import org.eclipse.cdt.internal.core.parser.pst.IUsingDirectiveSymbol;
import org.eclipse.cdt.internal.core.parser.pst.NamespaceSymbolExtension;
import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
@@ -97,7 +104,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
private final static List SUBSCRIPT;
+ private final static IProblemFactory problemFactory = new ASTProblemFactory();
//private final IASTExtensionFactory extensionFactory;
+ private final IFilenameProvider fileProvider;
static
{
@@ -117,10 +126,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
}
- public CompleteParseASTFactory( ParserLanguage language, ParserMode mode, IASTExtensionFactory factory )
+ public CompleteParseASTFactory( IFilenameProvider filenameProvider, ParserLanguage language, ParserMode mode, IASTExtensionFactory factory )
{
super();
pst = new ParserSymbolTable( language, mode );
+ fileProvider = filenameProvider;
// extensionFactory = factory;
}
@@ -144,6 +154,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
references.add(reference);
}
+
/*
* Test if the provided list is a valid parameter list
* Parameters are list of TypeInfos
@@ -162,8 +173,9 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return true;
}
- private ISymbol lookupElement (IContainerSymbol startingScope, String name, TypeInfo.eType type, List parameters, LookupType lookupType ) throws ParserSymbolTableException{
+ private ISymbol lookupElement (IContainerSymbol startingScope, String name, TypeInfo.eType type, List parameters, LookupType lookupType ) throws ASTSemanticException {
ISymbol result = null;
+ if( startingScope == null ) return null;
try {
if((type == TypeInfo.t_function) || (type == TypeInfo.t_constructor)){
// looking for a function
@@ -198,7 +210,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
} catch (ParserSymbolTableException e) {
if( e.reason != ParserSymbolTableException.r_UnableToResolveFunction )
- throw e;
+ handleProblem( e.createProblemID(), name );
}
return result;
}
@@ -210,31 +222,26 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, String name, TypeInfo.eType type, List parameters, int offset, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException
{
ISymbol result = null;
- try
- {
- if( name == null ) throw new ASTSemanticException();
- try
- {
- result = lookupElement(startingScope, name, type, parameters, lookup);
- if( result != null )
- addReference(references, createReference( result, name, offset ));
- else
- throw new ASTSemanticException();
- }
- catch (ParserSymbolTableException e)
- {
- throw new ASTSemanticException();
- }
+ if( name == null && throwOnError )
+ handleProblem( IProblem.SEMANTIC_NAME_NOT_PROVIDED, null );
+ else if( name == null ) return null;
+ try
+ {
+ result = lookupElement(startingScope, name, type, parameters, lookup);
+ if( result != null )
+ addReference(references, createReference( result, name, offset ));
+ else if( throwOnError )
+ handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, name );
}
- catch( ASTSemanticException se )
+ catch (ASTSemanticException e)
{
if( throwOnError )
- throw se;
+ throw new ASTSemanticException( e );
+
return null;
}
return result;
-
}
protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, List references, boolean throwOnError ) throws ASTSemanticException{
@@ -247,81 +254,74 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return lookupQualifiedName( startingScope, name, type, parameters, references, throwOnError, LookupType.UNQUALIFIED );
}
- protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, TypeInfo.eType type, List parameters, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException
+ protected ISymbol lookupQualifiedName( IContainerSymbol startingScope, ITokenDuple name, TypeInfo.eType type, List parameters, List references, boolean throwOnError, LookupType lookup ) throws ASTSemanticException
+ {
+ ISymbol result = null;
+ IToken firstSymbol = null;
+ if( name == null && throwOnError ) handleProblem( IProblem.SEMANTIC_NAME_NOT_PROVIDED, null );
+ else if( name == null ) return null;
+
+ switch( name.length() )
{
- ISymbol result = null;
- IToken firstSymbol = null;
- try
- {
- if( name == null ) throw new ASTSemanticException();
-
- switch( name.length() )
- {
- case 0:
- if( throwOnError )
- throw new ASTSemanticException();
- case 1:
- firstSymbol = name.getFirstToken();
- try
- {
- result = lookupElement(startingScope, firstSymbol.getImage(), type, parameters, lookup );
- if( result != null )
- addReference( references, createReference( result, firstSymbol.getImage(), firstSymbol.getOffset() ));
- else
- {
- if( startingScope.getASTExtension().getPrimaryDeclaration() instanceof IASTCodeScope )
- {
- if( ((IASTCodeScope) startingScope.getASTExtension().getPrimaryDeclaration()).getContainingFunction() instanceof IASTMethod )
- {
- IASTClassSpecifier classSpecifier = ((IASTMethod) ((IASTCodeScope) startingScope.getASTExtension().getPrimaryDeclaration()).getContainingFunction()).getOwnerClassSpecifier();
- ((ASTClassSpecifier)classSpecifier).addUnresolvedReference( new UnresolvedReferenceDuple( startingScope, name ));
- break;
- }
- }
- throw new ASTSemanticException();
- }
- }
- catch (ParserSymbolTableException e)
- {
- throw new ASTSemanticException();
- }
- break;
- default:
- Iterator iter = name.iterator();
- firstSymbol = name.getFirstToken();
- result = startingScope;
- if( firstSymbol.getType() == IToken.tCOLONCOLON )
- result = pst.getCompilationUnit();
-
- while( iter.hasNext() )
- {
- IToken t = (IToken)iter.next();
- if( t.getType() == IToken.tCOLONCOLON ) continue;
- if( t.isPointer() ) break;
- try
- {
- if( t == name.getLastToken() )
- result = lookupElement((IContainerSymbol)result, t.getImage(), type, parameters, ( lookup == LookupType.FORDEFINITION ) ? lookup : LookupType.QUALIFIED );
- else
- result = ((IContainerSymbol)result).lookupNestedNameSpecifier( t.getImage() );
- addReference( references, createReference( result, t.getImage(), t.getOffset() ));
- }
- catch( ParserSymbolTableException pste )
- {
- throw new ASTSemanticException();
- }
- }
-
- }
- }
- catch( ASTSemanticException se )
- {
+ case 0:
if( throwOnError )
- throw se;
- return null;
- }
- return result;
+ handleProblem( IProblem.SEMANTIC_NAME_NOT_PROVIDED, null );
+ else
+ return null;
+ case 1:
+ firstSymbol = name.getFirstToken();
+ result = lookupElement(startingScope, firstSymbol.getImage(), type, parameters, lookup );
+ if( result != null )
+ addReference( references, createReference( result, firstSymbol.getImage(), firstSymbol.getOffset() ));
+ else
+ {
+ if( startingScope.getASTExtension().getPrimaryDeclaration() instanceof IASTCodeScope )
+ {
+ if( ((IASTCodeScope) startingScope.getASTExtension().getPrimaryDeclaration()).getContainingFunction() instanceof IASTMethod )
+ {
+ IASTClassSpecifier classSpecifier = ((IASTMethod) ((IASTCodeScope) startingScope.getASTExtension().getPrimaryDeclaration()).getContainingFunction()).getOwnerClassSpecifier();
+ ((ASTClassSpecifier)classSpecifier).addUnresolvedReference( new UnresolvedReferenceDuple( startingScope, name ));
+ break;
+ }
+ }
+ if ( throwOnError )
+ handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, firstSymbol.getImage() );
+ return null;
+ }
+ break;
+ default:
+ Iterator iter = name.iterator();
+ firstSymbol = name.getFirstToken();
+ result = startingScope;
+ if( firstSymbol.getType() == IToken.tCOLONCOLON )
+ result = pst.getCompilationUnit();
+
+ while( iter.hasNext() )
+ {
+ IToken t = (IToken)iter.next();
+ if( t.getType() == IToken.tCOLONCOLON ) continue;
+ if( t.isPointer() ) break;
+ try
+ {
+ if( t == name.getLastToken() )
+ result = lookupElement((IContainerSymbol)result, t.getImage(), type, parameters, ( lookup == LookupType.FORDEFINITION ) ? lookup : LookupType.QUALIFIED );
+ else
+ result = ((IContainerSymbol)result).lookupNestedNameSpecifier( t.getImage() );
+ if( result != null )
+ addReference( references, createReference( result, t.getImage(), t.getOffset() ));
+ else
+ break;
+ }
+ catch( ParserSymbolTableException pste )
+ {
+ if ( throwOnError )
+ handleProblem( pste.createProblemID(), t.getImage() );
+ return null;
+ }
+ }
}
+ return result;
+ }
/* (non-Javadoc)
@@ -342,11 +342,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
try {
usingDirective = ((ASTScope)scope).getContainerSymbol().addUsingDirective( (IContainerSymbol)symbol );
} catch (ParserSymbolTableException pste) {
- throw new ASTSemanticException();
+ handleProblem( pste.createProblemID(), duple.toString(), startingOffset, endingOffset, startingLine );
}
- IASTUsingDirective astUD = new ASTUsingDirective( scopeToSymbol(scope), usingDirective, startingOffset, startingLine, endingOffset, endingLine, references );
- return astUD;
+ return new ASTUsingDirective( scopeToSymbol(scope), usingDirective, startingOffset, startingLine, endingOffset, endingLine, references );
}
@@ -384,18 +383,41 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
int startingLine, int endingOffset, int endingLine) throws ASTSemanticException
{
List references = new ArrayList();
- ISymbol symbol = lookupQualifiedName( scopeToSymbol(scope), name, references, true );
- try
+ IUsingDeclarationSymbol endResult = null;
+
+ if( name.length() != 1 )
{
- scopeToSymbol(scope).addUsingDeclaration( name.getLastToken().getImage(), symbol.getContainingSymbol() );
- }
- catch (ParserSymbolTableException e)
- {
- throw new ASTSemanticException();
- }
- return new ASTUsingDeclaration( scope,
- symbol.getASTExtension().getPrimaryDeclaration(), isTypeName, startingOffset, startingLine, endingOffset, endingLine, references );
+ ITokenDuple duple = name.getSubrange(0,name.length() - 3 );
+ IContainerSymbol containerSymbol = (IContainerSymbol) lookupQualifiedName( scopeToSymbol(scope), duple, references, true );
+
+ try
+ {
+ endResult = scopeToSymbol(scope).addUsingDeclaration( name.getLastToken().getImage(), containerSymbol );
+ }
+ catch (ParserSymbolTableException e)
+ {
+ handleProblem(e.createProblemID(), name.getLastToken().getImage(), startingOffset, endingOffset, startingLine );
+ }
+ } else
+ try {
+ endResult = scopeToSymbol(scope).addUsingDeclaration(name.getLastToken().getImage());
+ } catch (ParserSymbolTableException e) {
+ handleProblem(e.createProblemID(), name.getLastToken().getImage(), startingOffset, endingOffset, startingLine );
+ }
+
+ if( endResult != null )
+ {
+ Iterator i = endResult.getReferencedSymbols().iterator();
+ while( i.hasNext() )
+ {
+ IASTReference reference = createReference( (ISymbol) i.next(), name.getLastToken().getImage(), name.getLastToken().getOffset() );
+ addReference( references, reference );
+ }
+ }
+
+ return new ASTUsingDeclaration( scope, name.getLastToken().getImage(),
+ endResult.getReferencedSymbols(), isTypeName, startingOffset, startingLine, endingOffset, endingLine, references );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTFactory#createASMDefinition(org.eclipse.cdt.core.parser.ast.IASTScope, java.lang.String, int, int)
@@ -406,7 +428,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
int startingOffset,
int startingLine, int endingOffset, int endingLine)
{
-
return new ASTASMDefinition( scopeToSymbol(scope), assembly, startingOffset, startingLine, endingOffset, endingLine);
}
/* (non-Javadoc)
@@ -421,7 +442,6 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
IContainerSymbol pstScope = scopeToSymbol(scope);
ISymbol namespaceSymbol = null;
-
if( ! identifier.equals( "" ) ) //$NON-NLS-1$
{
@@ -431,14 +451,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem( e.createProblemID(), identifier, nameOffset, nameEndOffset, nameLineNumber );
}
}
if( namespaceSymbol != null )
{
if( namespaceSymbol.getType() != TypeInfo.t_namespace )
- throw new ASTSemanticException();
+ handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, identifier, nameOffset, nameEndOffset, nameLineNumber );
}
else
{
@@ -454,20 +474,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e1)
{
- // not overloading, should never happen
+// assert false : e1;
}
}
}
ASTNamespaceDefinition namespaceDef = new ASTNamespaceDefinition( namespaceSymbol, startingOffset, startingLine, nameOffset, nameEndOffset, nameLineNumber);
- try
- {
- attachSymbolExtension( namespaceSymbol, namespaceDef );
- }
- catch (ExtensionException e1)
- {
- // will not happen with namespaces
- }
+ attachSymbolExtension( namespaceSymbol, namespaceDef, true );
return namespaceDef;
}
/* (non-Javadoc)
@@ -477,32 +490,24 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
ISymbol symbol = pst.getCompilationUnit();
ASTCompilationUnit compilationUnit = new ASTCompilationUnit( symbol );
- try
- {
- attachSymbolExtension(symbol, compilationUnit );
- }
- catch (ExtensionException e)
- {
- //should not happen with CompilationUnit
- }
+ attachSymbolExtension(symbol, compilationUnit, true );
return compilationUnit;
}
protected void attachSymbolExtension(
ISymbol symbol,
- ASTSymbol astSymbol ) throws ExtensionException
+ ASTSymbol astSymbol, boolean asDefinition )
{
ISymbolASTExtension extension = symbol.getASTExtension();
if( extension == null )
{
- if( astSymbol instanceof IASTNamespaceDefinition ||
- astSymbol instanceof IASTEnumerationSpecifier ||
- astSymbol instanceof IASTClassSpecifier ||
- astSymbol instanceof IASTElaboratedTypeSpecifier )
-
+ if( astSymbol instanceof IASTNamespaceDefinition )
extension = new NamespaceSymbolExtension( symbol, astSymbol );
- else if( astSymbol instanceof IASTFunction || astSymbol instanceof IASTMethod )
+ else if( astSymbol instanceof IASTFunction || astSymbol instanceof IASTMethod ||
+ astSymbol instanceof IASTEnumerationSpecifier ||
+ astSymbol instanceof IASTClassSpecifier ||
+ astSymbol instanceof IASTElaboratedTypeSpecifier )
{
extension = new ForewardDeclaredSymbolExtension( symbol, astSymbol );
}
@@ -514,7 +519,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
else
{
- extension.addDefinition( astSymbol );
+ if( asDefinition )
+ try {
+ extension.addDefinition( astSymbol );
+ } catch (ExtensionException e) {
+// assert false : ExtensionException.class;
+ }
}
}
@@ -555,7 +565,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
currentScopeSymbol = (IContainerSymbol)lookupQualifiedName( currentScopeSymbol,
containerSymbolName, references, true);
if( currentScopeSymbol == null )
- throw new ASTSemanticException();
+ handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, containerSymbolName.toString(), containerSymbolName.getFirstToken().getOffset(), containerSymbolName.getLastToken().getEndOffset(), containerSymbolName.getLastToken().getLineNumber() );
}
newSymbolName = lastToken.getImage();
}
@@ -568,14 +578,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem(IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED, name.toString(), nameOffset, nameEndOffset, nameLine);
}
if( classSymbol != null && ! classSymbol.isForwardDeclaration() )
- throw new ASTSemanticException();
+ handleProblem( IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED, newSymbolName );
if( classSymbol != null && classSymbol.getType() != pstType )
- throw new ASTSemanticException();
+ handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, newSymbolName );
}
IDerivableContainerSymbol newSymbol = pst.newDerivableContainerSymbol( newSymbolName, pstType );
@@ -589,23 +599,47 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e2)
{
- throw new ASTSemanticException();
+ handleProblem( e2.createProblemID(), newSymbolName );
}
ASTClassSpecifier classSpecifier = new ASTClassSpecifier( newSymbol, kind, type, access, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references );
- try
- {
- attachSymbolExtension(newSymbol, classSpecifier );
- }
- catch (ExtensionException e1)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension(newSymbol, classSpecifier, true );
return classSpecifier;
}
- protected TypeInfo.eType classKindToTypeInfo(ASTClassKind kind)
- throws ASTSemanticException
+
+ protected void handleProblem( int id, String attribute ) throws ASTSemanticException
+ {
+ handleProblem( id, attribute, -1, -1, -1 ); //TODO make this right
+ }
+
+ /**
+ * @param id
+ * @param attribute
+ * @param startOffset
+ * @param endOffset
+ * @param lineNumber
+ * @throws ASTSemanticException
+ */
+ protected void handleProblem(int id, String attribute, int startOffset, int endOffset, int lineNumber) throws ASTSemanticException {
+ Map arguments = new HashMap();
+
+ if( attribute != null )
+ {
+ String attributes [] = problemFactory.getRequiredAttributesForId( id );
+ arguments.put( attributes[ 0 ], attribute );
+ }
+
+ IProblem p = problemFactory.createProblem( id,
+ startOffset, endOffset, lineNumber, fileProvider.getCurrentFilename(), arguments, false, true );
+
+ StringBuffer logMessage = new StringBuffer( "CompleteParseASTFactory - IProblem : ");
+ logMessage.append( p.getMessage() );
+ logService.traceLog( logMessage.toString() );
+ throw new ASTSemanticException(p);
+ }
+
+ protected TypeInfo.eType classKindToTypeInfo(ASTClassKind kind)
{
TypeInfo.eType pstType = null;
@@ -617,8 +651,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
pstType = TypeInfo.t_union;
else if( kind == ASTClassKind.ENUM )
pstType = TypeInfo.t_enumeration;
- else
- throw new ASTSemanticException();
+// else
+// assert false : kind ;
return pstType;
}
@@ -633,74 +667,49 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ITokenDuple parentClassName) throws ASTSemanticException
{
IDerivableContainerSymbol classSymbol = (IDerivableContainerSymbol)scopeToSymbol( astClassSpec);
- Iterator iterator = parentClassName.iterator();
+ Iterator iterator = null;
List references = new ArrayList();
- if( ! iterator.hasNext() )
- throw new ASTSemanticException();
-
- IContainerSymbol symbol = null;
-
- symbol = getScopeToSearchUpon(astClassSpec, parentClassName.getFirstToken(), iterator );
-
- while( iterator.hasNext() )
- {
- IToken t = (IToken)iterator.next();
- if( t.getType() == IToken.tCOLONCOLON ) continue;
- try
- {
- if( t == parentClassName.getLastToken())
- symbol = (IContainerSymbol)symbol.lookup( t.getImage() );
- else
- symbol = symbol.lookupNestedNameSpecifier( t.getImage() );
-
- if( symbol != null )
- addReference( references, createReference( symbol, t.getImage(), t.getOffset() ));
- else
- throw new ASTSemanticException();
- }
- catch( ParserSymbolTableException pste )
- {
- throw new ASTSemanticException();
- }
- }
-
+ if( parentClassName != null )
+ {
+ iterator = parentClassName.iterator();
+ if( !iterator.hasNext() )
+ handleProblem( IProblem.SEMANTIC_NAME_NOT_PROVIDED, null );
+ }
+ else
+ handleProblem( IProblem.SEMANTIC_NAME_NOT_PROVIDED, null );
+
+ IContainerSymbol symbol = (IContainerSymbol) lookupQualifiedName( classSymbol, parentClassName, references, true );
classSymbol.addParent( symbol, isVirtual, visibility, parentClassName.getFirstToken().getOffset(), references );
}
/**
* @param symbol
- * @param string
+ * @param referenceElementName
* @return
*/
- protected IASTReference createReference(ISymbol symbol, String string, int offset ) throws ASTSemanticException
+ protected IASTReference createReference(ISymbol symbol, String referenceElementName, int offset ) throws ASTSemanticException
{
- if( symbol == null ) throw new ASTSemanticException();
+// assert (symbol != null ) : "createReference cannot be called on null symbol ";
if( symbol.getType() == TypeInfo.t_namespace )
- {
- return new ASTNamespaceReference( offset, string, (IASTNamespaceDefinition)symbol.getASTExtension().getPrimaryDeclaration());
- }
+ return new ASTNamespaceReference( offset, referenceElementName, (IASTNamespaceDefinition)symbol.getASTExtension().getPrimaryDeclaration());
else if( symbol.getType() == TypeInfo.t_class ||
symbol.getType() == TypeInfo.t_struct ||
symbol.getType() == TypeInfo.t_union )
- {
- return new ASTClassReference( offset, string, (IASTTypeSpecifier)symbol.getASTExtension().getPrimaryDeclaration() );
- }
+ return new ASTClassReference( offset, referenceElementName, (IASTTypeSpecifier)symbol.getASTExtension().getPrimaryDeclaration() );
else if( symbol.getTypeInfo().checkBit( TypeInfo.isTypedef ))
- {
- return new ASTTypedefReference( offset, string, (IASTTypedefDeclaration)symbol.getASTExtension().getPrimaryDeclaration());
- }
+ return new ASTTypedefReference( offset, referenceElementName, (IASTTypedefDeclaration)symbol.getASTExtension().getPrimaryDeclaration());
else if( symbol.getType() == TypeInfo.t_enumeration )
- return new ASTEnumerationReference( offset, string, (IASTEnumerationSpecifier)symbol.getASTExtension().getPrimaryDeclaration() );
+ return new ASTEnumerationReference( offset, referenceElementName, (IASTEnumerationSpecifier)symbol.getASTExtension().getPrimaryDeclaration() );
else if( symbol.getType() == TypeInfo.t_enumerator )
- return new ASTEnumeratorReference( offset, string, (IASTEnumerator)symbol.getASTExtension().getPrimaryDeclaration() );
+ return new ASTEnumeratorReference( offset, referenceElementName, (IASTEnumerator)symbol.getASTExtension().getPrimaryDeclaration() );
else if(( symbol.getType() == TypeInfo.t_function ) || (symbol.getType() == TypeInfo.t_constructor))
{
if( symbol.getContainingSymbol().getTypeInfo().isType( TypeInfo.t_class, TypeInfo.t_union ) )
- return new ASTMethodReference( offset, string, (IASTMethod)symbol.getASTExtension().getPrimaryDeclaration() );
+ return new ASTMethodReference( offset, referenceElementName, (IASTMethod)symbol.getASTExtension().getPrimaryDeclaration() );
else
- return new ASTFunctionReference( offset, string, (IASTFunction)symbol.getASTExtension().getPrimaryDeclaration() );
+ return new ASTFunctionReference( offset, referenceElementName, (IASTFunction)symbol.getASTExtension().getPrimaryDeclaration() );
}
else if( ( symbol.getType() == TypeInfo.t_type ) ||
( symbol.getType() == TypeInfo.t_bool )||
@@ -717,7 +726,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
symbol.getContainingSymbol().getType() == TypeInfo.t_struct ||
symbol.getContainingSymbol().getType() == TypeInfo.t_union )
{
- return new ASTFieldReference( offset, string, (IASTField)symbol.getASTExtension().getPrimaryDeclaration());
+ return new ASTFieldReference( offset, referenceElementName, (IASTField)symbol.getASTExtension().getPrimaryDeclaration());
}
else if( ( symbol.getContainingSymbol().getType() == TypeInfo.t_function ||
symbol.getContainingSymbol().getType() == TypeInfo.t_constructor ) &&
@@ -725,18 +734,19 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
((IParameterizedSymbol)symbol.getContainingSymbol()).getParameterList() != null &&
((IParameterizedSymbol)symbol.getContainingSymbol()).getParameterList().contains( symbol ) )
{
- return new ASTParameterReference( offset, string, (IASTParameterDeclaration)symbol.getASTExtension().getPrimaryDeclaration() );
+ return new ASTParameterReference( offset, referenceElementName, (IASTParameterDeclaration)symbol.getASTExtension().getPrimaryDeclaration() );
}
else
{
ASTSymbol s = symbol.getASTExtension().getPrimaryDeclaration();
if(s instanceof IASTVariable)
- return new ASTVariableReference( offset, string, (IASTVariable)s);
+ return new ASTVariableReference( offset, referenceElementName, (IASTVariable)s);
else if (s instanceof IASTParameterDeclaration)
- return new ASTParameterReference( offset, string, (IASTParameterDeclaration)s);
+ return new ASTParameterReference( offset, referenceElementName, (IASTParameterDeclaration)s);
}
}
- throw new ASTSemanticException();
+// assert false : "Unreachable code : createReference()";
+ return null;
}
/* (non-Javadoc)
@@ -758,19 +768,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem( e.createProblemID(), name );
}
ASTEnumerationSpecifier enumSpecifier = new ASTEnumerationSpecifier( classSymbol, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine );
- try
- {
- attachSymbolExtension(classSymbol, enumSpecifier );
- }
- catch (ExtensionException e1)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension(classSymbol, enumSpecifier, true );
return enumSpecifier;
}
/* (non-Javadoc)
@@ -778,32 +781,27 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
*/
public void addEnumerator(
IASTEnumerationSpecifier enumeration,
- String string,
+ String name,
int startingOffset,
int startingLine,
int nameOffset, int nameEndOffset, int nameLine, int endingOffset, int endLine, IASTExpression initialValue) throws ASTSemanticException
{
IContainerSymbol enumerationSymbol = (IContainerSymbol)((ISymbolOwner)enumeration).getSymbol();
- ISymbol enumeratorSymbol = pst.newSymbol( string, TypeInfo.t_enumerator );
+ ISymbol enumeratorSymbol = pst.newSymbol( name, TypeInfo.t_enumerator );
try
{
enumerationSymbol.addSymbol( enumeratorSymbol );
}
catch (ParserSymbolTableException e1)
{
- throw new ASTSemanticException();
+ if( e1.reason == ParserSymbolTableException.r_InvalidOverload )
+ handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, name, startingOffset, endingOffset, startingLine );
+// assert false : e1;
}
ASTEnumerator enumerator = new ASTEnumerator( enumeratorSymbol, enumeration, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, endingOffset, endLine, initialValue );
((ASTEnumerationSpecifier)enumeration).addEnumerator( enumerator );
- try
- {
- attachSymbolExtension( enumeratorSymbol, enumerator );
- }
- catch (ExtensionException e)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension( enumeratorSymbol, enumerator, true );
}
/* (non-Javadoc)
@@ -818,30 +816,38 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
IASTTypeId typeId,
ITokenDuple idExpression, String literal, IASTNewExpressionDescriptor newDescriptor) throws ASTSemanticException
{
- try{
- List references = new ArrayList();
- ISymbol symbol = getExpressionSymbol(scope, kind, lhs, rhs, idExpression, references );
-
- // Try to figure out the result that this expression evaluates to
- ExpressionResult expressionResult = getExpressionResultType(kind, lhs, rhs, thirdExpression, typeId, literal, symbol);
+ StringBuffer logMessage = new StringBuffer();
+ logMessage.append( "Entering createExpression with Kind=" );
+ logMessage.append( kind.getKindName() );
+ if( idExpression != null )
+ {
+ logMessage.append( " idexpression=" );
+ logMessage.append( "idExpression.toString()");
+ }
+ else if( literal != null && !literal.equals( "" ))
+ {
+ logMessage.append( " literal=" );
+ logMessage.append( literal );
+ }
+
+ logService.traceLog( logMessage.toString() );
+ List references = new ArrayList();
+ ISymbol symbol = getExpressionSymbol(scope, kind, lhs, rhs, idExpression, references );
+
+ // Try to figure out the result that this expression evaluates to
+ ExpressionResult expressionResult = getExpressionResultType(kind, lhs, rhs, thirdExpression, typeId, literal, symbol);
- // expression results could be empty, but should not be null
- if(expressionResult == null)
- throw new ASTSemanticException();
+ // expression results could be empty, but should not be null
+// assert expressionResult != null : expressionResult; //throw new ASTSemanticException();
- // create the ASTExpression
- ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
+ // create the ASTExpression
+ ASTExpression expression = new ASTExpression( kind, lhs, rhs, thirdExpression,
typeId, idExpression, literal, newDescriptor, references);
- // Assign the result to the created expression
- expression.setResultType (expressionResult);
+ // Assign the result to the created expression
+ expression.setResultType (expressionResult);
- return expression;
-
- }catch (ASTSemanticException e){
- throw e;
- }
-
+ return expression;
}
/*
* Try and dereference the symbol in the expression
@@ -872,7 +878,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
try{
symbol = startingScope.lookup("this"); //$NON-NLS-1$
}catch (ParserSymbolTableException e){
- throw new ASTSemanticException();
+ handleProblem( e.createProblemID(), "this");
}
}
// lookup symbol if it is a function call
@@ -901,18 +907,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
* Returns the function ID token
*/
private ITokenDuple getFunctionId (IASTExpression expression){
- if((expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS)
- || (expression.getExpressionKind() == IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP)
- || (expression.getExpressionKind() == IASTExpression.Kind.PM_DOTSTAR)
- || (expression.getExpressionKind() == IASTExpression.Kind.PM_ARROWSTAR)
- ){
+ if(expression.getExpressionKind().isPostfixMemberReference() )
return ((ASTExpression)expression.getRHSExpression()).getIdExpressionTokenDuple();
- }
- else {
+ else
return ((ASTExpression)expression).getIdExpressionTokenDuple();
- }
}
private IContainerSymbol getSearchScope (Kind kind, IASTExpression lhs, IContainerSymbol startingScope) throws ASTSemanticException{
@@ -934,11 +932,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return (IContainerSymbol)firstContainingScope;
}
} else {
- throw new ASTSemanticException();
+// assert firstContainingScope != null : "Malformed Expression";
+ return null;
}
- } else {
- throw new ASTSemanticException();
- }
+ }
+// assert lhsInfo != null : "Malformed Expression";
+ return null;
}
else {
return startingScope;
@@ -991,7 +990,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( !lhs.isType(TypeInfo.t__Bool, TypeInfo.t_enumerator ) &&
!rhs.isType(TypeInfo.t__Bool, TypeInfo.t_enumerator ) )
{
- throw new ASTSemanticException();
+ handleProblem( IProblem.SEMANTIC_INVALID_CONVERSION_TYPE, null );
}
TypeInfo info = new TypeInfo();
@@ -1057,398 +1056,395 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
private TypeInfo addToInfo(ASTExpression exp, boolean flag, int mask)
- throws ASTSemanticException{
- if(exp == null)
- throw new ASTSemanticException();
+ {
+// assert exp != null : exp;
TypeInfo info = exp.getResultType().getResult();
info.setBit(flag, mask);
return info;
}
protected ExpressionResult getExpressionResultType(
- Kind kind,
- IASTExpression lhs,
- IASTExpression rhs,
- IASTExpression thirdExpression,
- IASTTypeId typeId,
- String literal,
- ISymbol symbol)
- throws ASTSemanticException{
+ Kind kind, IASTExpression lhs,
+ IASTExpression rhs,
+ IASTExpression thirdExpression,
+ IASTTypeId typeId,
+ String literal,
+ ISymbol symbol) throws ASTSemanticException{
+
ExpressionResult result = null;
TypeInfo info = new TypeInfo();
- try {
- // types that resolve to void
- if ((kind == IASTExpression.Kind.PRIMARY_EMPTY)
- || (kind == IASTExpression.Kind.THROWEXPRESSION)
- || (kind == IASTExpression.Kind.POSTFIX_DOT_DESTRUCTOR)
- || (kind == IASTExpression.Kind.POSTFIX_ARROW_DESTRUCTOR)
- || (kind == IASTExpression.Kind.DELETE_CASTEXPRESSION)
- || (kind == IASTExpression.Kind.DELETE_VECTORCASTEXPRESSION)
- ){
- info.setType(TypeInfo.t_void);
- result = new ExpressionResult(info);
- return result;
+
+ // types that resolve to void
+ if ((kind == IASTExpression.Kind.PRIMARY_EMPTY)
+ || (kind == IASTExpression.Kind.THROWEXPRESSION)
+ || (kind == IASTExpression.Kind.POSTFIX_DOT_DESTRUCTOR)
+ || (kind == IASTExpression.Kind.POSTFIX_ARROW_DESTRUCTOR)
+ || (kind == IASTExpression.Kind.DELETE_CASTEXPRESSION)
+ || (kind == IASTExpression.Kind.DELETE_VECTORCASTEXPRESSION)
+ ){
+ info.setType(TypeInfo.t_void);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // types that resolve to int
+ if ((kind == IASTExpression.Kind.PRIMARY_INTEGER_LITERAL)
+ || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_INT)
+ ){
+ info.setType(TypeInfo.t_int);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // size of is always unsigned int
+ if ((kind == IASTExpression.Kind.UNARY_SIZEOF_TYPEID)
+ || (kind == IASTExpression.Kind.UNARY_SIZEOF_UNARYEXPRESSION)
+ ){
+ info.setType(TypeInfo.t_int);
+ info.setBit(true, TypeInfo.isUnsigned);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // types that resolve to char
+ if( (kind == IASTExpression.Kind.PRIMARY_CHAR_LITERAL)
+ || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR)){
+ info.setType(TypeInfo.t_char);
+ // check that this is really only one literal
+ if(literal.length() > 1){
+ // this is a string
+ info.addPtrOperator(new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
}
- // types that resolve to int
- if ((kind == IASTExpression.Kind.PRIMARY_INTEGER_LITERAL)
- || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_INT)
- ){
- info.setType(TypeInfo.t_int);
- result = new ExpressionResult(info);
- return result;
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // types that resolve to string
+ if (kind == IASTExpression.Kind.PRIMARY_STRING_LITERAL){
+ info.setType(TypeInfo.t_char);
+ info.addPtrOperator(new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // types that resolve to float
+ if( (kind == IASTExpression.Kind.PRIMARY_FLOAT_LITERAL)
+ || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_FLOAT)){
+ info.setType(TypeInfo.t_float);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // types that resolve to double
+ if( kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_DOUBLE){
+ info.setType(TypeInfo.t_double);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // types that resolve to wchar
+ if(kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_WCHART){
+ info.setType(TypeInfo.t_wchar_t);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // types that resolve to bool
+ if( (kind == IASTExpression.Kind.PRIMARY_BOOLEAN_LITERAL)
+ || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_BOOL)
+ || (kind == IASTExpression.Kind.RELATIONAL_GREATERTHAN)
+ || (kind == IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO)
+ || (kind == IASTExpression.Kind.RELATIONAL_LESSTHAN)
+ || (kind == IASTExpression.Kind.RELATIONAL_LESSTHANEQUALTO)
+ || (kind == IASTExpression.Kind.EQUALITY_EQUALS)
+ || (kind == IASTExpression.Kind.EQUALITY_NOTEQUALS)
+ || (kind == IASTExpression.Kind.LOGICALANDEXPRESSION)
+ || (kind == IASTExpression.Kind.LOGICALOREXPRESSION)
+ )
+ {
+ info.setType(TypeInfo.t_bool);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // short added to a type
+ if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT ){
+ info = addToInfo((ASTExpression)lhs, true, TypeInfo.isShort);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // long added to a type
+ if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG ){
+ info = addToInfo((ASTExpression)lhs, true, TypeInfo.isLong);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // signed added to a type
+ if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED ){
+ info = addToInfo((ASTExpression)lhs, false, TypeInfo.isUnsigned);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // unsigned added to a type
+ if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED ){
+ info = addToInfo((ASTExpression)lhs, true, TypeInfo.isUnsigned);
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // Id expressions resolve to t_type, symbol already looked up
+ if( kind == IASTExpression.Kind.ID_EXPRESSION )
+ {
+ info.setType(TypeInfo.t_type);
+ info.setTypeSymbol(symbol);
+ result = new ExpressionResult(info);
+ if (symbol == null)
+ result.setFailedToDereference(true);
+ return result;
+ }
+
+ // an ampersand implies a pointer operation of type reference
+ if (kind == IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION){
+ ASTExpression left =(ASTExpression)lhs;
+ if(left == null)
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+
+ info = left.getResultType().getResult();
+ if ((info != null) && (info.getTypeSymbol() != null)){
+ info.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
+ } else
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+
+ result = new ExpressionResult(info);
+ return result;
+ }
+
+ // a star implies a pointer operation of type pointer
+ if (kind == IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION){
+ ASTExpression left =(ASTExpression)lhs;
+ if(left == null)
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+ info = left.getResultType().getResult();
+ if ((info != null)&& (info.getTypeSymbol() != null)){
+ info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
+ }else
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // subscript
+ if (kind == IASTExpression.Kind.POSTFIX_SUBSCRIPT){
+ ASTExpression left =(ASTExpression)lhs;
+ if(left == null)
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+ info = left.getResultType().getResult();
+ if ((info != null) && (info.getTypeSymbol() != null)){
+ info.addOperatorExpression( TypeInfo.OperatorExpression.subscript );
+ }else {
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
}
- // size of is always unsigned int
- if ((kind == IASTExpression.Kind.UNARY_SIZEOF_TYPEID)
- || (kind == IASTExpression.Kind.UNARY_SIZEOF_UNARYEXPRESSION)
- ){
- info.setType(TypeInfo.t_int);
- info.setBit(true, TypeInfo.isUnsigned);
- result = new ExpressionResult(info);
- return result;
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // the dot and the arrow resolves to the type of the member
+ if ((kind == IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION)
+ || (kind == IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION)
+ || (kind == IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS)
+ || (kind == IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP)
+ ){
+ if(symbol != null){
+ info = new TypeInfo(symbol.getTypeInfo());
}
- // types that resolve to char
- if( (kind == IASTExpression.Kind.PRIMARY_CHAR_LITERAL)
- || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_CHAR)){
- info.setType(TypeInfo.t_char);
- // check that this is really only one literal
- if(literal.length() > 1){
- // this is a string
- info.addPtrOperator(new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
- }
- result = new ExpressionResult(info);
- return result;
- }
- // types that resolve to string
- if (kind == IASTExpression.Kind.PRIMARY_STRING_LITERAL){
- info.setType(TypeInfo.t_char);
- info.addPtrOperator(new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
- result = new ExpressionResult(info);
- return result;
- }
- // types that resolve to float
- if( (kind == IASTExpression.Kind.PRIMARY_FLOAT_LITERAL)
- || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_FLOAT)){
- info.setType(TypeInfo.t_float);
- result = new ExpressionResult(info);
- return result;
- }
- // types that resolve to double
- if( kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_DOUBLE){
- info.setType(TypeInfo.t_double);
- result = new ExpressionResult(info);
- return result;
- }
- // types that resolve to wchar
- if(kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_WCHART){
- info.setType(TypeInfo.t_wchar_t);
- result = new ExpressionResult(info);
- return result;
- }
- // types that resolve to bool
- if( (kind == IASTExpression.Kind.PRIMARY_BOOLEAN_LITERAL)
- || (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_BOOL)
- || (kind == IASTExpression.Kind.RELATIONAL_GREATERTHAN)
- || (kind == IASTExpression.Kind.RELATIONAL_GREATERTHANEQUALTO)
- || (kind == IASTExpression.Kind.RELATIONAL_LESSTHAN)
- || (kind == IASTExpression.Kind.RELATIONAL_LESSTHANEQUALTO)
- || (kind == IASTExpression.Kind.EQUALITY_EQUALS)
- || (kind == IASTExpression.Kind.EQUALITY_NOTEQUALS)
- || (kind == IASTExpression.Kind.LOGICALANDEXPRESSION)
- || (kind == IASTExpression.Kind.LOGICALOREXPRESSION)
- )
- {
- info.setType(TypeInfo.t_bool);
- result = new ExpressionResult(info);
- return result;
- }
- // short added to a type
- if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SHORT ){
- info = addToInfo((ASTExpression)lhs, true, TypeInfo.isShort);
- result = new ExpressionResult(info);
- return result;
- }
- // long added to a type
- if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_LONG ){
- info = addToInfo((ASTExpression)lhs, true, TypeInfo.isLong);
- result = new ExpressionResult(info);
- return result;
- }
- // signed added to a type
- if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_SIGNED ){
- info = addToInfo((ASTExpression)lhs, false, TypeInfo.isUnsigned);
- result = new ExpressionResult(info);
- return result;
- }
- // unsigned added to a type
- if (kind == IASTExpression.Kind.POSTFIX_SIMPLETYPE_UNSIGNED ){
- info = addToInfo((ASTExpression)lhs, true, TypeInfo.isUnsigned);
- result = new ExpressionResult(info);
- return result;
- }
- // Id expressions resolve to t_type, symbol already looked up
- if( kind == IASTExpression.Kind.ID_EXPRESSION )
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // the dot* and the arrow* are the same as dot/arrow + unary star
+ if ((kind == IASTExpression.Kind.PM_DOTSTAR)
+ || (kind == IASTExpression.Kind.PM_ARROWSTAR)
+ ){
+ ASTExpression right =(ASTExpression)rhs;
+ if (right == null)
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+ info = right.getResultType().getResult();
+ if ((info != null) && (symbol != null)){
+ info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
+ info.setTypeSymbol(symbol);
+ } else
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // this
+ if (kind == IASTExpression.Kind.PRIMARY_THIS){
+ if(symbol != null)
{
info.setType(TypeInfo.t_type);
- info.setTypeSymbol(symbol);
- result = new ExpressionResult(info);
- if (symbol == null)
- result.setFailedToDereference(true);
- return result;
- }
- // an ampersand implies a pointer operation of type reference
- if (kind == IASTExpression.Kind.UNARY_AMPSND_CASTEXPRESSION){
- ASTExpression left =(ASTExpression)lhs;
- if(left == null)
- throw new ASTSemanticException();
- info = left.getResultType().getResult();
- if ((info != null) && (info.getTypeSymbol() != null)){
- info.addOperatorExpression( TypeInfo.OperatorExpression.addressof );
- } else {
- throw new ASTSemanticException();
- }
- result = new ExpressionResult(info);
- return result;
- }
+ info.setTypeSymbol(symbol);
+ } else
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
- // a star implies a pointer operation of type pointer
- if (kind == IASTExpression.Kind.UNARY_STAR_CASTEXPRESSION){
- ASTExpression left =(ASTExpression)lhs;
- if(left == null)
- throw new ASTSemanticException();
- info = left.getResultType().getResult();
- if ((info != null)&& (info.getTypeSymbol() != null)){
- info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
- }else {
- throw new ASTSemanticException();
- }
- result = new ExpressionResult(info);
- return result;
- }
- // subscript
- if (kind == IASTExpression.Kind.POSTFIX_SUBSCRIPT){
- ASTExpression left =(ASTExpression)lhs;
- if(left == null)
- throw new ASTSemanticException();
- info = left.getResultType().getResult();
- if ((info != null) && (info.getTypeSymbol() != null)){
- info.addOperatorExpression( TypeInfo.OperatorExpression.subscript );
- }else {
- throw new ASTSemanticException();
- }
- result = new ExpressionResult(info);
- return result;
- }
- // the dot and the arrow resolves to the type of the member
- if ((kind == IASTExpression.Kind.POSTFIX_DOT_IDEXPRESSION)
- || (kind == IASTExpression.Kind.POSTFIX_ARROW_IDEXPRESSION)
- || (kind == IASTExpression.Kind.POSTFIX_DOT_TEMPL_IDEXPRESS)
- || (kind == IASTExpression.Kind.POSTFIX_ARROW_TEMPL_IDEXP)
- ){
- if(symbol != null){
- info = new TypeInfo(symbol.getTypeInfo());
- }
-// else {
-// throw new ASTSemanticException();
-// }
- result = new ExpressionResult(info);
- return result;
- }
- // the dot* and the arrow* are the same as dot/arrow + unary star
- if ((kind == IASTExpression.Kind.PM_DOTSTAR)
- || (kind == IASTExpression.Kind.PM_ARROWSTAR)
- ){
- ASTExpression right =(ASTExpression)rhs;
- if (right == null)
- throw new ASTSemanticException();
- info = right.getResultType().getResult();
- if ((info != null) && (symbol != null)){
- info.addOperatorExpression( TypeInfo.OperatorExpression.indirection );
- info.setTypeSymbol(symbol);
- } else {
- throw new ASTSemanticException();
- }
- result = new ExpressionResult(info);
- return result;
- }
- // this
- if (kind == IASTExpression.Kind.PRIMARY_THIS){
- if(symbol != null)
- {
- info.setType(TypeInfo.t_type);
- info.setTypeSymbol(symbol);
- } else {
- throw new ASTSemanticException();
- }
- result = new ExpressionResult(info);
- return result;
- }
- // conditional
- if (kind == IASTExpression.Kind.CONDITIONALEXPRESSION){
- ASTExpression right = (ASTExpression)rhs;
- ASTExpression third = (ASTExpression)thirdExpression;
- if((right != null ) && (third != null)){
- TypeInfo rightType =right.getResultType().getResult();
- TypeInfo thirdType =third.getResultType().getResult();
- if((rightType != null) && (thirdType != null)){
- info = conditionalExpressionConversions(rightType, thirdType);
- } else {
- throw new ASTSemanticException();
- }
- } else {
- throw new ASTSemanticException();
- }
- result = new ExpressionResult(info);
- return result;
- }
- // new
- if( ( kind == IASTExpression.Kind.NEW_TYPEID )
- || ( kind == IASTExpression.Kind.NEW_NEWTYPEID ) )
- {
- try
- {
- info = typeId.getTypeSymbol().getTypeInfo();
- info.addPtrOperator( new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
- }
- catch (ASTNotImplementedException e)
- {
- // will never happen
- }
- result = new ExpressionResult(info);
- return result;
- }
- // types that use the usual arithmetic conversions
- if((kind == IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY)
- || (kind == IASTExpression.Kind.MULTIPLICATIVE_DIVIDE)
- || (kind == IASTExpression.Kind.MULTIPLICATIVE_MODULUS)
- || (kind == IASTExpression.Kind.ADDITIVE_PLUS)
- || (kind == IASTExpression.Kind.ADDITIVE_MINUS)
- || (kind == IASTExpression.Kind.ANDEXPRESSION)
- || (kind == IASTExpression.Kind.EXCLUSIVEOREXPRESSION)
- || (kind == IASTExpression.Kind.INCLUSIVEOREXPRESSION)
- ){
- ASTExpression left = (ASTExpression)lhs;
- ASTExpression right = (ASTExpression)rhs;
- if((left != null ) && (right != null)){
- TypeInfo leftType =left.getResultType().getResult();
- TypeInfo rightType =right.getResultType().getResult();
- info = usualArithmeticConversions(leftType, rightType);
- }
- else {
- throw new ASTSemanticException();
- }
- result = new ExpressionResult(info);
- return result;
- }
- // types that resolve to LHS types
- if ((kind == IASTExpression.Kind.PRIMARY_BRACKETED_EXPRESSION)
- || (kind == IASTExpression.Kind.POSTFIX_INCREMENT)
- || (kind == IASTExpression.Kind.POSTFIX_DECREMENT)
- || (kind == IASTExpression.Kind.POSTFIX_TYPEID_EXPRESSION)
- || (kind == IASTExpression.Kind.UNARY_INCREMENT)
- || (kind == IASTExpression.Kind.UNARY_DECREMENT)
- || (kind == IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION)
- || (kind == IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION)
- || (kind == IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION)
- || (kind == IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION)
- || (kind == IASTExpression.Kind.SHIFT_LEFT)
- || (kind == IASTExpression.Kind.SHIFT_RIGHT)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR)
- || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR)
- ){
- ASTExpression left = (ASTExpression)lhs;
- if(left != null){
- info =left.getResultType().getResult();
- } else {
- throw new ASTSemanticException();
- }
- result = new ExpressionResult(info);
- return result;
- }
- // the cast changes the types to the type looked up in typeId = symbol
- if(( kind == IASTExpression.Kind.CASTEXPRESSION )
- || ( kind == IASTExpression.Kind.POSTFIX_DYNAMIC_CAST )
- || ( kind == IASTExpression.Kind.POSTFIX_STATIC_CAST )
- || ( kind == IASTExpression.Kind.POSTFIX_REINTERPRET_CAST )
- || ( kind == IASTExpression.Kind.POSTFIX_CONST_CAST )
- ){
- try{
- info = new TypeInfo(typeId.getTypeSymbol().getTypeInfo());
- }catch (ASTNotImplementedException e)
- {
- // will never happen
- }
- result = new ExpressionResult(info);
- return result;
- }
- // a list collects all types of left and right hand sides
- if(kind == IASTExpression.Kind.EXPRESSIONLIST){
- result = new ExpressionResultList();
- if(lhs != null){
- TypeInfo leftType = ((ASTExpression)lhs).getResultType().getResult();
- result.setResult(leftType);
- }
- if(rhs != null){
- TypeInfo rightType = ((ASTExpression)rhs).getResultType().getResult();
- result.setResult(rightType);
- }
- return result;
- }
- // a function call type is the return type of the function
- if(kind == IASTExpression.Kind.POSTFIX_FUNCTIONCALL){
- if(symbol != null){
- IParameterizedSymbol psymbol = (IParameterizedSymbol) symbol;
- ISymbol returnTypeSymbol = psymbol.getReturnType();
- if(returnTypeSymbol != null){
- info.setType(returnTypeSymbol.getType());
- info.setTypeSymbol(returnTypeSymbol);
- }else {
- // this is call to a constructor
- }
- }
- result = new ExpressionResult(info);
- if(symbol == null)
- result.setFailedToDereference(true);
- return result;
- }
- // typeid
- if( kind == IASTExpression.Kind.POSTFIX_TYPEID_TYPEID )
- {
- try
- {
- info = typeId.getTypeSymbol().getTypeInfo();
- }
- catch (ASTNotImplementedException e)
- {
- // will not ever happen from within CompleteParseASTFactory
- }
- result = new ExpressionResult(info);
- return result;
- }
- // typename
- if ( ( kind == IASTExpression.Kind.POSTFIX_TYPENAME_IDENTIFIER )
- || ( kind == IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID ) )
- {
- if(symbol != null){
- info.setType(TypeInfo.t_type);
- info.setTypeSymbol(symbol);
- } else {
- throw new ASTSemanticException();
- }
- result = new ExpressionResult(info);
- return result;
- }
- } catch (Exception e){
- throw new ASTSemanticException();
+ result = new ExpressionResult(info);
+ return result;
}
+
+ // conditional
+ if (kind == IASTExpression.Kind.CONDITIONALEXPRESSION){
+ ASTExpression right = (ASTExpression)rhs;
+ ASTExpression third = (ASTExpression)thirdExpression;
+ if((right != null ) && (third != null)){
+ TypeInfo rightType =right.getResultType().getResult();
+ TypeInfo thirdType =third.getResultType().getResult();
+ if((rightType != null) && (thirdType != null)){
+ info = conditionalExpressionConversions(rightType, thirdType);
+ } else
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+
+ } else
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // new
+ if( ( kind == IASTExpression.Kind.NEW_TYPEID )
+ || ( kind == IASTExpression.Kind.NEW_NEWTYPEID ) )
+ {
+ try
+ {
+ info = typeId.getTypeSymbol().getTypeInfo();
+ info.addPtrOperator( new TypeInfo.PtrOp(TypeInfo.PtrOp.t_pointer));
+ }
+ catch (ASTNotImplementedException e)
+ {
+ // will never happen
+ }
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // types that use the usual arithmetic conversions
+ if((kind == IASTExpression.Kind.MULTIPLICATIVE_MULTIPLY)
+ || (kind == IASTExpression.Kind.MULTIPLICATIVE_DIVIDE)
+ || (kind == IASTExpression.Kind.MULTIPLICATIVE_MODULUS)
+ || (kind == IASTExpression.Kind.ADDITIVE_PLUS)
+ || (kind == IASTExpression.Kind.ADDITIVE_MINUS)
+ || (kind == IASTExpression.Kind.ANDEXPRESSION)
+ || (kind == IASTExpression.Kind.EXCLUSIVEOREXPRESSION)
+ || (kind == IASTExpression.Kind.INCLUSIVEOREXPRESSION)
+ ){
+ ASTExpression left = (ASTExpression)lhs;
+ ASTExpression right = (ASTExpression)rhs;
+ if((left != null ) && (right != null)){
+ TypeInfo leftType =left.getResultType().getResult();
+ TypeInfo rightType =right.getResultType().getResult();
+ info = usualArithmeticConversions(leftType, rightType);
+ }
+ else
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+
+ result = new ExpressionResult(info);
+ return result;
+ }
+
+ // types that resolve to LHS types
+ if ((kind == IASTExpression.Kind.PRIMARY_BRACKETED_EXPRESSION)
+ || (kind == IASTExpression.Kind.POSTFIX_INCREMENT)
+ || (kind == IASTExpression.Kind.POSTFIX_DECREMENT)
+ || (kind == IASTExpression.Kind.POSTFIX_TYPEID_EXPRESSION)
+ || (kind == IASTExpression.Kind.UNARY_INCREMENT)
+ || (kind == IASTExpression.Kind.UNARY_DECREMENT)
+ || (kind == IASTExpression.Kind.UNARY_PLUS_CASTEXPRESSION)
+ || (kind == IASTExpression.Kind.UNARY_MINUS_CASTEXPRESSION)
+ || (kind == IASTExpression.Kind.UNARY_NOT_CASTEXPRESSION)
+ || (kind == IASTExpression.Kind.UNARY_TILDE_CASTEXPRESSION)
+ || (kind == IASTExpression.Kind.SHIFT_LEFT)
+ || (kind == IASTExpression.Kind.SHIFT_RIGHT)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_NORMAL)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_PLUS)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MINUS)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MULT)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_DIV)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_MOD)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_LSHIFT)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_RSHIFT)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_AND)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_OR)
+ || (kind == IASTExpression.Kind.ASSIGNMENTEXPRESSION_XOR)
+ ){
+ ASTExpression left = (ASTExpression)lhs;
+ if(left != null){
+ info =left.getResultType().getResult();
+ } else
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // the cast changes the types to the type looked up in typeId = symbol
+ if(( kind == IASTExpression.Kind.CASTEXPRESSION )
+ || ( kind == IASTExpression.Kind.POSTFIX_DYNAMIC_CAST )
+ || ( kind == IASTExpression.Kind.POSTFIX_STATIC_CAST )
+ || ( kind == IASTExpression.Kind.POSTFIX_REINTERPRET_CAST )
+ || ( kind == IASTExpression.Kind.POSTFIX_CONST_CAST )
+ ){
+ try{
+ info = new TypeInfo(typeId.getTypeSymbol().getTypeInfo());
+ }catch (ASTNotImplementedException e)
+ {
+ // will never happen
+ }
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // a list collects all types of left and right hand sides
+ if(kind == IASTExpression.Kind.EXPRESSIONLIST){
+ result = new ExpressionResultList();
+ if(lhs != null){
+ TypeInfo leftType = ((ASTExpression)lhs).getResultType().getResult();
+ result.setResult(leftType);
+ }
+ if(rhs != null){
+ TypeInfo rightType = ((ASTExpression)rhs).getResultType().getResult();
+ result.setResult(rightType);
+ }
+ return result;
+ }
+ // a function call type is the return type of the function
+ if(kind == IASTExpression.Kind.POSTFIX_FUNCTIONCALL){
+ if(symbol != null){
+ IParameterizedSymbol psymbol = (IParameterizedSymbol) symbol;
+ ISymbol returnTypeSymbol = psymbol.getReturnType();
+ if(returnTypeSymbol != null){
+ info.setType(returnTypeSymbol.getType());
+ info.setTypeSymbol(returnTypeSymbol);
+ }else {
+ // this is call to a constructor
+ }
+ }
+ result = new ExpressionResult(info);
+ if(symbol == null)
+ result.setFailedToDereference(true);
+ return result;
+ }
+ // typeid
+ if( kind == IASTExpression.Kind.POSTFIX_TYPEID_TYPEID )
+ {
+ try
+ {
+ info = typeId.getTypeSymbol().getTypeInfo();
+ }
+ catch (ASTNotImplementedException e)
+ {
+ // will not ever happen from within CompleteParseASTFactory
+ }
+ result = new ExpressionResult(info);
+ return result;
+ }
+ // typename
+ if ( ( kind == IASTExpression.Kind.POSTFIX_TYPENAME_IDENTIFIER )
+ || ( kind == IASTExpression.Kind.POSTFIX_TYPENAME_TEMPLATEID ) )
+ {
+ if(symbol != null){
+ info.setType(TypeInfo.t_type);
+ info.setTypeSymbol(symbol);
+ } else
+ handleProblem( IProblem.SEMANTIC_MALFORMED_EXPRESSION, null );
+
+ result = new ExpressionResult(info);
+ return result;
+ }
+// assert false : this;
return null;
}
@@ -1575,11 +1571,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
if( typeSymbol != null )
addReference( references, createReference( typeSymbol, current.getImage(), current.getOffset() ));
else
- throw new ASTSemanticException();
+ handleProblem( IProblem.SEMANTIC_NAME_NOT_FOUND, current.getImage() );
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem( e.createProblemID(), current.getImage() );
}
}
s.setTypeSymbol( typeSymbol );
@@ -1706,21 +1702,14 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem( e.createProblemID(), name.toString());
}
} else {
symbol = functionDeclaration;
}
ASTFunction function = new ASTFunction( symbol, nameEndOffset, parameters, returnType, exception, startOffset, startLine, nameOffset, nameLine, ownerTemplate, references, previouslyDeclared, hasFunctionTryBlock );
- try
- {
- attachSymbolExtension(symbol, function);
- }
- catch (ExtensionException e1)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension(symbol, function, isFunctionDefinition);
return function;
}
@@ -1772,14 +1761,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
else if( kind == IASTSimpleTypeSpecifier.Type._BOOL ){
type.setType( TypeInfo.t__Bool );
}
- else
- throw new ASTSemanticException();
- type.setBit( simpleType.isLong(), TypeInfo.isLong);
- type.setBit( simpleType.isShort(), TypeInfo.isShort);
- type.setBit( simpleType.isUnsigned(), TypeInfo.isUnsigned);
- type.setBit( simpleType.isComplex(), TypeInfo.isComplex);
- type.setBit( simpleType.isImaginary(), TypeInfo.isImaginary);
- type.setBit( simpleType.isSigned(), TypeInfo.isSigned);
+// else
+// assert false : "Unexpected IASTSimpleTypeSpecifier.Type";
+
+ setTypeBitFlags(type, simpleType);
+
}
else if( absDecl.getTypeSpecifier() instanceof IASTClassSpecifier )
{
@@ -1790,8 +1776,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
type.setType(TypeInfo.t_struct);
else if( kind == ASTClassKind.UNION )
type.setType(TypeInfo.t_union);
- else
- throw new ASTSemanticException();
+// else
+// assert false : this;
}
else if( absDecl.getTypeSpecifier() instanceof IASTEnumerationSpecifier )
{
@@ -1808,14 +1794,27 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
type.setType(TypeInfo.t_union);
else if( kind == ASTClassKind.ENUM )
type.setType(TypeInfo.t_enumeration);
- else
- throw new ASTSemanticException();
+// else
+// assert false : this;
}
- else
- throw new ASTSemanticException();
+// else
+// assert false : this;
return type;
}
/**
+ * @param type
+ * @param simpleType
+ */
+ private void setTypeBitFlags(TypeInfo type, IASTSimpleTypeSpecifier simpleType) {
+ type.setBit( simpleType.isLong(), TypeInfo.isLong);
+ type.setBit( simpleType.isShort(), TypeInfo.isShort);
+ type.setBit( simpleType.isUnsigned(), TypeInfo.isUnsigned);
+ type.setBit( simpleType.isComplex(), TypeInfo.isComplex);
+ type.setBit( simpleType.isImaginary(), TypeInfo.isImaginary);
+ type.setBit( simpleType.isSigned(), TypeInfo.isSigned);
+ }
+
+ /**
* @param symbol
* @param returnType
*/
@@ -1846,7 +1845,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
xrefSymbol = elab.getSymbol();
newReferences = new ArrayList();
newReferences.addAll( elab.getReferences() );
- newReferences.add( createReference( xrefSymbol, elab.getName(), elab.getNameOffset()) );
+ if( xrefSymbol != null )
+ newReferences.add( createReference( xrefSymbol, elab.getName(), elab.getNameOffset()) );
}
String paramName = ""; //$NON-NLS-1$
@@ -1876,14 +1876,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
ASTParameterDeclaration parm = (ASTParameterDeclaration)absDecl;
parm.setSymbol( paramSymbol );
- try
- {
- attachSymbolExtension( paramSymbol, parm );
- }
- catch (ExtensionException e)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension( paramSymbol, parm, true );
}
}
@@ -1904,8 +1897,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_pointer, true, false ));
else if( pointerOperator == ASTPointerOperator.VOLATILE_POINTER )
symbol.addPtrOperator( new TypeInfo.PtrOp( TypeInfo.PtrOp.t_pointer, false, true));
- else
- throw new ASTSemanticException();
+// else
+// assert false : pointerOperator;
}
while( arrayModsIterator.hasNext() )
@@ -2035,8 +2028,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
visibility = ASTAccessVisibility.PRIVATE;
} else
{
- //for a friend function declaration, if there is no prior declaration, the program is illformed
- throw new ASTSemanticException();
+ handleProblem( IProblem.SEMANTIC_ILLFORMED_FRIEND, nameDuple.toString(), nameDuple.getStartOffset(), nameDuple.getEndOffset(), nameDuple.getLineNumber() );
}
} else if( functionDeclaration != null )
@@ -2063,27 +2055,20 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem(e.createProblemID(), nameDuple.toString(), nameDuple.getStartOffset(), nameDuple.getEndOffset(), nameDuple.getLineNumber() );
}
resolveLeftoverConstructorInitializerMembers( symbol, constructorChain );
ASTMethod method = new ASTMethod( symbol, parameters, returnType, exception, startOffset, startingLine, nameOffset, nameEndOffset, nameLine, ownerTemplate, references, previouslyDeclared, isConstructor, isDestructor, isPureVirtual, visibility, constructorChain, hasFunctionTryBlock );
- try
- {
- attachSymbolExtension( symbol, method );
- }
- catch (ExtensionException e1)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension( symbol, method, isFunctionDefinition );
return method;
}
/**
* @param symbol
* @param constructorChain
*/
- protected void resolveLeftoverConstructorInitializerMembers(IParameterizedSymbol symbol, List constructorChain)
+ protected void resolveLeftoverConstructorInitializerMembers(IParameterizedSymbol symbol, List constructorChain) throws ASTSemanticException
{
if( constructorChain != null )
{
@@ -2096,18 +2081,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
((ASTConstructorMemberInitializer)initializer).requiresNameResolution() )
{
ASTConstructorMemberInitializer realInitializer = ((ASTConstructorMemberInitializer)initializer);
- try
- {
- IDerivableContainerSymbol container = (IDerivableContainerSymbol) symbol.getContainingSymbol();
- lookupQualifiedName(container, initializer.getName(), TypeInfo.t_any, null, realInitializer.getNameOffset(), realInitializer.getReferences(), false, LookupType.QUALIFIED);
- }
- catch( ASTSemanticException ase )
- {
- }
+ IDerivableContainerSymbol container = (IDerivableContainerSymbol) symbol.getContainingSymbol();
+ lookupQualifiedName(container, initializer.getName(), TypeInfo.t_any, null, realInitializer.getNameOffset(), realInitializer.getReferences(), false, LookupType.QUALIFIED);
+ // TODO try and resolve parameter references now in the expression list
}
-
- // TODO try and resolve parameter references now in the expression list
-
}
}
@@ -2229,7 +2206,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- // TODO Auto-generated catch block
+ handleProblem(e.createProblemID(), name );
}
ASTVariable variable = new ASTVariable( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references, constructorExpression, previouslyDeclared );
@@ -2239,14 +2216,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
addDesignatorReferences( (ASTInitializerClause)variable.getInitializerClause() );
}
- try
- {
- attachSymbolExtension(newSymbol, variable );
- }
- catch (ExtensionException e)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension(newSymbol, variable, !isStatic );
return variable;
}
@@ -2286,7 +2256,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
try
{
- clause.getReferences().add( createReference( lookup, designator.fieldName(), designator.fieldOffset() ));
+ if( lookup != null )
+ clause.getReferences().add( createReference( lookup, designator.fieldName(), designator.fieldOffset() ));
}
catch (ASTSemanticException e1)
{
@@ -2338,8 +2309,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
IASTAbstractDeclaration abstractDeclaration,
List references) throws ASTSemanticException
{
- if( abstractDeclaration.getTypeSpecifier() == null )
- throw new ASTSemanticException();
+// assert abstractDeclaration.getTypeSpecifier() != null : this;
ISymbol newSymbol = null;
ISymbol symbolToBeCloned = null;
if( abstractDeclaration.getTypeSpecifier() instanceof ASTSimpleTypeSpecifier )
@@ -2357,7 +2327,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ASTElaboratedTypeSpecifier elab = ((ASTElaboratedTypeSpecifier)abstractDeclaration.getTypeSpecifier());
symbolToBeCloned = pst.newSymbol(name, TypeInfo.t_type);
symbolToBeCloned.setTypeSymbol(elab.getSymbol());
- references.add( createReference( elab.getSymbol(), elab.getName(), elab.getNameOffset()) );
+ if( elab.getSymbol() != null )
+ references.add( createReference( elab.getSymbol(), elab.getName(), elab.getNameOffset()) );
}
newSymbol = (ISymbol) symbolToBeCloned.clone();
newSymbol.setName( name );
@@ -2441,18 +2412,11 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem(e.createProblemID(), name );
}
ASTField field = new ASTField( newSymbol, abstractDeclaration, initializerClause, bitfieldExpression, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references, previouslyDeclared, constructorExpression, visibility );
- try
- {
- attachSymbolExtension(newSymbol, field );
- }
- catch (ExtensionException e)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension(newSymbol, field, !isStatic );
return field;
@@ -2529,17 +2493,10 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem(e.createProblemID(), name );
}
ASTTypedef d = new ASTTypedef( newSymbol, mapping, startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, references );
- try
- {
- attachSymbolExtension(newSymbol, d );
- }
- catch (ExtensionException e1)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension(newSymbol, d, true );
return d;
}
/* (non-Javadoc)
@@ -2562,23 +2519,21 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
TypeInfo.eType pstType = classKindToTypeInfo(kind);
List references = new ArrayList();
IToken lastToken = name.getLastToken();
+
if( name.length() != 1 ) // qualified name
{
ITokenDuple containerSymbolName =
name.getSubrange( 0, name.length() - 3 ); // -1 for index, -2 for last hop of qualified name
currentScopeSymbol = (IContainerSymbol)lookupQualifiedName( currentScopeSymbol,
- containerSymbolName, references, true);
+ containerSymbolName, references, false);
if( currentScopeSymbol == null )
- throw new ASTSemanticException();
+ handleProblem(IProblem.SEMANTIC_NAME_NOT_FOUND, containerSymbolName.toString(), containerSymbolName.getStartOffset(), containerSymbolName.getEndOffset(), containerSymbolName.getLineNumber() );
}
ISymbol checkSymbol = null;
try
{
if( isFriend ){
- if( !(currentScopeSymbol instanceof IDerivableContainerSymbol) ){
- throw new ASTSemanticException();
- }
checkSymbol = ((IDerivableContainerSymbol)currentScopeSymbol).lookupForFriendship( lastToken.getImage() );
} else {
checkSymbol = currentScopeSymbol.elaboratedLookup( pstType, lastToken.getImage());
@@ -2586,7 +2541,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem(e.createProblemID(),lastToken.getImage(), lastToken.getOffset(), lastToken.getEndOffset(), lastToken.getLineNumber() );
}
@@ -2606,20 +2561,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e1)
{
- throw new ASTSemanticException();
+ handleProblem(e1.createProblemID(),lastToken.getImage(), lastToken.getOffset(), lastToken.getEndOffset(), lastToken.getLineNumber() );
}
ASTElaboratedTypeSpecifier elab =
new ASTElaboratedTypeSpecifier( checkSymbol, kind, startingOffset, startingLine, name.getFirstToken().getOffset(), name.getLastToken().getEndOffset(), name.getLastToken().getLineNumber(), endOffset, endingLine, references, isForewardDecl );
- try
- {
- attachSymbolExtension( checkSymbol, elab );
- }
- catch (ExtensionException e2)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension( checkSymbol, elab, isForewardDecl );
} else if( isFriend ){
((IDerivableContainerSymbol)currentScopeSymbol).addFriend( checkSymbol );
}
@@ -2630,14 +2578,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
)
{
ASTElaboratedTypeSpecifier elab = new ASTElaboratedTypeSpecifier( checkSymbol, kind, startingOffset, startingLine, name.getFirstToken().getOffset(), name.getLastToken().getEndOffset(), name.getLastToken().getLineNumber(), endOffset, endingLine, references, isForewardDecl );
- try
- {
- attachSymbolExtension( checkSymbol, elab );
- }
- catch (ExtensionException e2)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension( checkSymbol, elab, isForewardDecl );
return elab;
}
@@ -2645,7 +2586,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
return (IASTElaboratedTypeSpecifier)checkSymbol.getASTExtension().getPrimaryDeclaration();
- throw new ASTSemanticException();
+// assert false : this;
+ return null;
}
protected ParserSymbolTable pst;
@@ -2662,7 +2604,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
ISymbol namespaceSymbol = lookupQualifiedName( startingSymbol, alias, references, true );
if( namespaceSymbol.getType() != TypeInfo.t_namespace )
- throw new ASTSemanticException();
+ handleProblem( IProblem.SEMANTIC_INVALID_OVERLOAD, alias.toString(), startingOffset, endOffset, startingLine );
ISymbol newSymbol = pst.newContainerSymbol( identifier, TypeInfo.t_namespace );
newSymbol.setTypeSymbol( namespaceSymbol );
@@ -2673,20 +2615,13 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
}
catch (ParserSymbolTableException e)
{
- throw new ASTSemanticException();
+ handleProblem( e.createProblemID(), identifier, startingOffset, endOffset, startingLine );
}
ASTNamespaceAlias astAlias = new ASTNamespaceAlias(
newSymbol, alias.toString(), (IASTNamespaceDefinition)namespaceSymbol.getASTExtension().getPrimaryDeclaration(),
startingOffset, startingLine, nameOffset, nameEndOffset, nameLine, endOffset, endingLine, references );
- try
- {
- attachSymbolExtension( newSymbol, astAlias );
- }
- catch (ExtensionException e1)
- {
- throw new ASTSemanticException();
- }
+ attachSymbolExtension( newSymbol, astAlias, true );
return astAlias;
}
@@ -2700,13 +2635,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
newScope.setContainingSymbol(symbol);
ASTCodeScope codeScope = new ASTCodeScope( newScope );
- try
- {
- attachSymbolExtension( newScope, codeScope );
- }
- catch (ExtensionException e)
- {
- }
+ attachSymbolExtension( newScope, codeScope, true );
return codeScope;
}
@@ -2795,7 +2724,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
{
ISymbol typeSymbol = lookupQualifiedName( scopeToSymbol(scope), typeId.getTokenDuple(), refs, true );
if( typeSymbol.getType() == TypeInfo.t_type )
- throw new ASTSemanticException();
+ handleProblem( IProblem.SEMANTIC_INVALID_TYPE, id.getTypeOrClassName() );
result.setTypeSymbol( typeSymbol );
typeId.addReferences( refs );
}
@@ -2880,9 +2809,7 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
s = lookupQualifiedName( scopeToSymbol( scope ), duple, new ArrayList(), false );
} catch (ASTSemanticException e) {
}
- if ( s == null )
- return null;
+ if ( s == null ) return null;
return s.getASTExtension().getPrimaryDeclaration();
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/expression/ExpressionParseASTFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/expression/ExpressionParseASTFactory.java
index b1aa08508f2..930c13aef1f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/expression/ExpressionParseASTFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/expression/ExpressionParseASTFactory.java
@@ -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.extension.IASTExpressionExtension;
import org.eclipse.cdt.core.parser.ast.extension.IASTExtensionFactory;
+import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
/**
* @author jcamelon
*/
-public class ExpressionParseASTFactory implements IASTFactory {
+public class ExpressionParseASTFactory extends BaseASTFactory implements IASTFactory {
private final IASTExtensionFactory extensionFactory;
@@ -914,4 +915,5 @@ public class ExpressionParseASTFactory implements IASTFactory {
return null;
}
+
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java
index f37baec14df..9886a9806ed 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java
@@ -10,9 +10,10 @@
***********************************************************************/
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.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.IASTUsingDeclaration;
import org.eclipse.cdt.internal.core.parser.ast.Offsets;
@@ -108,7 +109,7 @@ public class ASTUsingDeclaration
/* (non-Javadoc)
* @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#getUsingType()
*/
- public IASTDeclaration getUsingType() throws ASTNotImplementedException
+ public Iterator getUsingTypes() throws ASTNotImplementedException
{
throw new ASTNotImplementedException();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
index b0cc5942de9..b2491e63f4a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
@@ -2205,7 +2205,7 @@ public class ParserSymbolTable {
parentAccess = parent.getAccess();
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() );
if( symbolAccess != null ){
- symbolAccess = ( parentAccess.getEnumValue() > symbolAccess.getEnumValue() ) ? parentAccess : symbolAccess;
+ symbolAccess = ( parentAccess.isGreaterThan( symbolAccess ) ) ? parentAccess : symbolAccess;
if( checkAllPaths ){
if( resultingAccess != null )
- resultingAccess = ( resultingAccess.getEnumValue() > symbolAccess.getEnumValue() ) ? symbolAccess : resultingAccess;
+ resultingAccess = resultingAccess.isGreaterThan( symbolAccess ) ? symbolAccess : resultingAccess;
else
resultingAccess = symbolAccess;
} else {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java
index 9f5de6f208a..ec3030988b9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java
@@ -11,6 +11,8 @@
package org.eclipse.cdt.internal.core.parser.pst;
+import org.eclipse.cdt.core.parser.IProblem;
+
/**
* @author aniefer
*/
@@ -44,5 +46,38 @@ public class ParserSymbolTableException extends Exception {
public static final int r_BadTemplateParameter = 9;
public static final int r_RedeclaredTemplateParam = 10;
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;
+ }
+ }
}
\ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java
index f7f01f4ecbd..46ddd60cbf3 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java
@@ -11,6 +11,8 @@
package org.eclipse.cdt.internal.core.parser.scanner;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
@@ -26,7 +28,6 @@ import java.util.StringTokenizer;
import java.util.Vector;
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.EndOfFileException;
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 {
- private final static String SCRATCH = ""; //$NON-NLS-1$
+ private final static String SCRATCH = "";
protected final IScannerData scannerData;
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 );
// trace log
- StringBuffer logMessage = new StringBuffer( "Scanner problem encountered: "); //$NON-NLS-1$
+ StringBuffer logMessage = new StringBuffer( "Scanner problem encountered: ");
logMessage.append( problem.getMessage() );
scannerData.getLogService().traceLog( logMessage.toString() );
@@ -110,7 +111,7 @@ public class Scanner implements IScanner {
if( scannerExtension instanceof GCCScannerExtension )
((GCCScannerExtension)scannerExtension).setScannerData( scannerData );
- scannerData.setASTFactory( ParserFactory.createASTFactory( scannerData.getParserMode(), language ) );
+ scannerData.setASTFactory( ParserFactory.createASTFactory( this, scannerData.getParserMode(), language ) );
try {
//this is a hack to get around a sudden EOF experience
scannerData.getContextStack().push(
@@ -174,18 +175,18 @@ public class Scanner implements IScanner {
scannerExtension.setupBuiltInMacros(scannerData.getLanguage());
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( 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 )
- addDefinition( __STDC_VERSION__, new ObjectMacroDescriptor( __STDC_VERSION__, "199001L")); //$NON-NLS-1$
+ addDefinition( __STDC_VERSION__, new ObjectMacroDescriptor( __STDC_VERSION__, "199001L"));
}
else
if( getDefinition( __CPLUSPLUS ) == null )
- addDefinition( __CPLUSPLUS, new ObjectMacroDescriptor( __CPLUSPLUS, "199711L")); //$NON-NLS-1$
+ addDefinition( __CPLUSPLUS, new ObjectMacroDescriptor( __CPLUSPLUS, "199711L"));
if( getDefinition(__FILE__) == null )
addDefinition( __FILE__,
@@ -222,17 +223,17 @@ public class Scanner implements IScanner {
if( Calendar.MONTH == Calendar.OCTOBER) return "Oct";
if( Calendar.MONTH == Calendar.NOVEMBER) return "Nov";
if( Calendar.MONTH == Calendar.DECEMBER) return "Dec";
- return ""; //$NON-NLS-1$
+ return "";
}
public String execute() {
StringBuffer result = new StringBuffer();
result.append( getMonth() );
- result.append(" "); //$NON-NLS-1$
+ result.append(" ");
if( Calendar.DAY_OF_MONTH < 10 )
- result.append(" "); //$NON-NLS-1$
+ result.append(" ");
result.append(Calendar.DAY_OF_MONTH);
- result.append(" "); //$NON-NLS-1$
+ result.append(" ");
result.append( Calendar.YEAR );
return result.toString();
}
@@ -308,7 +309,6 @@ public class Scanner implements IScanner {
buffer.append( tokenizer.nextToken() );
}
file = new File( buffer.toString() );
- path = buffer.toString();
}
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 {
- CodeReader duple = null;
+ FileReader inclusionReader = null;
+ String newPath = null;
+
totalLoop: for( int i = 0; i < 2; ++i )
{
if( useIncludePaths ) // search include paths for this file
@@ -507,33 +509,65 @@ public class Scanner implements IScanner {
while (iter.hasNext()) {
String path = (String)iter.next();
- duple = createReaderDuple( path, fileName );
- if( duple != null )
- break totalLoop;
+ File pathFile = new File(path);
+ //TODO assert pathFile.isDirectory();
+ 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 );
}
else // local inclusion
{
- duple = createReaderDuple( new File( scannerData.getContextStack().getCurrentContext().getFilename() ).getParentFile().getAbsolutePath(), fileName );
- if( duple != null )
- break totalLoop;
- useIncludePaths = true;
- continue totalLoop;
+ String currentFilename = scannerData.getContextStack().getCurrentContext().getFilename();
+ File currentIncludeFile = new File( currentFilename );
+ String parentDirectory = currentIncludeFile.getParentFile().getAbsolutePath();
+ currentIncludeFile = null;
+
+ 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 (duple!= null) {
+ if (inclusionReader != null) {
IASTInclusion inclusion = null;
try
{
inclusion =
scannerData.getASTFactory().createInclusion(
fileName,
- duple.getFilename(),
+ newPath,
!useIncludePaths,
beginOffset,
startLine,
@@ -547,7 +581,7 @@ public class Scanner implements IScanner {
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)
{
@@ -559,14 +593,14 @@ public class Scanner implements IScanner {
// constants
private static final int NOCHAR = -1;
- private static final String TEXT = ""; //$NON-NLS-1$
- private static final String START = ""; //$NON-NLS-1$
- private static final String EXPRESSION = ""; //$NON-NLS-1$
- private static final String PASTING = ""; //$NON-NLS-1$
+ private static final String TEXT = "";
+ private static final String START = "";
+ private static final String EXPRESSION = "";
+ private static final String PASTING = "";
- private static final String DEFINED = "defined"; //$NON-NLS-1$
- private static final String _PRAGMA = "_Pragma"; //$NON-NLS-1$
- private static final String POUND_DEFINE = "#define "; //$NON-NLS-1$
+ private static final String DEFINED = "defined";
+ private static final String _PRAGMA = "_Pragma";
+ private static final String POUND_DEFINE = "#define ";
private IScannerContext lastContext = null;
@@ -634,39 +668,39 @@ public class Scanner implements IScanner {
c = getChar(insideString);
switch (c) {
case '(':
- expandDefinition("??(", "[", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("??(", "[", baseOffset);
c = getChar(insideString);
break;
case ')':
- expandDefinition("??)", "]", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("??)", "]", baseOffset);
c = getChar(insideString);
break;
case '<':
- expandDefinition("??<", "{", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("??<", "{", baseOffset);
c = getChar(insideString);
break;
case '>':
- expandDefinition("??>", "}", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("??>", "}", baseOffset);
c = getChar(insideString);
break;
case '=':
- expandDefinition("??=", "#", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("??=", "#", baseOffset);
c = getChar(insideString);
break;
case '/':
- expandDefinition("??/", "\\", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("??/", "\\", baseOffset);
c = getChar(insideString);
break;
case '\'':
- expandDefinition("??\'", "^", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("??\'", "^", baseOffset);
c = getChar(insideString);
break;
case '!':
- expandDefinition("??!", "|", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("??!", "|", baseOffset);
c = getChar(insideString);
break;
case '-':
- expandDefinition("??-", "~", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("??-", "~", baseOffset);
c = getChar(insideString);
break;
default:
@@ -709,10 +743,10 @@ public class Scanner implements IScanner {
if (c == '<') {
c = getChar(false);
if (c == '%') {
- expandDefinition("<%", "{", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("<%", "{", baseOffset);
c = getChar(false);
} else if (c == ':') {
- expandDefinition("<:", "[", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("<:", "[", baseOffset);
c = getChar(false);
} else {
// Not a digraph
@@ -722,7 +756,7 @@ public class Scanner implements IScanner {
} else if (c == ':') {
c = getChar(false);
if (c == '>') {
- expandDefinition(":>", "]", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition(":>", "]", baseOffset);
c = getChar(false);
} else {
// Not a digraph
@@ -732,10 +766,10 @@ public class Scanner implements IScanner {
} else if (c == '%') {
c = getChar(false);
if (c == '>') {
- expandDefinition("%>", "}", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("%>", "}", baseOffset);
c = getChar(false);
} else if (c == ':') {
- expandDefinition("%:", "#", baseOffset); //$NON-NLS-1$ //$NON-NLS-2$
+ expandDefinition("%:", "#", baseOffset);
c = getChar(false);
} else {
// Not a digraph
@@ -1081,17 +1115,17 @@ public class Scanner implements IScanner {
if( ! firstCharZero && floatingPoint && !(c >= '0' && c <= '9') ){
//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 == '*' ){
- return newToken( IToken.tDOTSTAR, ".*", scannerData.getContextStack().getCurrentContext() ); //$NON-NLS-1$
+ return newToken( IToken.tDOTSTAR, ".*", scannerData.getContextStack().getCurrentContext() );
} else if( c == '.' ){
if( getChar() == '.' )
- return newToken( IToken.tELLIPSIS, "...", scannerData.getContextStack().getCurrentContext() ); //$NON-NLS-1$
+ return newToken( IToken.tELLIPSIS, "...", scannerData.getContextStack().getCurrentContext() );
else
handleProblem( IProblem.SCANNER_BAD_FLOATING_POINT, null, beginOffset, false, true );
} else {
ungetChar( c );
- return newToken( IToken.tDOT, ".", scannerData.getContextStack().getCurrentContext() ); //$NON-NLS-1$
+ return newToken( IToken.tDOT, ".", scannerData.getContextStack().getCurrentContext() );
}
}
} else if (c == 'x') {
@@ -1212,7 +1246,7 @@ public class Scanner implements IScanner {
int tokenType;
String result = buff.toString();
- if( floatingPoint && result.equals(".") ) //$NON-NLS-1$
+ if( floatingPoint && result.equals(".") )
tokenType = IToken.tDOT;
else
tokenType = floatingPoint ? IToken.tFLOATINGPT : IToken.tINTEGER;
@@ -1238,12 +1272,12 @@ public class Scanner implements IScanner {
if( c == '#' )
{
if( skipped )
- handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "# #", beginningOffset, false, true ); //$NON-NLS-1$
+ handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "# #", beginningOffset, false, true );
else
- return newToken( tPOUNDPOUND, "##" ); //$NON-NLS-1$
+ return newToken( tPOUNDPOUND, "##" );
} else if( tokenizingMacroReplacementList ) {
ungetChar( c );
- return newToken( tPOUND, "#" ); //$NON-NLS-1$
+ return newToken( tPOUND, "#" );
}
while (((c >= 'a') && (c <= 'z'))
@@ -1263,7 +1297,7 @@ public class Scanner implements IScanner {
if (directive == null) {
if( scannerExtension.canHandlePreprocessorDirective( token ) )
scannerExtension.handlePreprocessorDirective( token, getRestOfPreprocessorLine() );
- StringBuffer buffer = new StringBuffer( "#"); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer( "#");
buffer.append( token );
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
} else {
@@ -1320,8 +1354,8 @@ public class Scanner implements IScanner {
if( isLimitReached() )
handleCompletionOnExpression( expression );
- if (expression.trim().equals("")) //$NON-NLS-1$
- handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#if", beginningOffset, false, true ); //$NON-NLS-1$
+ if (expression.trim().equals(""))
+ handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#if", beginningOffset, false, true );
boolean expressionEvalResult = false;
@@ -1355,9 +1389,9 @@ public class Scanner implements IScanner {
if( isLimitReached() )
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 );
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
}
@@ -1415,8 +1449,8 @@ public class Scanner implements IScanner {
handleCompletionOnExpression( elifExpression );
- if (elifExpression.equals("")) //$NON-NLS-1$
- handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#elif", beginningOffset, false, true ); //$NON-NLS-1$
+ if (elifExpression.equals(""))
+ handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, "#elif", beginningOffset, false, true );
boolean elsifResult = false;
if( scannerData.getBranchTracker().queryCurrentBranchForElif() )
@@ -1467,15 +1501,15 @@ public class Scanner implements IScanner {
case PreprocessorDirectives.BLANK :
String remainderOfLine =
getRestOfPreprocessorLine().trim();
- if (!remainderOfLine.equals("")) { //$NON-NLS-1$
- StringBuffer buffer = new StringBuffer( "# "); //$NON-NLS-1$
+ if (!remainderOfLine.equals("")) {
+ StringBuffer buffer = new StringBuffer( "# ");
buffer.append( remainderOfLine );
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true);
}
c = getChar();
continue;
default :
- StringBuffer buffer = new StringBuffer( "# "); //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer( "# ");
buffer.append( token );
handleProblem( IProblem.PREPROCESSOR_INVALID_DIRECTIVE, buffer.toString(), beginningOffset, false, true );
}
@@ -1490,51 +1524,51 @@ public class Scanner implements IScanner {
case ':' :
return newToken(
IToken.tCOLONCOLON,
- "::", //$NON-NLS-1$
+ "::",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tCOLON,
- ":", //$NON-NLS-1$
+ ":",
scannerData.getContextStack().getCurrentContext());
}
case ';' :
- return newToken(IToken.tSEMI, ";", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tSEMI, ";", scannerData.getContextStack().getCurrentContext());
case ',' :
- return newToken(IToken.tCOMMA, ",", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tCOMMA, ",", scannerData.getContextStack().getCurrentContext());
case '?' :
- return newToken(IToken.tQUESTION, "?", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tQUESTION, "?", scannerData.getContextStack().getCurrentContext());
case '(' :
- return newToken(IToken.tLPAREN, "(", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tLPAREN, "(", scannerData.getContextStack().getCurrentContext());
case ')' :
- return newToken(IToken.tRPAREN, ")", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tRPAREN, ")", scannerData.getContextStack().getCurrentContext());
case '[' :
- return newToken(IToken.tLBRACKET, "[", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tLBRACKET, "[", scannerData.getContextStack().getCurrentContext());
case ']' :
- return newToken(IToken.tRBRACKET, "]", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tRBRACKET, "]", scannerData.getContextStack().getCurrentContext());
case '{' :
- return newToken(IToken.tLBRACE, "{", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tLBRACE, "{", scannerData.getContextStack().getCurrentContext());
case '}' :
- return newToken(IToken.tRBRACE, "}", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tRBRACE, "}", scannerData.getContextStack().getCurrentContext());
case '+' :
c = getChar();
switch (c) {
case '=' :
return newToken(
IToken.tPLUSASSIGN,
- "+=", //$NON-NLS-1$
+ "+=",
scannerData.getContextStack().getCurrentContext());
case '+' :
return newToken(
IToken.tINCR,
- "++", //$NON-NLS-1$
+ "++",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tPLUS,
- "+", //$NON-NLS-1$
+ "+",
scannerData.getContextStack().getCurrentContext());
}
case '-' :
@@ -1543,12 +1577,12 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tMINUSASSIGN,
- "-=", //$NON-NLS-1$
+ "-=",
scannerData.getContextStack().getCurrentContext());
case '-' :
return newToken(
IToken.tDECR,
- "--", //$NON-NLS-1$
+ "--",
scannerData.getContextStack().getCurrentContext());
case '>' :
c = getChar();
@@ -1556,20 +1590,20 @@ public class Scanner implements IScanner {
case '*' :
return newToken(
IToken.tARROWSTAR,
- "->*", //$NON-NLS-1$
+ "->*",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tARROW,
- "->", //$NON-NLS-1$
+ "->",
scannerData.getContextStack().getCurrentContext());
}
default :
ungetChar(c);
return newToken(
IToken.tMINUS,
- "-", //$NON-NLS-1$
+ "-",
scannerData.getContextStack().getCurrentContext());
}
case '*' :
@@ -1578,13 +1612,13 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tSTARASSIGN,
- "*=", //$NON-NLS-1$
+ "*=",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tSTAR,
- "*", //$NON-NLS-1$
+ "*",
scannerData.getContextStack().getCurrentContext());
}
case '%' :
@@ -1593,13 +1627,13 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tMODASSIGN,
- "%=", //$NON-NLS-1$
+ "%=",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tMOD,
- "%", //$NON-NLS-1$
+ "%",
scannerData.getContextStack().getCurrentContext());
}
case '^' :
@@ -1608,13 +1642,13 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tXORASSIGN,
- "^=", //$NON-NLS-1$
+ "^=",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tXOR,
- "^", //$NON-NLS-1$
+ "^",
scannerData.getContextStack().getCurrentContext());
}
case '&' :
@@ -1623,18 +1657,18 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tAMPERASSIGN,
- "&=", //$NON-NLS-1$
+ "&=",
scannerData.getContextStack().getCurrentContext());
case '&' :
return newToken(
IToken.tAND,
- "&&", //$NON-NLS-1$
+ "&&",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tAMPER,
- "&", //$NON-NLS-1$
+ "&",
scannerData.getContextStack().getCurrentContext());
}
case '|' :
@@ -1643,35 +1677,35 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tBITORASSIGN,
- "|=", //$NON-NLS-1$
+ "|=",
scannerData.getContextStack().getCurrentContext());
case '|' :
return newToken(
IToken.tOR,
- "||", //$NON-NLS-1$
+ "||",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tBITOR,
- "|", //$NON-NLS-1$
+ "|",
scannerData.getContextStack().getCurrentContext());
}
case '~' :
- return newToken(IToken.tCOMPL, "~", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tCOMPL, "~", scannerData.getContextStack().getCurrentContext());
case '!' :
c = getChar();
switch (c) {
case '=' :
return newToken(
IToken.tNOTEQUAL,
- "!=", //$NON-NLS-1$
+ "!=",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tNOT,
- "!", //$NON-NLS-1$
+ "!",
scannerData.getContextStack().getCurrentContext());
}
case '=' :
@@ -1680,13 +1714,13 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tEQUAL,
- "==", //$NON-NLS-1$
+ "==",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tASSIGN,
- "=", //$NON-NLS-1$
+ "=",
scannerData.getContextStack().getCurrentContext());
}
case '<' :
@@ -1698,25 +1732,25 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tSHIFTLASSIGN,
- "<<=", //$NON-NLS-1$
+ "<<=",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tSHIFTL,
- "<<", //$NON-NLS-1$
+ "<<",
scannerData.getContextStack().getCurrentContext());
}
case '=' :
return newToken(
IToken.tLTEQUAL,
- "<=", //$NON-NLS-1$
+ "<=",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
if( forInclusion )
temporarilyReplaceDefinitionsMap();
- return newToken(IToken.tLT, "<", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tLT, "<", scannerData.getContextStack().getCurrentContext());
}
case '>' :
c = getChar();
@@ -1727,25 +1761,25 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tSHIFTRASSIGN,
- ">>=", //$NON-NLS-1$
+ ">>=",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tSHIFTR,
- ">>", //$NON-NLS-1$
+ ">>",
scannerData.getContextStack().getCurrentContext());
}
case '=' :
return newToken(
IToken.tGTEQUAL,
- ">=", //$NON-NLS-1$
+ ">=",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
if( forInclusion )
restoreDefinitionsMap();
- return newToken(IToken.tGT, ">", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tGT, ">", scannerData.getContextStack().getCurrentContext());
}
case '.' :
c = getChar();
@@ -1756,7 +1790,7 @@ public class Scanner implements IScanner {
case '.' :
return newToken(
IToken.tELLIPSIS,
- "...", //$NON-NLS-1$
+ "...",
scannerData.getContextStack().getCurrentContext());
default :
break;
@@ -1765,13 +1799,13 @@ public class Scanner implements IScanner {
case '*' :
return newToken(
IToken.tDOTSTAR,
- ".*", //$NON-NLS-1$
+ ".*",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tDOT,
- ".", //$NON-NLS-1$
+ ".",
scannerData.getContextStack().getCurrentContext());
}
break;
@@ -1789,13 +1823,13 @@ public class Scanner implements IScanner {
case '=' :
return newToken(
IToken.tDIVASSIGN,
- "/=", //$NON-NLS-1$
+ "/=",
scannerData.getContextStack().getCurrentContext());
default :
ungetChar(c);
return newToken(
IToken.tDIV,
- "/", //$NON-NLS-1$
+ "/",
scannerData.getContextStack().getCurrentContext());
}
default :
@@ -1838,9 +1872,9 @@ public class Scanner implements IScanner {
int completionPoint = expression.length() + 2;
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());
IToken lastToken = null;
@@ -1883,7 +1917,7 @@ public class Scanner implements IScanner {
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
@@ -1948,7 +1982,7 @@ public class Scanner implements IScanner {
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 );
case ',' :
if (tokenImage.length() > 0) throw endOfMacroToken;
- return newToken(IToken.tCOMMA, ",", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tCOMMA, ",", scannerData.getContextStack().getCurrentContext());
case '(' :
if (tokenImage.length() > 0) throw endOfMacroToken;
- return newToken(IToken.tLPAREN, "(", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tLPAREN, "(", scannerData.getContextStack().getCurrentContext());
case ')' :
if (tokenImage.length() > 0) throw endOfMacroToken;
- return newToken(IToken.tRPAREN, ")", scannerData.getContextStack().getCurrentContext()); //$NON-NLS-1$
+ return newToken(IToken.tRPAREN, ")", scannerData.getContextStack().getCurrentContext());
case '/' :
if (tokenImage.length() > 0) throw endOfMacroToken;
c = getChar();
@@ -2231,7 +2265,7 @@ public class Scanner implements IScanner {
if( scannerData.getParserMode() == ParserMode.QUICK_PARSE )
{
- if( expression.trim().equals( "0" ) ) //$NON-NLS-1$
+ if( expression.trim().equals( "0" ) )
return false;
return true;
@@ -2275,7 +2309,7 @@ public class Scanner implements IScanner {
protected void skipOverSinglelineComment() throws ScannerException, EndOfFileException {
- StringBuffer comment = new StringBuffer("//"); //$NON-NLS-1$
+ StringBuffer comment = new StringBuffer("//");
int c;
loop:
@@ -2298,7 +2332,7 @@ public class Scanner implements IScanner {
protected boolean skipOverMultilineComment() throws ScannerException, EndOfFileException {
int state = 0;
boolean encounteredNewline = false;
- StringBuffer comment = new StringBuffer("/*"); //$NON-NLS-1$
+ StringBuffer comment = new StringBuffer("/*");
// simple state machine to handle multi-line comments
// state 0 == no end of comment in site
// state 1 == encountered *, expecting /
@@ -2337,7 +2371,7 @@ public class Scanner implements IScanner {
}
protected void poundInclude( int beginningOffset, int startLine ) throws ScannerException, EndOfFileException {
- StringBuffer potentialErrorLine = new StringBuffer( "#include "); //$NON-NLS-1$
+ StringBuffer potentialErrorLine = new StringBuffer( "#include ");
skipOverWhitespace();
int baseOffset = lastContext.getOffset() - lastContext.undoStackSize();
int nameLine = scannerData.getContextStack().getCurrentLineNumber();
@@ -2348,7 +2382,7 @@ public class Scanner implements IScanner {
int startOffset = baseOffset;
int endOffset = baseOffset;
- if (! includeLine.equals("")) { //$NON-NLS-1$
+ if (! includeLine.equals("")) {
Scanner helperScanner = new Scanner(
new StringReader(includeLine),
null,
@@ -2429,7 +2463,7 @@ public class Scanner implements IScanner {
i =
scannerData.getASTFactory().createInclusion(
f,
- "", //$NON-NLS-1$
+ "",
!useIncludePath,
beginningOffset,
startLine,
@@ -2481,7 +2515,7 @@ public class Scanner implements IScanner {
protected List tokenizeReplacementString( int beginning, String key, String replacementString, List parameterIdentifiers )
{
List macroReplacementTokens = new ArrayList();
- if( replacementString.trim().equals( "" ) ) //$NON-NLS-1$
+ if( replacementString.trim().equals( "" ) )
return macroReplacementTokens;
IScanner helperScanner=null;
try {
@@ -2602,7 +2636,7 @@ public class Scanner implements IScanner {
String parameters = buffer.toString();
// replace StringTokenizer later -- not performant
- StringTokenizer tokenizer = new StringTokenizer(parameters, ","); //$NON-NLS-1$
+ StringTokenizer tokenizer = new StringTokenizer(parameters, ",");
ArrayList parameterIdentifiers =
new ArrayList(tokenizer.countTokens());
while (tokenizer.hasMoreTokens()) {
@@ -2615,7 +2649,7 @@ public class Scanner implements IScanner {
String replacementString = getRestOfPreprocessorLine();
- macroReplacementTokens = ( ! replacementString.equals( "" ) ) ? //$NON-NLS-1$
+ macroReplacementTokens = ( ! replacementString.equals( "" ) ) ?
tokenizeReplacementString( beginning, key, replacementString, parameterIdentifiers ) :
EMPTY_LIST;
@@ -2623,7 +2657,7 @@ public class Scanner implements IScanner {
fullSignature.append( key );
fullSignature.append( '(');
fullSignature.append( parameters );
- fullSignature.append( ") "); //$NON-NLS-1$
+ fullSignature.append( ") ");
fullSignature.append( replacementString );
descriptor = new FunctionMacroDescriptor(
key,
@@ -2638,8 +2672,8 @@ public class Scanner implements IScanner {
}
else if ((c == '\n') || (c == '\r'))
{
- checkValidMacroRedefinition(key, previousDefinition, "", beginning); //$NON-NLS-1$
- addDefinition( key, "" ); //$NON-NLS-1$
+ checkValidMacroRedefinition(key, previousDefinition, "", beginning);
+ addDefinition( key, "" );
}
else if ((c == ' ') || (c == '\t') ) {
// this is a simple definition
@@ -2657,33 +2691,33 @@ public class Scanner implements IScanner {
if (c == '/') // one line comment
{
skipOverSinglelineComment();
- checkValidMacroRedefinition(key, previousDefinition, "", beginning); //$NON-NLS-1$
- addDefinition(key, ""); //$NON-NLS-1$
+ checkValidMacroRedefinition(key, previousDefinition, "", beginning);
+ addDefinition(key, "");
} else if (c == '*') // multi-line comment
{
if (skipOverMultilineComment()) {
// we have gone over a newline
// therefore, this symbol was defined to an empty string
- checkValidMacroRedefinition(key, previousDefinition, "", beginning); //$NON-NLS-1$
- addDefinition(key, ""); //$NON-NLS-1$
+ checkValidMacroRedefinition(key, previousDefinition, "", beginning);
+ addDefinition(key, "");
} else {
String value = getRestOfPreprocessorLine();
- checkValidMacroRedefinition(key, previousDefinition, "", beginning); //$NON-NLS-1$
+ checkValidMacroRedefinition(key, previousDefinition, "", beginning);
addDefinition(key, value);
}
} else {
// this is not a comment
// it is a bad statement
potentialErrorMessage.append( key );
- potentialErrorMessage.append( " /"); //$NON-NLS-1$
+ potentialErrorMessage.append( " /");
potentialErrorMessage.append( getRestOfPreprocessorLine() );
handleProblem( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN, potentialErrorMessage.toString(), beginning, false, true );
return;
}
} else {
potentialErrorMessage = new StringBuffer();
- potentialErrorMessage.append( "#define"); //$NON-NLS-1$
+ potentialErrorMessage.append( "#define");
potentialErrorMessage.append( key );
potentialErrorMessage.append( (char)c );
potentialErrorMessage.append( getRestOfPreprocessorLine() );
@@ -2798,7 +2832,7 @@ public class Scanner implements IScanner {
buffer.append('\"');
break;
case IToken.tLSTRING :
- buffer.append( "L\""); //$NON-NLS-1$
+ buffer.append( "L\"");
buffer.append(t.getImage());
buffer.append('\"');
break;
@@ -2958,7 +2992,7 @@ public class Scanner implements IScanner {
buffer.append('\"');
break;
case IToken.tLSTRING:
- buffer.append("L\""); //$NON-NLS-1$
+ buffer.append("L\"");
buffer.append(t.getImage());
buffer.append('\"');
break;
@@ -2987,7 +3021,7 @@ public class Scanner implements IScanner {
if( t.getType() != tPOUNDPOUND && ! pastingNext )
if (i < (numberOfTokens-1)) // Do not append to the last one
- buffer.append( " " ); //$NON-NLS-1$
+ buffer.append( " " );
}
String finalString = buffer.toString();
try
@@ -3013,7 +3047,7 @@ public class Scanner implements IScanner {
}
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() );
scannerData.getLogService().traceLog( logMessage.toString() );
}
@@ -3034,8 +3068,8 @@ public class Scanner implements IScanner {
c = getChar();
if (c != ')')
{
- handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, "defined()", o, false, true ); //$NON-NLS-1$
- return "0"; //$NON-NLS-1$
+ handleProblem( IProblem.PREPROCESSOR_MACRO_USAGE_ERROR, "defined()", o, false, true );
+ return "0";
}
}
else
@@ -3045,9 +3079,9 @@ public class Scanner implements IScanner {
}
if (getDefinition(definitionIdentifier) != null)
- return "1"; //$NON-NLS-1$
+ return "1";
- return "0"; //$NON-NLS-1$
+ return "0";
}
public void setThrowExceptionOnBadCharacterRead( boolean throwOnBad ){
@@ -3093,55 +3127,11 @@ public class Scanner implements IScanner {
*/
public boolean isOnTopContext() {
return ( scannerData.getContextStack().getCurrentContext() == scannerData.getContextStack().getTopContext() );
- }
-
- 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
+ } /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.IFilenameProvider#getCurrentFilename()
*/
- private String reconcilePath(String originalPath ) {
- if( originalPath == null ) return null;
- 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();
+ public char[] getCurrentFilename() {
+ return getCurrentFile().toCharArray();
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerProblemFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerProblemFactory.java
index 1e179f94f4b..e38ac68f3ee 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerProblemFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerProblemFactory.java
@@ -22,8 +22,9 @@ import org.eclipse.cdt.internal.core.parser.problem.*;
*/
public class ScannerProblemFactory extends BaseProblemFactory implements IProblemFactory
{
- protected static Map errorMessages = new HashMap();
+ protected static final Map errorMessages;
static {
+ errorMessages = new HashMap();
errorMessages.put(
new Integer(IProblem.PREPROCESSOR_POUND_ERROR),
"#error encountered with text: ");
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/TokenDuple.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/TokenDuple.java
index de59d8e9ea7..a26e95b049d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/TokenDuple.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/token/TokenDuple.java
@@ -28,6 +28,7 @@ public class TokenDuple implements ITokenDuple {
public TokenDuple( IToken first, IToken last )
{
+// assert ( first != null && last != null ) : this;
firstToken = first;
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();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index 6fbd31763ce..c4e8c69ecf0 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -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
Fixed missing key for Working Set name and content on
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
index fc0628343f1..50ea988c56c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
@@ -189,7 +189,6 @@ public abstract class FindAction extends Action {
}
catch (ParseError er){
ParseErrorKind per = er.getErrorKind();
- int val = per.getEnumValue();
er.printStackTrace();
}
catch (Exception ex){