[Pkg-javascript-commits] [node-lexical-scope] 74/83: passing implicit property implementation

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:45:53 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-lexical-scope.

commit 09e9846d285b58250c57650e4cb4e7b9aa2eb03a
Author: James Halliday <mail at substack.net>
Date:   Fri Sep 18 12:16:14 2015 -0700

    passing implicit property implementation
---
 index.js | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/index.js b/index.js
index e38f222..69da470 100644
--- a/index.js
+++ b/index.js
@@ -4,6 +4,7 @@ module.exports = function (src) {
     var locals = {};
     var implicit = {};
     var exported = {};
+    var implicitProps = {};
     
     if (typeof src === 'string') {
         src = String(src).replace(/^#![^\n]*\n/, '');
@@ -65,6 +66,18 @@ module.exports = function (src) {
             if (!exported[node.name]
             || exported[node.name] < keyOf(node).length) {
                 implicit[node.name] = keyOf(node).length;
+                if (!implicitProps[node.name]) implicitProps[node.name] = {};
+                if (node.parent && node.parent.type === 'MemberExpression'
+                && node.parent.property.type === 'Identifier') {
+                    implicitProps[node.name][node.parent.property.name] = true;
+                }
+                else if (node.parent && node.parent.type === 'CallExpression'
+                && node.parent.callee === node) {
+                    implicitProps[node.name]['()'] = true;
+                }
+                else {
+                    implicitProps[node.name]['*'] = true;
+                }
             }
         }
     });
@@ -75,11 +88,17 @@ module.exports = function (src) {
         var key = lks[i];
         localScopes[key] = objectKeys(locals[key]);
     }
-    
+
+    var props = {};
+    var pkeys = objectKeys(implicitProps);
+    for (var i = 0; i < pkeys.length; i++) {
+        props[pkeys[i]] = objectKeys(implicitProps[pkeys[i]]);
+    }
     return {
         locals: localScopes,
         globals: {
             implicit: objectKeys(implicit),
+            implicitProperties: props,
             exported: objectKeys(exported)
         }
     };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-lexical-scope.git



More information about the Pkg-javascript-commits mailing list