-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(ast): add comment fields * feat(formatter): implement getComment * feat(parser): store comments in parser * feat(ast): add Comment field for Definition * feat(ast): implement Dumper interface for CommentGroup * feat(parser): add comment support for schema parsing * fix(parser): add comments to schema extensions * test(formatter): add comments for schema test * fix(ast,parser): treat multiline comments * feat(formatter): format schema comments * test(formatter): update golden * feat(parser): implement comment parsing * test(formatter): add query comment tests * refactor(formatter): remove unused function * refactor(parser): use dot import * refactor(ast): remove unused methods * fix: support comments before and after description * test(parser): add test case with comments and descriptions * fix: fix lost of comments after desription * test(formatter): add description to scalar test case * fix(parser): remove empty line
- Loading branch information
Showing
33 changed files
with
645 additions
and
73 deletions.
There are no files selected for viewing
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,31 @@ | ||
package ast | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
type Comment struct { | ||
Value string | ||
Position *Position | ||
} | ||
|
||
func (c *Comment) Text() string { | ||
return strings.TrimSpace(strings.TrimPrefix(c.Value, "#")) | ||
} | ||
|
||
type CommentGroup struct { | ||
List []*Comment | ||
} | ||
|
||
func (c *CommentGroup) Dump() string { | ||
if len(c.List) == 0 { | ||
return "" | ||
} | ||
var builder strings.Builder | ||
for _, comment := range c.List { | ||
builder.WriteString(comment.Value) | ||
builder.WriteString("\n") | ||
} | ||
return strconv.Quote(builder.String()) | ||
} |
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
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
Oops, something went wrong.