[Pkg-javascript-commits] [less.js] 38/285: move visitors to a different namespace
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:23:35 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v2.0.0
in repository less.js.
commit 7f34acd6d17f73ef8bc2e8bd8f4518ef5561ded9
Author: Luke Page <luke.a.page at gmail.com>
Date: Sun Mar 2 12:28:04 2014 +0000
move visitors to a different namespace
---
lib/less/non-node-index.js | 9 ++-------
lib/less/parser.js | 10 +++++-----
lib/less/{ => visitor}/extend-visitor.js | 6 +++---
lib/less/{ => visitor}/import-visitor.js | 12 ++++++------
lib/less/visitor/index.js | 13 +++++++++++++
lib/less/{ => visitor}/join-selector-visitor.js | 0
lib/less/{ => visitor}/to-css-visitor.js | 4 ++--
lib/less/{ => visitor}/visitor.js | 0
8 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/lib/less/non-node-index.js b/lib/less/non-node-index.js
index e3426a7..cacb207 100644
--- a/lib/less/non-node-index.js
+++ b/lib/less/non-node-index.js
@@ -6,16 +6,11 @@ var less = {
};
less.tree = (require('./tree'))(less);
-less.Parser = (require('./parser'))(less, less.tree);
+less.visitor = require('./visitor/index.js')(less, less.tree);
+less.Parser = (require('./parser'))(less, less.tree, less.visitor);
less.tree.functions = (require('./functions'))(less, less.tree);
require('./env')(less.tree);
-less.tree.visitor = require('./visitor.js')(less.tree);
-less.tree.importVisitor = require('./import-visitor.js')(less.tree);
-less.tree.extendVisitor = require('./extend-visitor.js')(less.tree);
-less.tree.joinSelectorVisitor = require('./join-selector-visitor.js')(less.tree.visitor);
-less.tree.toCSSVisitor = require('./to-css-visitor.js')(less.tree);
-
less.tree.sourceMapOutput = require('./source-map-output.js')(less);
module.exports = less;
diff --git a/lib/less/parser.js b/lib/less/parser.js
index b2ae224..cdbdbe9 100644
--- a/lib/less/parser.js
+++ b/lib/less/parser.js
@@ -1,4 +1,4 @@
-module.exports = function(less, tree) {
+module.exports = function(less, tree, visitor) {
//
// less.js - parser
//
@@ -557,9 +557,9 @@ var Parser = function Parser(env) {
try {
var preEvalVisitors = [],
visitors = [
- new(tree.joinSelectorVisitor)(),
- new(tree.extendVisitor)(),
- new(tree.toCSSVisitor)({compress: Boolean(options.compress)})
+ new(visitor.joinSelectorVisitor)(),
+ new(visitor.extendVisitor)(),
+ new(visitor.toCSSVisitor)({compress: Boolean(options.compress)})
], i, root = this;
if (options.plugins) {
@@ -679,7 +679,7 @@ var Parser = function Parser(env) {
};
if (env.processImports !== false) {
- new tree.importVisitor(this.imports, finish)
+ new visitor.importVisitor(this.imports, finish)
.run(root);
} else {
return finish();
diff --git a/lib/less/extend-visitor.js b/lib/less/visitor/extend-visitor.js
similarity index 99%
rename from lib/less/extend-visitor.js
rename to lib/less/visitor/extend-visitor.js
index 0fd22a4..bd63614 100644
--- a/lib/less/extend-visitor.js
+++ b/lib/less/visitor/extend-visitor.js
@@ -1,8 +1,8 @@
-module.exports = function (tree) {
+module.exports = function (visitor, tree) {
/*jshint loopfunc:true */
var extendFinderVisitor = function() {
- this._visitor = new tree.visitor(this);
+ this._visitor = new visitor(this);
this.contexts = [];
this.allExtendsStack = [[]];
};
@@ -86,7 +86,7 @@ module.exports = function (tree) {
};
var processExtendsVisitor = function() {
- this._visitor = new tree.visitor(this);
+ this._visitor = new visitor(this);
};
processExtendsVisitor.prototype = {
diff --git a/lib/less/import-visitor.js b/lib/less/visitor/import-visitor.js
similarity index 93%
rename from lib/less/import-visitor.js
rename to lib/less/visitor/import-visitor.js
index 3da88b5..91ea6c9 100644
--- a/lib/less/import-visitor.js
+++ b/lib/less/visitor/import-visitor.js
@@ -1,6 +1,6 @@
-module.exports = function (tree) {
- var importVisitor = function(importer, finish, evalEnv, onceFileDetectionMap, recursionDetector) {
- this._visitor = new tree.visitor(this);
+module.exports = function (visitor, tree) {
+ var ImportVisitor = function(importer, finish, evalEnv, onceFileDetectionMap, recursionDetector) {
+ this._visitor = new visitor(this);
this._importer = importer;
this._finish = finish;
this.env = evalEnv || new tree.evalEnv();
@@ -16,7 +16,7 @@ module.exports = function (tree) {
}
};
- importVisitor.prototype = {
+ ImportVisitor.prototype = {
isReplacing: true,
run: function (root) {
var error;
@@ -92,7 +92,7 @@ module.exports = function (tree) {
if (!inlineCSS && (env.importMultiple || !duplicateImport)) {
importVisitor.recursionDetector[fullPath] = true;
- new(tree.importVisitor)(importVisitor._importer, subFinish, env, importVisitor.onceFileDetectionMap, importVisitor.recursionDetector)
+ new(ImportVisitor)(importVisitor._importer, subFinish, env, importVisitor.onceFileDetectionMap, importVisitor.recursionDetector)
.run(root);
return;
}
@@ -138,5 +138,5 @@ module.exports = function (tree) {
this.env.frames.shift();
}
};
- return importVisitor;
+ return ImportVisitor;
};
diff --git a/lib/less/visitor/index.js b/lib/less/visitor/index.js
new file mode 100644
index 0000000..243910e
--- /dev/null
+++ b/lib/less/visitor/index.js
@@ -0,0 +1,13 @@
+module.exports = function(less, tree) {
+ var visitor = require("./visitor")(tree),
+ visitors = {
+ visitor: visitor
+ };
+
+ visitors.importVisitor = require('./import-visitor.js')(visitor, tree);
+ visitors.extendVisitor = require('./extend-visitor.js')(visitor, tree);
+ visitors.joinSelectorVisitor = require('./join-selector-visitor.js')(visitor);
+ visitors.toCSSVisitor = require('./to-css-visitor.js')(visitor, tree);
+ return visitors;
+
+};
\ No newline at end of file
diff --git a/lib/less/join-selector-visitor.js b/lib/less/visitor/join-selector-visitor.js
similarity index 100%
rename from lib/less/join-selector-visitor.js
rename to lib/less/visitor/join-selector-visitor.js
diff --git a/lib/less/to-css-visitor.js b/lib/less/visitor/to-css-visitor.js
similarity index 99%
rename from lib/less/to-css-visitor.js
rename to lib/less/visitor/to-css-visitor.js
index ad689e4..ad5cb44 100644
--- a/lib/less/to-css-visitor.js
+++ b/lib/less/visitor/to-css-visitor.js
@@ -1,6 +1,6 @@
-module.exports = function (tree) {
+module.exports = function (visitor, tree) {
var toCSSVisitor = function(env) {
- this._visitor = new tree.visitor(this);
+ this._visitor = new visitor(this);
this._env = env;
};
diff --git a/lib/less/visitor.js b/lib/less/visitor/visitor.js
similarity index 100%
rename from lib/less/visitor.js
rename to lib/less/visitor/visitor.js
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list