diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-02-14 12:48:53 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-02-16 14:10:08 +0100 |
commit | 24a2cf02e26aaeaa726b23354711c2d664286d20 (patch) | |
tree | a66f4abd6e34de3f17b56dbcaa69673d493f290f /mesonbuild/rewriter.py | |
parent | 683c768feddcf074c86eb09e810495eacf8a187a (diff) | |
download | meson-24a2cf02e26aaeaa726b23354711c2d664286d20.zip meson-24a2cf02e26aaeaa726b23354711c2d664286d20.tar.gz meson-24a2cf02e26aaeaa726b23354711c2d664286d20.tar.bz2 |
Can now find the assignment node of a value
Diffstat (limited to 'mesonbuild/rewriter.py')
-rw-r--r-- | mesonbuild/rewriter.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/mesonbuild/rewriter.py b/mesonbuild/rewriter.py index 60c762e..6752189 100644 --- a/mesonbuild/rewriter.py +++ b/mesonbuild/rewriter.py @@ -292,9 +292,10 @@ rewriter_func_kwargs = { class Rewriter: def __init__(self, sourcedir: str, generator: str = 'ninja'): self.sourcedir = sourcedir - self.interpreter = IntrospectionInterpreter(sourcedir, '', generator) - self.id_generator = AstIDGenerator() + self.interpreter = IntrospectionInterpreter(sourcedir, '', generator, visitors = [AstIDGenerator(), AstIndentationGenerator()]) self.modefied_nodes = [] + self.to_remove_nodes = [] + self.to_add_nodes = [] self.functions = { 'kwargs': self.process_kwargs, 'target': self.process_target, @@ -306,8 +307,6 @@ class Rewriter: self.interpreter.analyze() mlog.log(' -- Project:', mlog.bold(self.interpreter.project_data['descriptive_name'])) mlog.log(' -- Version:', mlog.cyan(self.interpreter.project_data['version'])) - self.interpreter.ast.accept(AstIndentationGenerator()) - self.interpreter.ast.accept(self.id_generator) def add_info(self, cmd_type: str, cmd_id: str, data: dict): if self.info_dump is None: @@ -456,6 +455,11 @@ class Rewriter: if num_changed > 0 and node not in self.modefied_nodes: self.modefied_nodes += [node] + def find_assignment_node(self, node: mparser.BaseNode) -> mparser.AssignmentNode: + if hasattr(node, 'ast_id') and node.ast_id in self.interpreter.reverse_assignment: + return self.interpreter.reverse_assignment[node.ast_id] + return None + @RequiredKeys(rewriter_keys['target']) def process_target(self, cmd): mlog.log('Processing target', mlog.bold(cmd['target']), 'operation', mlog.cyan(cmd['operation'])) |