1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 06:32:10 +02:00

Bug 312423: Unifies ids for problem bindings and problem types.

This commit is contained in:
Markus Schorn 2010-10-12 13:37:04 +00:00
parent 0dea806506
commit a28e2e0f59
8 changed files with 93 additions and 144 deletions

View file

@ -49,75 +49,22 @@ public interface IProblemBinding extends IBinding, IScope, IType, ISemanticProbl
* Parser Semantic Problems
* All Semantic problems take a char[] as an argument
*/
/**
* Attempt to use a symbol that was not found.
* Require attributes: A_SYMBOL_NAME
*/
public final static int SEMANTIC_NAME_NOT_FOUND = 0x001;
/**
* Invalid overload of a particular name.
* Required attributes: A_SYMBOL_NAME
*/
public static final int SEMANTIC_INVALID_OVERLOAD = 0x002;
/**
* Invalid using directive.
* Required attributes: A_NAMESPACE_NAME
*/
public static final int SEMANTIC_INVALID_USING = 0x003;
/**
* Ambiguous lookup for given name.
* Required attributes: A_SYMBOL_NAME
*/
public static final int SEMANTIC_AMBIGUOUS_LOOKUP = 0x004;
/**
* Invalid type provided
* Required attributes: A_TYPE_NAME
*/
public static final int SEMANTIC_INVALID_TYPE = 0x005;
/**
* circular inheritance was detected for a class
*/
public static final int SEMANTIC_CIRCULAR_INHERITANCE = 0x006;
/**
* the definition for the class/function can not be found
*/
public static final int SEMANTIC_DEFINITION_NOT_FOUND = 0x007;
/**
* the declaration for the K&R style function parameter can not be found
*/
public static final int SEMANTIC_KNR_PARAMETER_DECLARATION_NOT_FOUND = 0x008;
/**
* a label statement can not be found to match a goto statement
*/
public static final int SEMANTIC_LABEL_STATEMENT_NOT_FOUND = 0x009;
/**
* there was a problem creating the scope
*/
public static final int SEMANTIC_BAD_SCOPE = 0x00A;
/**
* invalid redefinition of the name
*/
public static final int SEMANTIC_INVALID_REDEFINITION = 0x00B;
/**
* invalid re-declaration of the name
*/
public static final int SEMANTIC_INVALID_REDECLARATION = 0x00C;
public static final int SEMANTIC_MEMBER_DECLARATION_NOT_FOUND = 0x00D;
public static final int SEMANTIC_RECURSION_IN_LOOKUP = 0x00E;
public final static int SEMANTIC_NAME_NOT_FOUND = BINDING_NOT_FOUND;
public static final int SEMANTIC_INVALID_OVERLOAD = BINDING_INVALID_OVERLOAD;
public static final int SEMANTIC_INVALID_USING = BINDING_INVALID_USING;
public static final int SEMANTIC_AMBIGUOUS_LOOKUP = BINDING_AMBIGUOUS_LOOKUP;
public static final int SEMANTIC_INVALID_TYPE = BINDING_INVALID_TYPE;
public static final int SEMANTIC_CIRCULAR_INHERITANCE = BINDING_CIRCULAR_INHERITANCE;
public static final int SEMANTIC_DEFINITION_NOT_FOUND = BINDING_DEFINITION_NOT_FOUND;
public static final int SEMANTIC_KNR_PARAMETER_DECLARATION_NOT_FOUND = BINDING_KNR_PARAMETER_DECLARATION_NOT_FOUND;
public static final int SEMANTIC_LABEL_STATEMENT_NOT_FOUND = BINDING_LABEL_STATEMENT_NOT_FOUND;
public static final int SEMANTIC_BAD_SCOPE = BINDING_BAD_SCOPE;
public static final int SEMANTIC_INVALID_REDEFINITION = BINDING_INVALID_REDEFINITION;
public static final int SEMANTIC_INVALID_REDECLARATION = BINDING_INVALID_REDECLARATION;
public static final int SEMANTIC_MEMBER_DECLARATION_NOT_FOUND = BINDING_MEMBER_DECLARATION_NOT_FOUND;
public static final int SEMANTIC_RECURSION_IN_LOOKUP = BINDING_RECURSION_IN_LOOKUP;
/** @since 5.1 */
public static final int SEMANTIC_INVALID_TEMPLATE_ARGUMENTS = BINDING_INVALID_TEMPLATE_ARGUMENTS;
/**
* @deprecated, there may be additional problems.
@ -125,9 +72,5 @@ public interface IProblemBinding extends IBinding, IScope, IType, ISemanticProbl
@Deprecated
public static final int LAST_PROBLEM = 0x00E;
/**
* @since 5.1
*/
public static final int SEMANTIC_INVALID_TEMPLATE_ARGUMENTS = 0x00F;
}

View file

@ -12,13 +12,29 @@ package org.eclipse.cdt.core.dom.ast;
/**
* Base interface for all semantic problems: {@link IProblemBinding}, {@link IProblemType}
* mstodo IProblemScope.
*
* @since 5.3
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ISemanticProblem {
int BINDING_NOT_FOUND = 1;
int BINDING_INVALID_OVERLOAD = 2;
int BINDING_INVALID_USING = 3;
int BINDING_AMBIGUOUS_LOOKUP = 4;
int BINDING_INVALID_TYPE = 5;
int BINDING_CIRCULAR_INHERITANCE = 6;
int BINDING_DEFINITION_NOT_FOUND = 7;
int BINDING_KNR_PARAMETER_DECLARATION_NOT_FOUND = 8;
int BINDING_LABEL_STATEMENT_NOT_FOUND = 9;
int BINDING_BAD_SCOPE = 10;
int BINDING_INVALID_REDEFINITION = 11;
int BINDING_INVALID_REDECLARATION = 12;
int BINDING_MEMBER_DECLARATION_NOT_FOUND = 13;
int BINDING_RECURSION_IN_LOOKUP = 14;
int BINDING_INVALID_TEMPLATE_ARGUMENTS = 15;
int BINDING_NO_CLASS = 16;
int TYPE_NO_NAME = 10000;
int TYPE_UNRESOLVED_NAME = 10001;
int TYPE_AUTO_FOR_NON_STATIC_FIELD = 10002;

View file

@ -82,39 +82,6 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
candidateBindings= foundBindings;
}
private String getMessagePattern() {
String result= ParserMessages.getProblemPattern(this);
if (result != null)
return result;
// mstodo remove after reworking problem ids.
String key= getMessageKey();
if (key != null)
return ParserMessages.getString(key);
return ""; //$NON-NLS-1$
}
private String getMessageKey() {
switch(id) {
case SEMANTIC_NAME_NOT_FOUND: return "ASTProblemFactory.error.semantic.nameNotFound"; //$NON-NLS-1$
case SEMANTIC_AMBIGUOUS_LOOKUP: return "ASTProblemFactory.error.semantic.pst.ambiguousLookup"; //$NON-NLS-1$
case SEMANTIC_INVALID_TYPE: return "ASTProblemFactory.error.semantic.pst.invalidType"; //$NON-NLS-1$
case SEMANTIC_CIRCULAR_INHERITANCE: return "ASTProblemFactory.error.semantic.pst.circularInheritance"; //$NON-NLS-1$
case SEMANTIC_INVALID_OVERLOAD: return "ASTProblemFactory.error.semantic.pst.invalidOverload"; //$NON-NLS-1$
case SEMANTIC_INVALID_USING: return "ASTProblemFactory.error.semantic.pst.invalidUsing"; //$NON-NLS-1$
case SEMANTIC_DEFINITION_NOT_FOUND: return "ASTProblemFactory.error.semantic.dom.definitionNotFound"; //$NON-NLS-1$
case SEMANTIC_KNR_PARAMETER_DECLARATION_NOT_FOUND: return "ASTProblemFactory.error.semantic.dom.knrParameterDeclarationNotFound"; //$NON-NLS-1$
case SEMANTIC_LABEL_STATEMENT_NOT_FOUND: return "ASTProblemFactory.error.semantic.dom.labelStatementNotFound"; //$NON-NLS-1$
case SEMANTIC_INVALID_REDEFINITION: return "ASTProblemFactory.error.semantic.dom.invalidRedefinition"; //$NON-NLS-1$
case SEMANTIC_INVALID_REDECLARATION: return "ASTProblemFactory.error.semantic.dom.invalidRedeclaration"; //$NON-NLS-1$
case SEMANTIC_BAD_SCOPE: return "ASTProblemFactory.error.semantic.dom.badScope"; //$NON-NLS-1$
case SEMANTIC_RECURSION_IN_LOOKUP: return "ASTProblemFactory.error.semantic.dom.recursionInResolution"; //$NON-NLS-1$
case SEMANTIC_MEMBER_DECLARATION_NOT_FOUND: return "ASTProblemFactory.error.semantic.dom.memberDeclNotFound"; //$NON-NLS-1$
case SEMANTIC_INVALID_TEMPLATE_ARGUMENTS: return "ASTProblemFactory.error.semantic.dom.invalidTemplateArgs"; //$NON-NLS-1$
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IProblemBinding#getID()
*/
@ -129,7 +96,10 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I
if (message != null)
return message;
String msg = getMessagePattern();
String msg = ParserMessages.getProblemPattern(this);
if (msg == null)
return ""; //$NON-NLS-1$
if (arg == null && node instanceof IASTName)
arg= ((IASTName) node).toCharArray();

View file

@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
@ -53,8 +53,8 @@ public class CCompositeTypeScope extends CScope implements ICCompositeTypeScope
IASTName [] names = action.getNames();
IBinding [] result = null;
for( int i = 0; i < names.length; i++ ){
IBinding b = names[i].resolveBinding();
for (IASTName astName : names) {
IBinding b = astName.resolveBinding();
if( b == null ) continue;
try {
if( b.getScope() == this )
@ -72,7 +72,7 @@ public class CCompositeTypeScope extends CScope implements ICCompositeTypeScope
if (binding instanceof ICompositeType)
return (ICompositeType) binding;
return new CStructure.CStructureProblem( compSpec.getName(), IProblemBinding.SEMANTIC_BAD_SCOPE, compSpec.getName().toCharArray() );
return new CStructure.CStructureProblem(compSpec.getName(), ISemanticProblem.BINDING_NO_CLASS, compSpec.getName().toCharArray() );
}
@Override
@ -87,8 +87,7 @@ public class CCompositeTypeScope extends CScope implements ICCompositeTypeScope
IASTNode node = members[i];
if (node instanceof IASTSimpleDeclaration) {
IASTDeclarator[] declarators = ((IASTSimpleDeclaration) node).getDeclarators();
for (int j = 0; j < declarators.length; j++) {
IASTDeclarator declarator = declarators[j];
for (IASTDeclarator declarator : declarators) {
IASTName dtorName = ASTQueries.findInnermostDeclarator(declarator).getName();
ASTInternal.addName(this, dtorName);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2009 IBM Corporation and others.
* Copyright (c) 2004, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -12,10 +12,14 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF;
import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType;
import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
@ -36,15 +40,18 @@ public class CPPBaseClause implements ICPPBase, ICPPInternalBase {
public IBinding getBaseClass() {
if (baseClass == null) {
IBinding b = base.getName().resolveBinding();
while (b instanceof ITypedef && ((ITypedef) b).getType() instanceof IBinding) {
b = (IBinding) ((ITypedef) b).getType();
}
if (b instanceof ICPPClassType || b instanceof ICPPTemplateParameter) {
baseClass = b;
} else if (b instanceof IProblemBinding) {
if (b instanceof IProblemBinding) {
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ((IProblemBinding) b).getID());
} else {
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
IType t= null;
if (b instanceof IType) {
t= getNestedType((IType) b, TDEF);
}
if (t instanceof ICPPClassType || t instanceof ICPPTemplateParameter) {
baseClass = (IBinding) t;
} else {
baseClass = new CPPClassType.CPPClassTypeProblem(base.getName(), ISemanticProblem.BINDING_NO_CLASS);
}
}
}
return baseClass;

View file

@ -33,8 +33,8 @@ import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
@ -366,7 +366,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
if (binding instanceof ICPPClassType)
return (ICPPClassType) binding;
return new CPPClassType.CPPClassTypeProblem(name, IProblemBinding.SEMANTIC_BAD_SCOPE, name.toCharArray());
return new CPPClassType.CPPClassTypeProblem(name, ISemanticProblem.BINDING_NO_CLASS, name.toCharArray());
}
/* (non-Javadoc)

View file

@ -76,6 +76,23 @@ public class ParserMessages {
@SuppressWarnings("nls")
private static String getProblemKey(int id) {
switch(id) {
case ISemanticProblem.BINDING_AMBIGUOUS_LOOKUP: return "ISemanticProblem.BINDING_AMBIGUOUS_LOOKUP";
case ISemanticProblem.BINDING_BAD_SCOPE: return "ISemanticProblem.BINDING_BAD_SCOPE";
case ISemanticProblem.BINDING_CIRCULAR_INHERITANCE: return "ISemanticProblem.BINDING_CIRCULAR_INHERITANCE";
case ISemanticProblem.BINDING_DEFINITION_NOT_FOUND: return "ISemanticProblem.BINDING_DEFINITION_NOT_FOUND";
case ISemanticProblem.BINDING_INVALID_OVERLOAD: return "ISemanticProblem.BINDING_INVALID_OVERLOAD";
case ISemanticProblem.BINDING_INVALID_REDECLARATION: return "ISemanticProblem.BINDING_INVALID_REDECLARATION";
case ISemanticProblem.BINDING_INVALID_REDEFINITION: return "ISemanticProblem.BINDING_INVALID_REDEFINITION";
case ISemanticProblem.BINDING_INVALID_TEMPLATE_ARGUMENTS: return "ISemanticProblem.BINDING_INVALID_TEMPLATE_ARGUMENTS";
case ISemanticProblem.BINDING_INVALID_TYPE: return "ISemanticProblem.BINDING_INVALID_TYPE";
case ISemanticProblem.BINDING_INVALID_USING: return "ISemanticProblem.BINDING_INVALID_USING";
case ISemanticProblem.BINDING_KNR_PARAMETER_DECLARATION_NOT_FOUND: return "ISemanticProblem.BINDING_KNR_PARAMETER_DECLARATION_NOT_FOUND";
case ISemanticProblem.BINDING_LABEL_STATEMENT_NOT_FOUND: return "ISemanticProblem.BINDING_LABEL_STATEMENT_NOT_FOUND";
case ISemanticProblem.BINDING_MEMBER_DECLARATION_NOT_FOUND: return "ISemanticProblem.BINDING_MEMBER_DECLARATION_NOT_FOUND";
case ISemanticProblem.BINDING_NO_CLASS: return "ISemanticProblem.BINDING_NO_CLASS";
case ISemanticProblem.BINDING_NOT_FOUND: return "ISemanticProblem.BINDING_NOT_FOUND";
case ISemanticProblem.BINDING_RECURSION_IN_LOOKUP: return "ISemanticProblem.BINDING_RECURSION_IN_LOOKUP";
case ISemanticProblem.TYPE_NO_NAME: return "ISemanticProblem.TYPE_NO_NAME";
case ISemanticProblem.TYPE_UNRESOLVED_NAME: return "ISemanticProblem.TYPE_UNRESOLVED_NAME";
case ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD: return "ISemanticProblem.TYPE_AUTO_FOR_NON_STATIC_FIELD";

View file

@ -44,26 +44,23 @@ ScannerProblemFactory.error.scanner.badCharacter=Bad character sequence encounte
ParserProblemFactory.error.syntax.syntaxError=Syntax error
ASTProblemFactory.error.semantic.nameNotFound=Attempt to use symbol failed: {0}
BaseProblemFactory.problemPattern={0} in file: {1}:{2, number, integer}
ASTProblemFactory.error.semantic.pst.ambiguousLookup=Ambiguity encountered during lookup: {0}
ASTProblemFactory.error.semantic.pst.invalidType=Invalid type encountered in: {0}
ASTProblemFactory.error.semantic.pst.circularInheritance=Circular inheritance encountered in: {0}
ASTProblemFactory.error.semantic.pst.invalidOverload=Invalid overload of the name: {0}
ASTProblemFactory.error.semantic.pst.invalidUsing=Invalid using directive/declaration: {0}
ASTProblemFactory.error.semantic.dom.definitionNotFound=A definition was not found for {0}
ASTProblemFactory.error.semantic.dom.knrParameterDeclarationNotFound=A declaration was not found for the K&R parameter {0}
ASTProblemFactory.error.semantic.dom.labelStatementNotFound=A label statement was not found for the name {0}
ASTProblemFactory.error.semantic.dom.invalidRedefinition=Invalid redefinition of the name {0}
ASTProblemFactory.error.semantic.dom.invalidRedeclaration=Invalid redeclaration of the name {0}
ASTProblemFactory.error.semantic.dom.recursionInResolution=Recursion while looking up ''{0}''
ASTProblemFactory.error.semantic.dom.badScope=A scope could not be created to represent the name {0}
ASTProblemFactory.error.semantic.dom.memberDeclNotFound=A declaration could not be found for this member definition: {0}
ASTProblemFactory.error.semantic.dom.invalidTemplateArgs=A template id provides illegal arguments for the instantiation: {0}
ISemanticProblem.BINDING_NOT_FOUND=Attempt to use symbol failed: {0}
ISemanticProblem.BINDING_AMBIGUOUS_LOOKUP=Ambiguity encountered during lookup: {0}
ISemanticProblem.BINDING_BAD_SCOPE=A scope could not be created to represent the name {0}
ISemanticProblem.BINDING_INVALID_TYPE=Invalid type encountered in: {0}
ISemanticProblem.BINDING_CIRCULAR_INHERITANCE=Circular inheritance encountered in: {0}
ISemanticProblem.BINDING_INVALID_OVERLOAD=Invalid overload of the name: {0}
ISemanticProblem.BINDING_INVALID_USING=Invalid using directive/declaration: {0}
ISemanticProblem.BINDING_DEFINITION_NOT_FOUND=A definition was not found for {0}
ISemanticProblem.BINDING_KNR_PARAMETER_DECLARATION_NOT_FOUND=A declaration was not found for the K&R parameter {0}
ISemanticProblem.BINDING_LABEL_STATEMENT_NOT_FOUND=A label statement was not found for the name {0}
ISemanticProblem.BINDING_INVALID_REDEFINITION=Invalid redefinition of the name {0}
ISemanticProblem.BINDING_INVALID_REDECLARATION=Invalid redeclaration of the name {0}
ISemanticProblem.BINDING_RECURSION_IN_LOOKUP=Recursion while looking up ''{0}''
ISemanticProblem.BINDING_MEMBER_DECLARATION_NOT_FOUND=A declaration could not be found for this member definition: {0}: return "ASTProblemFactory.error.semantic.dom.memberDeclNotFound"; //$NON-NLS-1$
ISemanticProblem.BINDING_INVALID_TEMPLATE_ARGUMENTS=A template id provides illegal arguments for the instantiation: {0}: return "ASTProblemFactory.error.semantic.dom.invalidTemplateArgs"; //$NON-NLS-1$
ISemanticProblem.TYPE_NO_NAME=Type specification lacks a name