JS: Add support for createNamespacedHelpers

This commit is contained in:
Asger Feldthaus
2021-07-01 09:00:49 +02:00
parent dd1e21c713
commit ee608540c5
2 changed files with 26 additions and 9 deletions

View File

@@ -96,10 +96,20 @@ module Vuex {
*/
private class MapHelperCall extends API::CallNode {
string helperName;
string namespace;
MapHelperCall() {
this = vuex().getMember(helperName).getACall() and
helperName = ["mapActions", "mapGetters", "mapMutations", "mapState"]
helperName = ["mapActions", "mapGetters", "mapMutations", "mapState"] and
(
this = vuex().getMember(helperName).getACall() and
namespace = ""
or
exists(API::CallNode call |
call = vuex().getMember("createNamespacedHelpers").getACall() and
namespace = call.getParameter(0).getAValueReachingRhs().getStringValue() + "/" and
this = call.getReturn().getMember(helperName).getACall()
)
)
}
/** Gets the name of the `vuex` method being invoked, such as `mapGetters`. */
@@ -109,10 +119,10 @@ module Vuex {
pragma[noinline]
string getPrefix() {
getNumArgument() = 2 and
result = getArgument(0).getStringValue() + "/"
result = namespace + getParameter(0).getAValueReachingRhs().getStringValue() + "/"
or
getNumArgument() = 1 and
result = ""
result = namespace
}
/**