Skip to content
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

refactor: Deprecate old Javadoc classes #5609

Merged
merged 4 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/main/java/spoon/javadoc/internal/Javadoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package spoon.javadoc.internal;

import static spoon.javadoc.internal.JavadocInlineTag.nextWord;

Check failure on line 17 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocInlineTag' is deprecated since version 11.0.0 and marked for removal

Check failure on line 17 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocInlineTag' is deprecated since version 11.0.0 and marked for removal
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
Expand All @@ -26,29 +26,32 @@
import spoon.reflect.code.CtComment;

/**
* The structured content of a single Javadoc comment.
*
* <p>It is composed by a description and a list of block tags.
*
* <p>An example would be the text contained in this very Javadoc comment. At the moment of this
* writing this comment does not contain any block tags (such as <code>@see AnotherClass</code>)
*/
* The structured content of a single Javadoc comment.
*
* <p>It is composed by a description and a list of block tags.
*
* <p>An example would be the text contained in this very Javadoc comment. At the moment of this
* writing this comment does not contain any block tags (such as <code>@see AnotherClass</code>)
*
* @deprecated Use the new javadoc parser submodule, see <a href="https://spoon.gforge.inria.fr/spoon_javadoc.html">Javadoc Parser</a>.
*/
@Deprecated(forRemoval = true, since = "11.0.0")
public class Javadoc implements Serializable {
private static final long serialVersionUID = 1L;

private JavadocDescription description;

Check failure on line 42 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
private List<JavadocBlockTag> blockTags;

Check failure on line 43 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocBlockTag' is deprecated since version 11.0.0 and marked for removal

public Javadoc() {
this(new JavadocDescription());

Check failure on line 46 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
}

public Javadoc(JavadocDescription description) {

Check failure on line 49 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
this.description = description;
this.blockTags = new LinkedList<>();
}

public Javadoc addBlockTag(JavadocBlockTag blockTag) {

Check failure on line 54 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocBlockTag' is deprecated since version 11.0.0 and marked for removal
this.blockTags.add(blockTag);
return this;
}
Expand All @@ -68,8 +71,8 @@
*/
public String toText() {
StringBuilder sb = new StringBuilder();
if (!description.isEmpty()) {

Check failure on line 74 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
sb.append(description.toText());

Check failure on line 75 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
sb.append(System.lineSeparator());
}
if (!blockTags.isEmpty()) {
Expand All @@ -77,18 +80,18 @@
}
blockTags.forEach(
bt -> {
sb.append(bt.toText());

Check failure on line 83 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocBlockTag' is deprecated since version 11.0.0 and marked for removal
sb.append(System.lineSeparator());
});
return sb.toString();
}

public JavadocDescription getDescription() {

Check failure on line 89 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
return description;
}

/** @return the current List of associated JavadocBlockTags */
public List<JavadocBlockTag> getBlockTags() {

Check failure on line 94 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocBlockTag' is deprecated since version 11.0.0 and marked for removal
return this.blockTags;
}

Expand All @@ -103,12 +106,12 @@

Javadoc document = (Javadoc) o;

return description.equals(document.description) && blockTags.equals(document.blockTags);

Check failure on line 109 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
}

@Override
public int hashCode() {
int result = description.hashCode();

Check failure on line 114 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
result = 31 * result + blockTags.hashCode();
return result;
}
Expand All @@ -123,20 +126,20 @@
Pattern.compile("^\\s*" + BLOCK_TAG_PREFIX, Pattern.MULTILINE);

/** parse the description part (before tags) of a Javadoc */
public static JavadocDescription parseText(String text) {

Check failure on line 129 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
JavadocDescription instance = new JavadocDescription();

Check failure on line 130 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal

Check failure on line 130 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
int index = 0;
Pair<Integer, Integer> nextInlineTagPos;
while ((nextInlineTagPos = indexOfNextInlineTag(text, index)) != null) {
if (nextInlineTagPos.getLeft() != index) {
instance.addElement(new JavadocSnippet(text.substring(index, nextInlineTagPos.getLeft())));

Check failure on line 135 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal

Check failure on line 135 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocSnippet' is deprecated since version 11.0.0 and marked for removal
}
instance.addElement(

Check failure on line 137 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
JavadocInlineTag.fromText(text.substring(nextInlineTagPos.getLeft(), nextInlineTagPos.getRight() + 1)));

Check failure on line 138 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocInlineTag' is deprecated since version 11.0.0 and marked for removal

Check failure on line 138 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocInlineTag' is deprecated since version 11.0.0 and marked for removal
index = nextInlineTagPos.getRight() + 1;
}
if (index < text.length()) {
instance.addElement(new JavadocSnippet(text.substring(index)));

Check failure on line 142 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal

Check failure on line 142 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocSnippet' is deprecated since version 11.0.0 and marked for removal
}
return instance;
}
Expand Down Expand Up @@ -225,11 +228,11 @@
return document;
}

private static JavadocBlockTag parseBlockTag(String line) {

Check failure on line 231 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocBlockTag' is deprecated since version 11.0.0 and marked for removal
line = line.trim().substring(1);
String tagName = nextWord(line);

Check failure on line 233 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocInlineTag' is deprecated since version 11.0.0 and marked for removal
String rest = line.substring(tagName.length()).trim();
return new JavadocBlockTag(tagName, rest);

Check failure on line 235 in src/main/java/spoon/javadoc/internal/Javadoc.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocBlockTag' is deprecated since version 11.0.0 and marked for removal
}

private static boolean isABlockLine(String line) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/spoon/javadoc/internal/JavadocBlockTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
*
* <p>Examples: <code>@see AnotherClass</code> <code>@since v0.0.1</code> <code>@author Jim O'Java
* </code>
* @deprecated Use the new javadoc parser submodule, see <a href="https://spoon.gforge.inria.fr/spoon_javadoc.html">Javadoc Parser</a>.
*/
@Deprecated(forRemoval = true, since = "11.0.0")
public class JavadocBlockTag implements Serializable {

Check warning on line 31 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Deprecated member is still used

Deprecated member 'JavadocBlockTag' is still used
private static final long serialVersionUID = 1L;

private CtJavaDocTag.TagType type;
private JavadocDescription content;

Check failure on line 35 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
private String name = "";
private String tagName;
private String tagRealName;
Expand All @@ -38,14 +40,14 @@
public JavadocBlockTag(CtJavaDocTag.TagType type, String content) {
this.type = type;
this.tagName = type.getName();
this.content = Javadoc.parseText(content);

Check failure on line 43 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.Javadoc' is deprecated since version 11.0.0 and marked for removal

Check failure on line 43 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.Javadoc' is deprecated since version 11.0.0 and marked for removal
}

public JavadocBlockTag(CtJavaDocTag.TagType type, String tagRealName, String content) {
this.type = type;
this.tagName = type.getName();
this.tagRealName = tagRealName;
this.content = Javadoc.parseText(content);

Check failure on line 50 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.Javadoc' is deprecated since version 11.0.0 and marked for removal

Check failure on line 50 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.Javadoc' is deprecated since version 11.0.0 and marked for removal
}

public JavadocBlockTag(String tagName, String content) {
Expand All @@ -63,7 +65,7 @@
return type;
}

public JavadocDescription getContent() {

Check failure on line 68 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
return content;
}

Expand All @@ -89,9 +91,9 @@
sb.append("@");
sb.append(tagRealName);
sb.append(" ").append(name);
if (!content.isEmpty()) {

Check failure on line 94 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
sb.append(" ");
sb.append(content.toText());

Check failure on line 96 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
}
return sb.toString();
}
Expand All @@ -110,7 +112,7 @@
if (type != that.type) {
return false;
}
if (!content.equals(that.content)) {

Check failure on line 115 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
return false;
}
return name.equals(that.name);
Expand All @@ -119,7 +121,7 @@
@Override
public int hashCode() {
int result = type.hashCode();
result = 31 * result + content.hashCode();

Check failure on line 124 in src/main/java/spoon/javadoc/internal/JavadocBlockTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescription' is deprecated since version 11.0.0 and marked for removal
result = 31 * result + name.hashCode();
return result;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/spoon/javadoc/internal/JavadocDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,35 @@

/**
* A javadoc text, potentially containing inline tags.
* @deprecated Use the new javadoc parser submodule, see <a href="https://spoon.gforge.inria.fr/spoon_javadoc.html">Javadoc Parser</a>.
*/
@Deprecated(forRemoval = true, since = "11.0.0")
public class JavadocDescription implements Serializable {
private static final long serialVersionUID = 1L;

private List<JavadocDescriptionElement> elements;

Check failure on line 29 in src/main/java/spoon/javadoc/internal/JavadocDescription.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescriptionElement' is deprecated since version 11.0.0 and marked for removal

public JavadocDescription() {
elements = new LinkedList<>();
}

public JavadocDescription(List<JavadocDescriptionElement> elements) {

Check failure on line 35 in src/main/java/spoon/javadoc/internal/JavadocDescription.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescriptionElement' is deprecated since version 11.0.0 and marked for removal
this();

this.elements.addAll(elements);
}

public boolean addElement(JavadocDescriptionElement element) {

Check failure on line 41 in src/main/java/spoon/javadoc/internal/JavadocDescription.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescriptionElement' is deprecated since version 11.0.0 and marked for removal
return this.elements.add(element);
}

public List<JavadocDescriptionElement> getElements() {

Check failure on line 45 in src/main/java/spoon/javadoc/internal/JavadocDescription.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescriptionElement' is deprecated since version 11.0.0 and marked for removal
return this.elements;
}

public String toText() {
StringBuilder sb = new StringBuilder();
elements.forEach(e -> sb.append(e.toText()));

Check failure on line 51 in src/main/java/spoon/javadoc/internal/JavadocDescription.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescriptionElement' is deprecated since version 11.0.0 and marked for removal
return sb.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
*
* <p>So for example <code>a text</code> or <code>{@link String}</code> could be valid description
* elements.
* @deprecated Use the new javadoc parser submodule, see <a href="https://spoon.gforge.inria.fr/spoon_javadoc.html">Javadoc Parser</a>.
*/
@Deprecated(forRemoval = true, since = "11.0.0")
public interface JavadocDescriptionElement {

Check warning on line 25 in src/main/java/spoon/javadoc/internal/JavadocDescriptionElement.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Deprecated member is still used

Deprecated member 'JavadocDescriptionElement' is still used
/** pretty-prints the Javadoc fragment */
String toText();
}
2 changes: 2 additions & 0 deletions src/main/java/spoon/javadoc/internal/JavadocInlineTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
* An inline tag contained in a Javadoc description.
*
* <p>For example <code>{@link String}</code>
* @deprecated Use the new javadoc parser submodule, see <a href="https://spoon.gforge.inria.fr/spoon_javadoc.html">Javadoc Parser</a>.
*/
@Deprecated(forRemoval = true, since = "11.0.0")
public class JavadocInlineTag implements JavadocDescriptionElement, Serializable {

Check warning on line 26 in src/main/java/spoon/javadoc/internal/JavadocInlineTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Deprecated member is still used

Deprecated member 'JavadocInlineTag' is still used

Check failure on line 26 in src/main/java/spoon/javadoc/internal/JavadocInlineTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescriptionElement' is deprecated since version 11.0.0 and marked for removal
private static final long serialVersionUID = 1L;

/** Return the next word of the string, in other words it stops when a space is encountered. */
Expand All @@ -34,7 +36,7 @@
}

/** parses a Javadoc tag */
public static JavadocDescriptionElement fromText(String text) {

Check failure on line 39 in src/main/java/spoon/javadoc/internal/JavadocInlineTag.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescriptionElement' is deprecated since version 11.0.0 and marked for removal
if (!text.startsWith("{@")) {
throw new IllegalArgumentException(
String.format("Expected to start with '{@'. Text '%s'", text));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/spoon/javadoc/internal/JavadocSnippet.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
*
* <p>For example in <code>A class totally unrelated to {@link String}, I swear!</code> we would
* have two snippets: one before and one after the inline tag (<code>{@link String}</code>).
* @deprecated Use the new javadoc parser submodule, see <a href="https://spoon.gforge.inria.fr/spoon_javadoc.html">Javadoc Parser</a>.
*/
@Deprecated(forRemoval = true, since = "11.0.0")
public class JavadocSnippet implements JavadocDescriptionElement, Serializable {

Check failure on line 27 in src/main/java/spoon/javadoc/internal/JavadocSnippet.java

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Usage of API marked for removal

'spoon.javadoc.internal.JavadocDescriptionElement' is deprecated since version 11.0.0 and marked for removal
private static final long serialVersionUID = 1L;
private String text;

Expand Down
Loading