Property definitions

nitc $ Phase :: defaultinit
# Abstraction of steps in the analysis/processing of Nit programs
# Specific phases should implements one of the `process_*` method
abstract class Phase
	# The toolcontext instance attached to the phase
	var toolcontext: ToolContext

	# The dependence relation of the phase with the other phases
	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
	do
		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)
			end
		end
	end

	# By default, the name is the lowercased prefix of the classname
	redef fun to_s do return class_name.strip_extension("Phase").to_snake_case

	# Is the phase globally disabled?
	# A disabled phase is not called automatically called by `ToolContext::run_phases` and cie.
	#
	# 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
	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

	# Specific actions to execute on the whole tree of a module
	# Called at the end of a phase on a module
	# Last called hook
	# @toimplement
	fun process_nmodule_after(nmodule: AModule) do end
end
src/phase.nit:207,1--264,3