use of graphql.language.Comment in project graphql-java by graphql-java.
the class GraphqlAntlrToLanguage method getCommentOnChannel.
private List<Comment> getCommentOnChannel(List<Token> refChannel) {
List<Comment> comments = new ArrayList<>();
for (Token refTok : refChannel) {
String text = refTok.getText();
// consumers can decide that
if (text == null) {
continue;
}
text = text.replaceFirst("^#", "");
comments.add(new Comment(text, new SourceLocation(refTok.getLine(), refTok.getCharPositionInLine())));
}
return comments;
}
use of graphql.language.Comment in project graphql-java by graphql-java.
the class SchemaPrinter method descriptionAndComments.
AstDescriptionAndComments descriptionAndComments(Supplier<String> stringSupplier, Supplier<Node> nodeSupplier, Supplier<Description> descriptionSupplier) {
String runtimeDesc = stringSupplier.get();
Node node = nodeSupplier.get();
Description description = null;
List<Comment> comments = null;
if (node != null) {
comments = node.getComments();
description = descriptionSupplier.get();
}
return new AstDescriptionAndComments(runtimeDesc, description, comments);
}
use of graphql.language.Comment in project graphql-java by graphql-java.
the class SchemaGeneratorHelper method buildDescription.
public String buildDescription(Node<?> node, Description description) {
if (description != null) {
return description.getContent();
}
List<Comment> comments = node.getComments();
List<String> lines = new ArrayList<>();
for (Comment comment : comments) {
String commentLine = comment.getContent();
if (commentLine.trim().isEmpty()) {
lines.clear();
} else {
lines.add(commentLine);
}
}
if (lines.size() == 0)
return null;
return lines.stream().collect(joining("\n"));
}
Aggregations