Added types declarations
This commit is contained in:
parent
857f9c63a6
commit
127e4013e0
7 changed files with 42 additions and 41 deletions
|
@ -65,7 +65,8 @@ public class Generator implements Callable<Integer> {
|
|||
this.verbose,
|
||||
this.outputDir,
|
||||
this.templateDir,
|
||||
transformer.getEndpoints()
|
||||
transformer.getEndpoints(),
|
||||
transformer.getDataTypes()
|
||||
);
|
||||
targetGenerator.generate();
|
||||
return 0;
|
||||
|
|
|
@ -146,7 +146,7 @@ public class NodeTransformer {
|
|||
SimpleNode payloadFieldParseNode =
|
||||
assertSimpleNodeType(
|
||||
compoundDatatTypeFields.jjtGetChild(i),
|
||||
TapirParserTreeConstants.JJTDATATYPEFIELDS
|
||||
TapirParserTreeConstants.JJTDATATYPEFIELD
|
||||
);
|
||||
int numFieldNodes = payloadFieldParseNode.jjtGetNumChildren();
|
||||
if (numFieldNodes != 2) {
|
||||
|
@ -173,7 +173,7 @@ public class NodeTransformer {
|
|||
int numPathSegments = pathsParseNode.jjtGetNumChildren();
|
||||
ArrayList<String> segments = new ArrayList<>();
|
||||
for (int i = 0; i < numPathSegments; i++) {
|
||||
SimpleNode segmentParseNode = assertSimpleNodeType(pathsParseNode.jjtGetChild(i), TapirParserTreeConstants.JJTPATH);
|
||||
SimpleNode segmentParseNode = assertSimpleNodeType(pathsParseNode.jjtGetChild(i), TapirParserTreeConstants.JJTPATHSEGMENT);
|
||||
segments.add(getStringValue(segmentParseNode));
|
||||
}
|
||||
return new PathsNode(segments);
|
||||
|
|
|
@ -19,6 +19,7 @@ public class TargetGenerator {
|
|||
private final boolean verbose;
|
||||
public static String ENDPOINTS_TEMPLATE_NAME = "endpoints.ftl";
|
||||
private final List<EndpointNode> endpoints;
|
||||
private final List<DataTypeNode> dataTypes;
|
||||
|
||||
public static class TargetGeneratorException extends Exception {
|
||||
public TargetGeneratorException(String message) {
|
||||
|
@ -34,7 +35,8 @@ public class TargetGenerator {
|
|||
final boolean verbose,
|
||||
Path outputPath,
|
||||
Path templatePath,
|
||||
List<EndpointNode> endpoints
|
||||
List<EndpointNode> endpoints,
|
||||
List<DataTypeNode> dataTypes
|
||||
) {
|
||||
this.verbose = verbose;
|
||||
this.outputPath = Objects.requireNonNull(
|
||||
|
@ -46,6 +48,7 @@ public class TargetGenerator {
|
|||
"Template path is required"
|
||||
);
|
||||
this.endpoints = Objects.requireNonNull(endpoints);
|
||||
this.dataTypes = Objects.requireNonNull(dataTypes);
|
||||
}
|
||||
|
||||
public void generate() throws TargetGeneratorException {
|
||||
|
@ -63,8 +66,9 @@ public class TargetGenerator {
|
|||
StandardOpenOption.CREATE,
|
||||
StandardOpenOption.TRUNCATE_EXISTING
|
||||
)) {
|
||||
HashMap<String, List<EndpointNode>> templateData = new HashMap<>();
|
||||
HashMap<String, Object> templateData = new HashMap<>();
|
||||
templateData.put("endpoints", endpoints);
|
||||
templateData.put("datatypes", dataTypes);
|
||||
temp.process(templateData, outputFile);
|
||||
}
|
||||
} catch (TemplateException | IOException ex) {
|
||||
|
|
|
@ -36,7 +36,7 @@ TOKEN : {
|
|||
void pathSegment() :
|
||||
{Token t;}
|
||||
{
|
||||
t=<IDENTIFIER>{jjtThis.value = t.image;} <SLASH>
|
||||
<SLASH> t=<IDENTIFIER>{jjtThis.value = t.image;}
|
||||
}
|
||||
|
||||
void path() :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue