Property definitions

nitc $ MGroup :: defaultinit
# A group of modules in a package
class MGroup
	super MConcern

	# The name of the group
	# empty name for a default group in a single-module package
	redef var name

	redef var location

	# The enclosing package
	var mpackage: MPackage

	# The parent group if any
	# see `in_nesting` for more
	var parent: nullable MGroup

	# Fully qualified name.
	# It includes each parent group separated by `>`.
	# The full_name is terminated by `>` to avoid collision with other entities.
	#
	# E.g. `core>` and `core>collection>`
	redef fun full_name
	do
		var p = parent
		if p == null then return "{name}>"
		return "{p.full_name}{name}>"
	end

	# The group is the group tree on the package (`mpackage.mgroups`)
	# nested groups (children) are smaller
	# nesting group (see `parent`) is bigger
	var in_nesting: POSetElement[MGroup] is noinit

	# Is `self` the root of its package?
	fun is_root: Bool do return mpackage.root == self

	# The filepath (usually a directory) of the group, if any
	#
	# safe alias to `location.file.filename`
	fun filepath: nullable String do
		var res
		res = self.location.file
		if res == null then return null
		return res.filename
	end

	init
	do
		var tree = mpackage.mgroups
		self.in_nesting = tree.add_node(self)
		var parent = self.parent
		if parent != null then
			tree.add_edge(self, parent)
		end
	end

	redef fun model do return mpackage.model

	redef fun parent_concern do
		if not is_root then return parent
		return mpackage
	end

	redef fun to_s do return name
end
src/model/mpackage.nit:115,1--180,3