modelize: add and use method mpropdef2node
[nit.git] / src / phase.nit
index df72660..2011cd8 100644 (file)
@@ -112,7 +112,7 @@ redef class ToolContext
                                        phase.process_nclassdef(nclassdef)
                                        for npropdef in nclassdef.n_propdefs do
                                                assert phase.toolcontext == self
-                                               phase.process_npropdef(npropdef)
+                                               phase_process_npropdef(phase, npropdef)
                                        end
                                end
                                if errcount != self.error_count then
@@ -132,6 +132,13 @@ redef class ToolContext
 
                var time1 = get_time
                self.info("*** END SEMANTIC ANALYSIS: {time1-time0} ***", 2)
+
+               errors_info
+       end
+
+       fun phase_process_npropdef(phase: Phase, npropdef: APropdef)
+       do
+               phase.process_npropdef(npropdef)
        end
 end
 
@@ -156,13 +163,16 @@ abstract class Phase
        var toolcontext: ToolContext
 
        # The dependence relation of the phase with the other phases
-       var in_hierarchy: POSetElement[Phase]
+       var in_hierarchy: POSetElement[Phase] is noinit
+
+       # The explicit dependences, used to initialize `in_importation`
+       var depends: nullable Collection[Phase]
 
        # Initialize and register a phase to the toolcontext
-       init(toolcontext: ToolContext, depends: nullable Collection[Phase])
+       init
        do
-               self.toolcontext = toolcontext
                in_hierarchy = toolcontext.phases.add_node(self)
+               var depends = self.depends
                if depends != null then
                        for d in depends do
                                toolcontext.phases.add_edge(self, d)
@@ -175,7 +185,9 @@ abstract class Phase
 
        # Is the phase globally disabled?
        # A disabled phase is not called automatically called by `ToolContext::run_phases` and cie.
-       var disabled = false
+       #
+       # Warning: disabling a phase may cause subsequent phases to work in a degraded way or to fail.
+       var disabled = false is writable
 
        # Specific actions to execute on the whole tree of a module
        # @toimplement