Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 78276 Details for
Bug 192449
[javadoc][assist] SelectionJavadocParser should not report problems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
[proposed patch + test case] on top v811 - all jdt.core tests OK
b192449_on_top_HEAD(v811)_v10.txt (text/plain), 12.08 KB, created by
Eric Jodet
on 2007-09-13 02:30:38 EDT
(
hide
)
Description:
[proposed patch + test case] on top v811 - all jdt.core tests OK
Filename:
MIME Type:
Creator:
Eric Jodet
Created:
2007-09-13 02:30:38 EDT
Size:
12.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >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 13 Sep 2007 06:26:32 -0000 >@@ -11,6 +11,9 @@ > 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; >@@ -33,8 +36,6 @@ > 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" >@@ -57,7 +58,7 @@ > public static Test suite() { > return buildAllCompliancesTestSuite(SelectionJavadocTest.class); > } >- >+ > class SelectionVisitor extends ASTVisitor { > > public boolean visit(ConstructorDeclaration constructor, ClassScope scope) { >@@ -163,6 +164,35 @@ > // Visit compilation unit declaration to find javadoc > unitDecl.traverse(new SelectionVisitor(), unitDecl.scope); > } >+ >+ protected CompilationResult parseCompilationUnit(String selection) { >+ >+ // Verify unit >+ assertNotNull("Missing compilation unit!", this.unit); >+ >+ // Get selection start and end >+ int selectionStart = source.indexOf(selection); >+ int length = selection.length(); >+ int selectionEnd = selectionStart + length - 1; >+ >+ // enable javadoc warnings >+ 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); >+ CompilerOptions options = new CompilerOptions(optionsMap); >+ // Parse unit >+ SelectionParser parser = new SelectionParser(new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), >+ options, >+ new DefaultProblemFactory(Locale.getDefault()))); >+ CompilationUnitDeclaration unitDecl = parser.dietParse(this.unit, new CompilationResult(this.unit, 0, 0, 0), selectionStart, selectionEnd); >+ parser.getMethodBodies(unitDecl); >+ >+ // Visit compilation unit declaration to find javadoc >+ unitDecl.traverse(new SelectionVisitor(), unitDecl.scope); >+ return unitDecl.compilationResult; >+ } > > public void test01() { > setUnit("Test.java", >@@ -861,4 +891,27 @@ > "/**<SelectOnType:Other>*/\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" + >+ "}" >+ ); >+ CompilationResult res = parseCompilationUnit("Test"); >+ assertFalse(res.hasProblems()); >+ } > } >#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 13 Sep 2007 06:26:43 -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 13 Sep 2007 06:26:44 -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 13 Sep 2007 06:28:10 -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 13 Sep 2007 06:26:56 -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 13 Sep 2007 06:27:57 -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 13 Sep 2007 06:26:51 -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 13 Sep 2007 06:28:10 -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) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 192449
:
73534
|
77115
|
78276
|
78959
|
79054
|
79197
|
79265
|
79366