-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to marshal location text (#6234)
- Loading branch information
1 parent
434d324
commit cd0bf5b
Showing
17 changed files
with
510 additions
and
220 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
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,33 @@ | ||
package json | ||
|
||
// Options defines the options for JSON operations, | ||
// currently only marshaling can be configured | ||
type Options struct { | ||
MarshalOptions MarshalOptions | ||
} | ||
|
||
// MarshalOptions defines the options for JSON marshaling, | ||
// currently only toggling the marshaling of location information is supported | ||
type MarshalOptions struct { | ||
// IncludeLocation toggles the marshaling of location information | ||
IncludeLocation NodeToggle | ||
// IncludeLocationText additionally/optionally includes the text of the location | ||
IncludeLocationText bool | ||
} | ||
|
||
// NodeToggle is a generic struct to allow the toggling of | ||
// settings for different ast node types | ||
type NodeToggle struct { | ||
Term bool | ||
Package bool | ||
Comment bool | ||
Import bool | ||
Rule bool | ||
Head bool | ||
Expr bool | ||
SomeDecl bool | ||
Every bool | ||
With bool | ||
Annotations bool | ||
AnnotationsRef bool | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package ast | ||
|
||
import ( | ||
astJSON "github.com/open-policy-agent/opa/ast/json" | ||
) | ||
|
||
// customJSON is an interface that can be implemented by AST nodes that | ||
// allows the parser to set options for JSON operations on that node. | ||
type customJSON interface { | ||
setJSONOptions(JSONOptions) | ||
setJSONOptions(astJSON.Options) | ||
} |
Oops, something went wrong.