generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Extract comments from Java code (#2788)
Extract comments from Java code for Verbs, Data, Enum, Config, and Secrets Closes #2417 Schema for the test data module is: ``` module javacomments { // Config comment config config String // Secret comment secret secretString String // Comment on a data class. export data DataClass { field String } export data EnumType { name String ordinal Int } // Comment on a verb export verb MultilineCommentVerb(javacomments.DataClass) javacomments.EnumType } ```
- Loading branch information
1 parent
c910edd
commit 093902a
Showing
9 changed files
with
218 additions
and
34 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...time/ftl-runtime/common/deployment/src/main/java/xyz/block/ftl/deployment/CommentKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package xyz.block.ftl.deployment; | ||
|
||
public class CommentKey { | ||
public static String ofVerb(String verb) { | ||
return "verb." + verb; | ||
} | ||
|
||
public static String ofData(String data) { | ||
return "data." + data; | ||
} | ||
|
||
public static String ofEnum(String enumName) { | ||
return "enum." + enumName; | ||
} | ||
|
||
public static String ofConfig(String config) { | ||
return "config." + config; | ||
} | ||
|
||
public static String ofSecret(String secret) { | ||
return "secret." + secret; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module = "javacomments" | ||
language = "java" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>xyz.block.ftl.examples</groupId> | ||
<artifactId>javacomments</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<parent> | ||
<groupId>xyz.block.ftl</groupId> | ||
<artifactId>ftl-build-parent-java</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>xyz.block</groupId> | ||
<artifactId>web5-dids</artifactId> | ||
<version>2.0.1-debug1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
33 changes: 33 additions & 0 deletions
33
.../testdata/java/javacomments/src/main/java/xyz/block/ftl/javacomments/CommentedModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package xyz.block.ftl.javacomments; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import xyz.block.ftl.Config; | ||
import xyz.block.ftl.Export; | ||
import xyz.block.ftl.Secret; | ||
import xyz.block.ftl.Verb; | ||
|
||
/** | ||
* Comment on a module class | ||
*/ | ||
public class CommentedModule { | ||
|
||
/** | ||
* Comment on a verb | ||
* | ||
* @param val Parameter comment | ||
* @param configString Config comment | ||
* @param secretString Secret comment | ||
* @return Great success | ||
*/ | ||
@Export | ||
@Verb | ||
public @NotNull EnumType MultilineCommentVerb( | ||
@NotNull DataClass val, | ||
@Config("config") String configString, | ||
@Secret("secretString") String secretString) { | ||
return EnumType.PORTENTOUS; | ||
} | ||
|
||
//TODO TypeAlias, Database, Topic, Subscription, Lease, Cron | ||
} |
14 changes: 14 additions & 0 deletions
14
...untime/testdata/java/javacomments/src/main/java/xyz/block/ftl/javacomments/DataClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package xyz.block.ftl.javacomments; | ||
|
||
import xyz.block.ftl.Export; | ||
|
||
/** | ||
* Comment on a data class. | ||
*/ | ||
@Export | ||
public class DataClass { | ||
/** | ||
* Comment on a data field. | ||
*/ | ||
private String field; | ||
} |
14 changes: 14 additions & 0 deletions
14
...runtime/testdata/java/javacomments/src/main/java/xyz/block/ftl/javacomments/EnumType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package xyz.block.ftl.javacomments; | ||
|
||
import xyz.block.ftl.Export; | ||
|
||
/** | ||
* Comment on an enum type | ||
*/ | ||
@Export | ||
public enum EnumType { | ||
/** | ||
* Comment on an enum value | ||
*/ | ||
PORTENTOUS | ||
} |