rta: use callsites in AFor instead re-resolving stuff
[nit.git] / src / phase.nit
index df35038..3a93084 100644 (file)
@@ -60,8 +60,10 @@ redef class ToolContext
                                end
                                errcount = self.error_count
                                for nclassdef in nmodule.n_classdefs do
+                                       self.info(" phase: {phase.class_name} for {nclassdef.location}", 3)
+                                       assert phase.toolcontext == self
+                                       phase.process_nclassdef(nclassdef)
                                        for npropdef in nclassdef.n_propdefs do
-                                               self.info(" phase: {phase.class_name} for {npropdef.location}", 4)
                                                assert phase.toolcontext == self
                                                phase.process_npropdef(npropdef)
                                        end
@@ -70,6 +72,12 @@ redef class ToolContext
                                        self.check_errors
                                        break
                                end
+                               var v = new AnnotationPhaseVisitor(phase)
+                               v.enter_visit(nmodule)
+                               if errcount != self.error_count then
+                                       self.check_errors
+                                       break
+                               end
                        end
                        self.check_errors
                end
@@ -79,9 +87,22 @@ redef class ToolContext
        end
 end
 
+private class AnnotationPhaseVisitor
+       super Visitor
+
+       var phase: Phase
+
+       init(phase: Phase) do self.phase = phase
+
+       redef fun visit(n)
+       do
+               n.visit_all(self)
+               if n isa AAnnotation then phase.process_annotated_node(n.parent.parent.as(not null), n)
+       end
+end
+
 # Abstraction of steps in the analysis/processing of Nit programs
-# Specific phases should implements either `process_nmodule` or
-# `process_npropdef`.
+# Specific phases should implements one of the `process_*` method
 abstract class Phase
        # The toolcontext instance attached to the phase
        var toolcontext: ToolContext
@@ -105,8 +126,18 @@ abstract class Phase
        # @toimplement
        fun process_nmodule(nmodule: AModule) do end
 
+       # Specific actions to execute on the tree of a class definition
+       # Note that the order of the visit is the one of the file
+       # @toimplement
+       fun process_nclassdef(nclassdef: AClassdef) do end
+
        # Specific actions to execute on the tree of a property
        # Note that the order of the visit is the one of the file
        # @toimplement
        fun process_npropdef(npropdef: APropdef) do end
+
+       # Specific actions to execute on annotated nodes
+       # Note that the order of the visit is the one of the file
+       # @toimplement
+       fun process_annotated_node(node: ANode, nat: AAnnotation) do end
 end