Skip to content

Commit

Permalink
Debug JsViewBindingPath
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongsoolee09 committed Jan 17, 2024
1 parent d935f6d commit 1bfb972
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ private newtype TBindingPath =
earlyPathPropertyBinding(_, binding, bindingPath)
or
latePathBinding(_, binding, bindingPath)
) and
not bindingPath.mayHaveStringValue(_)
)
// and
// not bindingPath.mayHaveStringValue(_)
}

/**
Expand Down Expand Up @@ -423,6 +424,13 @@ private newtype TBindingTarget =
TXmlContextBindingTarget(ContextBindingAttribute target, Binding binding) {
binding = TXmlContextBinding(target, _)
} or
TEarlyJavaScriptBindingTarget(DataFlow::Node target, Binding binding) {
exists(DataFlow::NewNode newNode, Property property |
binding = TEarlyJavaScriptPropertyBinding(newNode, _) and
newNode.getAnArgument().getALocalSource().asExpr().(ObjectExpr).getAProperty() = property and
target = property.getInit().flow().getALocalSource()
)
} or
TLateJavaScriptBindingTarget(DataFlow::Node target, Binding binding) {
exists(DataFlow::MethodCallNode call |
binding = TLateJavaScriptContextBinding(call, _) and
Expand Down Expand Up @@ -453,6 +461,11 @@ class BindingTarget extends TBindingTarget {
result = attribute.getName()
)
or
exists(DataFlow::Node target |
this = TEarlyJavaScriptBindingTarget(target, _) and
result = target.toString()
)
or
exists(DataFlow::Node target |
this = TLateJavaScriptBindingTarget(target, _) and
result = target.toString()
Expand Down Expand Up @@ -484,7 +497,10 @@ class BindingTarget extends TBindingTarget {

DataFlow::Node asDataFlowNode() {
exists(DataFlow::Node target |
this = TLateJavaScriptBindingTarget(target, _) and
(
this = TEarlyJavaScriptBindingTarget(target, _) or
this = TLateJavaScriptBindingTarget(target, _)
) and
result = target
)
}
Expand All @@ -500,6 +516,11 @@ class BindingTarget extends TBindingTarget {
result = attribute.getLocation()
)
or
exists(DataFlow::Node target |
this = TEarlyJavaScriptBindingTarget(target, _) and
result = target.asExpr().getLocation()
)
or
exists(DataFlow::Node target |
this = TLateJavaScriptBindingTarget(target, _) and
result = target.asExpr().getLocation()
Expand All @@ -514,6 +535,7 @@ class BindingTarget extends TBindingTarget {
Binding getBinding() {
this = TXmlPropertyBindingTarget(_, result) or
this = TXmlContextBindingTarget(_, result) or
this = TEarlyJavaScriptBindingTarget(_, result) or
this = TLateJavaScriptBindingTarget(_, result) or
this = TJsonPropertyBindingTarget(_, _, result)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ abstract class UI5BindingPath extends BindingPath {
/**
* Gets the view that this binding path resides in.
*/
/*
* NOTE:
* - [[Declarative (inside data format): path --getFile--> view]] --getController--> controller --getModel--> model.
* - Procedural (inside JS source code): [[path --(getting the handler it's inside and getting the owner controller of the handler )--> controller --getView--> view]].
*/

UI5View getView() {
/* 1. Declarative, inside a certain data format. */
this.getLocation().getFile() = result
Expand Down Expand Up @@ -392,10 +386,11 @@ class JsonView extends UI5View {

class JsViewBindingPath extends UI5BindingPath {
DataFlow::Node bindingTarget;
Binding binding;

JsViewBindingPath() {
this.getBinding().getBindingTarget().asDataFlowNode() = bindingTarget //and
//bindingTarget.getFile() instanceof JsView
bindingTarget = binding.getBindingTarget().asDataFlowNode() and
binding.getBindingPath() = this
}

override string getLiteralRepr() { result = bindingTarget.getALocalSource().getStringValue() }
Expand Down

0 comments on commit 1bfb972

Please sign in to comment.