-
Notifications
You must be signed in to change notification settings - Fork 136
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
[23] JEP 467 - Compiler changes for supporting markdown Javadoc comments #2731
Conversation
The changes especially include the scanner changes to recognize the markdown format and resolve, validate and report tags and references inside the markdown comments.
Hi @jarthana, this looks very promising! Do you already have ideas how clients can detect the style (html / markdown) of a given Once this information is available, I might be able to start playing with the JDT/UI side of it :) |
I couldn't hold my horses :) and made some experiments towards populating DOM's Javadoc with parsed markdown comments. Turned out I only needed to tweak one scanner method to achieve first results: diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java
index 263d1c0..7ebfaf0 100644
--- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java
+++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/parser/Scanner.java
@@ -3124,6 +3124,21 @@
int stopPosition = this.currentPosition;
switch (token) {
case TokenNameCOMMENT_LINE:
+ if (commentStart+2 < stopPosition && this.source[commentStart+2] == '/') { // check for third '/'
+ if (this.commentPtr > -1) {
+ // is this a continuation of a previous markdown comment?
+ int prevStop = this.commentStops[this.commentPtr];
+ while (CharOperation.isWhitespace(this.source[prevStop])) {
+ if (++prevStop == commentStart) {
+ // extend markdown region, FIXME: need to check if previous actually is a markdown comment
+ this.commentStops[this.commentPtr] = stopPosition;
+ return;
+ }
+ if (prevStop >= this.source.length) break; // safety, shouldn't happen
+ }
+ }
+ break; // add new markdown comment below (positive positions to signal javadoc!)
+ }
// both positions are negative
commentStart = -this.startPosition;
stopPosition = -this.lastCommentLinePosition; This addresses two issues:
Does this fit your design? For handling of tags, also DocCommentParser will need to implement Both hacks together resulted in some Javadoc that I can play with, but I should mention that the result wasn't yet complete. In particular I had a |
Stephan, I was thinking of taking a step-by-step approach. Hence the limited change to the dom* code. I have asked @noopur2507 to spend some time and tell us what the jdt.ui needs/wants from JDT core APIs. I plan to take this patch to completion and take up the DOM changes immediately in another PR. Thanks for spending time on this - this helps! |
converted to Javadoc without a distinction from regular Javadoc. This needs to be addressed in DOM
I forgot that we have to replicate the scanner code from getNextToken0() in jumpOverMethodBody() as well. I have also added an explicit case in the recordComment now for the markdown.
I just went by what we do with parseTag(), where we seem to have different implementation for these two parsers. Perhaps we can abstract out few things to AbstractCommentParser, but don't yet know.
|
What it does
Compiler changes for supporting markdown Javadoc comments (#2429)
How to test
Author checklist