diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java index c4e1ab5bf72..4abcc546d7d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java @@ -416,7 +416,7 @@ public class ASTTypeUtil { needSpace= appendCVQ(result, needSpace, qt.isConst(), qt.isVolatile()); } else if (type instanceof ITypedef) { result.append(((ITypedef) type).getNameCharArray()); - } else if (type instanceof IProblemBinding) { + } else if (type instanceof ISemanticProblem) { result.append('?'); } else if (type != null) { result.append('@').append(type.hashCode()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemBinding.java index eca5b6f2aae..c16f331143f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemBinding.java @@ -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 @@ -17,34 +17,20 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. */ -public interface IProblemBinding extends IBinding, IScope, IType { +public interface IProblemBinding extends IBinding, IScope, IType, ISemanticProblem { /** - * 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(); - - /** - * get the AST node that this problem was created for + * Returns the AST node that this problem was created for */ public IASTNode getASTNode(); /** - * returns the file name this problem occurred in if known. + * Returns the file name this problem occurred in, or null if it is unknown. */ public String getFileName(); /** - * returns the line number for this problem if known + * Returns the line number for this problem, or -1 if it is unknown. */ public int getLineNumber(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemType.java new file mode 100644 index 00000000000..facc9fa48c8 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemType.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2010 Wind River Systems, Inc. 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.ast; + +/** + * Represents an type that cannot be determined or is illegal. Reasons include + * + * + * @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 IProblemType extends IType, ISemanticProblem { + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ISemanticProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ISemanticProblem.java new file mode 100644 index 00000000000..96302255d24 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ISemanticProblem.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2010 Wind River Systems, Inc. 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ +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 { + + /** + * Returns the ID of the problem. + */ + int getID(); + + /** + * A human-readable message that describes the problem. + */ + String getMessage(); +} 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 7f1df9be8be..3661b20e67a 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 @@ -1,22 +1,19 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation + * John Camelon (IBM Corporation) - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.parser; -import org.eclipse.cdt.internal.core.parser.ParserMessages; /** - * @author jcamelon - * - * Description of a C/C++ parse/compilation problem, as detected by the parser or some of the underlying - * clients of the parser. + * Description of a C/C++ syntax problems and spelling errors as detected by the lexer, preprocessor, + * parser or the spelling engine. * * A problem provides access to: * - * + *

Note, that semantic problems are modeled via {@link org.eclipse.cdt.core.dom.ast.ISemanticProblem}. * @noimplement This interface is not intended to be implemented by clients. * @noextend This interface is not intended to be extended by clients. */ @@ -33,15 +30,11 @@ public interface IProblem { /** * 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 + * Returns a human-readable message describing the problem. */ String getMessage(); @@ -52,67 +45,46 @@ public interface IProblem String getMessageWithLocation(); /** - * Return to the client a map between parameter names and values. - * - * The keys and values are all Strings. - * - * - * @return a map between parameter names and values. + * Returns a possibly empty argument array to compute the message. */ String[] getArguments(); /** - * Answer the file name in which the problem was found. - * - * @return the file name in which the problem was found + * Returns the file name in which the problem was found */ char[] getOriginatingFileName(); /** - * Answer the end position of the problem (inclusive), or -1 if unknown. - * - * @return the end position of the problem (inclusive), or -1 if unknown - */ - int getSourceEnd(); - - /** - * Answer the line number in source where the problem begins. - * - * @return the line number in source where the problem begins, or -1 if unknown - */ - int getSourceLineNumber(); - - /** - * Answer the start position of the problem (inclusive), or -1 if unknown. - * - * @return the start position of the problem (inclusive), or -1 if unknown + * Returns the start position of the problem (inclusive), or {@link #INT_VALUE_NOT_PROVIDED} if unknown. */ int getSourceStart(); /** - * Checks the severity to see if the Error bit is set. - * - * @return true if the Error bit is set for the severity, false otherwise + * Returns the end position of the problem (inclusive), or {@link #INT_VALUE_NOT_PROVIDED} if unknown. + */ + int getSourceEnd(); + + /** + * Returns the line number where the problem begins, or {@link #INT_VALUE_NOT_PROVIDED} if unknown. + */ + int getSourceLineNumber(); + + /** + * Returns whether the problem is an error. */ boolean isError(); /** - * Checks the severity to see if the Warning bit is not set. - * - * @return true if the Warning bit is not set for the severity, false otherwise + * Returns whether the problem is a warning. */ boolean isWarning(); + /** - * Unknown Numeric Value for line numbers and offsets; use this constant + * -1, returned when an offset or a line number is unknown. */ public final static int INT_VALUE_NOT_PROVIDED = -1; - /** - * Unknown filename sentinel value - */ - public final static String FILENAME_NOT_PROVIDED = ParserMessages.getString("IProblem.unknownFileName"); //$NON-NLS-1$ - /** * Problem Categories * The high bits of a problem ID contains information about the category of a problem. @@ -140,11 +112,6 @@ public interface IProblem */ public final static int SYNTAX_RELATED = 0x04000000; - /** - * IProblem relates to a valid semantical error in the parser - */ - public final static int SEMANTICS_RELATED = 0x08000000; - /** * IProblem relates to an implementation of design limitation */ @@ -152,11 +119,11 @@ public interface IProblem /** - * Check the parameter bitmask against an IProblem's ID to broadly segregate the + * Check the parameter bit-mask against an IProblem's ID to broadly segregate the * types of problems. * * @param bitmask - * @return true if ( (id & bitmask ) != 0 ) + * @return true if ( (id & bit-mask ) != 0 ) */ public boolean checkCategory(int bitmask); @@ -165,89 +132,11 @@ public interface IProblem */ public final static int IGNORE_CATEGORIES_MASK = 0xFFFFFF; - /** - * Below are listed all available problem attributes. The JavaDoc for each problem ID indicates - * when they should be contributed to creating a problem of that type. - */ - // Preprocessor IProblem attributes - /** - * The text that follows a #error preprocessor directive - */ - public final static String A_PREPROC_POUND_ERROR = ParserMessages.getString("IProblem.preproc.poundError"); //$NON-NLS-1$ - /** - * The text that follows a #warning preprocessor directive - */ - public final static String A_PREPROC_POUND_WARNING = ParserMessages.getString("IProblem.preproc.poundWarning"); //$NON-NLS-1$ - - /** - * The filename that failed somehow in an preprocessor include directive - */ - public final static String A_PREPROC_INCLUDE_FILENAME = ParserMessages.getString("IProblem.preproc.include"); //$NON-NLS-1$ - - /** - * A preprocessor macro name - */ - public final static String A_PREPROC_MACRO_NAME = ParserMessages.getString("IProblem.preproc.macro"); //$NON-NLS-1$ - - /** - * A preprocessor conditional that could not be evaluated - * - * #if X + Y == Z <== that one, if X, Y or Z are not defined - * #endif - */ - public final static String A_PREPROC_CONDITION = ParserMessages.getString("IProblem.preproc.condition"); //$NON-NLS-1$ - - /** - * A preprocessor directive that could not be interpretted - * - * e.g. #blah - */ - public final static String A_PREPROC_UNKNOWN_DIRECTIVE = ParserMessages.getString("IProblem.preproc.unknownDirective"); //$NON-NLS-1$ - - /** - * The preprocessor conditional statement that caused an unbalanced mismatch. - * - * #if X - * #else - * #else <=== that one - * #endif - */ - public final static String A_PREPROC_CONDITIONAL_MISMATCH = ParserMessages.getString("IProblem.preproc.conditionalMismatch"); //$NON-NLS-1$ - - /** - * The Bad character encountered in scanner - */ - public static final String A_SCANNER_BADCHAR = null; - - /** - * A_SYMBOL_NAME - symbol name - */ - public static final String A_SYMBOL_NAME = ParserMessages.getString("IProblem.symbolName"); //$NON-NLS-1$ - - /** - * A_NAMESPACE_NAME = namespace name - */ - public static final String A_NAMESPACE_NAME = ParserMessages.getString("IProblem.namespaceName"); //$NON-NLS-1$ - - /** - * A_TYPE_NAME - type name - */ - public static final String A_TYPE_NAME = ParserMessages.getString("IProblem.typeName"); //$NON-NLS-1$ - - /** - * 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. - */ - - /* - * Scanner Problems - */ - + // Lexer /** * Bad character encountered by Scanner. * Required attributes: A_SCANNER_BADCHAR - * @see #A_SCANNER_BADCHAR */ public final static int SCANNER_BAD_CHARACTER = SCANNER_RELATED | 0x001; @@ -270,7 +159,7 @@ public interface IProblem public final static int SCANNER_BAD_FLOATING_POINT = SCANNER_RELATED | 0x004; /** - * Bad hexidecimal encountered by Scanner. + * Bad hexadecimal encountered by Scanner. * Required attributes: none. */ public final static int SCANNER_BAD_HEX_FORMAT = SCANNER_RELATED | 0x005; @@ -336,11 +225,7 @@ public interface IProblem */ public final static int SCANNER_BAD_BINARY_FORMAT = SCANNER_RELATED | 0x00F; - - /* - * Preprocessor Problems - */ - + // Preprocessor /** * #error encountered by Preprocessor. * Required attributes: A_PREPROC_POUND_ERROR @@ -438,82 +323,72 @@ public interface IProblem */ public final static int PREPROCESSOR_POUND_WARNING = PREPROCESSOR_RELATED | 0x00E; - /* - * Parser Syntactic Problems + /** + * Syntax error, detected by the parser. */ 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 - */ + @Deprecated + public final static int SEMANTICS_RELATED = 0x08000000; + @Deprecated + public final static String A_PREPROC_POUND_ERROR = ""; //$NON-NLS-1$ + @Deprecated + public final static String A_PREPROC_POUND_WARNING = ""; //$NON-NLS-1$ + @Deprecated + public final static String A_PREPROC_INCLUDE_FILENAME = ""; //$NON-NLS-1$ + @Deprecated + public final static String A_PREPROC_MACRO_NAME = ""; //$NON-NLS-1$ + @Deprecated + public final static String A_PREPROC_CONDITION = ""; //$NON-NLS-1$ + @Deprecated + public final static String A_PREPROC_UNKNOWN_DIRECTIVE = ""; //$NON-NLS-1$ + @Deprecated + public final static String A_PREPROC_CONDITIONAL_MISMATCH = ""; //$NON-NLS-1$ + @Deprecated + public static final String A_SCANNER_BADCHAR = ""; //$NON-NLS-1$ + @Deprecated + public static final String A_SYMBOL_NAME = ""; //$NON-NLS-1$ + @Deprecated + public static final String A_NAMESPACE_NAME = ""; //$NON-NLS-1$ + @Deprecated + public static final String A_TYPE_NAME = ""; //$NON-NLS-1$ + @Deprecated + public final static String FILENAME_NOT_PROVIDED = ""; //$NON-NLS-1$ + @Deprecated 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 - */ + @Deprecated public final static int SEMANTIC_NAME_NOT_FOUND = SEMANTICS_RELATED | 0x002; - - /** - * Name not provided in context that it was required. - * Require attributes: none - */ + @Deprecated 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 - */ + @Deprecated public static final int SEMANTIC_INVALID_OVERLOAD = SEMANTICS_RELATED | 0x004; - - /** - * Invalid using directive. - * Required attributes: A_NAMESPACE_NAME - * @see #A_NAMESPACE_NAME - */ + @Deprecated public static final int SEMANTIC_INVALID_USING = SEMANTICS_RELATED | 0x005; - - /** - * Ambiguous lookup for given name. - * Required attributes: A_SYMBOL_NAME - * @see #A_SYMBOL_NAME - */ + @Deprecated public static final int SEMANTIC_AMBIGUOUS_LOOKUP = SEMANTICS_RELATED | 0x006; - - /** - * Invalid type provided - * Required attributes: A_TYPE_NAME - * @see #A_TYPE_NAME - */ + @Deprecated public static final int SEMANTIC_INVALID_TYPE = SEMANTICS_RELATED | 0x007; - + @Deprecated public static final int SEMANTIC_CIRCULAR_INHERITANCE = SEMANTICS_RELATED | 0x008; - + @Deprecated public static final int SEMANTIC_INVALID_TEMPLATE = SEMANTICS_RELATED | 0x009; - + @Deprecated public static final int SEMANTIC_BAD_VISIBILITY = SEMANTICS_RELATED | 0x00A; - + @Deprecated public static final int SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION = SEMANTICS_RELATED | 0x00B; - + @Deprecated public static final int SEMANTIC_INVALID_TEMPLATE_ARGUMENT = SEMANTICS_RELATED | 0x00C; - + @Deprecated public static final int SEMANTIC_INVALID_TEMPLATE_PARAMETER = SEMANTICS_RELATED | 0x00D; - + @Deprecated public static final int SEMANTIC_REDECLARED_TEMPLATE_PARAMETER = SEMANTICS_RELATED | 0x00E; - + @Deprecated public static final int SEMANTIC_INVALID_CONVERSION_TYPE = SEMANTICS_RELATED | 0x00F; - + @Deprecated public static final int SEMANTIC_MALFORMED_EXPRESSION = SEMANTICS_RELATED | 0x010; - + @Deprecated public static final int SEMANTIC_ILLFORMED_FRIEND = SEMANTICS_RELATED | 0x011; - + @Deprecated public static final int SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION = SEMANTICS_RELATED | 0x012; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java index 12e01a07163..c192d023e27 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java @@ -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,7 +12,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; -import com.ibm.icu.text.MessageFormat; import java.util.HashMap; import java.util.Map; @@ -22,6 +21,8 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTProblem; import org.eclipse.cdt.internal.core.parser.ParserMessages; +import com.ibm.icu.text.MessageFormat; + /** * Models problems, all problems should derive from this class. @@ -184,7 +185,7 @@ public class ASTProblem extends ASTNode implements IASTProblem { if (location != null) { return location.getNodeOffset() + location.getNodeLength() - 1; } - return -1; + return INT_VALUE_NOT_PROVIDED; } /* @@ -195,7 +196,7 @@ public class ASTProblem extends ASTNode implements IASTProblem { if (location != null) { return location.getStartingLineNumber(); } - return -1; + return INT_VALUE_NOT_PROVIDED; } /* @@ -206,6 +207,6 @@ public class ASTProblem extends ASTNode implements IASTProblem { if (location != null) { return location.getNodeOffset(); } - return -1; + return INT_VALUE_NOT_PROVIDED; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java index 85638c073d9..9e1f9eaa965 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java @@ -82,24 +82,37 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I candidateBindings= foundBindings; } - protected static final String[] errorMessages; - static { - errorMessages = new String[IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS]; - errorMessages[SEMANTIC_NAME_NOT_FOUND - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.nameNotFound"); //$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_USING - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidUsing"); //$NON-NLS-1$ - errorMessages[SEMANTIC_DEFINITION_NOT_FOUND - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.dom.definitionNotFound"); //$NON-NLS-1$ - errorMessages[SEMANTIC_KNR_PARAMETER_DECLARATION_NOT_FOUND - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.dom.knrParameterDeclarationNotFound"); //$NON-NLS-1$ - errorMessages[SEMANTIC_LABEL_STATEMENT_NOT_FOUND - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.dom.labelStatementNotFound"); //$NON-NLS-1$ - errorMessages[SEMANTIC_INVALID_REDEFINITION - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.dom.invalidRedefinition"); //$NON-NLS-1$ - errorMessages[SEMANTIC_INVALID_REDECLARATION - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.dom.invalidRedeclaration"); //$NON-NLS-1$ - errorMessages[SEMANTIC_BAD_SCOPE - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.dom.badScope"); //$NON-NLS-1$ - errorMessages[SEMANTIC_RECURSION_IN_LOOKUP - 1] = ParserMessages.getString("ASTProblemFactory.error.semantic.dom.recursionInResolution"); //$NON-NLS-1$ - errorMessages[SEMANTIC_MEMBER_DECLARATION_NOT_FOUND - 1]= ParserMessages.getString("ASTProblemFactory.error.semantic.dom.memberDeclNotFound"); //$NON-NLS-1$ - errorMessages[SEMANTIC_INVALID_TEMPLATE_ARGUMENTS - 1]= ParserMessages.getString("ASTProblemFactory.error.semantic.dom.invalidTemplateArgs"); //$NON-NLS-1$ + 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) @@ -116,8 +129,7 @@ public class ProblemBinding extends PlatformObject implements IProblemBinding, I if (message != null) return message; - String msg = (id > 0 && id <= errorMessages.length) ? errorMessages[id - 1] : ""; //$NON-NLS-1$ - + String msg = getMessagePattern(); if (arg == null && node instanceof IASTName) arg= ((IASTName) node).toCharArray(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java new file mode 100644 index 00000000000..9854fe1ab2d --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemType.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2010 Wind River Systems, Inc. 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser; + +import org.eclipse.cdt.core.dom.ast.IProblemType; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.internal.core.parser.ParserMessages; + + +/** + * Implementation of problem types. + */ +public class ProblemType implements IProblemType { + private final int fID; + + public ProblemType(int id) { + fID= id; + } + + public int getID() { + return fID; + } + + public String getMessage() { + return ParserMessages.getProblemPattern(this); + } + + public boolean isSameType(IType type) { + return type == this; + } + + @Override + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + return null; + } + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java index 560b8cd19a5..a8fd822f12e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTBinaryExpression.java @@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; +import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; @@ -301,14 +302,14 @@ public class CPPASTBinaryExpression extends ASTNode implements ICPPASTBinaryExpr final int op = getOperator(); IType type1 = prvalueType(operand1.getExpressionType()); - if (type1 instanceof IProblemBinding) { + if (type1 instanceof ISemanticProblem) { return type1; } IType type2 = null; if (operand2 instanceof IASTExpression) { type2= prvalueType(((IASTExpression) operand2).getExpressionType()); - if (type2 instanceof IProblemBinding) { + if (type2 instanceof ISemanticProblem) { return type2; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java index 293d23976bb..80050e10054 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTConditionalExpression.java @@ -26,6 +26,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; import org.eclipse.cdt.core.dom.ast.IBasicType.Kind; import org.eclipse.cdt.core.dom.ast.IProblemBinding; +import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; @@ -186,11 +187,11 @@ public class CPPASTConditionalExpression extends ASTNode implements IASTConditio final IType uqt2= getNestedType(t2, TDEF | REF | CVTYPE); final IType uqt3= getNestedType(t3, TDEF | REF | CVTYPE); - if (uqt2 instanceof IProblemBinding || uqt2 instanceof ICPPUnknownType) { + if (uqt2 instanceof ISemanticProblem || uqt2 instanceof ICPPUnknownType) { fType= uqt2; return; } - if (uqt3 instanceof IProblemBinding || uqt3 instanceof ICPPUnknownType) { + if (uqt3 instanceof ISemanticProblem || uqt3 instanceof ICPPUnknownType) { fType= uqt3; return; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java index d5d77ed914f..c53d26decc3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java @@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IProblemBinding; +import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument; @@ -130,7 +130,7 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI } } else { IType type= CPPVisitor.createType(arg); - if (type == null || type instanceof IProblemBinding) { + if (type == null || type instanceof ISemanticProblem) { buf.append(arg.getRawSignature()); } else { buf.append(ASTTypeUtil.getType(type, false)); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java index 553a1a96d87..d7e94420907 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTUnaryExpression.java @@ -34,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IPointerType; import org.eclipse.cdt.core.dom.ast.IProblemBinding; +import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression; @@ -241,7 +242,7 @@ public class CPPASTUnaryExpression extends ASTNode implements ICPPASTUnaryExpres if (op == op_star) { IType type= operand.getExpressionType(); type = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE); - if (type instanceof IProblemBinding) { + if (type instanceof ISemanticProblem) { return type; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java index 11af1fb58f0..87a6d12969b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AccessContext.java @@ -132,9 +132,6 @@ public class AccessContext { ICPPBase[] bases = derivedClass.getBases(); if (bases != null) { for (ICPPBase base : bases) { - if (base instanceof IProblemBinding) { - continue; - } IBinding baseBinding = base.getBaseClass(); if (!(baseBinding instanceof ICPPClassType)) { continue; @@ -174,8 +171,7 @@ public class AccessContext { return accessLevel; } - private boolean isAccessibleBaseClass(ICPPClassType classType, ICPPClassType defived, int depth) - throws DOMException { + private boolean isAccessibleBaseClass(ICPPClassType classType, ICPPClassType defived, int depth) { if (depth > CPPSemantics.MAX_INHERITANCE_DEPTH) return false; @@ -185,9 +181,6 @@ public class AccessContext { ICPPBase[] bases = defived.getBases(); if (bases != null) { for (ICPPBase base : bases) { - if (base instanceof IProblemBinding) { - continue; - } IBinding baseClass = base.getBaseClass(); if (!(baseClass instanceof ICPPClassType)) { continue; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java index c71f933b237..6cef2cc00e4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java @@ -190,8 +190,6 @@ class BaseClassLookup { } for (int i = 0; i < grandBases.length; i++) { ICPPBase grandBase = grandBases[i]; - if (grandBase instanceof IProblemBinding) - continue; if (selectedBases != null && !selectedBases.get(i)) continue; @@ -282,9 +280,6 @@ class BaseClassLookup { bases= fClassType.getBases(); if (bases != null && bases.length > 0) { for (ICPPBase base : bases) { - if (base instanceof IProblemBinding) - continue; - IBinding baseBinding = base.getBaseClass(); if (!(baseBinding instanceof ICPPClassType)) { continue; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java index 7b15b2fee19..b35fb41daa9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BuiltinOperators.java @@ -30,8 +30,8 @@ import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IPointerType; -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.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; @@ -85,13 +85,13 @@ class BuiltinOperators { fGlobalCandidates= globCandidates; if (args.length > 0 && args[0] instanceof IASTExpression) { IType type= typeOrFunctionSet((IASTExpression) args[0]); - if (!(type instanceof IProblemBinding)) + if (!(type instanceof ISemanticProblem)) fType1= type; } if (args.length > 1 && args[1] instanceof IASTExpression) { IType type= typeOrFunctionSet((IASTExpression) args[1]); - if (!(type instanceof IProblemBinding)) + if (!(type instanceof ISemanticProblem)) fType2= type; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index f8d00892c58..931ff489066 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -82,6 +82,7 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IPointerType; 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.ITypedef; import org.eclipse.cdt.core.dom.ast.IVariable; @@ -683,11 +684,9 @@ public class CPPSemantics { ICPPClassType ct= (ICPPClassType) t; ICPPBase[] bases = ct.getBases(); for (ICPPBase base : bases) { - if (!(base instanceof IProblemBinding)) { - IBinding b = base.getBaseClass(); - if (b instanceof IType) - getAssociatedScopes((IType) b, namespaces, handled, tu); - } + IBinding b = base.getBaseClass(); + if (b instanceof IType) + getAssociatedScopes((IType) b, namespaces, handled, tu); } // Furthermore, if T is a class template ... // * ... types of the template arguments for template type parameters @@ -762,6 +761,7 @@ public class CPPSemantics { if (scope instanceof ICPPScope) { return (ICPPScope) scope; } else if (scope instanceof IProblemBinding) { + // mstodo scope problems return new CPPScope.CPPScopeProblem(((IProblemBinding) scope).getASTNode(), IProblemBinding.SEMANTIC_BAD_SCOPE, ((IProblemBinding) scope).getNameCharArray()); } @@ -1047,7 +1047,7 @@ public class CPPSemantics { return false; IType t= SemanticUtil.getNestedType((ITypedef) type, TDEF); - if (t instanceof ICPPUnknownBinding || t instanceof IProblemBinding || + if (t instanceof ICPPUnknownBinding || t instanceof ISemanticProblem || !(t instanceof ICPPClassType)) { return false; } @@ -3039,7 +3039,7 @@ public class CPPSemantics { type = SemanticUtil.getNestedType(((ICPPVariable) binding).getType(), TDEF | CVTYPE); if (!(type instanceof ICPPClassType)) return null; - if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownClassType || type instanceof IProblemBinding) + if (type instanceof ICPPClassTemplate || type instanceof ICPPUnknownClassType || type instanceof ISemanticProblem) return null; final ICPPClassType classType = (ICPPClassType) type; @@ -3243,7 +3243,7 @@ public class CPPSemantics { // Find a method LookupData methodData = null; CPPASTName methodName = null; - if (methodLookupType instanceof IProblemBinding) + if (methodLookupType instanceof ISemanticProblem) return null; if (methodLookupType instanceof ICPPClassType) { ICPPClassType classType = (ICPPClassType) methodLookupType; @@ -3412,7 +3412,7 @@ public class CPPSemantics { } private static boolean isUserDefined(IType type) { - if (type instanceof IProblemBinding) + if (type instanceof ISemanticProblem) return false; return type instanceof ICPPClassType || type instanceof IEnumeration || type instanceof ICPPUnknownType; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 474d4db4ec4..4c0eb1bd99f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -45,6 +45,7 @@ import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.IFunctionType; 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.ITypedef; import org.eclipse.cdt.core.dom.ast.IValue; @@ -246,7 +247,7 @@ public class CPPTemplates { IScope scope= CPPVisitor.getContainingScope(start); while (scope instanceof IASTInternalScope) { - if (scope instanceof IProblemBinding) + if (scope instanceof ISemanticProblem) return null; final IASTInternalScope internalScope = (IASTInternalScope) scope; if (scope instanceof ICPPClassScope) { @@ -1923,7 +1924,7 @@ public class CPPTemplates { while (t instanceof ITypeContainer) { t = ((ITypeContainer) t).getType(); } - return !(t instanceof IProblemBinding); + return !(t instanceof ISemanticProblem); } static boolean isValidArgument(ICPPTemplateArgument arg) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java index db65747d90e..5ec2429ffa8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java @@ -18,8 +18,8 @@ import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumerator; 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.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IValue; @@ -197,7 +197,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } return at; } - if (rtype instanceof IBasicType || rtype == null || rtype instanceof IProblemBinding) { + if (rtype instanceof IBasicType || rtype == null || rtype instanceof ISemanticProblem) { return rtype; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.java index 0bf82acef93..2cc1b3592bc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.java @@ -13,6 +13,8 @@ package org.eclipse.cdt.internal.core.parser; import java.util.MissingResourceException; import java.util.ResourceBundle; +import org.eclipse.cdt.core.dom.ast.ISemanticProblem; + import com.ibm.icu.text.MessageFormat; public class ParserMessages { @@ -63,4 +65,17 @@ public class ParserMessages { return MessageFormat.format(format, new Object[] { arg }); } + + public static String getProblemPattern(ISemanticProblem problem) { + String key= getProblemKey(problem.getID()); + if (key != null) + return getString(key); + return null; + } + + private static String getProblemKey(int id) { + switch(id) { + } + return null; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.properties b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.properties index 43d8ed03c7a..adca3c60e27 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.properties +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ParserMessages.properties @@ -11,18 +11,6 @@ # Markus Schorn (Wind River Systems) ############################################################################### -IProblem.unknownFileName= -IProblem.preproc.poundError=#error text -IProblem.preproc.poundWarning=#warning text -IProblem.preproc.include=include file -IProblem.preproc.macro=macro name -IProblem.preproc.condition=preprocessor condition -IProblem.preproc.unknownDirective=bad preprocessor directive -IProblem.preproc.conditionalMismatch=conditional mismatch -IProblem.symbolName=symbol name -IProblem.namespaceName=namespace name -IProblem.typeName=type name - ScannerProblemFactory.error.preproc.error=#error encountered with text: {0} ScannerProblemFactory.error.preproc.warning=#warning encountered with text: {0} ScannerProblemFactory.error.preproc.inclusionNotFound=Unresolved inclusion: {0} @@ -36,7 +24,7 @@ ScannerProblemFactory.error.preproc.circularInclusion=Circular inclusion for fil ScannerProblemFactory.error.preproc.invalidDirective=Invalid preprocessor directive: {0} ScannerProblemFactory.error.preproc.macroPasting=Invalid use of macro pasting in macro: {0} ScannerProblemFactory.error.preproc.missingRParen=missing '')'' in parameter list of macro: {0} -ScannerProblemFactory.error.preproc.invalidVaArgs=__VA_ARGS__ can only appear in the expansion of a C99 variadic macro +ScannerProblemFactory.error.preproc.invalidVaArgs=__VA_ARGS__ can only appear in the expansion of a variadic macro ScannerProblemFactory.error.scanner.invalidEscapeChar=Invalid escape character encountered ScannerProblemFactory.error.scanner.unboundedString=Unbounded string encountered @@ -76,4 +64,3 @@ ASTProblemFactory.error.semantic.dom.recursionInResolution=Recursion while looki 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} -CPPASTAmbiguousTemplateArgument_InvalidConstruction=Internal parser error: Template argument ambiguity constructed with {0} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java index f52bbd37f8e..04453b03e84 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java @@ -71,6 +71,7 @@ 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.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IVariable; @@ -482,7 +483,7 @@ public class ASTManager { if (t1 == t2) { return TRUE; } - if (t1 == null || t2 == null || t1 instanceof IProblemBinding || t2 instanceof IProblemBinding) { + if (t1 == null || t2 == null || t1 instanceof ISemanticProblem || t2 instanceof ISemanticProblem) { return UNKNOWN; }