correct this handling
This commit is contained in:
14
query.cm
14
query.cm
@@ -4,15 +4,21 @@
|
||||
|
||||
var query = {}
|
||||
|
||||
// Top-level this: references where name=="this" and enclosing==null.
|
||||
query.top_level_this = function(idx) {
|
||||
// Find this references. scope: "top" (top-level only), "fn" (in functions), null (all).
|
||||
query.find_this = function(idx, scope) {
|
||||
var hits = []
|
||||
var i = 0
|
||||
var ref = null
|
||||
while (i < length(idx.references)) {
|
||||
ref = idx.references[i]
|
||||
if (ref.name == "this" && ref.enclosing == null) {
|
||||
hits[] = ref
|
||||
if (ref.name == "this") {
|
||||
if (scope == null) {
|
||||
hits[] = ref
|
||||
} else if (scope == "top" && ref.enclosing == null) {
|
||||
hits[] = ref
|
||||
} else if (scope == "fn" && ref.enclosing != null) {
|
||||
hits[] = ref
|
||||
}
|
||||
}
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user