1
/*******************************************************************************
2
* Copyright (c) 2000, 2009 IBM Corporation and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* IBM Corporation - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.cdt.core.parser;
13
import org.eclipse.cdt.internal.core.parser.ParserMessages;
18
* Description of a C/C++ parse/compilation problem, as detected by the parser or some of the underlying
19
* clients of the parser.
21
* A problem provides access to:
23
* <li> its location (originating source file name, source position, line number), </li>
24
* <li> its message description and a predicate to check its severity (warning or error). </li>
25
* <li> its ID : an number identifying the very nature of this problem. All possible IDs are listed
26
* as constants on this interface. </li>
29
* @noimplement This interface is not intended to be implemented by clients.
30
* @noextend This interface is not intended to be extended by clients.
32
public interface IProblem
35
* Returns the problem id
37
* @return the problem id
42
* Answer a localized, human-readable message string which describes the problem.
44
* @return a localized, human-readable message string which describes the problem
49
* Returns a human-readable message string describing the problem, adding
50
* location information.
52
String getMessageWithLocation();
55
* Return to the client a map between parameter names and values.
57
* The keys and values are all Strings.
60
* @return a map between parameter names and values.
62
String[] getArguments();
65
* Answer the file name in which the problem was found.
67
* @return the file name in which the problem was found
69
char[] getOriginatingFileName();
72
* Answer the end position of the problem (inclusive), or -1 if unknown.
74
* @return the end position of the problem (inclusive), or -1 if unknown
79
* Answer the line number in source where the problem begins.
81
* @return the line number in source where the problem begins, or -1 if unknown
83
int getSourceLineNumber();
86
* Answer the start position of the problem (inclusive), or -1 if unknown.
88
* @return the start position of the problem (inclusive), or -1 if unknown
93
* Checks the severity to see if the Error bit is set.
95
* @return true if the Error bit is set for the severity, false otherwise
100
* Checks the severity to see if the Warning bit is not set.
102
* @return true if the Warning bit is not set for the severity, false otherwise
107
* Unknown Numeric Value for line numbers and offsets; use this constant
109
public final static int INT_VALUE_NOT_PROVIDED = -1;
112
* Unknown filename sentinel value
114
public final static String FILENAME_NOT_PROVIDED = ParserMessages.getString("IProblem.unknownFileName"); //$NON-NLS-1$
118
* The high bits of a problem ID contains information about the category of a problem.
119
* For example, (problemID & TypeRelated) != 0, indicates that this problem is type related.
121
* A problem category can help to implement custom problem filters. Indeed, when numerous problems
122
* are listed, focusing on import related problems first might be relevant.
124
* When a problem is tagged as Internal, it means that no change other than a local source code change
125
* can fix the corresponding problem.
129
* IProblem relates to a valid error on the Scanner
131
public final static int SCANNER_RELATED = 0x01000000;
134
* IProblem relates to a valid error on the preprocessor
136
public final static int PREPROCESSOR_RELATED = 0x02000000;
139
* IProblem relates to a valid syntax error in the parser
141
public final static int SYNTAX_RELATED = 0x04000000;
144
* IProblem relates to a valid semantical error in the parser
146
public final static int SEMANTICS_RELATED = 0x08000000;
149
* IProblem relates to an implementation of design limitation
151
public final static int INTERNAL_RELATED = 0x10000000;
155
* Check the parameter bitmask against an IProblem's ID to broadly segregate the
159
* @return true if ( (id & bitmask ) != 0 )
161
public boolean checkCategory(int bitmask);
164
* Mask to use in order to filter out the category portion of the problem ID.
166
public final static int IGNORE_CATEGORIES_MASK = 0xFFFFFF;
169
* Below are listed all available problem attributes. The JavaDoc for each problem ID indicates
170
* when they should be contributed to creating a problem of that type.
173
// Preprocessor IProblem attributes
175
* The text that follows a #error preprocessor directive
177
public final static String A_PREPROC_POUND_ERROR = ParserMessages.getString("IProblem.preproc.poundError"); //$NON-NLS-1$
179
* The text that follows a #warning preprocessor directive
181
public final static String A_PREPROC_POUND_WARNING = ParserMessages.getString("IProblem.preproc.poundWarning"); //$NON-NLS-1$
184
* The filename that failed somehow in an preprocessor include directive
186
public final static String A_PREPROC_INCLUDE_FILENAME = ParserMessages.getString("IProblem.preproc.include"); //$NON-NLS-1$
189
* A preprocessor macro name
191
public final static String A_PREPROC_MACRO_NAME = ParserMessages.getString("IProblem.preproc.macro"); //$NON-NLS-1$
194
* A preprocessor conditional that could not be evaluated
196
* #if X + Y == Z <== that one, if X, Y or Z are not defined
199
public final static String A_PREPROC_CONDITION = ParserMessages.getString("IProblem.preproc.condition"); //$NON-NLS-1$
202
* A preprocessor directive that could not be interpretted
206
public final static String A_PREPROC_UNKNOWN_DIRECTIVE = ParserMessages.getString("IProblem.preproc.unknownDirective"); //$NON-NLS-1$
209
* The preprocessor conditional statement that caused an unbalanced mismatch.
213
* #else <=== that one
216
public final static String A_PREPROC_CONDITIONAL_MISMATCH = ParserMessages.getString("IProblem.preproc.conditionalMismatch"); //$NON-NLS-1$
219
* The Bad character encountered in scanner
221
public static final String A_SCANNER_BADCHAR = null;
224
* A_SYMBOL_NAME - symbol name
226
public static final String A_SYMBOL_NAME = ParserMessages.getString("IProblem.symbolName"); //$NON-NLS-1$
229
* A_NAMESPACE_NAME = namespace name
231
public static final String A_NAMESPACE_NAME = ParserMessages.getString("IProblem.namespaceName"); //$NON-NLS-1$
234
* A_TYPE_NAME - type name
236
public static final String A_TYPE_NAME = ParserMessages.getString("IProblem.typeName"); //$NON-NLS-1$
239
* Below are listed all available problem IDs. Note that this list could be augmented in the future,
240
* as new features are added to the C/C++ core implementation.
248
* Bad character encountered by Scanner.
249
* Required attributes: A_SCANNER_BADCHAR
250
* @see #A_SCANNER_BADCHAR
252
public final static int SCANNER_BAD_CHARACTER = SCANNER_RELATED | 0x001;
255
* Unbounded literal string encountered by Scanner.
256
* Required attributes: none.
258
public final static int SCANNER_UNBOUNDED_STRING = SCANNER_RELATED | 0x002;
261
* Invalid escape sequence encountered by Scanner.
262
* Required attributes: none.
264
public final static int SCANNER_INVALID_ESCAPECHAR = SCANNER_RELATED | 0x003;
267
* Bad floating point encountered by Scanner.
268
* Required attributes: none.
270
public final static int SCANNER_BAD_FLOATING_POINT = SCANNER_RELATED | 0x004;
273
* Bad hexidecimal encountered by Scanner.
274
* Required attributes: none.
276
public final static int SCANNER_BAD_HEX_FORMAT = SCANNER_RELATED | 0x005;
279
* Unexpected EOF encountered by Scanner.
280
* Required attributes: none.
282
public final static int SCANNER_UNEXPECTED_EOF = SCANNER_RELATED | 0x006;
285
* Bad octal encountered by Scanner.
286
* Required attributes: none.
288
public final static int SCANNER_BAD_OCTAL_FORMAT = SCANNER_RELATED | 0x007;
291
* Bad decimal encountered by Scanner.
292
* Required attributes: none.
294
public final static int SCANNER_BAD_DECIMAL_FORMAT = SCANNER_RELATED | 0x008;
297
* Assignment '=' encountered in macro by Scanner.
298
* Required attributes: none.
300
public final static int SCANNER_ASSIGNMENT_NOT_ALLOWED = SCANNER_RELATED | 0x009;
303
* Division by 0 encountered in macro by Scanner.
304
* Required attributes: none.
306
public final static int SCANNER_DIVIDE_BY_ZERO = SCANNER_RELATED | 0x00A;
309
* Missing ')' encountered in macro by Scanner.
310
* Required attributes: none.
312
public final static int SCANNER_MISSING_R_PAREN = SCANNER_RELATED | 0x00B;
315
* Expression syntax error encountered in macro by Scanner.
316
* Required attributes: none.
318
public final static int SCANNER_EXPRESSION_SYNTAX_ERROR = SCANNER_RELATED | 0x00C;
321
* Expression syntax error encountered in macro by Scanner.
322
* Required attributes: none.
324
public final static int SCANNER_ILLEGAL_IDENTIFIER = SCANNER_RELATED | 0x00D;
327
* Division by 0 encountered in macro by Scanner.
328
* Required attributes: none.
330
public final static int SCANNER_BAD_CONDITIONAL_EXPRESSION = SCANNER_RELATED | 0x00E;
333
* Bad binary encountered by Scanner.
334
* Required attributes: none.
337
public final static int SCANNER_BAD_BINARY_FORMAT = SCANNER_RELATED | 0x00F;
341
* Preprocessor Problems
345
* #error encountered by Preprocessor.
346
* Required attributes: A_PREPROC_POUND_ERROR
347
* @see #A_PREPROC_POUND_ERROR
349
public final static int PREPROCESSOR_POUND_ERROR = PREPROCESSOR_RELATED | 0x001;
352
* Inclusion not found by Preprocessor.
353
* Required attributes: A_PREPROC_INCLUDE_FILENAME
354
* @see #A_PREPROC_INCLUDE_FILENAME
356
public final static int PREPROCESSOR_INCLUSION_NOT_FOUND = PREPROCESSOR_RELATED | 0x002;
359
* Macro definition not found by Preprocessor.
360
* Required attributes: A_PREPROC_MACRO_NAME
361
* @see #A_PREPROC_MACRO_NAME
363
public final static int PREPROCESSOR_DEFINITION_NOT_FOUND = PREPROCESSOR_RELATED | 0x003;
366
* Preprocessor conditionals seem unbalanced.
367
* Required attributes: A_PREPROC_CONDITIONAL_MISMATCH
368
* @see #A_PREPROC_CONDITIONAL_MISMATCH
371
public final static int PREPROCESSOR_UNBALANCE_CONDITION = PREPROCESSOR_RELATED | 0x004;
374
* Invalid format to Macro definition.
375
* Required attributes: A_PREPROC_MACRO_NAME
376
* @see #A_PREPROC_MACRO_NAME
378
public final static int PREPROCESSOR_INVALID_MACRO_DEFN = PREPROCESSOR_RELATED | 0x005;
381
* Invalid or unknown preprocessor directive encountered by Preprocessor.
382
* Required attributes: A_PREPROC_UNKNOWN_DIRECTIVE
383
* @see #A_PREPROC_UNKNOWN_DIRECTIVE
385
public final static int PREPROCESSOR_INVALID_DIRECTIVE = PREPROCESSOR_RELATED | 0x006;
388
* Invalid macro redefinition encountered by Preprocessor.
389
* Required attributes: A_PREPROC_MACRO_NAME
390
* @see #A_PREPROC_MACRO_NAME
392
public final static int PREPROCESSOR_INVALID_MACRO_REDEFN = PREPROCESSOR_RELATED | 0x007;
395
* Preprocessor Conditional cannot not be evaluated due.
396
* Required attributes: A_PREPROC_CONDITION
397
* @see #A_PREPROC_CONDITION
399
public final static int PREPROCESSOR_CONDITIONAL_EVAL_ERROR = PREPROCESSOR_RELATED | 0x008;
402
* Invalid macro usage encountered by Preprocessor.
403
* Required attributes: A_PREPROC_MACRO_NAME
404
* @see #A_PREPROC_MACRO_NAME
406
public final static int PREPROCESSOR_MACRO_USAGE_ERROR = PREPROCESSOR_RELATED | 0x009;
409
* Invalid Macro Pasting encountered by Preprocessor.
410
* Required attributes: A_PREPROC_MACRO_NAME
411
* @see #A_PREPROC_MACRO_NAME
413
public final static int PREPROCESSOR_MACRO_PASTING_ERROR = PREPROCESSOR_RELATED | 0x00A;
416
* Circular inclusion encountered by Preprocessor.
417
* Required attributes: A_PREPROC_INCLUDE_FILENAME
418
* @see #A_PREPROC_INCLUDE_FILENAME
420
public final static int PREPROCESSOR_CIRCULAR_INCLUSION = PREPROCESSOR_RELATED | 0x00B;
423
* macro argument "..." encountered without the required ')' i.e. must be last argument if used
424
* Required attributes: none
426
public final static int PREPROCESSOR_MISSING_RPAREN_PARMLIST = PREPROCESSOR_RELATED | 0x00C;
429
* __VA_ARGS__ encountered in macro definition without the required '...' parameter
430
* Required attributes: none
432
public final static int PREPROCESSOR_INVALID_VA_ARGS = PREPROCESSOR_RELATED | 0x00D;
435
* #warning encountered by Preprocessor.
436
* Required attributes: A_PREPROC_POUND_WARNING
437
* @see #A_PREPROC_POUND_WARNING
439
public final static int PREPROCESSOR_POUND_WARNING = PREPROCESSOR_RELATED | 0x00E;
442
* Parser Syntactic Problems
444
public final static int SYNTAX_ERROR = SYNTAX_RELATED | 0x001;
447
* Parser Semantic Problems
451
* Attempt to add a unique symbol, yet the value was already defined.
452
* Require attributes: A_SYMBOL_NAME
453
* @see #A_SYMBOL_NAME
455
public final static int SEMANTIC_UNIQUE_NAME_PREDEFINED = SEMANTICS_RELATED | 0x001;
458
* Attempt to use a symbol that was not found.
459
* Require attributes: A_SYMBOL_NAME
460
* @see #A_SYMBOL_NAME
462
public final static int SEMANTIC_NAME_NOT_FOUND = SEMANTICS_RELATED | 0x002;
465
* Name not provided in context that it was required.
466
* Require attributes: none
468
public final static int SEMANTIC_NAME_NOT_PROVIDED = SEMANTICS_RELATED | 0x003;
471
* Invalid overload of a particular name.
472
* Required attributes: A_SYMBOL_NAME
473
* @see #A_SYMBOL_NAME
475
public static final int SEMANTIC_INVALID_OVERLOAD = SEMANTICS_RELATED | 0x004;
478
* Invalid using directive.
479
* Required attributes: A_NAMESPACE_NAME
480
* @see #A_NAMESPACE_NAME
482
public static final int SEMANTIC_INVALID_USING = SEMANTICS_RELATED | 0x005;
485
* Ambiguous lookup for given name.
486
* Required attributes: A_SYMBOL_NAME
487
* @see #A_SYMBOL_NAME
489
public static final int SEMANTIC_AMBIGUOUS_LOOKUP = SEMANTICS_RELATED | 0x006;
492
* Invalid type provided
493
* Required attributes: A_TYPE_NAME
496
public static final int SEMANTIC_INVALID_TYPE = SEMANTICS_RELATED | 0x007;
498
public static final int SEMANTIC_CIRCULAR_INHERITANCE = SEMANTICS_RELATED | 0x008;
500
public static final int SEMANTIC_INVALID_TEMPLATE = SEMANTICS_RELATED | 0x009;
502
public static final int SEMANTIC_BAD_VISIBILITY = SEMANTICS_RELATED | 0x00A;
504
public static final int SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION = SEMANTICS_RELATED | 0x00B;
506
public static final int SEMANTIC_INVALID_TEMPLATE_ARGUMENT = SEMANTICS_RELATED | 0x00C;
508
public static final int SEMANTIC_INVALID_TEMPLATE_PARAMETER = SEMANTICS_RELATED | 0x00D;
510
public static final int SEMANTIC_REDECLARED_TEMPLATE_PARAMETER = SEMANTICS_RELATED | 0x00E;
512
public static final int SEMANTIC_INVALID_CONVERSION_TYPE = SEMANTICS_RELATED | 0x00F;
514
public static final int SEMANTIC_MALFORMED_EXPRESSION = SEMANTICS_RELATED | 0x010;
516
public static final int SEMANTIC_ILLFORMED_FRIEND = SEMANTICS_RELATED | 0x011;
518
public static final int SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION = SEMANTICS_RELATED | 0x012;