@@ -42,6 +42,7 @@ def set_global_options(self, cfg):
4242
4343 def accept (self , node , memo ):
4444 """ Accept a node, possibly creating a child visitor. """
45+ if node .token is None : return None ## bug?
4546 tokType = tokens .map .get (node .token .type )
4647 missing = lambda node , memo :self
4748 call = getattr (self , 'accept{0}' .format (tokens .title (tokType )), missing )
@@ -51,6 +52,9 @@ def accept(self, node, memo):
5152
5253 def insertComments (self , tmpl , tree , index , memo ):
5354 """ Add comments to the template from tokens in the tree. """
55+ if not hasattr (tree , 'parser' ):
56+ ## see: lang/selector.py class Type, method __call__
57+ return
5458 prefix = self .config .last ('commentPrefix' , '# ' )
5559 cache , parser , comTypes = memo .comments , tree .parser , tokens .commentTypes
5660 comNew = lambda t :t .type in comTypes and (t .index not in cache )
@@ -93,12 +97,13 @@ def walk(self, tree, memo=None):
9397 visitor .walk (child , memo )
9498 comIns (visitor , child , child .tokenStopIndex , memo )
9599 comIns (self , tree , tree .tokenStopIndex , memo )
96- if tree .isJavaSource :
97- comIns (self , tree , len (tree .parser .input .tokens ), memo )
98- # fixme: we're calling the mutators far too frequently instead
99- # of only once per object after its walk is finished.
100- for handler in self .configHandlers ('PostWalk' , suffix = 'Mutators' ):
101- handler (self )
100+ if hasattr (tree , 'isJavaSource' ): ## else CommonNodeError
101+ if tree .isJavaSource :
102+ comIns (self , tree , len (tree .parser .input .tokens ), memo )
103+ # fixme: we're calling the mutators far too frequently instead
104+ # of only once per object after its walk is finished.
105+ for handler in self .configHandlers ('PostWalk' , suffix = 'Mutators' ):
106+ handler (self )
102107
103108 def zipWalk (self , nodes , visitors , memo ):
104109 """ Walk the given nodes zipped with the given visitors. """
0 commit comments