New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDK-8273244: Improve diagnostic output related to ErroneousTree #5510
JDK-8273244: Improve diagnostic output related to ErroneousTree #5510
Conversation
|
@jonathan-gibbons The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclint/DocLint.java
Outdated
Show resolved
Hide resolved
As this PR contains a lot clean-up changes and improvements, it will take me extra time to review it. Here's the first batch of comments.
src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java
Outdated
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/parser/ReferenceParser.java
Show resolved
Hide resolved
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java
Outdated
Show resolved
Hide resolved
I'd feel more confident if Hannes looked at changes related to ReferenceParser. |
I suppose we don't need to reflect this change anywhere in the API (CSR), do we? |
src/jdk.compiler/share/classes/jdk/internal/shellsupport/doc/JavadocHelper.java
Show resolved
Hide resolved
I don't believe the specification is so fine-grained. |
add new StartEndPosChecker for DocCommentTester add new CoverageTest, to ensure DocCommentTester tests provide full coverage
It turns out there is remarkable similarity between the new |
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java
Outdated
Show resolved
Hide resolved
@jonathan-gibbons This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 253 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
/integrate |
Going to push as commit 0ca094b.
Your commit was automatically rebased without conflicts. |
@jonathan-gibbons Pushed as commit 0ca094b. |
Please review a medium size update/overhaul to the way that positions and diagnostic positions are handled in the
DocTree
/DCTree
world.Previously ...
Previously, most
DCTree
nodes only had an explicit "position" (pos
). Start and end positions were provided byDocSourcePositions
, but these were not directly available in tree nodes, because of the lack of access to theDocSourcePositions
class. (In contrast,JCTree
nodes do have position info, via static methods inTreeInfo
.) The one notable exception to these guidelines wasDCErroneous
which (by analogy withJCTree
) directly implementedJCDiagnostic.DiagnosticPosition
but that was an arguably bad implementation because the positions were relative to the start of the comment, and not the start of the file. This did not show up in code and tests, because diagnostics related toDocTree
nodes usedDCTree.pos
which returned aSimpleDiagnosticPosition
referencing just the start position -- at least in part because more specific information was not easily available.Now ...
All
DCTree
nodes have 4 positions, 3 publicly available.pos
getStartPosition()
getPreferredPosition()
getEndPosition()
.These are all relative to the beginning of the comment text, and are converted to file positions as needed.
Code to implement the end position is moved from
JavacTrees
toDCTree
. It's still a switch on kind, but could reasonably be converted to using overriding methods.DCErroneous
no longer implementsJCDiagnostic.DiagnosticPosition
. the constructor methods to create a diagnostic are removed, in favor of passing in a correctly-formed diagnostic.DCTree
has a new improvedpos(DCDocComment)
method which now uses the new start/pref/end position methods.DocCommentParser.ParseException
and theerroneous
method now take an optional "pos" parameter to allow the position of an error to be more accurately specified.Testing ...
Up until the point at which
DCTree.pos
was modified, all tests passed without change. WhenDCTree.pos()
was modified, a few (3) doclint tests starting failing, demonstrating a latent reliance of the old form ofDCTree.pos()
. These tests are updated.Rather than write a single new test, the existing
DocCommentTester
class is updated to include a newChecker
which, generally, checks the "left to right" nature of all positions in a doc comment tree and its subtrees. This leverages all the existing good and bad test cases in thetools/javac/doctree
directory, which therefore all get tagged with the bug number for this issue.Behavior ...
Apart from fixing generally bad behavior, there is one other tiny behavioral change. For an empty
DocCommentTree
the ending position is now the same at the starting position, and notNOPOS
. This was triggered by the new code inDocCommentTester
, but which affected onejshell
test, which started gettingStringIndexOutOfBounds
exception. This is minimally fixed for now, but the code in question would arguably be better to use the new comment-based positions, rather than the file-based positions. But that seems out of scope for this work. Also worth investigating is the methodJavacTrees.getDocCommentTree(FileObject fileObject)
which uses a fixed offset of 0 (JavacTrees, line 1052) when creating doc comments for HTML files.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5510/head:pull/5510
$ git checkout pull/5510
Update a local copy of the PR:
$ git checkout pull/5510
$ git pull https://git.openjdk.java.net/jdk pull/5510/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5510
View PR using the GUI difftool:
$ git pr show -t 5510
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5510.diff