mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-18 10:14:58 +00:00
[#2934] Copy last param javadoc, copy param javadoc in eclipse
This commit is contained in:
1 parent
eabcc3fb4a
commit
26c8271b3e
6 files changed
+50
-11
No files matched your search
@@ -974,7 +974,7 @@ public class HandlerUtil {
|
||||
|
||||
public static String getParamJavadoc(String methodComment, String param) {
|
||||
if (methodComment == null || methodComment.isEmpty()) return methodComment;
|
||||
Pattern pattern = Pattern.compile("@param " + param + " (\\S|\\s)+?(?=^ ?@)", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
Pattern pattern = Pattern.compile("@param " + param + " (\\S|\\s)+?(?=^ ?@|\\z)", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(methodComment);
|
||||
if (matcher.find()) {
|
||||
return matcher.group();
|
||||
|
||||
@@ -2800,10 +2800,21 @@ public class EclipseHandlerUtil {
|
||||
public static String getDocComment(EclipseNode eclipseNode) {
|
||||
if (eclipseNode.getAst().getSource() == null) return null;
|
||||
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
|
||||
final ASTNode node = eclipseNode.get();
|
||||
if (node instanceof FieldDeclaration) {
|
||||
FieldDeclaration fieldDeclaration = (FieldDeclaration) node;
|
||||
char[] rawContent = CharOperation.subarray(eclipseNode.getAst().getSource(), fieldDeclaration.declarationSourceStart, fieldDeclaration.declarationSourceEnd);
|
||||
start = fieldDeclaration.declarationSourceStart;
|
||||
end = fieldDeclaration.declarationSourceEnd;
|
||||
} else if (node instanceof AbstractMethodDeclaration) {
|
||||
AbstractMethodDeclaration abstractMethodDeclaration = (AbstractMethodDeclaration) node;
|
||||
start = abstractMethodDeclaration.declarationSourceStart;
|
||||
end = abstractMethodDeclaration.declarationSourceEnd;
|
||||
}
|
||||
if (start != -1 && end != -1) {
|
||||
char[] rawContent = CharOperation.subarray(eclipseNode.getAst().getSource(), start, end);
|
||||
String rawContentString = new String(rawContent);
|
||||
int startIndex = rawContentString.indexOf("/**");
|
||||
int endIndex = rawContentString.indexOf("*/");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2021 The Project Lombok Authors.
|
||||
* Copyright (C) 2013-2024 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -1053,7 +1053,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
|
||||
MethodDeclaration setter = HandleSetter.createSetter(td, deprecate, fieldNode, setterName, bfd.name, bfd.nameOfSetFlag, job.oldChain, toEclipseModifier(job.accessInners),
|
||||
job.sourceNode, methodAnnsList, bfd.annotations != null ? Arrays.asList(copyAnnotations(source, bfd.annotations)) : Collections.<Annotation>emptyList());
|
||||
if (job.sourceNode.up().getKind() == Kind.METHOD) {
|
||||
copyJavadocFromParam(bfd.originalFieldNode.up(), setter, td, bfd.name.toString());
|
||||
copyJavadocFromParam(bfd.originalFieldNode.up(), setter, td, new String(bfd.name));
|
||||
} else {
|
||||
copyJavadoc(bfd.originalFieldNode, setter, td, CopyJavadoc.SETTER, true);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,9 @@ class BuilderConstructorJavadoc<T> {
|
||||
* {@code @code} or <code>tags</code>
|
||||
* @param predef don't copy this one
|
||||
* @param predefWithJavadoc don't copy this one
|
||||
* @param last also copy last param
|
||||
*/
|
||||
BuilderConstructorJavadoc(int basic, int multiline, int predef, int predefWithJavadoc) {
|
||||
BuilderConstructorJavadoc(int basic, int multiline, int predef, int predefWithJavadoc, int last) {
|
||||
}
|
||||
public static class BuilderConstructorJavadocBuilder<T> {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
@@ -25,6 +26,9 @@ class BuilderConstructorJavadoc<T> {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
@lombok.Generated
|
||||
private int predefWithJavadoc;
|
||||
@java.lang.SuppressWarnings("all")
|
||||
@lombok.Generated
|
||||
private int last;
|
||||
public BuilderConstructorJavadocBuilder<T> predef(final int x) {
|
||||
this.predef = x;
|
||||
return this;
|
||||
@@ -64,16 +68,26 @@ class BuilderConstructorJavadoc<T> {
|
||||
this.multiline = multiline;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @param last also copy last param
|
||||
* @return {@code this}.
|
||||
*/
|
||||
@java.lang.SuppressWarnings("all")
|
||||
@lombok.Generated
|
||||
public BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder<T> last(final int last) {
|
||||
this.last = last;
|
||||
return this;
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
@lombok.Generated
|
||||
public BuilderConstructorJavadoc<T> build() {
|
||||
return new BuilderConstructorJavadoc<T>(this.basic, this.multiline, this.predef, this.predefWithJavadoc);
|
||||
return new BuilderConstructorJavadoc<T>(this.basic, this.multiline, this.predef, this.predefWithJavadoc, this.last);
|
||||
}
|
||||
@java.lang.Override
|
||||
@java.lang.SuppressWarnings("all")
|
||||
@lombok.Generated
|
||||
public java.lang.String toString() {
|
||||
return "BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder(basic=" + this.basic + ", multiline=" + this.multiline + ", predef=" + this.predef + ", predefWithJavadoc=" + this.predefWithJavadoc + ")";
|
||||
return "BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder(basic=" + this.basic + ", multiline=" + this.multiline + ", predef=" + this.predef + ", predefWithJavadoc=" + this.predefWithJavadoc + ", last=" + this.last + ")";
|
||||
}
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
|
||||
@@ -5,6 +5,7 @@ class BuilderConstructorJavadoc<T> {
|
||||
private @java.lang.SuppressWarnings("all") @lombok.Generated int multiline;
|
||||
private @java.lang.SuppressWarnings("all") @lombok.Generated int predef;
|
||||
private @java.lang.SuppressWarnings("all") @lombok.Generated int predefWithJavadoc;
|
||||
private @java.lang.SuppressWarnings("all") @lombok.Generated int last;
|
||||
public BuilderConstructorJavadocBuilder<T> predef(final int x) {
|
||||
this.predef = x;
|
||||
return this;
|
||||
@@ -17,6 +18,7 @@ class BuilderConstructorJavadoc<T> {
|
||||
super();
|
||||
}
|
||||
/**
|
||||
* @param basic tag is moved to the setter
|
||||
* @return {@code this}.
|
||||
*/
|
||||
public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder<T> basic(final int basic) {
|
||||
@@ -24,20 +26,31 @@ class BuilderConstructorJavadoc<T> {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @param multiline a param comment
|
||||
* can be on multiple lines and can use
|
||||
* {@code @code} or <code>tags</code>
|
||||
* @return {@code this}.
|
||||
*/
|
||||
public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder<T> multiline(final int multiline) {
|
||||
this.multiline = multiline;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @param last also copy last param
|
||||
* @return {@code this}.
|
||||
*/
|
||||
public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder<T> last(final int last) {
|
||||
this.last = last;
|
||||
return this;
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") @lombok.Generated BuilderConstructorJavadoc<T> build() {
|
||||
return new BuilderConstructorJavadoc<T>(this.basic, this.multiline, this.predef, this.predefWithJavadoc);
|
||||
return new BuilderConstructorJavadoc<T>(this.basic, this.multiline, this.predef, this.predefWithJavadoc, this.last);
|
||||
}
|
||||
public @java.lang.Override @java.lang.SuppressWarnings("all") @lombok.Generated java.lang.String toString() {
|
||||
return (((((((("BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder(basic=" + this.basic) + ", multiline=") + this.multiline) + ", predef=") + this.predef) + ", predefWithJavadoc=") + this.predefWithJavadoc) + ")");
|
||||
return (((((((((("BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder(basic=" + this.basic) + ", multiline=") + this.multiline) + ", predef=") + this.predef) + ", predefWithJavadoc=") + this.predefWithJavadoc) + ", last=") + this.last) + ")");
|
||||
}
|
||||
}
|
||||
@lombok.Builder BuilderConstructorJavadoc(int basic, int multiline, int predef, int predefWithJavadoc) {
|
||||
@lombok.Builder BuilderConstructorJavadoc(int basic, int multiline, int predef, int predefWithJavadoc, int last) {
|
||||
super();
|
||||
}
|
||||
public static @java.lang.SuppressWarnings("all") @lombok.Generated <T>BuilderConstructorJavadoc.BuilderConstructorJavadocBuilder<T> builder() {
|
||||
|
||||
@@ -10,9 +10,10 @@ class BuilderConstructorJavadoc<T> {
|
||||
* {@code @code} or <code>tags</code>
|
||||
* @param predef don't copy this one
|
||||
* @param predefWithJavadoc don't copy this one
|
||||
* @param last also copy last param
|
||||
*/
|
||||
@lombok.Builder
|
||||
BuilderConstructorJavadoc(int basic, int multiline, int predef, int predefWithJavadoc) {
|
||||
BuilderConstructorJavadoc(int basic, int multiline, int predef, int predefWithJavadoc, int last) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user