@@ -155,7 +155,8 @@ abstract class UserModule extends CallExpr {
155155class SapDefineModule extends AmdModuleDefinition:: Range , MethodCallExpr , UserModule {
156156 SapDefineModule ( ) {
157157 /*
158- * NOTE: This only matches a call to the dot expression `sap.ui.define`, and does not consider a flow among `sap`, `ui`, and `define`.
158+ * NOTE: This only matches a call to the dot expression `sap.ui.define`, and does not
159+ * consider a flow among `sap`, `ui`, and `define`.
159160 */
160161
161162 exists ( GlobalVarAccess sap , DotExpr sapUi , DotExpr sapUiDefine |
@@ -220,50 +221,11 @@ class JQueryDefineModule extends UserModule, MethodCallExpr {
220221 }
221222}
222223
223- private SourceNode sapControl ( TypeTracker t ) {
224- t .start ( ) and
225- exists ( UserModule d , string dependencyType |
226- dependencyType = [ "sap/ui/core/Control" , "sap.ui.core.Control" ]
227- |
228- d .getADependency ( ) = dependencyType and
229- result = d .getRequiredObject ( dependencyType ) .asSourceNode ( )
230- )
231- or
232- exists ( TypeTracker t2 | result = sapControl ( t2 ) .track ( t2 , t ) )
233- }
234-
235- private SourceNode sapControl ( ) { result = sapControl ( TypeTracker:: end ( ) ) }
236-
237- private SourceNode sapController ( TypeTracker t ) {
238- t .start ( ) and
239- exists ( UserModule d , string dependencyType |
240- dependencyType = [ "sap/ui/core/mvc/Controller" , "sap.ui.core.mvc.Controller" ]
241- |
242- d .getADependency ( ) = dependencyType and
243- result = d .getRequiredObject ( dependencyType ) .asSourceNode ( )
244- )
245- or
246- exists ( TypeTracker t2 | result = sapController ( t2 ) .track ( t2 , t ) )
247- }
248-
249- private SourceNode sapController ( ) { result = sapController ( TypeTracker:: end ( ) ) }
250-
251- private SourceNode sapRenderer ( TypeTracker t ) {
252- t .start ( ) and
253- exists ( UserModule d , string dependencyType |
254- dependencyType = [ "sap/ui/core/Renderer" , "sap.ui.core.Renderer" ]
255- |
256- d .getADependency ( ) = dependencyType and
257- result = d .getRequiredObject ( dependencyType ) .asSourceNode ( )
258- )
259- or
260- exists ( TypeTracker t2 | result = sapController ( t2 ) .track ( t2 , t ) )
261- }
262-
263- private SourceNode sapRenderer ( ) { result = sapRenderer ( TypeTracker:: end ( ) ) }
264-
265- private class Renderer extends SapExtendCall {
266- Renderer ( ) { this .getReceiver ( ) .getALocalSource ( ) = sapRenderer ( ) }
224+ class Renderer extends SapExtendCall {
225+ Renderer ( ) {
226+ this .getReceiver ( ) .getALocalSource ( ) =
227+ TypeTrackers:: hasDependency ( [ "sap/ui/core/Renderer" , "sap.ui.core.Renderer" ] )
228+ }
267229
268230 FunctionNode getRenderer ( ) {
269231 /* 1. Old API */
@@ -276,7 +238,8 @@ private class Renderer extends SapExtendCall {
276238
277239class CustomControl extends SapExtendCall {
278240 CustomControl ( ) {
279- this .getReceiver ( ) .getALocalSource ( ) = sapControl ( ) or
241+ this .getReceiver ( ) .getALocalSource ( ) =
242+ TypeTrackers:: hasDependency ( [ "sap/ui/core/mvc/Controller" , "sap.ui.core.mvc.Controller" ] ) or
280243 exists ( SapDefineModule sapModule | this .getDefine ( ) = sapModule .getExtendingModule ( ) )
281244 }
282245
@@ -450,7 +413,8 @@ class CustomController extends SapExtendCall {
450413 string name ;
451414
452415 CustomController ( ) {
453- this .getReceiver ( ) .getALocalSource ( ) = sapController ( ) and
416+ this .getReceiver ( ) .getALocalSource ( ) =
417+ TypeTrackers:: hasDependency ( [ "sap/ui/core/mvc/Controller" , "sap.ui.core.mvc.Controller" ] ) and
454418 name = this .getFile ( ) .getBaseName ( ) .regexpCapture ( "([a-zA-Z0-9]+).[cC]ontroller.js" , 1 )
455419 }
456420
@@ -772,35 +736,24 @@ abstract class UI5InternalModel extends UI5Model, NewNode {
772736 abstract string getPathString ( Property property ) ;
773737}
774738
775- /**
776- * Represents models that are loaded from an external source, e.g. OData service.
777- * It is the value flowing to a `setModel` call in a handler of a `CustomController` (which is represented by `ControllerHandler`), since it is the closest we can get to the actual model itself.
778- */
779- private SourceNode sapComponent ( TypeTracker t ) {
780- t .start ( ) and
781- exists ( UserModule d , string dependencyType |
782- dependencyType =
783- [
784- "sap/ui/core/mvc/Component" , "sap.ui.core.mvc.Component" , "sap/ui/core/UIComponent" ,
785- "sap.ui.core.UIComponent"
786- ]
787- |
788- d .getADependency ( ) = dependencyType and
789- result = d .getRequiredObject ( dependencyType ) .asSourceNode ( )
790- )
791- or
792- exists ( TypeTracker t2 | result = sapComponent ( t2 ) .track ( t2 , t ) )
793- }
794-
795- private SourceNode sapComponent ( ) { result = sapComponent ( TypeTracker:: end ( ) ) }
796-
797739import ManifestJson
798740
799741/**
800742 * A UI5 Component that may contain other controllers or controls.
801743 */
802744class Component extends SapExtendCall {
803- Component ( ) { this .getReceiver ( ) .getALocalSource ( ) = sapComponent ( ) }
745+ Component ( ) {
746+ this .getReceiver ( ) .getALocalSource ( ) =
747+ /*
748+ * Represents models that are loaded from an external source, e.g. OData service.
749+ * It is the value flowing to a `setModel` call in a handler of a `CustomController` (which is represented by `ControllerHandler`), since it is the closest we can get to the actual model itself.
750+ */
751+
752+ TypeTrackers:: hasDependency ( [
753+ "sap/ui/core/mvc/Component" , "sap.ui.core.mvc.Component" , "sap/ui/core/UIComponent" ,
754+ "sap.ui.core.UIComponent"
755+ ] )
756+ }
804757
805758 string getId ( ) { result = this .getName ( ) .regexpCapture ( "([a-zA-Z0-9.]+).Component" , 1 ) }
806759
@@ -1490,3 +1443,19 @@ class PropertyMetadata extends ObjectLiteralNode {
14901443 inSameWebApp ( this .getFile ( ) , result .getFile ( ) )
14911444 }
14921445}
1446+
1447+ module TypeTrackers {
1448+ private SourceNode hasDependency ( TypeTracker t , string dependencyPath ) {
1449+ t .start ( ) and
1450+ exists ( UserModule d |
1451+ d .getADependency ( ) = dependencyPath and
1452+ result = d .getRequiredObject ( dependencyPath ) .asSourceNode ( )
1453+ )
1454+ or
1455+ exists ( TypeTracker t2 | result = hasDependency ( t2 , dependencyPath ) .track ( t2 , t ) )
1456+ }
1457+
1458+ SourceNode hasDependency ( string dependencyPath ) {
1459+ result = hasDependency ( TypeTracker:: end ( ) , dependencyPath )
1460+ }
1461+ }
0 commit comments