[Pkg-javascript-commits] [node-acorn-jsx] 90/484: Add walk.findNodeAround
Bastien Roucariès
rouca at moszumanska.debian.org
Sat Aug 19 14:20:09 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-acorn-jsx.
commit 792fa96e93a9afb1c8f41cb4f0dc6f87aa360102
Author: Marijn Haverbeke <marijnh at gmail.com>
Date: Mon Jan 28 17:17:51 2013 +0100
Add walk.findNodeAround
---
util/walk.js | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/util/walk.js b/util/walk.js
index 28659e4..01f12c2 100644
--- a/util/walk.js
+++ b/util/walk.js
@@ -66,6 +66,26 @@
}
};
+ // Find the innermost node of a given type that contains the given
+ // position. Interface similar to findNodeAt.
+ exports.findNodeAround = function(node, pos, targetType, base, state) {
+ try {
+ if (!base) base = exports;
+ var c = function(node, st, override) {
+ var type = override || node.type;
+ var inside = node.start <= pos && node.end >= pos;
+ if (inside)
+ base[type](node, st, c);
+ if (inside && (targetType == null || type == targetType))
+ throw new Found(node, st);
+ };
+ c(node, state);
+ } catch (e) {
+ if (e instanceof Found) return e;
+ throw e;
+ }
+ };
+
// Used to create a custom walker. Will fill in all missing node
// type properties with the defaults.
exports.make = function(funcs, base) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git
More information about the Pkg-javascript-commits
mailing list