[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 397ef04 005/271: Detect globals.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 397ef04 005/271: Detect globals. |
Date: |
Thu, 05 Feb 2015 18:29:21 +0000 |
branch: master
commit 397ef04ca3999a4070fbad48c0a153696e31087d
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Detect globals.
---
tokenizer/cli.js | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/tokenizer/cli.js b/tokenizer/cli.js
index 457ca74..9ac8262 100644
--- a/tokenizer/cli.js
+++ b/tokenizer/cli.js
@@ -16,16 +16,37 @@ process.stdin.on('readable', function () {
});
process.stdin.on('end', function () {
- var tokens;
+ var data, tokens;
// Generate a syntax tree for the input.
JSLINT(whole);
+ data = JSLINT.data();
// Minimize an otherwise-circular structure.
- tokens = JSLINT.data().tokens.map(function (token) {
+ tokens = data.tokens.map(function (token) {
+ var origin = token,
+ level;
+
+ // We always consider the function keyword to be "part" of the scope it
+ // creates, even if the name leaks in the case of function statements.
+ if (token.kind !== 'function') {
+ // Find a variable/parameter's origin.
+ while (origin.master) {
+ origin = origin.master;
+ }
+ }
+
+ // Globality is not indicated by origin function.
+ if (token.kind !== 'function' &&
+ data.global.indexOf(token.string) > -1) {
+ level = 0;
+ } else {
+ level = origin.function.level;
+ }
+
return {
from: token.from,
- level: token.function.level,
+ level: level,
line: token.line,
thru: token.thru
};
- [elpa] master 5fd312b 002/271: More planning and research., (continued)
- [elpa] master 5fd312b 002/271: More planning and research., Jackson Ray Hamilton, 2015/02/05
- [elpa] master ebc0b99 013/271: Add rollover font lock optimization., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 615ce2c 004/271: Wow, actually works., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6d79b91 024/271: Idly colorizing after changes working. Cancelling seemingly not working., Jackson Ray Hamilton, 2015/02/05
- [elpa] master fd4b629 007/271: Add mode., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6e991c4 014/271: Fix off-by-one error., Jackson Ray Hamilton, 2015/02/05
- [elpa] master b35380b 019/271: Vastly improve idle timer strategy., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 7ac8db6 012/271: Fix a bug where strings were matched., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 806398e 016/271: Use asynchronous command execution strategy., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d0f5470 022/271: Successfully lexically bind buffer., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 397ef04 005/271: Detect globals.,
Jackson Ray Hamilton <=
- [elpa] master 409a05b 017/271: Enable font lock again., Jackson Ray Hamilton, 2015/02/05
- [elpa] master a72314c 008/271: Write temp files., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 6a2a7df 018/271: Use idle timers instead of font lock., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 0a4248b 009/271: Update chunk size., Jackson Ray Hamilton, 2015/02/05
- [elpa] master ffd69f5 026/271: Minutia., Jackson Ray Hamilton, 2015/02/05
- [elpa] master f349ecb 027/271: Minutia., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 35453e0 015/271: Only color changed regions., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 222276b 001/271: Init., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 09166f9 021/271: Some progress, probably have to switch back to lexical., Jackson Ray Hamilton, 2015/02/05
- [elpa] master e448e2f 025/271: Cancelling working., Jackson Ray Hamilton, 2015/02/05