@@ -12,11 +12,10 @@ module Twirp {
12
12
*/
13
13
class ProtobufGeneratedFile extends File {
14
14
ProtobufGeneratedFile ( ) {
15
- this .getBaseName ( ) .matches ( "%.pb.go" ) and
16
- exists ( File f |
17
- this .getParentContainer ( ) = f .getParentContainer ( ) and
18
- this .getBaseName ( ) .splitAt ( "." , 0 ) = f .getBaseName ( ) .splitAt ( "." , 0 ) and
19
- f .getBaseName ( ) .matches ( "%.twirp.go" )
15
+ exists ( string name , File t |
16
+ this .getBaseName ( ) = name + ".pb.go" and
17
+ this .getParentContainer ( ) = t .getParentContainer ( ) and
18
+ t .getBaseName ( ) = name + ".twirp.go"
20
19
)
21
20
}
22
21
}
@@ -27,11 +26,10 @@ module Twirp {
27
26
*/
28
27
class ServicesGeneratedFile extends File {
29
28
ServicesGeneratedFile ( ) {
30
- this .getBaseName ( ) .matches ( "%.twirp.go" ) and
31
- exists ( File f |
32
- this .getParentContainer ( ) = f .getParentContainer ( ) and
33
- this .getBaseName ( ) .splitAt ( "." , 0 ) = f .getBaseName ( ) .splitAt ( "." , 0 ) and
34
- f .getBaseName ( ) .matches ( "%.pb.go" )
29
+ exists ( string name , File t |
30
+ this .getBaseName ( ) = name + ".twirp.go" and
31
+ this .getParentContainer ( ) = t .getParentContainer ( ) and
32
+ t .getBaseName ( ) = name + ".pb.go"
35
33
)
36
34
}
37
35
}
@@ -78,10 +76,12 @@ module Twirp {
78
76
*/
79
77
class ServiceClientType extends NamedType {
80
78
ServiceClientType ( ) {
81
- exists ( ServiceInterfaceType i , PointerType p |
79
+ exists ( ServiceInterfaceType i , PointerType p , TypeEntity te |
82
80
p .implements ( i ) and
83
81
this = p .getBaseType ( ) and
84
- this .getName ( ) .toLowerCase ( ) = i .getName ( ) .toLowerCase ( ) + [ "protobuf" , "json" ] + "client"
82
+ this .getName ( ) .toLowerCase ( ) = i .getName ( ) .toLowerCase ( ) + [ "protobuf" , "json" ] + "client" and
83
+ te .getType ( ) = this and
84
+ te .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ServicesGeneratedFile
85
85
)
86
86
}
87
87
}
@@ -91,9 +91,11 @@ module Twirp {
91
91
*/
92
92
class ServiceServerType extends NamedType {
93
93
ServiceServerType ( ) {
94
- exists ( ServiceInterfaceType i |
94
+ exists ( ServiceInterfaceType i , TypeEntity te |
95
95
this .implements ( i ) and
96
- this .getName ( ) .toLowerCase ( ) = i .getName ( ) .toLowerCase ( ) + "server"
96
+ this .getName ( ) .toLowerCase ( ) = i .getName ( ) .toLowerCase ( ) + "server" and
97
+ te .getType ( ) = this and
98
+ te .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ServicesGeneratedFile
97
99
)
98
100
}
99
101
}
@@ -106,7 +108,8 @@ module Twirp {
106
108
exists ( ServiceClientType c |
107
109
this .getName ( ) .toLowerCase ( ) = "new" + c .getName ( ) .toLowerCase ( ) and
108
110
this .getParameter ( 0 ) .getType ( ) instanceof StringType and
109
- this .getParameterType ( 1 ) .getName ( ) = "HTTPClient"
111
+ this .getParameterType ( 1 ) .getName ( ) = "HTTPClient" and
112
+ this .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ServicesGeneratedFile
110
113
)
111
114
}
112
115
}
@@ -119,7 +122,8 @@ module Twirp {
119
122
ServerConstructor ( ) {
120
123
exists ( ServiceServerType c , ServiceInterfaceType i |
121
124
this .getName ( ) .toLowerCase ( ) = "new" + c .getName ( ) .toLowerCase ( ) and
122
- this .getParameter ( 0 ) .getType ( ) = i .getNamedType ( )
125
+ this .getParameter ( 0 ) .getType ( ) = i .getNamedType ( ) and
126
+ this .getDeclaration ( ) .getLocation ( ) .getFile ( ) instanceof ServicesGeneratedFile
123
127
)
124
128
}
125
129
}
0 commit comments