Skip to content

Commit 07be336

Browse files
author
Dimitry Ivanov
committed
Added enum javadocing
1 parent fc9172f commit 07be336

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.gradle
22
/.idea
33
**/build
4-
**/out
4+
**/out
5+
**/gen

build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
group 'ru.noties'
11-
version '1.0.0'
11+
version '1.0.1'
1212

1313
apply plugin: 'java'
1414
apply plugin: 'application'
@@ -40,3 +40,19 @@ task wrapper(type: Wrapper) {
4040
gradleVersion '4.5'
4141
distributionType 'all'
4242
}
43+
44+
afterEvaluate {
45+
final def folder = new File(rootDir, '/gen/ru/noties/enhance')
46+
if (!folder.exists()) {
47+
folder.mkdirs()
48+
}
49+
final def file = new File(folder, 'EnhanceVersion.java')
50+
file.write("""
51+
package ru.noties.enhance;
52+
class EnhanceVersion { static final String NAME = \"${version}\"; }
53+
""")
54+
}
55+
56+
sourceSets {
57+
main.java.srcDirs += new File(rootDir, 'gen')
58+
}

src/main/java/ru/noties/enhance/Enhance.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class Enhance {
1515

1616
public static void main(String[] args) {
1717

18+
log("[Enhance] version: %s", EnhanceVersion.NAME);
19+
1820
final long start = System.currentTimeMillis();
1921

2022
final EnhanceOptions options = EnhanceOptions.create(args);

src/main/java/ru/noties/enhance/EnhanceWriterImpl.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.github.javaparser.JavaParser;
44
import com.github.javaparser.ast.CompilationUnit;
5+
import com.github.javaparser.ast.NodeList;
56
import com.github.javaparser.ast.PackageDeclaration;
67
import com.github.javaparser.ast.body.*;
78
import com.github.javaparser.ast.nodeTypes.NodeWithJavadoc;
@@ -128,12 +129,38 @@ public void visit(PackageDeclaration n, ApiInfoStore arg) {
128129
super.visit(n, arg);
129130
}
130131

132+
@Override
133+
public void visit(EnumDeclaration n, ApiInfoStore arg) {
134+
super.visit(n, arg);
135+
136+
final String type = typeName(n);
137+
138+
final NodeList<EnumConstantDeclaration> constants = n.getEntries();
139+
if (constants != null) {
140+
for (EnumConstantDeclaration declaration : constants) {
141+
setApiInfo(declaration, arg.field(type, declaration.getNameAsString()));
142+
}
143+
}
144+
145+
visit(type, n, arg, n.getConstructors());
146+
}
147+
131148
@Override
132149
public void visit(ClassOrInterfaceDeclaration n, ApiInfoStore api) {
133150
super.visit(n, api);
134151

135152
final String type = typeName(n);
136153

154+
visit(type, n, api, n.getConstructors());
155+
}
156+
157+
private void visit(
158+
@Nonnull String type,
159+
@Nonnull TypeDeclaration<?> n,
160+
@Nonnull ApiInfoStore api,
161+
@Nullable List<ConstructorDeclaration> constructors
162+
) {
163+
137164
final List<FieldDeclaration> fields = n.getFields();
138165
if (fields != null) {
139166

@@ -154,7 +181,6 @@ public void visit(ClassOrInterfaceDeclaration n, ApiInfoStore api) {
154181
callableDeclarations.addAll(methods);
155182
}
156183

157-
final List<ConstructorDeclaration> constructors = n.getConstructors();
158184
if (constructors != null) {
159185
callableDeclarations.addAll(constructors);
160186
}

0 commit comments

Comments
 (0)