[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master ff988f3 051/271: Fix duplicate tokens and tail-end bug.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master ff988f3 051/271: Fix duplicate tokens and tail-end bug. |
Date: |
Thu, 05 Feb 2015 18:29:42 +0000 |
branch: master
commit ff988f3e20bbc74f0ddb24f0650b43242a36feb7
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Fix duplicate tokens and tail-end bug.
---
context-coloring.el | 4 ++--
scopifier.js | 28 +++++++++++++++++-----------
2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 82708e4..7d1fb02 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -193,7 +193,7 @@ calling FUNCTION with the parsed list of tokens."
(with-current-buffer buffer
(context-coloring-apply-tokens tokens))
(setq context-coloring-scopifier-process nil)
- ;; (message "Colorized (after %f seconds)." (-
(float-time) start-time))
+ (message "Colorized (after %f seconds)." (-
(float-time) start-time))
)))))
;; Give the process its input.
@@ -206,7 +206,7 @@ calling FUNCTION with the parsed list of tokens."
(defun context-coloring-colorize ()
(interactive)
(setq context-coloring-colorize-start-time (float-time))
- ;; (message "%s" "Colorizing.")
+ (message "%s" "Colorizing.")
(context-coloring-scopify))
(defun context-coloring-change-function (start end length)
diff --git a/scopifier.js b/scopifier.js
index c534ca7..3b2338d 100644
--- a/scopifier.js
+++ b/scopifier.js
@@ -4,6 +4,13 @@
var escope = require('escope'),
esprima = require('esprima'),
+ isDefined = function (definitions, range) {
+ return definitions.some(function (definition) {
+ // Check for identical definitions.
+ return definition[1] === range[0] &&
+ definition[2] === range[1];
+ });
+ },
whole = '';
process.stdin.setEncoding('utf8');
@@ -36,6 +43,7 @@ process.stdin.on('end', function () {
}
analyzedScopes.forEach(function (scope) {
+ var scopeDefinitions;
if (scope.level === undefined) {
if (scope.upper) {
if (scope.upper.functionExpressionScope) {
@@ -57,6 +65,7 @@ process.stdin.on('end', function () {
scope.block.range[0],
scope.block.range[1]
]);
+ scopeDefinitions = [];
scope.variables.forEach(function (variable) {
var definitions = [],
references = [];
@@ -69,13 +78,8 @@ process.stdin.on('end', function () {
]);
});
variable.references.forEach(function (reference) {
- var range = reference.identifier.range,
- isDefined = definitions.some(function (definition) {
- // Check for identical definitions.
- return definition[1] === range[0] &&
- definition[2] === range[1];
- });
- if (isDefined) {
+ var range = reference.identifier.range;
+ if (isDefined(definitions, range)) {
return;
}
references.push([
@@ -84,16 +88,16 @@ process.stdin.on('end', function () {
range[1]
]);
});
+ Array.prototype.push.apply(scopeDefinitions, definitions);
Array.prototype.push.apply(symbols, definitions);
Array.prototype.push.apply(symbols, references);
});
scope.references.forEach(function (reference) {
- var range;
- if (reference.resolved) {
+ var range = reference.identifier.range;
+ if (reference.resolved || isDefined(scopeDefinitions, range)) {
return;
}
// Handle global references.
- range = reference.identifier.range;
symbols.push([
0,
range[0],
@@ -118,7 +122,9 @@ process.stdin.on('end', function () {
continuous = continuous.slice(1).reduce(function (soFar, token) {
var previous = soFar[soFar.length - 1];
- if (previous[0] === token[0]) {
+ // Detect same-color exact tail ends (nothing else is safe to join).
+ if (previous[0] === token[0] &&
+ previous[2] === token[1] - 1) {
previous[2] = token[2];
return soFar;
}
- [elpa] master 6cd2827 044/271: Cleanup old scopifier., (continued)
- [elpa] master 6cd2827 044/271: Cleanup old scopifier., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 2b8bc05 052/271: Remove buggy tail optimization. Move stdin cruft to cli., Jackson Ray Hamilton, 2015/02/05
- [elpa] master f75af43 036/271: Fix installation instructions., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d881130 049/271: Rename test., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 40c9d93 048/271: Readme updates., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 348b4ca 056/271: Teeny., Jackson Ray Hamilton, 2015/02/05
- [elpa] master c9a7a2d 050/271: Add tail-end optimization., Jackson Ray Hamilton, 2015/02/05
- [elpa] master d2114ae 053/271: Remove indentation level., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 028370d 054/271: Refactor to be more functional., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 0e64e85 055/271: Simplify to 2 arrays., Jackson Ray Hamilton, 2015/02/05
- [elpa] master ff988f3 051/271: Fix duplicate tokens and tail-end bug.,
Jackson Ray Hamilton <=
- [elpa] master 0143a29 058/271: Leverage .jslintrc files., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 38f0821 059/271: Perf with ugly for loops., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 148e55b 046/271: Readme updates., Jackson Ray Hamilton, 2015/02/05
- [elpa] master a02fe9f 064/271: Switch to microoptimized., Jackson Ray Hamilton, 2015/02/05
- [elpa] master f07ce20 061/271: Revert back to functions., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 0ab3ed5 060/271: And it still made no difference., Jackson Ray Hamilton, 2015/02/05
- [elpa] master c2114e9 040/271: Uglify tokenizer now working., Jackson Ray Hamilton, 2015/02/05
- [elpa] master b1e7a1d 076/271: Switch to 1-dimensional array., Jackson Ray Hamilton, 2015/02/05
- [elpa] master 7c8e32c 062/271: Restore microooptimized, add more benchmarks, add tests., Jackson Ray Hamilton, 2015/02/05
- [elpa] master eb2e6b3 070/271: Formalize italic support., Jackson Ray Hamilton, 2015/02/05