diff options
author | Danny van Bruggen <hexagonaal@gmail.com> | 2018-02-22 21:59:23 +0100 |
---|---|---|
committer | Danny van Bruggen <hexagonaal@gmail.com> | 2018-02-22 21:59:23 +0100 |
commit | ebc7a58c69999062a4a52cc502e70c74a44af7e4 (patch) | |
tree | e88d6da773420e77af652d166ab2bca4e6d6692e | |
parent | 4d7b99a8a60e1d7d29836c4ce3ad5b125cb00a2b (diff) | |
download | platform_external_javaparser-ebc7a58c69999062a4a52cc502e70c74a44af7e4.tar.gz platform_external_javaparser-ebc7a58c69999062a4a52cc502e70c74a44af7e4.tar.bz2 platform_external_javaparser-ebc7a58c69999062a4a52cc502e70c74a44af7e4.zip |
Some small improvements
4 files changed, 30 insertions, 4 deletions
diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithJavadoc.java b/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithJavadoc.java index f4a7013b0..592947e07 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithJavadoc.java +++ b/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithJavadoc.java @@ -64,7 +64,7 @@ public interface NodeWithJavadoc<N extends Node> { */ @SuppressWarnings("unchecked") default N setJavadocComment(String comment) { - return setJavadocComment(new JavadocComment(comment)); + return setJavadocComment(new JavadocComment(" " + comment)); } default N setJavadocComment(JavadocComment comment) { @@ -73,8 +73,11 @@ public interface NodeWithJavadoc<N extends Node> { } default N setJavadocComment(String indentation, Javadoc javadoc) { - JavadocComment comment = javadoc.toComment(indentation); - return setJavadocComment(comment); + return setJavadocComment(javadoc.toComment(indentation)); + } + + default N setJavadocComment(Javadoc javadoc) { + return setJavadocComment(javadoc.toComment()); } default boolean removeJavaDocComment() { diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithSimpleName.java b/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithSimpleName.java index a979e7bdf..3f2fa116f 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithSimpleName.java +++ b/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithSimpleName.java @@ -22,6 +22,7 @@ package com.github.javaparser.ast.nodeTypes; import com.github.javaparser.ast.Node; +import com.github.javaparser.ast.expr.NameExpr; import com.github.javaparser.ast.expr.SimpleName; import static com.github.javaparser.utils.Utils.assertNonEmpty; @@ -45,4 +46,6 @@ public interface NodeWithSimpleName<N extends Node> { default String getNameAsString() { return getName().getIdentifier(); } + + default NameExpr getNameExpr() {return new NameExpr(getName()); } } diff --git a/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithType.java b/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithType.java index d97030cd7..06e66fb91 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithType.java +++ b/javaparser-core/src/main/java/com/github/javaparser/ast/nodeTypes/NodeWithType.java @@ -72,4 +72,7 @@ public interface NodeWithType<N extends Node, T extends Type> { return setType((T) parseType(typeString));
}
+ default String getTypeAsString() {
+ return getType().asString();
+ }
}
diff --git a/javaparser-core/src/main/java/com/github/javaparser/javadoc/Javadoc.java b/javaparser-core/src/main/java/com/github/javaparser/javadoc/Javadoc.java index 62e1957cc..1c56b1475 100644 --- a/javaparser-core/src/main/java/com/github/javaparser/javadoc/Javadoc.java +++ b/javaparser-core/src/main/java/com/github/javaparser/javadoc/Javadoc.java @@ -56,6 +56,16 @@ public class Javadoc { return addBlockTag(new JavadocBlockTag(tagName, content)); } + /** + * for tags like "@param abc this is a parameter" where + * tagName is "param", + * parameter is "abc" + * and the rest is content. + */ + public Javadoc addBlockTag(String tagName, String parameter, String content) { + return addBlockTag(tagName, parameter + " " + content); + } + public Javadoc addBlockTag(String tagName) { return addBlockTag(tagName, ""); } @@ -81,7 +91,14 @@ public class Javadoc { } /** - * Create a JavadocComment, by formatting the text of the Javadoc using the given indentation/ + * Create a JavadocComment, by formatting the text of the Javadoc using no indentation (expecting the pretty printer to do the formatting.) + */ + public JavadocComment toComment() { + return toComment(""); + } + + /** + * Create a JavadocComment, by formatting the text of the Javadoc using the given indentation. */ public JavadocComment toComment(String indentation) { for (char c : indentation.toCharArray()) { |