Fix intelliij inspection warnings
This commit is contained in:
parent
2558a52b42
commit
6c8f9f66a6
3 changed files with 15 additions and 14 deletions
|
@ -5,7 +5,6 @@ import nu.zoom.dsl.parser.EndpointsParser;
|
|||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class EndpointsVisitorTransformer extends EndpointsBaseVisitor<EndpointsParser.DocumentContext> {
|
||||
private final ArrayList<EndpointNode> endpoints = new ArrayList<>();
|
||||
|
@ -71,7 +70,7 @@ public class EndpointsVisitorTransformer extends EndpointsBaseVisitor<EndpointsP
|
|||
requestTypeName = requestBodyContext.IDENTIFIER().getText() ;
|
||||
}
|
||||
if (requestTypeName == null) {
|
||||
throw new ParseException("Unable to create the request body data type for " + segments.stream().collect(Collectors.joining())) ;
|
||||
throw new ParseException("Unable to create the request body data type for " + String.join("", segments)) ;
|
||||
}
|
||||
var endpoint = new EndpointNode(new PathsNode(segments), requestTypeName);
|
||||
this.endpoints.add(endpoint);
|
||||
|
@ -101,7 +100,7 @@ public class EndpointsVisitorTransformer extends EndpointsBaseVisitor<EndpointsP
|
|||
}
|
||||
|
||||
private void addDatatType(TypeNode type, int lineNumber) throws ParseException {
|
||||
if (this.dataTypes.stream().filter(t -> t.name().equals(type.name())).findAny().isPresent()) {
|
||||
if (this.dataTypes.stream().anyMatch(t -> t.name().equals(type.name()))) {
|
||||
throw new ParseException("Duplicate datatype '" + type.name()+ "' at line " + lineNumber) ;
|
||||
} else {
|
||||
this.dataTypes.add(type);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package nu.zoom.dsl.ast;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public record TypeNode(String name, List<FieldNode> fields) {
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.nio.file.Path;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Generator {
|
||||
private final Path templatesDir ;
|
||||
|
@ -34,18 +35,20 @@ public class Generator {
|
|||
}
|
||||
|
||||
public List<Path> generate() throws IOException, TemplateException {
|
||||
List<Path> templates = Files.list(templatesDir).filter(p -> p.toString().endsWith(".ftl")).toList() ;
|
||||
ArrayList<Path> out = new ArrayList<>();
|
||||
for (Path template : templates) {
|
||||
// TODO file ending
|
||||
Path outpath = outputDir.resolve(outputFilenameFromTemplate(template.getFileName()));
|
||||
Template ftl = this.cfg.getTemplate(template.getFileName().toString()) ;
|
||||
try (var outw = Files.newBufferedWriter(outpath, StandardCharsets.UTF_8)) {
|
||||
ftl.process(this.data, outw);
|
||||
out.add(outpath);
|
||||
try (Stream<Path> files = Files.list(templatesDir)) {
|
||||
List<Path> templates = files.filter(p -> p.toString().endsWith(".ftl")).toList() ;
|
||||
ArrayList<Path> out = new ArrayList<>();
|
||||
for (Path template : templates) {
|
||||
// TODO file ending
|
||||
Path outpath = outputDir.resolve(outputFilenameFromTemplate(template.getFileName()));
|
||||
Template ftl = this.cfg.getTemplate(template.getFileName().toString()) ;
|
||||
try (var outw = Files.newBufferedWriter(outpath, StandardCharsets.UTF_8)) {
|
||||
ftl.process(this.data, outw);
|
||||
out.add(outpath);
|
||||
}
|
||||
}
|
||||
return out ;
|
||||
}
|
||||
return out ;
|
||||
}
|
||||
|
||||
private String outputFilenameFromTemplate(Path template) {
|
||||
|
|
Loading…
Add table
Reference in a new issue