Skip to content

Commit

Permalink
Added enum javadocing
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitry Ivanov committed Jan 31, 2018
1 parent fc9172f commit 07be336
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.gradle
/.idea
**/build
**/out
**/out
**/gen
18 changes: 17 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

group 'ru.noties'
version '1.0.0'
version '1.0.1'

apply plugin: 'java'
apply plugin: 'application'
Expand Down Expand Up @@ -40,3 +40,19 @@ task wrapper(type: Wrapper) {
gradleVersion '4.5'
distributionType 'all'
}

afterEvaluate {
final def folder = new File(rootDir, '/gen/ru/noties/enhance')
if (!folder.exists()) {
folder.mkdirs()
}
final def file = new File(folder, 'EnhanceVersion.java')
file.write("""
package ru.noties.enhance;
class EnhanceVersion { static final String NAME = \"${version}\"; }
""")
}

sourceSets {
main.java.srcDirs += new File(rootDir, 'gen')
}
2 changes: 2 additions & 0 deletions src/main/java/ru/noties/enhance/Enhance.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class Enhance {

public static void main(String[] args) {

log("[Enhance] version: %s", EnhanceVersion.NAME);

final long start = System.currentTimeMillis();

final EnhanceOptions options = EnhanceOptions.create(args);
Expand Down
28 changes: 27 additions & 1 deletion src/main/java/ru/noties/enhance/EnhanceWriterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.javaparser.JavaParser;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.NodeList;
import com.github.javaparser.ast.PackageDeclaration;
import com.github.javaparser.ast.body.*;
import com.github.javaparser.ast.nodeTypes.NodeWithJavadoc;
Expand Down Expand Up @@ -128,12 +129,38 @@ public void visit(PackageDeclaration n, ApiInfoStore arg) {
super.visit(n, arg);
}

@Override
public void visit(EnumDeclaration n, ApiInfoStore arg) {
super.visit(n, arg);

final String type = typeName(n);

final NodeList<EnumConstantDeclaration> constants = n.getEntries();
if (constants != null) {
for (EnumConstantDeclaration declaration : constants) {
setApiInfo(declaration, arg.field(type, declaration.getNameAsString()));
}
}

visit(type, n, arg, n.getConstructors());
}

@Override
public void visit(ClassOrInterfaceDeclaration n, ApiInfoStore api) {
super.visit(n, api);

final String type = typeName(n);

visit(type, n, api, n.getConstructors());
}

private void visit(
@Nonnull String type,
@Nonnull TypeDeclaration<?> n,
@Nonnull ApiInfoStore api,
@Nullable List<ConstructorDeclaration> constructors
) {

final List<FieldDeclaration> fields = n.getFields();
if (fields != null) {

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

final List<ConstructorDeclaration> constructors = n.getConstructors();
if (constructors != null) {
callableDeclarations.addAll(constructors);
}
Expand Down

0 comments on commit 07be336

Please sign in to comment.