Remove line numbers from export-operations file
This was sort of accidental from putting them in line numbers, and it turns out it's more annoying than useful. Easy enough to remove. Fixes #40.
This commit is contained in:
+13
-3
@@ -48,8 +48,8 @@ type operation struct {
|
|||||||
Args []argument `json:"-"`
|
Args []argument `json:"-"`
|
||||||
// The type-name for the operation's response type.
|
// The type-name for the operation's response type.
|
||||||
ResponseName string `json:"-"`
|
ResponseName string `json:"-"`
|
||||||
// The original location of this query.
|
// The original filename from which we got this query.
|
||||||
SourceLocation string `json:"sourceLocation"`
|
SourceFilename string `json:"sourceLocation"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type exportedOperations struct {
|
type exportedOperations struct {
|
||||||
@@ -167,6 +167,16 @@ func (g *generator) addOperation(op *ast.OperationDefinition) error {
|
|||||||
docComment = "// " + strings.ReplaceAll(commentLines, "\n", "\n// ")
|
docComment = "// " + strings.ReplaceAll(commentLines, "\n", "\n// ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the filename is a pseudo-filename filename.go:startline, just
|
||||||
|
// put the filename in the export; we don't figure out the line offset
|
||||||
|
// anyway, and if you want to check those exports in they will change a
|
||||||
|
// lot if they have line numbers.
|
||||||
|
// TODO: refactor to use the errorPos machinery for this
|
||||||
|
sourceFilename := op.Position.Src.Name
|
||||||
|
if i := strings.LastIndex(sourceFilename, ":"); i != -1 {
|
||||||
|
sourceFilename = sourceFilename[:i]
|
||||||
|
}
|
||||||
|
|
||||||
g.Operations = append(g.Operations, operation{
|
g.Operations = append(g.Operations, operation{
|
||||||
Type: op.Operation,
|
Type: op.Operation,
|
||||||
Name: op.Name,
|
Name: op.Name,
|
||||||
@@ -175,7 +185,7 @@ func (g *generator) addOperation(op *ast.OperationDefinition) error {
|
|||||||
Body: "\n" + builder.String(),
|
Body: "\n" + builder.String(),
|
||||||
Args: args,
|
Args: args,
|
||||||
ResponseName: responseName,
|
ResponseName: responseName,
|
||||||
SourceLocation: op.Position.Src.Name,
|
SourceFilename: op.Position.Src.Name,
|
||||||
})
|
})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user