-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from mercari/show-warning-file-import
Show warning about file import
- Loading branch information
Showing
58 changed files
with
843 additions
and
460 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
_examples/11_multi_service/federation/federation_grpc_federation.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
_examples/11_multi_service/federation/other_grpc_federation.pb.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package cel | ||
|
||
import "github.com/google/cel-go/common/ast" | ||
|
||
func ToIdentifiers(expr ast.Expr) []string { | ||
var idents []string | ||
switch expr.Kind() { | ||
case ast.CallKind: | ||
call := expr.AsCall() | ||
idents = append(idents, ToIdentifiers(call.Target())...) | ||
for _, arg := range call.Args() { | ||
idents = append(idents, ToIdentifiers(arg)...) | ||
} | ||
case ast.IdentKind: | ||
idents = append(idents, expr.AsIdent()) | ||
case ast.ListKind: | ||
l := expr.AsList() | ||
for _, e := range l.Elements() { | ||
idents = append(idents, ToIdentifiers(e)...) | ||
} | ||
case ast.MapKind: | ||
m := expr.AsMap() | ||
for _, entry := range m.Entries() { | ||
idents = append(idents, toEntryNames(entry)...) | ||
} | ||
case ast.SelectKind: | ||
idents = append(idents, toSelectorName(expr)) | ||
case ast.StructKind: | ||
idents = append(idents, expr.AsStruct().TypeName()) | ||
for _, field := range expr.AsStruct().Fields() { | ||
idents = append(idents, toEntryNames(field)...) | ||
} | ||
} | ||
return idents | ||
} | ||
|
||
func toEntryNames(entry ast.EntryExpr) []string { | ||
var ident []string | ||
switch entry.Kind() { | ||
case ast.MapEntryKind: | ||
ident = append(ident, ToIdentifiers(entry.AsMapEntry().Key())...) | ||
ident = append(ident, ToIdentifiers(entry.AsMapEntry().Value())...) | ||
case ast.StructFieldKind: | ||
ident = append(ident, ToIdentifiers(entry.AsStructField().Value())...) | ||
} | ||
return ident | ||
} | ||
|
||
func toSelectorName(v ast.Expr) string { | ||
switch v.Kind() { | ||
case ast.SelectKind: | ||
sel := v.AsSelect() | ||
parent := toSelectorName(sel.Operand()) | ||
if parent != "" { | ||
return parent + "." + sel.FieldName() | ||
} | ||
return sel.FieldName() | ||
case ast.IdentKind: | ||
return v.AsIdent() | ||
default: | ||
return "" | ||
} | ||
} |
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.