### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java,v retrieving revision 1.17 diff -u -r1.17 AbstractSelectionTest.java --- src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java 10 May 2006 18:07:26 -0000 1.17 +++ src/org/eclipse/jdt/core/tests/compiler/parser/AbstractSelectionTest.java 24 Sep 2007 08:37:36 -0000 @@ -11,33 +11,95 @@ package org.eclipse.jdt.core.tests.compiler.parser; import java.util.Locale; +import java.util.Map; +import org.eclipse.jdt.core.compiler.CharOperation; +import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; +import org.eclipse.jdt.core.tests.util.Util; +import org.eclipse.jdt.internal.codeassist.select.SelectionJavadoc; import org.eclipse.jdt.internal.codeassist.select.SelectionParser; import org.eclipse.jdt.internal.codeassist.select.SelectionScanner; +import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; -import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.ASTNode; +import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.Block; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; +import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; import org.eclipse.jdt.internal.compiler.ast.Initializer; +import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import org.eclipse.jdt.internal.compiler.lookup.BlockScope; +import org.eclipse.jdt.internal.compiler.lookup.ClassScope; +import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; +import org.eclipse.jdt.internal.compiler.lookup.MethodScope; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; -import org.eclipse.jdt.core.compiler.CharOperation; -import org.eclipse.jdt.core.tests.util.AbstractCompilerTest; -import org.eclipse.jdt.core.tests.util.Util; public abstract class AbstractSelectionTest extends AbstractCompilerTest { public final static String NONE = ""; + protected StringBuffer result; + public AbstractSelectionTest(String testName){ super(testName); } + + class SelectionVisitor extends ASTVisitor { + + public boolean visit(ConstructorDeclaration constructor, ClassScope scope) { + if (constructor.javadoc != null) { + assertTrue("Invalid type for Javadoc on " + constructor, constructor.javadoc instanceof SelectionJavadoc); + AbstractSelectionTest.this.result.append(constructor.javadoc.toString()); + } + return super.visit(constructor, scope); + } + + public boolean visit(FieldDeclaration field, MethodScope scope) { + if (field.javadoc != null) { + assertTrue("Invalid type for Javadoc on " + field, field.javadoc instanceof SelectionJavadoc); + AbstractSelectionTest.this.result.append(field.javadoc.toString()); + } + return super.visit(field, scope); + } + + public boolean visit(MethodDeclaration method, ClassScope scope) { + if (method.javadoc != null) { + assertTrue("Invalid type for Javadoc on " + method, method.javadoc instanceof SelectionJavadoc); + AbstractSelectionTest.this.result.append(method.javadoc.toString()); + } + return super.visit(method, scope); + } + + public boolean visit(TypeDeclaration type, BlockScope scope) { + if (type.javadoc != null) { + assertTrue("Invalid type for Javadoc on " + type, type.javadoc instanceof SelectionJavadoc); + AbstractSelectionTest.this.result.append(type.javadoc.toString()); + } + return super.visit(type, scope); + } + + public boolean visit(TypeDeclaration type, ClassScope scope) { + if (type.javadoc != null) { + assertTrue("Invalid type for Javadoc on " + type, type.javadoc instanceof SelectionJavadoc); + AbstractSelectionTest.this.result.append(type.javadoc.toString()); + } + return super.visit(type, scope); + } + + public boolean visit(TypeDeclaration type, CompilationUnitScope scope) { + if (type.javadoc != null) { + assertTrue("Invalid type for Javadoc on " + type, type.javadoc instanceof SelectionJavadoc); + AbstractSelectionTest.this.result.append(type.javadoc.toString()); + } + return super.visit(type, scope); + } + } /* * DietParse with selectionNode check */ @@ -327,4 +389,35 @@ expectedReplacedSource, testName); } + + protected void runTestParseCompilationUnit(ICompilationUnit unit, String selection, Map customOptions, String expectedResult) { + // Verify params + assertNotNull("Missing source!", unit); + assertNotNull("Missing selection!", selection); + + // enable custom options if any + Map currentOptionsMap = getCompilerOptions(); + if (customOptions != null) { + currentOptionsMap.putAll(customOptions); + } + CompilerOptions options = new CompilerOptions(currentOptionsMap); + + // Get selection start and end + int selectionStart = CharOperation.indexOf(selection.toCharArray(), unit.getContents(), true); + int length = selection.length(); + int selectionEnd = selectionStart + length - 1; + + // Parse unit + SelectionParser parser = new SelectionParser(new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), + options, + new DefaultProblemFactory(Locale.getDefault()))); + CompilationUnitDeclaration unitDecl = parser.dietParse(unit, new CompilationResult(unit, 0, 0, 0), selectionStart, selectionEnd); + parser.getMethodBodies(unitDecl); + + // Visit compilation unit declaration to find javadoc + unitDecl.traverse(new SelectionVisitor(), unitDecl.scope); + + // check results + assertEquals(expectedResult, Util.getProblemLog(unitDecl.compilationResult, false, false)); + } } Index: src/org/eclipse/jdt/core/tests/compiler/parser/SelectionJavadocTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SelectionJavadocTest.java,v retrieving revision 1.5 diff -u -r1.5 SelectionJavadocTest.java --- src/org/eclipse/jdt/core/tests/compiler/parser/SelectionJavadocTest.java 29 Mar 2006 03:50:23 -0000 1.5 +++ src/org/eclipse/jdt/core/tests/compiler/parser/SelectionJavadocTest.java 24 Sep 2007 08:37:36 -0000 @@ -11,30 +11,21 @@ package org.eclipse.jdt.core.tests.compiler.parser; import java.util.Locale; +import java.util.Map; + +import junit.framework.Test; import org.eclipse.jdt.core.tests.util.Util; -import org.eclipse.jdt.internal.codeassist.select.SelectionJavadoc; import org.eclipse.jdt.internal.codeassist.select.SelectionParser; -import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; -import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration; -import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; -import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration; -import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.eclipse.jdt.internal.compiler.batch.CompilationUnit; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; -import org.eclipse.jdt.internal.compiler.lookup.BlockScope; -import org.eclipse.jdt.internal.compiler.lookup.ClassScope; -import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope; -import org.eclipse.jdt.internal.compiler.lookup.MethodScope; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; -import junit.framework.Test; - /** * Class to test selection in Javadoc comments. * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=54968" @@ -42,7 +33,6 @@ public class SelectionJavadocTest extends AbstractSelectionTest { String source; - StringBuffer result; ICompilationUnit unit; public SelectionJavadocTest(String testName) { @@ -58,57 +48,6 @@ return buildAllCompliancesTestSuite(SelectionJavadocTest.class); } - class SelectionVisitor extends ASTVisitor { - - public boolean visit(ConstructorDeclaration constructor, ClassScope scope) { - if (constructor.javadoc != null) { - assertTrue("Invalid type for Javadoc on " + constructor, constructor.javadoc instanceof SelectionJavadoc); - SelectionJavadocTest.this.result.append(constructor.javadoc.toString()); - } - return super.visit(constructor, scope); - } - - public boolean visit(FieldDeclaration field, MethodScope scope) { - if (field.javadoc != null) { - assertTrue("Invalid type for Javadoc on " + field, field.javadoc instanceof SelectionJavadoc); - SelectionJavadocTest.this.result.append(field.javadoc.toString()); - } - return super.visit(field, scope); - } - - public boolean visit(MethodDeclaration method, ClassScope scope) { - if (method.javadoc != null) { - assertTrue("Invalid type for Javadoc on " + method, method.javadoc instanceof SelectionJavadoc); - SelectionJavadocTest.this.result.append(method.javadoc.toString()); - } - return super.visit(method, scope); - } - - public boolean visit(TypeDeclaration type, BlockScope scope) { - if (type.javadoc != null) { - assertTrue("Invalid type for Javadoc on " + type, type.javadoc instanceof SelectionJavadoc); - SelectionJavadocTest.this.result.append(type.javadoc.toString()); - } - return super.visit(type, scope); - } - - public boolean visit(TypeDeclaration type, ClassScope scope) { - if (type.javadoc != null) { - assertTrue("Invalid type for Javadoc on " + type, type.javadoc instanceof SelectionJavadoc); - SelectionJavadocTest.this.result.append(type.javadoc.toString()); - } - return super.visit(type, scope); - } - - public boolean visit(TypeDeclaration type, CompilationUnitScope scope) { - if (type.javadoc != null) { - assertTrue("Invalid type for Javadoc on " + type, type.javadoc instanceof SelectionJavadoc); - SelectionJavadocTest.this.result.append(type.javadoc.toString()); - } - return super.visit(type, scope); - } - } - protected void assertValid(String expected) { String actual = this.result.toString(); if (!actual.equals(expected)) { @@ -163,7 +102,7 @@ // Visit compilation unit declaration to find javadoc unitDecl.traverse(new SelectionVisitor(), unitDecl.scope); } - + public void test01() { setUnit("Test.java", "public class Test {\n" + @@ -861,4 +800,31 @@ "/***/\n" ); } + + /** + * @bug 192449: [javadoc][assist] SelectionJavadocParser should not report problems + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=192449" + */ + public void test26() { + setUnit("Test.java", + "public class Test {\n" + + " public void bar() {\n" + + " new Object() {\n" + + " /**\n" + + " * @see \n" + + " * @see Test\n" + + " * @see Other\n" + + " */\n" + + " public class Other {}\n" + + " };\n" + + " }\n" + + "}" + ); + Map optionsMap = getCompilerOptions(); + optionsMap.put(CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED); + optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.WARNING); + optionsMap.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED); + optionsMap.put(CompilerOptions.OPTION_ReportMissingJavadoc, CompilerOptions.WARNING); + runTestParseCompilationUnit(this.unit, "NoReference", optionsMap, ""); // SelectionJavadocParser should not report errors + } } Index: src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java,v retrieving revision 1.16 diff -u -r1.16 Requestor.java --- src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java 29 Mar 2006 03:50:23 -0000 1.16 +++ src/org/eclipse/jdt/core/tests/compiler/regression/Requestor.java 24 Sep 2007 08:37:36 -0000 @@ -16,14 +16,11 @@ import junit.framework.Assert; -import org.eclipse.jdt.core.compiler.CategorizedProblem; +import org.eclipse.jdt.core.tests.util.Util; import org.eclipse.jdt.internal.compiler.ClassFile; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.ICompilerRequestor; import org.eclipse.jdt.internal.compiler.IProblemFactory; -import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; -import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; -import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; public class Requestor extends Assert implements ICompilerRequestor { public boolean hasErrors = false; @@ -45,48 +42,8 @@ this.showWarningToken = showWarningToken; } public void acceptResult(CompilationResult compilationResult) { - StringBuffer buffer = new StringBuffer(100); - hasErrors |= compilationResult.hasErrors(); - if (compilationResult.hasProblems() || compilationResult.hasTasks()) { - CategorizedProblem[] problems = compilationResult.getAllProblems(); - int count = problems.length; - int problemCount = 0; - char[] unitSource = compilationResult.compilationUnit.getContents(); - for (int i = 0; i < count; i++) { - DefaultProblem problem = (DefaultProblem) problems[i]; - if (problem != null) { - if (problemCount == 0) - buffer.append("----------\n"); - problemCount++; - buffer.append(problemCount + (problem.isError() ? ". ERROR" : ". WARNING")); - buffer.append(" in " + new String(problem.getOriginatingFileName()).replace('/', '\\')); - try { - buffer.append(problem.errorReportSource(unitSource)); - buffer.append("\n"); - if (showCategory) { - String category = problem.getInternalCategoryMessage(); - if (category != null) { - buffer.append("[@cat:").append(category).append("] "); - } - } - if (showWarningToken) { - long irritant = ProblemReporter.getIrritant(problem.getID()); - if (irritant != 0) { - String warningToken = CompilerOptions.warningTokenFromIrritant(irritant); - if (warningToken != null) { - buffer.append("[@sup:").append(warningToken).append("] "); - } - } - } - buffer.append(problem.getMessage()); - buffer.append("\n"); - } catch (Exception e) { - } - buffer.append("----------\n"); - } - } - problemLog += buffer.toString(); - } + this.hasErrors |= compilationResult.hasErrors(); + this.problemLog += Util.getProblemLog(compilationResult, this.showCategory, this.showWarningToken); outputClassFiles(compilationResult); if (this.clientRequestor != null) { this.clientRequestor.acceptResult(compilationResult); Index: src/org/eclipse/jdt/core/tests/util/Util.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java,v retrieving revision 1.57 diff -u -r1.57 Util.java --- src/org/eclipse/jdt/core/tests/util/Util.java 5 Jul 2007 15:11:25 -0000 1.57 +++ src/org/eclipse/jdt/core/tests/util/Util.java 24 Sep 2007 08:37:37 -0000 @@ -20,8 +20,10 @@ import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.core.tests.compiler.regression.Requestor; +import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.Compiler; import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.IProblemFactory; @@ -31,6 +33,7 @@ import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.problem.DefaultProblem; import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory; +import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; public class Util { // Trace for delete operation /* @@ -1230,4 +1233,55 @@ } } } +/** + * Returns the compilation errors / warnings for the given CompilationResult. + * + * @param compilationResult the compilation result + * @param showCategory + * @param showWarningToken + * @return String the problem log + */ +public static String getProblemLog(CompilationResult compilationResult, boolean showCategory, boolean showWarningToken) { + StringBuffer buffer = new StringBuffer(100); + if (compilationResult.hasProblems() || compilationResult.hasTasks()) { + CategorizedProblem[] problems = compilationResult.getAllProblems(); + int count = problems.length; + int problemCount = 0; + char[] unitSource = compilationResult.compilationUnit.getContents(); + for (int i = 0; i < count; i++) { + DefaultProblem problem = (DefaultProblem) problems[i]; + if (problem != null) { + if (problemCount == 0) + buffer.append("----------\n"); + problemCount++; + buffer.append(problemCount + (problem.isError() ? ". ERROR" : ". WARNING")); + buffer.append(" in " + new String(problem.getOriginatingFileName()).replace('/', '\\')); + try { + buffer.append(problem.errorReportSource(unitSource)); + buffer.append("\n"); + if (showCategory) { + String category = problem.getInternalCategoryMessage(); + if (category != null) { + buffer.append("[@cat:").append(category).append("] "); + } + } + if (showWarningToken) { + long irritant = ProblemReporter.getIrritant(problem.getID()); + if (irritant != 0) { + String warningToken = CompilerOptions.warningTokenFromIrritant(irritant); + if (warningToken != null) { + buffer.append("[@sup:").append(warningToken).append("] "); + } + } + } + buffer.append(problem.getMessage()); + buffer.append("\n"); + } catch (Exception e) { + } + buffer.append("----------\n"); + } + } + } + return buffer.toString(); +} } #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadocParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadocParser.java,v retrieving revision 1.28 diff -u -r1.28 CompletionJavadocParser.java --- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadocParser.java 6 Mar 2007 02:38:48 -0000 1.28 +++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionJavadocParser.java 24 Sep 2007 08:37:38 -0000 @@ -57,7 +57,6 @@ super(sourceParser); this.scanner = new CompletionScanner(ClassFileConstants.JDK1_3); this.kind = COMPLETION_PARSER | TEXT_PARSE; - this.reportProblems = false; initLevelTags(); } Index: codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadocParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadocParser.java,v retrieving revision 1.5 diff -u -r1.5 SelectionJavadocParser.java --- codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadocParser.java 6 Mar 2007 02:38:50 -0000 1.5 +++ codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionJavadocParser.java 24 Sep 2007 08:37:38 -0000 @@ -28,6 +28,7 @@ public SelectionJavadocParser(SelectionParser sourceParser) { super(sourceParser); + this.shouldReportProblems = false; this.kind = SELECTION_PARSER | TEXT_PARSE; } Index: model/org/eclipse/jdt/internal/compiler/SourceElementParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementParser.java,v retrieving revision 1.75 diff -u -r1.75 SourceElementParser.java --- model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 23 Jul 2007 18:42:09 -0000 1.75 +++ model/org/eclipse/jdt/internal/compiler/SourceElementParser.java 24 Sep 2007 08:37:42 -0000 @@ -176,9 +176,10 @@ // check deprecation in last comment if javadoc (can be followed by non-javadoc comments which are simply ignored) while (lastComment >= 0 && this.scanner.commentStops[lastComment] < 0) lastComment--; // non javadoc comment have negative end positions if (lastComment >= 0 && this.javadocParser != null) { - int commentEnd = this.scanner.commentStops[lastComment] - 1; //stop is one over, - // do not report problem before last parsed comment while recovering code... - this.javadocParser.reportProblems = this.currentElement == null || commentEnd > this.lastJavadocEnd; + int commentEnd = this.scanner.commentStops[lastComment] - 1; //stop is one over + + this.javadocParser.refreshErrorHandlingPolicy(this.currentElement, commentEnd, this.lastJavadocEnd); + if (this.javadocParser.checkDeprecation(lastComment)) { checkAndSetModifiers(ClassFileConstants.AccDeprecated); } Index: compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java,v retrieving revision 1.63 diff -u -r1.63 JavadocParser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java 27 Apr 2007 15:51:39 -0000 1.63 +++ compiler/org/eclipse/jdt/internal/compiler/parser/JavadocParser.java 24 Sep 2007 08:37:39 -0000 @@ -819,4 +819,16 @@ System.arraycopy(this.docComment.paramTypeParameters, paramTypeParamPtr, this.docComment.paramTypeParameters = new JavadocSingleTypeReference[size - paramTypeParamPtr], 0, size - paramTypeParamPtr); } } + + /* + * refresh report error policy. Do not report problems when: + * - the JavadocParser should not report errors (see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=192449") + * - we're in recover mode + * - we already parsed all Javadoc + */ + public void refreshErrorHandlingPolicy(RecoveredElement element, int commentEnd, int lastJavadocEnd) { + if (this.shouldReportProblems) { + this.reportProblems = element == null || commentEnd > lastJavadocEnd; + } + } } Index: compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java,v retrieving revision 1.376 diff -u -r1.376 Parser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 31 Jul 2007 19:08:58 -0000 1.376 +++ compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java 24 Sep 2007 08:37:42 -0000 @@ -1111,9 +1111,10 @@ // check deprecation in last comment if javadoc (can be followed by non-javadoc comments which are simply ignored) while (lastComment >= 0 && this.scanner.commentStops[lastComment] < 0) lastComment--; // non javadoc comment have negative end positions if (lastComment >= 0 && this.javadocParser != null) { - int commentEnd = this.scanner.commentStops[lastComment] - 1; //stop is one over, - // do not report problem before last parsed comment while recovering code... - this.javadocParser.reportProblems = this.currentElement == null || commentEnd > this.lastJavadocEnd; + int commentEnd = this.scanner.commentStops[lastComment] - 1; //stop is one over + + this.javadocParser.refreshErrorHandlingPolicy(this.currentElement, commentEnd, this.lastJavadocEnd); + if (this.javadocParser.checkDeprecation(lastComment)) { checkAndSetModifiers(ClassFileConstants.AccDeprecated); } @@ -10387,4 +10388,5 @@ exp.sourceEnd = this.intStack[this.intPtr--]; exp.sourceStart = this.intStack[this.intPtr--]; } + } Index: compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java,v retrieving revision 1.68 diff -u -r1.68 AbstractCommentParser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 16 Jul 2007 20:02:16 -0000 1.68 +++ compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 24 Sep 2007 08:37:39 -0000 @@ -47,7 +47,10 @@ // Options public boolean checkDocComment = false; - public boolean reportProblems; + // returns whether this comment parser is reporting error or not (overrides reportProblems) + // see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=192449" + public boolean shouldReportProblems = true; + public boolean reportProblems = false; protected long complianceLevel; protected long sourceLevel; @@ -98,7 +101,6 @@ this.identifierLengthStack = new int[10]; this.astStack = new Object[30]; this.astLengthStack = new int[20]; - this.reportProblems = sourceParser != null; if (sourceParser != null) { this.checkDocComment = this.sourceParser.options.docCommentSupport; this.sourceLevel = this.sourceParser.options.sourceLevel; Index: model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java,v retrieving revision 1.23 diff -u -r1.23 CommentRecorderParser.java --- model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java 27 Apr 2007 15:51:39 -0000 1.23 +++ model/org/eclipse/jdt/internal/core/util/CommentRecorderParser.java 24 Sep 2007 08:37:42 -0000 @@ -64,10 +64,11 @@ checkDeprecated = true; int commentSourceEnd = this.scanner.commentStops[lastCommentIndex] - 1; //stop is one over - // do not report problem before last parsed comment while recovering code... - this.javadocParser.reportProblems = this.currentElement == null || commentSourceEnd > this.lastJavadocEnd; + this.javadocParser.refreshErrorHandlingPolicy(this.currentElement, commentSourceEnd, this.lastJavadocEnd); + deprecated = this.javadocParser.checkDeprecation(lastCommentIndex); this.javadoc = this.javadocParser.docComment; + if (currentElement == null) this.lastJavadocEnd = commentSourceEnd; break nextComment; } if (deprecated) {