These are chat archives for less/less.js

2nd
Dec 2015
Zephraph
@zephraph
Dec 02 2015 01:58
Hey folks!
I'm trying to write a visitor plugin that visits variables and creates a new variable if a certain condition is met.
Zephraph
@zephraph
Dec 02 2015 02:04
There wasn't a whole lot of documentation so I've been skimming the source... from the visitor source it appears that I should be able to visit a node by creating a function like 'visit' + node.type.
This is essentially what I have
  visitVariable(variable, args) {
    console.log('var: %j', variable);
  }
I'm not really getting any output... so I guess it's not working? I did verify that a variable type has a node of Variable. I also definitely have a variable in my test file.
I've got a visitRuleset method that is working.
Any hints on what I may be doing wrong?
Zephraph
@zephraph
Dec 02 2015 02:18
Nevermind, I figured it out. Annoyingly the variable node doesn't have an accept method on its prototype so it's not visited.
Zephraph
@zephraph
Dec 02 2015 02:57
I thought it was a simple mistake of not adding the accept method onto the variable prototype. Seems like I was wrong with that. Generally the accept parameter relies on a value that's passed in from the constructor... but for whatever reason a variable doesn't get that.
This message was deleted
Zephraph
@zephraph
Dec 02 2015 03:04
I suppose I misinterpreted the nature of the variable node. Perhaps it's considered a different node if the variable is being defined?
Zephraph
@zephraph
Dec 02 2015 06:25
I figured everything out. I'll post my solution after I get some sleep.