0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

runtime(java): Recognise all available standard doclet tags

* Complement the tag set with @spec, {@systemProperty},
  {@summary}, @provides, @uses, @hidden, and {@index}.
* Do not hoard all tags under a single highlighting group.
* Skip over nested balanced braces in inline tags.
* Observe that tag names are case sensitive: both {@docRoot}
  and {@inheritDoc} are valid, whereas {@inheritdoc} and
  {@docroot} are not.
* In the @see tag arguments, allow for:
  - module name prefixes (e.g. java.base/java.lang.String);
  - references to arbitrary URI fragments (e.g. ##foo);
  - matching any tag variation arguments on the next line.
* Test directives and tags for Java module declarations.
* Enforce the word end for "module-info" candidates.

References:
https://bugs.openjdk.org/browse/JDK-8226279 (@spec)
https://bugs.openjdk.org/browse/JDK-8214559 ({@systemProperty})
https://bugs.openjdk.org/browse/JDK-8173425 ({@summary})
https://bugs.openjdk.org/browse/JDK-8160196 (@provides & @uses)
https://bugs.openjdk.org/browse/JDK-8073100 (@hidden)
https://bugs.openjdk.org/browse/JDK-8044243 ({@index})
https://docs.oracle.com/en/java/javase/21/docs/specs/javadoc/doc-comment-spec.html
https://github.com/openjdk/jdk/blob/jdk-21-ga/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java

closes: #15652

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Aliaksei Budavei
2024-09-10 21:00:33 +02:00
committed by Christian Brabandt
parent 508403687d
commit a9ae38dc3f
15 changed files with 417 additions and 143 deletions

View File

@@ -1,7 +1,19 @@
// VIM_TEST_SETUP unlet! g:java_ignore_javadoc g:java_no_trail_space_error
// VIM_TEST_SETUP unlet! g:java_no_tab_space_error
// VIM_TEST_SETUP let [g:java_space_errors,g:java_comment_strings] = [1,1]
// VIM_TEST_SETUP setlocal spell | highlight link javaCommentStart Todo
// VIM_TEST_SETUP unlet! g:java_no_tab_space_error g:java_ignore_javadoc
// VIM_TEST_SETUP unlet! g:java_no_trail_space_error
// VIM_TEST_SETUP let [g:java_space_errors,g:java_comment_strings]=[1,1]
// VIM_TEST_SETUP setlocal spell fdc=2 fdl=64 fdm=syntax fen
// VIM_TEST_SETUP highlight link javaCommentStart Todo
// VIM_TEST_SETUP highlight link javaCommentTitle Underlined
@@ -11,8 +23,10 @@
* {@snippet file = Snippets.java region = main id = _01}
* <p>There is no textual representation:
* {@snippet class = Snippets region = toString id = _02} */
class CommentsTests
class CommentsTests implements Comparable<CommentsTests>
{
private CommentsTests() { }
/** No-op, i. e. no operation.
* ({@literal@literal} may be used with {@code .} for contraction.)
* @return {@code null} */
@@ -49,6 +63,22 @@ class CommentsTests
/** {@return {@code null}, with no-op, i.e. no operation} . . */
Void noOp9() { return null; }
/** {@return the major Java version} @hidden */
protected int majorVersion() { return 21; }
/** {@summary Compares this instance with the passed {@code that}
* instance for order by invoking {@link Integer#compare(int, int)
* compare} and passing it {@code this.majorVersion()} and
* {@code that.majorVersion()} as respective @arguments.}
*
* {@inheritDoc} */
@Override public int compareTo(CommentsTests that)
{
java.util.Objects.requireNonNull(that, "that");
return Integer.compare(this.majorVersion(),
that.majorVersion());
}
/** Returns an empty string for an @Override annotated method
* (see Chapter 9.6.4.4 {@literal @Override} in a Java Language
* Specification) overridden from <code>java.lang.Object</code>
@@ -57,15 +87,17 @@ class CommentsTests
@Override public String toString() { return ""; }
}
// javadoc --snippet-path . --source-path . -d /tmp/doc/ -package \
// javadoc --snippet-path . --source-path . -d /tmp/docs/ -package \
// -tag 'jls:a:See Java Language Specification:' Snippets.java
/** Snippets for comment tests. */
class Snippets
{ /* TRAILING BLANKS AND MESSPILLINGS ARE SIGNIFICANT! */
private Snippets() { }
/** The method {@code main} must be declared {@code public}, {@code
* static}, and {@code void}. It must specify a formal parameter
* whose declared type is array of {@link String}. Therefore,
* either of the following declarations is acceptable:
* <em>either</em> of the following declarations is acceptable:
* {@snippet lang="java":
* // @highlight substring="main" type="italic":
* public static void main(String[] args) { }
@@ -79,9 +111,9 @@ class Snippets
public static void main(String[] args) { }
// @end
/** {@return an empty string}
/** {@return an empty string}
* @see <a href="https://docs.oracle.com/javase/specs/jls/se21/html/jls-3.html#jls-3.10.5">3.10.5 String Literals</a>
* @see Object#toString() */
* @see java.base/java.lang.Object#toString() */
// @start region = toString
// @replace substring = '""' replacement = "\u0022\u0022"
// @link regex = '\bString' target = java.lang.String type = linkplain :