mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
initial work for IProblemBindings
This commit is contained in:
parent
3ba300630d
commit
2713b4695c
8 changed files with 327 additions and 351 deletions
|
@ -34,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
|
@ -791,5 +792,86 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertInstances( collector, g, 2 );
|
||||
assertInstances( collector, h, 2 );
|
||||
}
|
||||
|
||||
public void testProblem_AmbiguousInParent() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "class P1 { public: int x; }; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "class P2 { public: int x; }; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "class B : public P1, public P2 {}; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "void main() { \n" ); //$NON-NLS-1$
|
||||
buffer.append( " B * b = new B(); \n" ); //$NON-NLS-1$
|
||||
buffer.append( " b->x; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "} \n" ); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
CPPVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
IProblemBinding x = (IProblemBinding) collector.getName( 12 ).resolveBinding();
|
||||
assertEquals( x.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP );
|
||||
}
|
||||
|
||||
public void testVirtualParentLookup() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "class D { public: int x; }; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "class C : public virtual D {}; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "class B : public virtual D {}; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "class A : public B, public C {}; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "void main() { \n" ); //$NON-NLS-1$
|
||||
buffer.append( " A * a = new A(); \n" ); //$NON-NLS-1$
|
||||
buffer.append( " a->x; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "} \n" ); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
CPPVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 15 );
|
||||
|
||||
ICPPClassType D = (ICPPClassType) collector.getName( 0 ).resolveBinding();
|
||||
ICPPField x = (ICPPField) collector.getName( 1 ).resolveBinding();
|
||||
ICPPClassType C = (ICPPClassType) collector.getName( 2 ).resolveBinding();
|
||||
ICPPClassType B = (ICPPClassType) collector.getName( 4 ).resolveBinding();
|
||||
ICPPClassType A = (ICPPClassType) collector.getName( 6 ).resolveBinding();
|
||||
|
||||
assertInstances( collector, D, 3 );
|
||||
assertInstances( collector, C, 2 );
|
||||
assertInstances( collector, B, 2 );
|
||||
assertInstances( collector, A, 3 );
|
||||
assertInstances( collector, x, 2 );
|
||||
}
|
||||
|
||||
public void testAmbiguousVirtualParentLookup() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( "class D { public: int x; }; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "class C : public D {}; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "class B : public D {}; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "class A : public B, public C {}; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "void main() { \n" ); //$NON-NLS-1$
|
||||
buffer.append( " A * a = new A(); \n" ); //$NON-NLS-1$
|
||||
buffer.append( " a->x; \n" ); //$NON-NLS-1$
|
||||
buffer.append( "} \n" ); //$NON-NLS-1$
|
||||
|
||||
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
CPPVisitor.visitTranslationUnit( tu, collector );
|
||||
|
||||
assertEquals( collector.size(), 15 );
|
||||
|
||||
ICPPClassType D = (ICPPClassType) collector.getName( 0 ).resolveBinding();
|
||||
ICPPField x1 = (ICPPField) collector.getName( 1 ).resolveBinding();
|
||||
ICPPClassType C = (ICPPClassType) collector.getName( 2 ).resolveBinding();
|
||||
ICPPClassType B = (ICPPClassType) collector.getName( 4 ).resolveBinding();
|
||||
ICPPClassType A = (ICPPClassType) collector.getName( 6 ).resolveBinding();
|
||||
|
||||
IProblemBinding x2 = (IProblemBinding) collector.getName( 14 ).resolveBinding();
|
||||
assertEquals( x2.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP );
|
||||
|
||||
assertInstances( collector, D, 3 );
|
||||
assertInstances( collector, C, 2 );
|
||||
assertInstances( collector, B, 2 );
|
||||
assertInstances( collector, A, 3 );
|
||||
assertInstances( collector, x1, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -387,77 +387,5 @@ public interface IASTProblem extends IASTNode {
|
|||
*/
|
||||
public final static int SYNTAX_ERROR = SYNTAX_RELATED | 0x001;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Name not provided in context that it was required.
|
||||
* Require attributes: none
|
||||
*/
|
||||
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;
|
||||
|
||||
public static final int SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION = SEMANTICS_RELATED | 0x012;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Jan 17, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public interface IProblemBinding extends IBinding {
|
||||
|
||||
/**
|
||||
* Returns the problem id
|
||||
*
|
||||
* @return the problem id
|
||||
*/
|
||||
int getID();
|
||||
|
||||
/**
|
||||
* Answer a localized, human-readable message string which describes the problem.
|
||||
*
|
||||
* @return a localized, human-readable message string which describes the problem
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
/*
|
||||
* 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 = 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 = 0x002;
|
||||
|
||||
/**
|
||||
* Name not provided in context that it was required.
|
||||
* Require attributes: none
|
||||
*/
|
||||
public final static int SEMANTIC_NAME_NOT_PROVIDED = 0x003;
|
||||
|
||||
/**
|
||||
* Invalid overload of a particular name.
|
||||
* Required attributes: A_SYMBOL_NAME
|
||||
* @see #A_SYMBOL_NAME
|
||||
*/
|
||||
public static final int SEMANTIC_INVALID_OVERLOAD = 0x004;
|
||||
|
||||
/**
|
||||
* Invalid using directive.
|
||||
* Required attributes: A_NAMESPACE_NAME
|
||||
* @see #A_NAMESPACE_NAME
|
||||
*/
|
||||
public static final int SEMANTIC_INVALID_USING = 0x005;
|
||||
|
||||
/**
|
||||
* Ambiguous lookup for given name.
|
||||
* Required attributes: A_SYMBOL_NAME
|
||||
* @see #A_SYMBOL_NAME
|
||||
*/
|
||||
public static final int SEMANTIC_AMBIGUOUS_LOOKUP = 0x006;
|
||||
|
||||
/**
|
||||
* Invalid type provided
|
||||
* Required attribugtes: A_TYPE_NAME
|
||||
* @see #A_TYPE_NAME
|
||||
*/
|
||||
public static final int SEMANTIC_INVALID_TYPE = 0x007;
|
||||
|
||||
public static final int SEMANTIC_CIRCULAR_INHERITANCE = 0x008;
|
||||
|
||||
public static final int SEMANTIC_INVALID_TEMPLATE = 0x009;
|
||||
|
||||
public static final int SEMANTIC_BAD_VISIBILITY = 0x00A;
|
||||
|
||||
public static final int SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION = 0x00B;
|
||||
|
||||
public static final int SEMANTIC_INVALID_TEMPLATE_ARGUMENT = 0x00C;
|
||||
|
||||
public static final int SEMANTIC_INVALID_TEMPLATE_PARAMETER = 0x00D;
|
||||
|
||||
public static final int SEMANTIC_REDECLARED_TEMPLATE_PARAMETER = 0x00E;
|
||||
|
||||
public static final int SEMANTIC_INVALID_CONVERSION_TYPE = 0x00F;
|
||||
|
||||
public static final int SEMANTIC_MALFORMED_EXPRESSION = 0x010;
|
||||
|
||||
public static final int SEMANTIC_ILLFORMED_FRIEND = 0x011;
|
||||
|
||||
public static final int SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION = 0x012;
|
||||
public static final int LAST_PROBLEM = SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION;
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on Jan 17, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class ProblemBinding implements IProblemBinding {
|
||||
private final static String EMPTY_NAME = ""; //$NON-NLS-1$
|
||||
private final static char[] EMPTY_NAME_ARRAY = new char[0];
|
||||
|
||||
private final int id;
|
||||
private final char [] arg;
|
||||
|
||||
private String message = null;
|
||||
|
||||
public ProblemBinding( int id, char [] arg ){
|
||||
this.id = id;
|
||||
this.arg = arg;
|
||||
}
|
||||
|
||||
protected final static String PROBLEM_PATTERN = "BaseProblemFactory.problemPattern"; //$NON-NLS-1$
|
||||
protected static final String [] errorMessages;
|
||||
static {
|
||||
errorMessages = new String [ IProblemBinding.LAST_PROBLEM ];
|
||||
errorMessages[SEMANTIC_UNIQUE_NAME_PREDEFINED - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.uniqueNamePredefined"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_NAME_NOT_FOUND - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.nameNotFound"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_NAME_NOT_PROVIDED - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.nameNotProvided"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_INVALID_CONVERSION_TYPE - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.invalidConversionType"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_MALFORMED_EXPRESSION - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.malformedExpression"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_AMBIGUOUS_LOOKUP - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.ambiguousLookup"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_INVALID_TYPE - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidType"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_CIRCULAR_INHERITANCE - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.circularInheritance"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_INVALID_OVERLOAD - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidOverload"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_INVALID_TEMPLATE - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplate"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_INVALID_USING - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidUsing"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_BAD_VISIBILITY - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.badVisibility"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.unableToResolveFunction"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_INVALID_TEMPLATE_ARGUMENT - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateArgument"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_INVALID_TEMPLATE_PARAMETER - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateParameter"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_REDECLARED_TEMPLATE_PARAMETER - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.redeclaredTemplateParameter"); //$NON-NLS-1$
|
||||
errorMessages[SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION - 1]= ParserMessages.getString("ASTProblemFactory.error.semantic.pst.recursiveTemplateInstantiation"); //$NON-NLS-1$
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IProblemBinding#getID()
|
||||
*/
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IProblemBinding#getMessage()
|
||||
*/
|
||||
public String getMessage() {
|
||||
if (message != null)
|
||||
return message;
|
||||
|
||||
String msg = ( id >= 0 && id < LAST_PROBLEM ) ? errorMessages[ id - 1 ] : ""; //$NON-NLS-1$
|
||||
|
||||
if (arg != null) {
|
||||
msg = MessageFormat.format(msg, new Object[] { new String(arg) });
|
||||
}
|
||||
|
||||
Object[] args = new Object[] { msg, new String("") /*file*/, new Integer(0) /*line*/}; //$NON-NLS-1$
|
||||
message = ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
|
||||
return message;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return EMPTY_NAME;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
|
||||
*/
|
||||
public char[] getNameCharArray() {
|
||||
return EMPTY_NAME_ARRAY;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
|
||||
*/
|
||||
public IScope getScope() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
|
||||
*/
|
||||
public IASTNode getPhysicalNode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -112,95 +112,6 @@ public class CASTProblem extends CASTNode implements IASTProblem {
|
|||
protected static final Map errorMessages;
|
||||
static {
|
||||
errorMessages = new HashMap();
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.uniqueNamePredefined")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_NAME_NOT_FOUND),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.nameNotFound")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_NAME_NOT_PROVIDED),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.nameNotProvided")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_CONVERSION_TYPE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.invalidConversionType")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_MALFORMED_EXPRESSION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.malformedExpression")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_AMBIGUOUS_LOOKUP),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.ambiguousLookup")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_TYPE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidType")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_CIRCULAR_INHERITANCE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.circularInheritance")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_OVERLOAD),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidOverload")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_TEMPLATE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplate")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_USING),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidUsing")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_BAD_VISIBILITY),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.badVisibility")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.unableToResolveFunction")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateArgument")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_INVALID_TEMPLATE_PARAMETER),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_REDECLARED_TEMPLATE_PARAMETER),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.redeclaredTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.recursiveTemplateInstantiation")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_POUND_ERROR),
|
||||
|
|
|
@ -111,95 +111,6 @@ public class CPPASTProblem extends CPPASTNode implements IASTProblem {
|
|||
protected static final Map errorMessages;
|
||||
static {
|
||||
errorMessages = new HashMap();
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.uniqueNamePredefined")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_NAME_NOT_FOUND),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.nameNotFound")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_NAME_NOT_PROVIDED),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.nameNotProvided")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_CONVERSION_TYPE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.invalidConversionType")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_MALFORMED_EXPRESSION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.malformedExpression")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_AMBIGUOUS_LOOKUP),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.ambiguousLookup")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_TYPE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidType")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_CIRCULAR_INHERITANCE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.circularInheritance")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_OVERLOAD),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidOverload")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_TEMPLATE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplate")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_USING),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidUsing")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_BAD_VISIBILITY),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.badVisibility")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.unableToResolveFunction")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateArgument")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_INVALID_TEMPLATE_PARAMETER),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_REDECLARED_TEMPLATE_PARAMETER),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.redeclaredTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.recursiveTemplateInstantiation")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_POUND_ERROR),
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
@ -72,6 +73,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
|
||||
import org.eclipse.cdt.internal.core.parser.pst.ITypeInfo;
|
||||
|
||||
|
@ -99,6 +101,7 @@ public class CPPSemantics {
|
|||
public Object [] functionParameters;
|
||||
public boolean forUserDefinedConversion;
|
||||
public boolean forUsingDeclaration;
|
||||
public ProblemBinding problem;
|
||||
|
||||
public LookupData( char[] n ){
|
||||
name = n;
|
||||
|
@ -249,9 +252,12 @@ public class CPPSemantics {
|
|||
//2: lookup
|
||||
lookup( data, name );
|
||||
|
||||
if( data.problem != null )
|
||||
return data.problem;
|
||||
|
||||
//3: resolve ambiguities
|
||||
IBinding binding = resolveAmbiguities( data, name );
|
||||
if( binding != null && data.forDefinition ){
|
||||
if( binding != null && data.forDefinition && !( binding instanceof IProblemBinding ) ){
|
||||
addDefinition( binding, name );
|
||||
}
|
||||
return binding;
|
||||
|
@ -371,14 +377,14 @@ public class CPPSemantics {
|
|||
}
|
||||
}
|
||||
|
||||
if( data.foundItems != null && !data.foundItems.isEmpty() )
|
||||
if( data.problem != null || data.foundItems != null && !data.foundItems.isEmpty() )
|
||||
return;
|
||||
|
||||
if( !data.usingDirectivesOnly && scope instanceof ICPPClassScope ){
|
||||
data.foundItems = lookupInParents( data, (ICPPClassScope) scope );
|
||||
}
|
||||
|
||||
if( data.foundItems != null && !data.foundItems.isEmpty() )
|
||||
if( data.problem != null || data.foundItems != null && !data.foundItems.isEmpty() )
|
||||
return;
|
||||
|
||||
//if still not found, loop and check our containing scope
|
||||
|
@ -433,7 +439,8 @@ public class CPPSemantics {
|
|||
inherited = lookupInParents( data, parent );
|
||||
}
|
||||
} else {
|
||||
//throw new ParserSymbolTableException( ParserSymbolTableException.r_CircularInheritance );
|
||||
data.problem = new ProblemBinding( IProblemBinding.SEMANTIC_CIRCULAR_INHERITANCE, bases[i].getName().toCharArray() );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -444,8 +451,8 @@ public class CPPSemantics {
|
|||
for( int j = 0; j < result.size(); j++ ) {
|
||||
IASTName n = (IASTName) result.get(j);
|
||||
if( !checkAmbiguity( n, inherited ) ){
|
||||
//throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
||||
return null;
|
||||
data.problem = new ProblemBinding( IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, n.toCharArray() );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -781,7 +788,7 @@ public class CPPSemantics {
|
|||
if( type == null ){
|
||||
type = temp;
|
||||
} else {
|
||||
//TODO
|
||||
return new ProblemBinding( IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
|
||||
}
|
||||
} else if( temp instanceof IFunction ){
|
||||
if( fns == null )
|
||||
|
@ -791,7 +798,7 @@ public class CPPSemantics {
|
|||
if( obj == null )
|
||||
obj = temp;
|
||||
else {
|
||||
//TODO
|
||||
return new ProblemBinding( IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -801,17 +808,17 @@ public class CPPSemantics {
|
|||
return type;
|
||||
IScope typeScope = type.getScope();
|
||||
if( obj != null && obj.getScope() != typeScope ){
|
||||
return null;//ambiguous
|
||||
return new ProblemBinding( IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
|
||||
} else if( fns != null ){
|
||||
for( int i = 0; i < fns.size(); i++ ){
|
||||
if( ((IBinding)fns.get(i)).getScope() != typeScope )
|
||||
return null; //ambiguous
|
||||
return new ProblemBinding( IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( fns != null){
|
||||
if( obj != null )
|
||||
return null; //ambiguous
|
||||
return new ProblemBinding( IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
|
||||
return resolveFunction( data, fns );
|
||||
}
|
||||
|
||||
|
@ -1048,7 +1055,7 @@ public class CPPSemantics {
|
|||
|
||||
|
||||
if( ambiguous || bestHasAmbiguousParam ){
|
||||
return null; //TODO throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
|
||||
return new ProblemBinding( IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name );
|
||||
}
|
||||
|
||||
return bestFn;
|
||||
|
|
|
@ -112,95 +112,6 @@ public class ScannerASTProblem extends ASTNode implements IASTProblem {
|
|||
protected static final Map errorMessages;
|
||||
static {
|
||||
errorMessages = new HashMap();
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.uniqueNamePredefined")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_NAME_NOT_FOUND),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.nameNotFound")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_NAME_NOT_PROVIDED),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.nameNotProvided")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_CONVERSION_TYPE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.invalidConversionType")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_MALFORMED_EXPRESSION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.malformedExpression")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_AMBIGUOUS_LOOKUP),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.ambiguousLookup")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_TYPE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidType")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_CIRCULAR_INHERITANCE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.circularInheritance")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_OVERLOAD),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidOverload")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_TEMPLATE),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplate")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_USING),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidUsing")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_BAD_VISIBILITY),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.badVisibility")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.unableToResolveFunction")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateArgument")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_INVALID_TEMPLATE_PARAMETER),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_REDECLARED_TEMPLATE_PARAMETER),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.redeclaredTemplateParameter")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(
|
||||
IASTProblem.SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION),
|
||||
ParserMessages
|
||||
.getString("ASTProblemFactory.error.semantic.pst.recursiveTemplateInstantiation")); //$NON-NLS-1$
|
||||
errorMessages
|
||||
.put(
|
||||
new Integer(IASTProblem.PREPROCESSOR_POUND_ERROR),
|
||||
|
|
Loading…
Add table
Reference in a new issue