Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-02-21 10:20:04 +0000
committerMarkus Schorn2008-02-21 10:20:04 +0000
commitf211b6d5124b7a3df51a975fe804a36d3f50fa7a (patch)
tree5dea1d7a489d719aa549c0da2ac35e8a0fcad88b
parentf7b257a9a219c44741802251a920fda33c48ec69 (diff)
downloadorg.eclipse.cdt-f211b6d5124b7a3df51a975fe804a36d3f50fa7a.tar.gz
org.eclipse.cdt-f211b6d5124b7a3df51a975fe804a36d3f50fa7a.tar.xz
org.eclipse.cdt-f211b6d5124b7a3df51a975fe804a36d3f50fa7a.zip
Removed class Problem, a duplicate of ASTProblem, related to bug 212864.
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java34
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java8
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java2
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java103
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblem.java415
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IProblem.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTProblem.java126
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/problem/BaseProblemFactory.java34
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/problem/Problem.java232
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerProblemFactory.java81
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/TraceUtil.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java5
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java17
-rw-r--r--core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.properties3
22 files changed, 170 insertions, 951 deletions
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java
index f13aba8fc23..cf1bd496b26 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/AbstractGCCBOPConsoleParserUtility.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 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 - Initial API and implementation
+ * IBM - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
@@ -15,6 +15,7 @@ import java.util.Iterator;
import java.util.Vector;
import org.eclipse.cdt.core.IMarkerGenerator;
+import org.eclipse.cdt.core.ProblemMarkerInfo;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
@@ -28,17 +29,17 @@ import org.eclipse.core.runtime.Path;
public abstract class AbstractGCCBOPConsoleParserUtility {
private IProject project;
private IPath fBaseDirectory;
- private Vector fDirectoryStack;
+ private Vector<IPath> fDirectoryStack;
private IMarkerGenerator fMarkerGenerator;
- private ArrayList fErrors;
+ private ArrayList<Problem> fErrors;
/**
*
*/
public AbstractGCCBOPConsoleParserUtility(IProject project, IPath workingDirectory,
IMarkerGenerator markerGenerator) {
- fDirectoryStack = new Vector();
- fErrors = new ArrayList();
+ fDirectoryStack = new Vector<IPath>();
+ fErrors = new ArrayList<Problem>();
this.project = project;
fBaseDirectory = project.getLocation();
if (workingDirectory != null) {
@@ -55,13 +56,13 @@ public abstract class AbstractGCCBOPConsoleParserUtility {
/**
* @return Returns the fDirectoryStack.
*/
- protected Vector getDirectoryStack() {
+ protected Vector<IPath> getDirectoryStack() {
return fDirectoryStack;
}
/**
* @return Returns the fErrors.
*/
- protected ArrayList getErrors() {
+ protected ArrayList<Problem> getErrors() {
return fErrors;
}
/**
@@ -79,7 +80,7 @@ public abstract class AbstractGCCBOPConsoleParserUtility {
public IPath getWorkingDirectory() {
if (fDirectoryStack.size() != 0) {
- return (IPath) fDirectoryStack.lastElement();
+ return fDirectoryStack.lastElement();
}
// Fallback to the Project Location
// FIXME: if the build did not start in the Project ?
@@ -114,7 +115,7 @@ public abstract class AbstractGCCBOPConsoleParserUtility {
protected IPath popDirectory() {
int i = getDirectoryLevel();
if (i != 0) {
- IPath dir = (IPath) fDirectoryStack.lastElement();
+ IPath dir = fDirectoryStack.lastElement();
fDirectoryStack.removeElementAt(i - 1);
return dir;
}
@@ -143,25 +144,25 @@ public abstract class AbstractGCCBOPConsoleParserUtility {
public boolean reportProblems() {
boolean reset = false;
- for (Iterator iter = fErrors.iterator(); iter.hasNext(); ) {
- Problem problem = (Problem) iter.next();
+ for (Iterator<Problem> iter = fErrors.iterator(); iter.hasNext(); ) {
+ Problem problem = iter.next();
if (problem.severity == IMarkerGenerator.SEVERITY_ERROR_BUILD) {
reset = true;
}
if (problem.file == null) {
- fMarkerGenerator.addMarker(
+ fMarkerGenerator.addMarker(new ProblemMarkerInfo(
project,
problem.lineNumber,
problem.description,
problem.severity,
- problem.variableName);
+ problem.variableName));
} else {
- fMarkerGenerator.addMarker(
+ fMarkerGenerator.addMarker(new ProblemMarkerInfo(
problem.file,
problem.lineNumber,
problem.description,
problem.severity,
- problem.variableName);
+ problem.variableName));
}
}
fErrors.clear();
@@ -194,5 +195,4 @@ public abstract class AbstractGCCBOPConsoleParserUtility {
fErrors.add(problem);
}
}
-
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java
index 08e4c6faf87..d041523c32f 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LocationMapTests.java
@@ -98,11 +98,13 @@ public class LocationMapTests extends BaseTestCase {
return suite(LocationMapTests.class);
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
fLocationMap= new LocationMap();
}
+ @Override
protected void tearDown() throws Exception {
fLocationMap= null;
super.tearDown();
@@ -177,7 +179,9 @@ public class LocationMapTests extends BaseTestCase {
private void checkProblem(IASTProblem problem, int id, String arg, String marked,
String filename, int offset, int length, int line, int endline) {
assertEquals(id, problem.getID());
- assertEquals(arg, problem.getArguments());
+ if (arg != null) {
+ assertEquals(arg, problem.getArguments()[0]);
+ }
assertFalse(problem.isError());
assertTrue(problem.isWarning());
checkASTNode(problem, fTu, IASTTranslationUnit.SCANNER_PROBLEM, filename, offset, length, line, endline, marked);
@@ -302,7 +306,7 @@ public class LocationMapTests extends BaseTestCase {
fLocationMap.encounterProblem(2, "b".toCharArray(), 5,16);
IASTProblem[] problems= fLocationMap.getScannerProblems();
assertEquals(3, problems.length);
- checkProblem(problems[0], 0, "", "", FN, 0,0,1,1);
+ checkProblem(problems[0], 0, null, "", FN, 0,0,1,1);
checkProblem(problems[1], 1, "a", "12", FN,1,2,1,1);
checkProblem(problems[2], 2, "b", "56789abcdef", FN,5,11,1,1);
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java
index c2b51145270..834b537cdde 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/PreprocessorTestsBase.java
@@ -168,7 +168,7 @@ public abstract class PreprocessorTestsBase extends BaseTestCase {
IASTProblem problem= fLocationResolver.getScannerProblems()[idx];
assertEquals(problemID, problem.getID());
if (detail != null) {
- assertEquals(detail, problem.getArguments());
+ assertEquals(detail, problem.getArguments()[0]);
}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java
index 785b99d4b22..4999f370e20 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java
@@ -75,7 +75,6 @@ import org.eclipse.cdt.core.model.IContributedModelBuilder;
import org.eclipse.cdt.core.model.IProblemRequestor;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguousDeclaration;
@@ -91,104 +90,6 @@ import org.eclipse.core.runtime.OperationCanceledException;
*/
public class CModelBuilder2 implements IContributedModelBuilder {
- /**
- * Adapts {@link IASTProblem} to {@link IProblem).
- */
- private static class ProblemAdapter implements IProblem {
-
- private IASTProblem fASTProblem;
-
- /**
- * @param problem
- */
- public ProblemAdapter(IASTProblem problem) {
- fASTProblem= problem;
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#checkCategory(int)
- */
- public boolean checkCategory(int bitmask) {
- return fASTProblem.checkCategory(bitmask);
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#getArguments()
- */
- public String[] getArguments() {
- return new String[] { fASTProblem.getArguments() };
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#getID()
- */
- public int getID() {
- return fASTProblem.getID();
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#getMessage()
- */
- public String getMessage() {
- return fASTProblem.getMessageWithoutLocation();
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#getOriginatingFileName()
- */
- public char[] getOriginatingFileName() {
- return fASTProblem.getContainingFilename().toCharArray();
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#getSourceEnd()
- */
- public int getSourceEnd() {
- IASTFileLocation location= fASTProblem.getFileLocation();
- if (location != null) {
- return location.getNodeOffset() + location.getNodeLength() - 1;
- }
- return -1;
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#getSourceLineNumber()
- */
- public int getSourceLineNumber() {
- IASTFileLocation location= fASTProblem.getFileLocation();
- if (location != null) {
- return location.getStartingLineNumber();
- }
- return -1;
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#getSourceStart()
- */
- public int getSourceStart() {
- IASTFileLocation location= fASTProblem.getFileLocation();
- if (location != null) {
- return location.getNodeOffset();
- }
- return -1;
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#isError()
- */
- public boolean isError() {
- return fASTProblem.isError();
- }
-
- /*
- * @see org.eclipse.cdt.core.parser.IProblem#isWarning()
- */
- public boolean isWarning() {
- return fASTProblem.isWarning();
- }
-
- }
-
private final TranslationUnit fTranslationUnit;
private String fTranslationUnitFileName;
private ASTAccessVisibility fCurrentVisibility;
@@ -340,14 +241,14 @@ public class CModelBuilder2 implements IContributedModelBuilder {
for (int i= 0; i < problems.length; i++) {
IASTProblem problem= problems[i];
if (isLocalToFile(problem)) {
- problemRequestor.acceptProblem(new ProblemAdapter(problem));
+ problemRequestor.acceptProblem(problem);
}
}
problems= CPPVisitor.getProblems(ast);
for (int i= 0; i < problems.length; i++) {
IASTProblem problem= problems[i];
if (isLocalToFile(problem)) {
- problemRequestor.acceptProblem(new ProblemAdapter(problem));
+ problemRequestor.acceptProblem(problem);
}
}
problemRequestor.endReporting();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
index 9c04705405d..29ef5306721 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
@@ -1083,6 +1083,6 @@ public class ASTSignatureUtil {
* Returns the same message as {@link IASTProblem#getMessageWithoutLocation()}.
*/
public static String getProblemMessage(int problemID, String detail) {
- return ASTProblem.getMessageWithoutLocation(problemID, detail);
+ return ASTProblem.getMessage(problemID, detail);
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblem.java
index b67d045d93f..ff9f596dce4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblem.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTProblem.java
@@ -11,419 +11,10 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
-import org.eclipse.cdt.internal.core.parser.ParserMessages;
+import org.eclipse.cdt.core.parser.IProblem;
/**
- * @author jcamelon
- *
- * Description of a C/C++ parse/compilation problem, as detected by the parser
- * or some of the underlying clients of the parser.
- *
- * A problem provides access to:
- * <ul>
- * <li> its location (originating source file name, source position, line
- * number), </li>
- * <li> its message description and a predicate to check its severity (warning
- * or error). </li>
- * <li> its ID : an number identifying the very nature of this problem. All
- * possible IDs are listed as constants on this interface. </li>
- * </ul>
+ * Interface for problems in the ast tree.
*/
-public interface IASTProblem extends IASTNode {
- /**
- * Returns the problem id
- *
- * @return the problem id
- */
- int getID();
-
- /**
- * Answer a localized, human-readable message string which describes the
- * problem including its location
- *
- * @return a localized, human-readable message string which describes the
- * problem
- */
- String getMessage();
-
- /**
- * Returns a human-readable message string describing the problem, without
- * location information.
- */
- String getMessageWithoutLocation();
-
- /**
- * 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.
- */
- String getArguments();
-
- /**
- * Checks the severity to see if the Error bit is set.
- *
- * @return true if the Error bit is set for the severity, false otherwise
- */
- 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
- */
- boolean isWarning();
-
- /**
- * Unknown Numeric Value for line numbers and offsets; use this constant
- */
- 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. For example, (problemID & TypeRelated) !=
- * 0, indicates that this problem is type related.
- *
- * A problem category can help to implement custom problem filters. Indeed,
- * when numerous problems are listed, focusing on import related problems
- * first might be relevant.
- *
- * When a problem is tagged as Internal, it means that no change other than
- * a local source code change can fix the corresponding problem.
- */
-
- /**
- * IProblem relates to a valid error on the Scanner
- */
- public final static int SCANNER_RELATED = 0x01000000;
-
- /**
- * IProblem relates to a valid error on the preprocessor
- */
- public final static int PREPROCESSOR_RELATED = 0x02000000;
-
- /**
- * IProblem relates to a valid syntax error in the parser
- */
- 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
- */
- public final static int INTERNAL_RELATED = 0x10000000;
-
- /**
- * Check the parameter bitmask against an IProblem's ID to broadly segregate
- * the types of problems.
- *
- * @param bitmask
- * @return true if ( (id & bitmask ) != 0 )
- */
- public boolean checkCategory(int bitmask);
-
- /**
- * Mask to use in order to filter out the category portion of the problem
- * ID.
- */
- 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
- */
-
- /**
- * Bad character encountered by Scanner. Required attributes:
- * A_SCANNER_BADCHAR
- *
- * @see #A_SCANNER_BADCHAR
- */
- public final static int SCANNER_BAD_CHARACTER = SCANNER_RELATED | 0x001;
-
- /**
- * Unbounded literal string encountered by Scanner. Required attributes:
- * none.
- */
- public final static int SCANNER_UNBOUNDED_STRING = SCANNER_RELATED | 0x002;
-
- /**
- * Invalid escape sequence encountered by Scanner. Required attributes:
- * none.
- */
- public final static int SCANNER_INVALID_ESCAPECHAR = SCANNER_RELATED | 0x003;
-
- /**
- * Bad floating point encountered by Scanner. Required attributes: none.
- */
- public final static int SCANNER_BAD_FLOATING_POINT = SCANNER_RELATED | 0x004;
-
- /**
- * Bad hexidecimal encountered by Scanner. Required attributes: none.
- */
- public final static int SCANNER_BAD_HEX_FORMAT = SCANNER_RELATED | 0x005;
-
- /**
- * Unexpected EOF encountered by Scanner. Required attributes: none.
- */
- public final static int SCANNER_UNEXPECTED_EOF = SCANNER_RELATED | 0x006;
-
- /**
- * Bad octal encountered by Scanner. Required attributes: none.
- */
- public final static int SCANNER_BAD_OCTAL_FORMAT = SCANNER_RELATED | 0x007;
-
- /**
- * Bad decimal encountered by Scanner. Required attributes: none.
- */
- public final static int SCANNER_BAD_DECIMAL_FORMAT = SCANNER_RELATED | 0x008;
-
- /**
- * Assignment '=' encountered in macro by Scanner. Required attributes:
- * none.
- */
- public final static int SCANNER_ASSIGNMENT_NOT_ALLOWED = SCANNER_RELATED | 0x009;
-
- /**
- * Division by 0 encountered in macro by Scanner. Required attributes: none.
- */
- public final static int SCANNER_DIVIDE_BY_ZERO = SCANNER_RELATED | 0x00A;
-
- /**
- * Missing ')' encountered in macro by Scanner. Required attributes: none.
- */
- public final static int SCANNER_MISSING_R_PAREN = SCANNER_RELATED | 0x00B;
-
- /**
- * Expression syntax error encountered in macro by Scanner. Required
- * attributes: none.
- */
- public final static int SCANNER_EXPRESSION_SYNTAX_ERROR = SCANNER_RELATED | 0x00C;
-
- /**
- * Expression syntax error encountered in macro by Scanner. Required
- * attributes: none.
- */
- public final static int SCANNER_ILLEGAL_IDENTIFIER = SCANNER_RELATED | 0x00D;
-
- /**
- * Division by 0 encountered in macro by Scanner. Required attributes: none.
- */
- public final static int SCANNER_BAD_CONDITIONAL_EXPRESSION = SCANNER_RELATED | 0x00E;
-
- /*
- * Preprocessor Problems
- */
-
- /**
- * #error encountered by Preprocessor. Required attributes:
- * A_PREPROC_POUND_ERROR
- *
- * @see #A_PREPROC_POUND_ERROR
- */
- public final static int PREPROCESSOR_POUND_ERROR = PREPROCESSOR_RELATED | 0x001;
-
- /**
- * Inclusion not found by Preprocessor. Required attributes:
- * A_PREPROC_INCLUDE_FILENAME
- *
- * @see #A_PREPROC_INCLUDE_FILENAME
- */
- public final static int PREPROCESSOR_INCLUSION_NOT_FOUND = PREPROCESSOR_RELATED | 0x002;
-
- /**
- * Macro definition not found by Preprocessor. Required attributes:
- * A_PREPROC_MACRO_NAME
- *
- * @see #A_PREPROC_MACRO_NAME
- */
- public final static int PREPROCESSOR_DEFINITION_NOT_FOUND = PREPROCESSOR_RELATED | 0x003;
-
- /**
- * Preprocessor conditionals seem unbalanced. Required attributes:
- * A_PREPROC_CONDITIONAL_MISMATCH
- *
- * @see #A_PREPROC_CONDITIONAL_MISMATCH
- */
-
- public final static int PREPROCESSOR_UNBALANCE_CONDITION = PREPROCESSOR_RELATED | 0x004;
-
- /**
- * Invalid format to Macro definition. Required attributes:
- * A_PREPROC_MACRO_NAME
- *
- * @see #A_PREPROC_MACRO_NAME
- */
- public final static int PREPROCESSOR_INVALID_MACRO_DEFN = PREPROCESSOR_RELATED | 0x005;
-
- /**
- * Invalid or unknown preprocessor directive encountered by Preprocessor.
- * Required attributes: A_PREPROC_UNKNOWN_DIRECTIVE
- *
- * @see #A_PREPROC_UNKNOWN_DIRECTIVE
- */
- public final static int PREPROCESSOR_INVALID_DIRECTIVE = PREPROCESSOR_RELATED | 0x006;
-
- /**
- * Invalid macro redefinition encountered by Preprocessor. Required
- * attributes: A_PREPROC_MACRO_NAME
- *
- * @see #A_PREPROC_MACRO_NAME
- */
- public final static int PREPROCESSOR_INVALID_MACRO_REDEFN = PREPROCESSOR_RELATED | 0x007;
-
- /**
- * Preprocessor Conditional cannot not be evaluated due. Required
- * attributes: A_PREPROC_CONDITION
- *
- * @see #A_PREPROC_CONDITION
- */
- public final static int PREPROCESSOR_CONDITIONAL_EVAL_ERROR = PREPROCESSOR_RELATED | 0x008;
-
- /**
- * Invalid macro usage encountered by Preprocessor. Required attributes:
- * A_PREPROC_MACRO_NAME
- *
- * @see #A_PREPROC_MACRO_NAME
- */
- public final static int PREPROCESSOR_MACRO_USAGE_ERROR = PREPROCESSOR_RELATED | 0x009;
-
- /**
- * Invalid Macro Pasting encountered by Preprocessor. Required attributes:
- * A_PREPROC_MACRO_NAME
- *
- * @see #A_PREPROC_MACRO_NAME
- */
- public final static int PREPROCESSOR_MACRO_PASTING_ERROR = PREPROCESSOR_RELATED | 0x00A;
-
- /**
- * Circular inclusion encountered by Preprocessor. Required attributes:
- * A_PREPROC_INCLUDE_FILENAME
- *
- * @see #A_PREPROC_INCLUDE_FILENAME
- */
- public final static int PREPROCESSOR_CIRCULAR_INCLUSION = PREPROCESSOR_RELATED | 0x00B;
-
- /**
- * macro argument "..." encountered without the required ')' i.e. must be
- * last argument if used Required attributes: none
- */
- public final static int PREPROCESSOR_MISSING_RPAREN_PARMLIST = PREPROCESSOR_RELATED | 0x00C;
-
- /**
- * __VA_ARGS__ encountered in macro definition without the required '...'
- * parameter Required attributes: none
- */
- public final static int PREPROCESSOR_INVALID_VA_ARGS = PREPROCESSOR_RELATED | 0x00D;
-
- /**
- * #warning encountered by Preprocessor. Required attributes:
- * A_PREPROC_POUND_WARNING
- *
- * @see #A_PREPROC_POUND_WARNING
- */
- public final static int PREPROCESSOR_POUND_WARNING = PREPROCESSOR_RELATED | 0x00E;
-
- /*
- * Parser Syntactic Problems
- */
- public final static int SYNTAX_ERROR = SYNTAX_RELATED | 0x001;
-
+public interface IASTProblem extends IProblem, IASTNode {
}
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 5f588d56f96..03561e8fbd1 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,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 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
@@ -43,6 +43,12 @@ public interface IProblem
String getMessage();
/**
+ * Returns a human-readable message string describing the problem, adding
+ * location information.
+ */
+ String getMessageWithLocation();
+
+ /**
* Return to the client a map between parameter names and values.
*
* The keys and values are all Strings.
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 f8a32b57dc0..9256e5bf0be 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
@@ -61,24 +61,16 @@ public class ASTProblem extends ASTNode implements IASTProblem {
return !isError;
}
- public String getMessage() {
- String msg= getMessageWithoutLocation();
-
- IASTFileLocation f = getFileLocation();
- String file = null;
- int line = 0;
- if( f == null )
- {
- file = ""; //$NON-NLS-1$
- } else {
- file = f.getFileName();
- line = f.getStartingLineNumber();
- }
+ public String getMessageWithLocation() {
+ String msg= getMessage();
+
+ char[] file= getOriginatingFileName();
+ int line= getSourceLineNumber();
Object[] args = new Object[] { msg, file, new Integer(line) };
return ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
}
- public static String getMessageWithoutLocation(int id, String arg) {
+ public static String getMessage(int id, String arg) {
String msg = errorMessages.get(new Integer(id));
if (msg == null)
msg = ""; //$NON-NLS-1$
@@ -89,81 +81,121 @@ public class ASTProblem extends ASTNode implements IASTProblem {
return msg;
}
- public String getMessageWithoutLocation() {
- return getMessageWithoutLocation(id, arg == null ? null : new String(arg));
+ public String getMessage() {
+ return getMessage(id, arg == null ? null : new String(arg));
}
public boolean checkCategory(int bitmask) {
return ((id & bitmask) != 0);
}
- public String getArguments() {
- return arg != null ? String.valueOf(arg) : ""; //$NON-NLS-1$
+ public String[] getArguments() {
+ return arg == null ? new String[0] : new String[] {new String(arg)};
}
protected static final Map<Integer, String> errorMessages;
static {
errorMessages = new HashMap<Integer, String>();
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_POUND_ERROR),
+ errorMessages.put(new Integer(PREPROCESSOR_POUND_ERROR),
ParserMessages.getString("ScannerProblemFactory.error.preproc.error")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_POUND_WARNING),
+ errorMessages.put(new Integer(PREPROCESSOR_POUND_WARNING),
ParserMessages.getString("ScannerProblemFactory.error.preproc.warning")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_INCLUSION_NOT_FOUND),
+ errorMessages.put(new Integer(PREPROCESSOR_INCLUSION_NOT_FOUND),
ParserMessages.getString("ScannerProblemFactory.error.preproc.inclusionNotFound")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_DEFINITION_NOT_FOUND),
+ errorMessages.put(new Integer(PREPROCESSOR_DEFINITION_NOT_FOUND),
ParserMessages.getString("ScannerProblemFactory.error.preproc.definitionNotFound")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_INVALID_MACRO_DEFN),
+ errorMessages.put(new Integer(PREPROCESSOR_INVALID_MACRO_DEFN),
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidMacroDefn")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_INVALID_MACRO_REDEFN),
+ errorMessages.put(new Integer(PREPROCESSOR_INVALID_MACRO_REDEFN),
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidMacroRedefn")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_UNBALANCE_CONDITION),
+ errorMessages.put(new Integer(PREPROCESSOR_UNBALANCE_CONDITION),
ParserMessages.getString("ScannerProblemFactory.error.preproc.unbalancedConditional")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR),
+ errorMessages.put(new Integer(PREPROCESSOR_CONDITIONAL_EVAL_ERROR),
ParserMessages.getString("ScannerProblemFactory.error.preproc.conditionalEval")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_MACRO_USAGE_ERROR),
+ errorMessages.put(new Integer(PREPROCESSOR_MACRO_USAGE_ERROR),
ParserMessages.getString("ScannerProblemFactory.error.preproc.macroUsage")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_CIRCULAR_INCLUSION),
+ errorMessages.put(new Integer(PREPROCESSOR_CIRCULAR_INCLUSION),
ParserMessages.getString("ScannerProblemFactory.error.preproc.circularInclusion")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_INVALID_DIRECTIVE),
+ errorMessages.put(new Integer(PREPROCESSOR_INVALID_DIRECTIVE),
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidDirective")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_MACRO_PASTING_ERROR),
+ errorMessages.put(new Integer(PREPROCESSOR_MACRO_PASTING_ERROR),
ParserMessages.getString("ScannerProblemFactory.error.preproc.macroPasting")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST),
+ errorMessages.put(new Integer(PREPROCESSOR_MISSING_RPAREN_PARMLIST),
ParserMessages.getString("ScannerProblemFactory.error.preproc.missingRParen")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.PREPROCESSOR_INVALID_VA_ARGS),
+ errorMessages.put(new Integer(PREPROCESSOR_INVALID_VA_ARGS),
ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidVaArgs")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_INVALID_ESCAPECHAR),
+ errorMessages.put(new Integer(SCANNER_INVALID_ESCAPECHAR),
ParserMessages.getString("ScannerProblemFactory.error.scanner.invalidEscapeChar")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_UNBOUNDED_STRING),
+ errorMessages.put(new Integer(SCANNER_UNBOUNDED_STRING),
ParserMessages.getString("ScannerProblemFactory.error.scanner.unboundedString")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_BAD_FLOATING_POINT),
+ errorMessages.put(new Integer(SCANNER_BAD_FLOATING_POINT),
ParserMessages.getString("ScannerProblemFactory.error.scanner.badFloatingPoint")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_BAD_HEX_FORMAT),
+ errorMessages.put(new Integer(SCANNER_BAD_HEX_FORMAT),
ParserMessages.getString("ScannerProblemFactory.error.scanner.badHexFormat")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_BAD_OCTAL_FORMAT),
+ errorMessages.put(new Integer(SCANNER_BAD_OCTAL_FORMAT),
ParserMessages.getString("ScannerProblemFactory.error.scanner.badOctalFormat")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_BAD_DECIMAL_FORMAT),
+ errorMessages.put(new Integer(SCANNER_BAD_DECIMAL_FORMAT),
ParserMessages.getString("ScannerProblemFactory.error.scanner.badDecimalFormat")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_ASSIGNMENT_NOT_ALLOWED),
+ errorMessages.put(new Integer(SCANNER_ASSIGNMENT_NOT_ALLOWED),
ParserMessages.getString("ScannerProblemFactory.error.scanner.assignmentNotAllowed")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_DIVIDE_BY_ZERO),
+ errorMessages.put(new Integer(SCANNER_DIVIDE_BY_ZERO),
ParserMessages.getString("ScannerProblemFactory.error.scanner.divideByZero")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_MISSING_R_PAREN),
+ errorMessages.put(new Integer(SCANNER_MISSING_R_PAREN),
ParserMessages.getString("ScannerProblemFactory.error.scanner.missingRParen")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_EXPRESSION_SYNTAX_ERROR),
+ errorMessages.put(new Integer(SCANNER_EXPRESSION_SYNTAX_ERROR),
ParserMessages.getString("ScannerProblemFactory.error.scanner.expressionSyntaxError")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_ILLEGAL_IDENTIFIER),
+ errorMessages.put(new Integer(SCANNER_ILLEGAL_IDENTIFIER),
ParserMessages.getString("ScannerProblemFactory.error.scanner.illegalIdentifier")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION),
+ errorMessages.put(new Integer(SCANNER_BAD_CONDITIONAL_EXPRESSION),
ParserMessages.getString("ScannerProblemFactory.error.scanner.badConditionalExpression")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_UNEXPECTED_EOF),
+ errorMessages.put(new Integer(SCANNER_UNEXPECTED_EOF),
ParserMessages.getString("ScannerProblemFactory.error.scanner.unexpectedEOF")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SCANNER_BAD_CHARACTER),
+ errorMessages.put(new Integer(SCANNER_BAD_CHARACTER),
ParserMessages.getString("ScannerProblemFactory.error.scanner.badCharacter")); //$NON-NLS-1$
- errorMessages.put(new Integer(IASTProblem.SYNTAX_ERROR),
+ errorMessages.put(new Integer(SYNTAX_ERROR),
ParserMessages.getString("ParserProblemFactory.error.syntax.syntaxError")); //$NON-NLS-1$
}
protected final static String PROBLEM_PATTERN = "BaseProblemFactory.problemPattern"; //$NON-NLS-1$
+
+ /*
+ * @see org.eclipse.cdt.core.parser.IProblem#getOriginatingFileName()
+ */
+ public char[] getOriginatingFileName() {
+ return getContainingFilename().toCharArray();
+ }
+
+ /*
+ * @see org.eclipse.cdt.core.parser.IProblem#getSourceEnd()
+ */
+ public int getSourceEnd() {
+ final IASTFileLocation location= getFileLocation();
+ if (location != null) {
+ return location.getNodeOffset() + location.getNodeLength() - 1;
+ }
+ return -1;
+ }
+
+ /*
+ * @see org.eclipse.cdt.core.parser.IProblem#getSourceLineNumber()
+ */
+ public int getSourceLineNumber() {
+ final IASTFileLocation location= getFileLocation();
+ if (location != null) {
+ return location.getStartingLineNumber();
+ }
+ return -1;
+ }
+
+ /*
+ * @see org.eclipse.cdt.core.parser.IProblem#getSourceStart()
+ */
+ public int getSourceStart() {
+ final IASTFileLocation location= getFileLocation();
+ if (location != null) {
+ return location.getNodeOffset();
+ }
+ return -1;
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
index ead967abe83..b99ec621b60 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java
@@ -67,6 +67,7 @@ import org.eclipse.cdt.core.parser.AbstractParserLogService;
import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IGCCToken;
import org.eclipse.cdt.core.parser.IParserLogService;
+import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
@@ -343,7 +344,7 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
IASTProblem result = null;
if (bt.getProblem() == null)
- result = createProblem(IASTProblem.SYNTAX_ERROR, bt.getOffset(), bt
+ result = createProblem(IProblem.SYNTAX_ERROR, bt.getOffset(), bt
.getLength());
else
result = bt.getProblem();
@@ -383,7 +384,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
}
}
- public String toString() {
+ @Override
+ public String toString() {
return scanner.toString();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
index f37c6d5b76a..d389f23603b 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
@@ -101,6 +101,7 @@ import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IGCCToken;
import org.eclipse.cdt.core.parser.IParserLogService;
+import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ParserMode;
@@ -2451,7 +2452,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
}
private IASTProblemDeclaration createKnRCProblemDeclaration(int length, int offset) throws EndOfFileException {
- IASTProblem p = createProblem(IASTProblem.SYNTAX_ERROR, offset, length);
+ IASTProblem p = createProblem(IProblem.SYNTAX_ERROR, offset, length);
IASTProblemDeclaration pd = createProblemDeclaration();
pd.setProblem(p);
((ASTNode) pd).setOffsetAndLength(((ASTNode) p).getOffset(), ((ASTNode) p).getLength());
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index 9d96d36b5da..09af7466058 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -134,6 +134,7 @@ import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.parser.EndOfFileException;
import org.eclipse.cdt.core.parser.IGCCToken;
import org.eclipse.cdt.core.parser.IParserLogService;
+import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.core.parser.IScanner;
import org.eclipse.cdt.core.parser.IToken;
import org.eclipse.cdt.core.parser.ITokenDuple;
@@ -3721,7 +3722,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
if (typeId != null) {
exceptionSpecIds.add(typeId);
} else {
- IASTProblem p = createProblem(IASTProblem.SYNTAX_ERROR,
+ IASTProblem p = createProblem(IProblem.SYNTAX_ERROR,
before.getOffset(), before.getLength());
IASTProblemTypeId typeIdProblem = createTypeIDProblem();
typeIdProblem.setProblem(p);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/problem/BaseProblemFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/problem/BaseProblemFactory.java
deleted file mode 100644
index e72d8824171..00000000000
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/problem/BaseProblemFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2006 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 Rational Software - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.parser.problem;
-
-import org.eclipse.cdt.core.parser.IProblem;
-
-/**
- * @author jcamelon
- */
-public abstract class BaseProblemFactory {
- protected final static String PROBLEM_PATTERN = "BaseProblemFactory.problemPattern"; //$NON-NLS-1$
-
- public IProblem createProblem(int id, int start, int end, int line, char[] file, String[] arg,
- boolean warn, boolean error) {
- return new Problem( id, start, end, line, file, arg, warn, error);
- }
-
- public boolean checkBitmask(int id, int bitmask) {
- return (id & bitmask) != 0;
- }
-
- protected IProblem createInternalProblem( int id, int start, int end, int line, char[] file, String[] arg,
- boolean warn, boolean error) {
- return createProblem(id, start, end, line, file, arg, warn, error);
- }
-}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/problem/Problem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/problem/Problem.java
deleted file mode 100644
index 7a58fca1dbe..00000000000
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/problem/Problem.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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 Rational Software - Initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.parser.problem;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.cdt.core.parser.IProblem;
-import org.eclipse.cdt.internal.core.parser.ParserMessages;
-
-/**
- * @author jcamelon
- */
-public class Problem implements IProblem {
- private final String[] arg;
- private final int id;
- private final int sourceStart;
- private final int sourceEnd;
- private final int lineNumber;
-
- private final boolean isError;
- private final boolean isWarning;
- private final char[] originatingFileName;
-
- private String message = null;
-
- public Problem(int id, int start, int end, int line, char[] file, String[] arg,
- boolean warn, boolean error) {
- this.id = id;
- this.sourceStart = start;
- this.sourceEnd = end;
- this.lineNumber = line;
- this.originatingFileName = file;
- this.arg = arg;
- this.isWarning = warn;
- this.isError = error;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IProblem#getID()
- */
- public int getID() {
- return id;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IProblem#getOriginatingFileName()
- */
- public char[] getOriginatingFileName() {
- return originatingFileName;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IProblem#getSourceEnd()
- */
- public int getSourceEnd() {
- return sourceEnd;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IProblem#getSourceLineNumber()
- */
- public int getSourceLineNumber() {
- return lineNumber;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IProblem#getSourceStart()
- */
- public int getSourceStart() {
- return sourceStart;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IProblem#isError()
- */
- public boolean isError() {
- return isError;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IProblem#isWarning()
- */
- public boolean isWarning() {
- return isWarning;
- }
-
- protected static final Map<Integer, String> errorMessages;
- static {
- errorMessages = new HashMap<Integer, String>();
- errorMessages.put(IProblem.SEMANTIC_UNIQUE_NAME_PREDEFINED,
- ParserMessages.getString("ASTProblemFactory.error.semantic.uniqueNamePredefined")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_NAME_NOT_FOUND,
- ParserMessages.getString("ASTProblemFactory.error.semantic.nameNotFound")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_NAME_NOT_PROVIDED,
- ParserMessages.getString("ASTProblemFactory.error.semantic.nameNotProvided")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_INVALID_CONVERSION_TYPE ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.invalidConversionType")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_MALFORMED_EXPRESSION ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.malformedExpression")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_AMBIGUOUS_LOOKUP ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.ambiguousLookup")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_INVALID_TYPE ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidType")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_CIRCULAR_INHERITANCE ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.circularInheritance")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_INVALID_OVERLOAD ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidOverload")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_INVALID_TEMPLATE ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplate")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_INVALID_USING ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidUsing")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_BAD_VISIBILITY ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.badVisibility")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_UNABLE_TO_RESOLVE_FUNCTION ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.unableToResolveFunction")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_INVALID_TEMPLATE_ARGUMENT ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateArgument")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_INVALID_TEMPLATE_PARAMETER ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.invalidTemplateParameter")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_REDECLARED_TEMPLATE_PARAMETER ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.redeclaredTemplateParameter")); //$NON-NLS-1$
- errorMessages.put(IProblem.SEMANTIC_RECURSIVE_TEMPLATE_INSTANTIATION ,
- ParserMessages.getString("ASTProblemFactory.error.semantic.pst.recursiveTemplateInstantiation")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_POUND_ERROR,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.error")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_POUND_WARNING,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.warning")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.inclusionNotFound")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_DEFINITION_NOT_FOUND,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.definitionNotFound")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_INVALID_MACRO_DEFN,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidMacroDefn")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_INVALID_MACRO_REDEFN,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidMacroRedefn")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_UNBALANCE_CONDITION,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.unbalancedConditional")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.conditionalEval")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_MACRO_USAGE_ERROR,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.macroUsage")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_CIRCULAR_INCLUSION,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.circularInclusion")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_INVALID_DIRECTIVE,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidDirective")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_MACRO_PASTING_ERROR,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.macroPasting")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_MISSING_RPAREN_PARMLIST,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.missingRParen")); //$NON-NLS-1$
- errorMessages.put(IProblem.PREPROCESSOR_INVALID_VA_ARGS,
- ParserMessages.getString("ScannerProblemFactory.error.preproc.invalidVaArgs")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_INVALID_ESCAPECHAR,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.invalidEscapeChar")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_UNBOUNDED_STRING,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.unboundedString")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_BAD_FLOATING_POINT,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.badFloatingPoint")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_BAD_HEX_FORMAT,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.badHexFormat")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_BAD_OCTAL_FORMAT,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.badOctalFormat")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_BAD_DECIMAL_FORMAT,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.badDecimalFormat")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_ASSIGNMENT_NOT_ALLOWED,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.assignmentNotAllowed")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_DIVIDE_BY_ZERO,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.divideByZero")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_MISSING_R_PAREN,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.missingRParen")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_EXPRESSION_SYNTAX_ERROR,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.expressionSyntaxError")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_ILLEGAL_IDENTIFIER,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.illegalIdentifier")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_BAD_CONDITIONAL_EXPRESSION,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.badConditionalExpression")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_UNEXPECTED_EOF,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.unexpectedEOF")); //$NON-NLS-1$
- errorMessages.put(IProblem.SCANNER_BAD_CHARACTER,
- ParserMessages.getString("ScannerProblemFactory.error.scanner.badCharacter")); //$NON-NLS-1$
- errorMessages.put(IProblem.SYNTAX_ERROR,
- ParserMessages.getString("ParserProblemFactory.error.syntax.syntaxError")); //$NON-NLS-1$
- }
- protected final static String PROBLEM_PATTERN = "BaseProblemFactory.problemPattern"; //$NON-NLS-1$
-
- public String getMessage() {
- if (message != null)
- return message;
-
- String msg = errorMessages.get(id);
- if (msg == null)
- msg = ""; //$NON-NLS-1$
-
- if (arg != null) {
- msg = MessageFormat.format(msg, (Object[]) arg);
- }
-
- String[] args = null;
- if (originatingFileName != null) {
- args = new String[] { msg, new String(originatingFileName), String.valueOf(lineNumber) };
- } else {
- args = new String[] { msg, "", String.valueOf(lineNumber) }; //$NON-NLS-1$
- }
-
- message = ParserMessages.getFormattedString(PROBLEM_PATTERN, args);
- return message;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IProblem#checkCategory(int)
- */
- public boolean checkCategory(int bitmask) {
- return (id & bitmask) != 0;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.IProblem#getArguments()
- */
- public String[] getArguments() {
- return arg;
- }
-}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerProblemFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerProblemFactory.java
deleted file mode 100644
index e4dd39f1e4b..00000000000
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerProblemFactory.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002, 2007 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 Rational Software - Initial API and implementation
- * Anton Leherbauer (Wind River Systems)
- *******************************************************************************/
-package org.eclipse.cdt.internal.core.parser.scanner;
-
-import org.eclipse.cdt.core.parser.IProblem;
-import org.eclipse.cdt.internal.core.parser.problem.BaseProblemFactory;
-import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
-
-/**
- * @author jcamelon
- *
- */
-public class ScannerProblemFactory extends BaseProblemFactory implements IProblemFactory
-{
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser.IProblemFactory#createProblem(int, int, int, int, char[], java.lang.String, boolean, boolean)
- */
- public IProblem createProblem(int id, int start, int end, int line, char[] file, String[] arg,
- boolean warn, boolean error) {
- if (checkBitmask(id, IProblem.INTERNAL_RELATED))
- return createInternalProblem(id, start, end, line, file, arg, warn, error);
-
- if (checkBitmask(id, IProblem.SCANNER_RELATED) ||
- checkBitmask(id, IProblem.PREPROCESSOR_RELATED)) {
- return super.createProblem(id, start, end, line, file, arg, warn, error);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.parser.IProblemFactory#getRequiredAttributesForId(int)
- */
- public String getRequiredAttributesForId(int id)
- {
- switch (id)
- {
- case IProblem.PREPROCESSOR_POUND_ERROR :
- return IProblem.A_PREPROC_POUND_ERROR;
- case IProblem.PREPROCESSOR_POUND_WARNING :
- return IProblem.A_PREPROC_POUND_WARNING;
- case IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND :
- return IProblem.A_PREPROC_INCLUDE_FILENAME;
- case IProblem.PREPROCESSOR_DEFINITION_NOT_FOUND :
- return IProblem.A_PREPROC_MACRO_NAME;
- case IProblem.PREPROCESSOR_UNBALANCE_CONDITION :
- return IProblem.A_PREPROC_CONDITIONAL_MISMATCH;
- case IProblem.PREPROCESSOR_INVALID_MACRO_DEFN :
- return IProblem.A_PREPROC_MACRO_NAME;
- case IProblem.PREPROCESSOR_INVALID_DIRECTIVE :
- return IProblem.A_PREPROC_UNKNOWN_DIRECTIVE;
- case IProblem.PREPROCESSOR_INVALID_MACRO_REDEFN :
- return IProblem.A_PREPROC_MACRO_NAME;
- case IProblem.PREPROCESSOR_CONDITIONAL_EVAL_ERROR :
- return IProblem.A_PREPROC_CONDITION;
- case IProblem.PREPROCESSOR_MACRO_USAGE_ERROR :
- return IProblem.A_PREPROC_MACRO_NAME;
- case IProblem.PREPROCESSOR_MACRO_PASTING_ERROR :
- return IProblem.A_PREPROC_MACRO_NAME;
- case IProblem.PREPROCESSOR_CIRCULAR_INCLUSION :
- return IProblem.A_PREPROC_INCLUDE_FILENAME;
- case IProblem.SCANNER_BAD_CHARACTER :
- return IProblem.A_SCANNER_BADCHAR;
- case IProblem.SCANNER_UNBOUNDED_STRING :
- case IProblem.SCANNER_INVALID_ESCAPECHAR :
- case IProblem.SCANNER_BAD_FLOATING_POINT :
- case IProblem.SCANNER_BAD_HEX_FORMAT :
- case IProblem.SCANNER_UNEXPECTED_EOF :
- break;
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/TraceUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/TraceUtil.java
index 5f98e821b2f..684dff1acd1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/TraceUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/util/TraceUtil.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 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
@@ -22,7 +22,7 @@ public class TraceUtil {
if( log.isTracing() ) {
StringBuffer buffer = new StringBuffer();
if( preface != null ) buffer.append( preface );
- if( problem != null ) buffer.append( problem.getMessage());
+ if( problem != null ) buffer.append( problem.getMessageWithLocation());
if( first != null ) buffer.append( first );
if( second != null ) buffer.append( second );
if( third != null ) buffer.append( third );
@@ -33,7 +33,7 @@ public class TraceUtil {
if( log.isTracing() ) {
StringBuffer buffer = new StringBuffer();
if( preface != null ) buffer.append( preface );
- if( problem != null ) buffer.append( problem.getMessage());
+ if( problem != null ) buffer.append( problem.getMessageWithLocation());
log.traceLog( buffer.toString() );
}
}
@@ -41,7 +41,7 @@ public class TraceUtil {
if( log.isTracing() ) {
StringBuffer buffer = new StringBuffer();
if( preface != null ) buffer.append( preface );
- if( problem != null ) buffer.append( problem.getMessage());
+ if( problem != null ) buffer.append( problem.getMessageWithLocation());
if( first != null ) buffer.append( first );
if( second != null ) buffer.append( second );
if( third != null ) buffer.append( third );
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java
index 111f690ff16..e5c195c6767 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java
@@ -42,6 +42,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexFileLocation;
+import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.index.IWritableIndex;
@@ -343,7 +344,7 @@ abstract public class PDOMWriter {
final boolean reportAll= fShowScannerProblems && fShowInclusionProblems;
IASTProblem[] scannerProblems= ast.getPreprocessorProblems();
for (IASTProblem problem : scannerProblems) {
- if (reportAll || (problem.getID() == IASTProblem.PREPROCESSOR_INCLUSION_NOT_FOUND) == fShowInclusionProblems) {
+ if (reportAll || (problem.getID() == IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND) == fShowInclusionProblems) {
reportProblem(problem);
}
}
@@ -492,7 +493,7 @@ abstract public class PDOMWriter {
}
private void reportProblem(IASTProblem problem) {
- String msg= "Indexer: " + problem.getMessage(); //$NON-NLS-1$
+ String msg= "Indexer: " + problem.getMessageWithLocation(); //$NON-NLS-1$
System.out.println(msg);
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
index 49fc9deef8f..f80f8a1a511 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
@@ -147,7 +147,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
private static class ASTProblemException extends RuntimeException {
ASTProblemException(IASTProblem problem) {
- super(problem.getMessage());
+ super(problem.getMessageWithLocation());
}
}
@@ -197,6 +197,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
public CodeFormatterVisitor(DefaultCodeFormatterOptions preferences, Map<String, String> settings, int offset, int length) {
localScanner = new Scanner() {
+ @Override
public Token nextToken() {
Token t= super.nextToken();
while (t != null && (t.isWhiteSpace() || t.isPreprocessor())) {
@@ -274,6 +275,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTTranslationUnit)
*/
+ @Override
public int visit(IASTTranslationUnit tu) {
// fake new line
scribe.lastNumberOfNewLines = 1;
@@ -310,6 +312,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
*/
+ @Override
public int visit(IASTDeclaration node) {
startNode(node);
int indentLevel= scribe.indentationLevel;
@@ -364,6 +367,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
*/
+ @Override
public int visit(IASTName node) {
startNode(node);
try {
@@ -383,6 +387,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTInitializer)
*/
+ @Override
public int visit(IASTInitializer node) {
if (node instanceof ICPPASTConstructorInitializer) {
visit((ICPPASTConstructorInitializer)node);
@@ -416,6 +421,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration)
*/
+ @Override
public int visit(IASTParameterDeclaration parameterDeclaration) {
formatNode(parameterDeclaration);
endOfNode(parameterDeclaration);
@@ -425,6 +431,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclarator)
*/
+ @Override
public int visit(IASTDeclarator node) {
startNode(node);
@@ -472,6 +479,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier)
*/
+ @Override
public int visit(IASTDeclSpecifier node) {
startNode(node);
try {
@@ -501,6 +509,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTExpression)
*/
+ @Override
public int visit(IASTExpression node) {
// scribe.printComment();
startNode(node);
@@ -539,6 +548,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTStatement)
*/
+ @Override
public int visit(IASTStatement node) {
// scribe.printComment();
startNode(node);
@@ -607,6 +617,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTTypeId)
*/
+ @Override
public int visit(IASTTypeId node) {
startNode(node);
try {
@@ -630,6 +641,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator)
*/
+ @Override
public int visit(IASTEnumerator enumerator) {
formatNode(enumerator);
endOfNode(enumerator);
@@ -639,6 +651,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier)
*/
+ @Override
public int visit(ICPPASTBaseSpecifier specifier) {
formatNode(specifier);
endOfNode(specifier);
@@ -648,6 +661,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
*/
+ @Override
public int visit(ICPPASTNamespaceDefinition node) {
scribe.printComment();
startNode(node);
@@ -721,6 +735,7 @@ public class CodeFormatterVisitor extends CPPASTVisitor {
/*
* @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter)
*/
+ @Override
public int visit(ICPPASTTemplateParameter node) {
startNode(node);
try {
diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java
index a536973a337..36b7df838cd 100644
--- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java
+++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 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 Rational Software - Initial API and implementation
+ * IBM Rational Software - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.DOMAST;
@@ -112,7 +112,7 @@ public class DOMASTNodeLeaf implements IAdaptable {
}
public String toString() {
- if( node == null ) return BLANK_STRING; //$NON-NLS-1$
+ if( node == null ) return BLANK_STRING;
StringBuffer buffer = new StringBuffer();
Class[] classes = node.getClass().getInterfaces();
@@ -132,7 +132,7 @@ public class DOMASTNodeLeaf implements IAdaptable {
if ( node instanceof IASTProblemHolder ) {
buffer.append(START_OF_LIST);
- buffer.append(((IASTProblemHolder)node).getProblem().getMessage());
+ buffer.append(((IASTProblemHolder)node).getProblem().getMessageWithLocation());
} else if ( node instanceof IASTSimpleDeclaration ) {
String name = null;
IASTDeclarator[] decltors = ((IASTSimpleDeclaration)node).getDeclarators();
@@ -287,21 +287,21 @@ public class DOMASTNodeLeaf implements IAdaptable {
if ( node == null ) return BLANK_STRING;
IASTFileLocation f = node.getFileLocation();
if( f == null )
- return BLANK_STRING; //$NON-NLS-1$
+ return BLANK_STRING;
return f.getFileName();
}
public int getOffset() {
IASTFileLocation f = node.getFileLocation();
if( f == null )
- return 0; //$NON-NLS-1$
+ return 0;
return f.getNodeOffset();
}
public int getLength() {
IASTFileLocation f = node.getFileLocation();
if( f == null )
- return 0; //$NON-NLS-1$
+ return 0;
return f.getNodeLength();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
index c6d80c4422d..2ddf7f3dcbc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java
@@ -307,7 +307,7 @@ public class CreateParserLogAction implements IObjectActionDelegate {
private void output(PrintStream out, String indent, IASTProblem[] preprocessorProblems) {
for (IASTProblem problem : preprocessorProblems) {
- out.println(indent + problem.getMessage());
+ out.println(indent + problem.getMessageWithLocation());
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java
index 633fd0f9380..73e2449ff3f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CoreSpellingProblem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2008 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
@@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.ui.text.spelling;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.cdt.core.parser.IPersistableProblem;
@@ -109,6 +110,14 @@ public class CoreSpellingProblem implements IPersistableProblem {
return fMessage;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.IProblem#getMessageWithLocation()
+ */
+ public String getMessageWithLocation() {
+ return NLS.bind(Messages.Spelling_msgWithLocation, new Object[] {fMessage, fOrigin, fLineNumber});
+ }
+
/*
* @see org.eclipse.cdt.core.parser.IProblem#getOriginatingFileName()
*/
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.java
index 2efd0f575af..d380d96fc99 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2008 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
@@ -32,6 +32,8 @@ public class Messages extends NLS {
public static String Spelling_ignore_info;
public static String Spelling_ignore_label;
+ public static String Spelling_msgWithLocation;
+
static {
// Initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.properties
index 032894175fa..0a6d20bab5b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/Messages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
+# Copyright (c) 2000, 2008 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
@@ -24,3 +24,4 @@ Spelling_error_case_label= The word ''{0}'' should have an initial upper case le
Spelling_error_label=The word ''{0}'' is not correctly spelled
Spelling_ignore_info=Ignores ''{0}'' during the current session
Spelling_ignore_label=Ignore ''{0}'' during the current session
+Spelling_msgWithLocation={0} in file: {1}:{2}

Back to the top