@@ -80,23 +80,23 @@ module CDS {
8080 }
8181
8282 /**
83- * Parameter of request handler of `_.on `:
83+ * Parameter of request handler phases `_.before`, `_.on` `_.after `:
8484 * ```js
8585 * _.on ('READ','Books', (req) => req.reply([...]))
8686 * ```
8787 */
88- class OnNodeParam extends ValueNode , ParameterNode {
89- MethodCallNode on ;
88+ class EventPhaseNodeParam extends ValueNode , ParameterNode {
89+ MethodCallNode eventPhase ;
9090
91- OnNodeParam ( ) {
91+ EventPhaseNodeParam ( ) {
9292 exists ( FunctionNode handler |
93- on .getMethodName ( ) = " on" and
94- on .getLastArgument ( ) = handler and
93+ eventPhase .getMethodName ( ) = [ "before" , " on", "after" ] and
94+ eventPhase .getLastArgument ( ) = handler and
9595 handler .getLastParameter ( ) = this
9696 )
9797 }
9898
99- MethodCallNode getOnNode ( ) { result = on }
99+ MethodCallNode getEventPhaseNode ( ) { result = eventPhase }
100100 }
101101
102102 /**
@@ -106,30 +106,35 @@ module CDS {
106106 * ```
107107 * not sure how else to know which service is registering the handler
108108 */
109- class RequestSource extends OnNodeParam {
109+ class RequestSource extends EventPhaseNodeParam {
110110 RequestSource ( ) {
111111 // TODO : consider - do we need to actually ever know which service the handler is associated to?
112112 exists ( UserDefinedApplicationService svc , FunctionNode init |
113113 svc .getAnInstanceMember ( ) = init and
114114 init .getName ( ) = "init" and
115- this .getOnNode ( ) .getEnclosingFunction ( ) = init .getAstNode ( )
115+ this .getEventPhaseNode ( ) .getEnclosingFunction ( ) = init .getAstNode ( )
116116 )
117117 or
118- exists ( WithCallParameter pa | this .getOnNode ( ) .getEnclosingFunction ( ) = pa .getFunction ( ) )
118+ exists ( WithCallParameter pa |
119+ this .getEventPhaseNode ( ) .getEnclosingFunction ( ) = pa .getFunction ( )
120+ )
119121 }
120122 }
121123
122124 class ApplicationService extends API:: Node {
123- ApplicationService ( ) { exists ( CdsFacade c | this = c .getMember ( "ApplicationService" ) ) }
125+ ApplicationService ( ) {
126+ exists ( CdsFacade c | this = c .getMember ( [ "ApplicationService" , "Service" ] ) )
127+ }
124128 }
125129
126130 /**
127131 * ```js
128132 * const cds = require('@sap/cds')
133+ * const cds = require('@sap/cds/lib')
129134 * ```
130135 */
131136 class CdsFacade extends API:: Node {
132- CdsFacade ( ) { this = API:: moduleImport ( "@sap/cds" ) }
137+ CdsFacade ( ) { this = API:: moduleImport ( [ "@sap/cds" , "@sap/cds/lib" ] ) }
133138 }
134139
135140 /**
@@ -143,13 +148,26 @@ module CDS {
143148 * Arguments of calls to `cds.log.{trace, debug, info, log, warn, error}`
144149 */
145150 class CdsLogSink extends DataFlow:: Node {
146- CdsLogSink ( ) { this = any ( CdsLogCall cdsLog ) .getACall ( ) .getAChainedMethodCall ( [ "trace" , "debug" , "info" , "log" , "warn" , "error" ] ) .getAnArgument ( ) }
151+ CdsLogSink ( ) {
152+ this =
153+ any ( CdsLogCall cdsLog )
154+ .getACall ( )
155+ .getAChainedMethodCall ( [ "trace" , "debug" , "info" , "log" , "warn" , "error" ] )
156+ .getAnArgument ( )
157+ }
147158 }
148159
149160 /**
150161 * Methods that parse source strings into a CQL expression
151162 */
152163 class ParseSink extends DataFlow:: Node {
153- ParseSink ( ) { this = any ( CdsFacade cds ) .getMember ( "parse" ) .getMember ( [ "expr" , "ref" , "xpr" ] ) .getACall ( ) .getAnArgument ( ) }
164+ ParseSink ( ) {
165+ this =
166+ any ( CdsFacade cds )
167+ .getMember ( "parse" )
168+ .getMember ( [ "expr" , "ref" , "xpr" ] )
169+ .getACall ( )
170+ .getAnArgument ( )
171+ }
154172 }
155173}
0 commit comments