Initialize the results list

This method must be redefined by CmdList subclasses.

Property definitions

nitc $ CmdList :: init_results
	# Initialize the `results` list
	#
	# This method must be redefined by CmdList subclasses.
	fun init_results: CmdMessage do return new CmdSuccess
src/doc/commands/commands_base.nit:255,2--258,54

nitc $ CmdSearch :: init_results
	# Return states:
	# * `CmdSuccess`: everything was ok;
	# * `ErrorNoQuery`: no `query` provided.
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res

		var query = self.query
		if query == null then return new ErrorNoQuery
		sorter = null
		results = model.find(query)
		return res
	end
src/doc/commands/commands_model.nit:266,2--280,4

nitc $ CmdModelEntities :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res

		var mentities = new Array[MEntity]
		if kind == "packages" then
			mentities = model.collect_mpackages(filter).to_a
		else if kind == "groups" then
			mentities = model.collect_mgroups(filter).to_a
		else if kind == "modules" then
			mentities = model.collect_mmodules(filter).to_a
		else if kind == "classes" then
			mentities = model.collect_mclasses(filter).to_a
		else if kind == "classdefs" then
			mentities = model.collect_mclassdefs(filter).to_a
		else if kind == "properties" then
			mentities = model.collect_mproperties(filter).to_a
		else if kind == "propdefs" then
			mentities = model.collect_mpropdefs(filter).to_a
		else
			mentities = model.collect_mentities(filter).to_a
		end
		results = mentities
		return res
	end
src/doc/commands/commands_model.nit:498,2--524,4

nitc $ CmdCatalogPackages :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res

		results = catalog.mpackages.values.to_a
		return res
	end
src/doc/commands/commands_catalog.nit:142,2--150,4

nitc $ CmdRandomEntities :: init_results
	# Always return `CmdSuccess`
	redef fun init_results do
		if results != null then return new CmdSuccess
		var res = super
		if not res isa CmdSuccess then return res
		randomize
		return res
	end
src/doc/commands/commands_model.nit:531,2--538,4

nitc $ CmdFeatures :: init_results
	# Same as `CmdEntity::init_mentity`
	#
	# Plus `WarningNoFeatures` if no features are found for `mentity`.
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		var mentities = new Array[MEntity]
		if mentity isa MPackage then
			mentities.add_all mentity.collect_mgroups(filter)
			mentities.add_all mentity.collect_mmodules(filter)
		else if mentity isa MGroup then
			mentities.add_all mentity.collect_mgroups(filter)
			mentities.add_all mentity.collect_mmodules(filter)
		else if mentity isa MModule then
			mentities.add_all mentity.collect_local_mclassdefs(filter)
		else if mentity isa MClass then
			mentities.add_all mentity.collect_intro_mproperties(filter)
			mentities.add_all mentity.collect_redef_mpropdefs(filter)
		else if mentity isa MClassDef then
			mentities.add_all mentity.collect_intro_mpropdefs(filter)
			mentities.add_all mentity.collect_redef_mpropdefs(filter)
		else if mentity isa MProperty then
			mentities.add_all mentity.collect_mpropdefs(filter)
		else
			return new WarningNoFeatures(mentity)
		end
		self.results = mentities
		return res
	end
src/doc/commands/commands_model.nit:296,2--328,4

nitc $ CmdNew :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		if mentity isa MClassDef then mentity = mentity.mclass
		if not mentity isa MClass then return new ErrorNotClass(mentity)

		var mentities = new HashSet[MEntity]
		for mpropdef in model.collect_mpropdefs(filter) do
			var visitor = new TypeInitVisitor(mentity)
			var npropdef = modelbuilder.mpropdef2node(mpropdef)
			if npropdef == null then continue
			visitor.enter_visit(npropdef)
			if visitor.called then
				mentities.add mpropdef
			end
		end
		results = mentities.to_a
		return res
	end
src/doc/commands/commands_usage.nit:101,2--123,4

nitc $ CmdCall :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		if mentity isa MPropDef then mentity = mentity.mproperty
		if not mentity isa MProperty then return new ErrorNotProperty(mentity)

		var mentities = new HashSet[MEntity]
		for mpropdef in model.collect_mpropdefs(filter) do
			if mpropdef.mproperty == mentity then continue
			var visitor = new MPropertyCallVisitor
			var npropdef = modelbuilder.mpropdef2node(mpropdef)
			if npropdef == null then continue
			visitor.enter_visit(npropdef)
			if visitor.calls.has(mentity) then
				mentities.add mpropdef
			end
		end
		results = mentities.to_a
		return res
	end
src/doc/commands/commands_usage.nit:137,2--160,4

nitc $ CmdReturn :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		if mentity isa MClassDef then mentity = mentity.mclass
		if not mentity isa MClass then return new ErrorNotClass(mentity)

		var mentities = new HashSet[MEntity]
		for mproperty in model.collect_mproperties(filter) do
			if not mproperty isa MMethod then continue
			var msignature = mproperty.intro.msignature
			if msignature != null then
				var mtype = msignature.return_mtype
				if mtype == null then continue
				if mtype isa MNullableType then mtype = mtype.mtype
				if not mtype isa MClassType then continue
				if mtype.mclass != mentity then continue
				mentities.add mproperty
			end
		end
		results = mentities.to_a
		return res
	end
src/doc/commands/commands_usage.nit:62,2--87,4

nitc $ CmdParam :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		if mentity isa MClassDef then mentity = mentity.mclass
		if not mentity isa MClass then return new ErrorNotClass(mentity)

		var mentities = new HashSet[MEntity]
		for mproperty in model.collect_mproperties(filter) do
			if not mproperty isa MMethod then continue
			var msignature = mproperty.intro.msignature
			if msignature != null then
				for mparam in msignature.mparameters do
					var mtype = mparam.mtype
					if mtype isa MNullableType then mtype = mtype.mtype
					if not mtype isa MClassType then continue
					if mtype.mclass != mentity then continue
					mentities.add mproperty
				end
			end
		end
		results = mentities.to_a
		return res
	end
src/doc/commands/commands_usage.nit:27,2--53,4

nitc $ CmdMains :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)
		var mentities = new Array[MEntity]

		if mentity isa MPackage then
			for mmodule in mentity.collect_all_mmodules(filter) do
				if mmodule_has_main(mmodule) then mentities.add mmodule
			end
		else if mentity isa MGroup then
			for mmodule in mentity.collect_all_mmodules(filter) do
				if mmodule_has_main(mmodule) then mentities.add mmodule
			end
		else if mentity isa MModule then
			if mmodule_has_main(mentity) then mentities.add mentity
		else
			return new WarningNoMains(mentity)
		end

		if mentities.is_empty then return new WarningNoMains(mentity)

		self.results = mentities
		return res
	end
src/doc/commands/commands_main.nit:23,2--49,4

nitc $ CmdTesting :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		var mentities = new Array[MEntity]
		if not mentity isa MPackage then return new WarningNoTest(mentity)

		for mgroup in mentity.collect_all_mgroups(filter) do
			if mgroup.is_test then
				mentities.add mgroup
				continue
			end
			for mmodule in mgroup.collect_mmodules(filter) do
				if mmodule.is_test then mentities.add mmodule
			end
		end

		if mentities.is_empty then return new WarningNoTest(mentity)

		self.results = mentities
		return res
	end
src/doc/commands/commands_main.nit:149,2--173,4

nitc $ CmdCatalogSearch :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res

		var query = self.query
		if query == null then return new ErrorNoQuery
		sorter = null

		var filter = self.filter
		var index = model.index

		# lookup by name prefix
		var matches = index.find_by_name_prefix(query, filter).uniq.
			sort(lname_sorter, name_sorter, kind_sorter)
		matches = matches.rerank.sort(vis_sorter, score_sorter)

		# lookup by tags
		var malus = matches.length
		if catalog.tag2proj.has_key(query) then
			for mpackage in catalog.tag2proj[query] do
				if filter != null and not filter.accept_mentity(mpackage) then continue
				matches.add new IndexMatch(mpackage, malus)
				malus += 1
			end
			matches = matches.uniq.rerank.sort(vis_sorter, score_sorter)
		end

		# lookup by full_name prefix
		malus = matches.length
		var full_matches = new IndexMatches
		for match in index.find_by_full_name_prefix(query, filter).
			sort(lfname_sorter, fname_sorter) do
			match.score += 1
			full_matches.add match
		end
		matches = matches.uniq

		# lookup by similarity
		malus = matches.length
		var sim_matches = new IndexMatches
		for match in index.find_by_similarity(query, filter).sort(score_sorter, kind_sorter, lname_sorter, name_sorter) do
			if match.score > query.length then break
			match.score += 1
			sim_matches.add match
		end
		matches.add_all sim_matches
		matches = matches.uniq
		results = matches.rerank.sort(vis_sorter, score_sorter).mentities
		return res
	end
src/doc/commands/commands_catalog.nit:38,2--89,4

nitc $ CmdCatalogTag :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res

		results = catalog.tag2proj[tag].to_a
		return res
	end
src/doc/commands/commands_catalog.nit:208,2--216,4

nitc $ CmdAncestors :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		var ancestors = mentity.collect_ancestors(mainmodule, filter).to_a
		if parents then
			results = ancestors
			return res
		end

		var parents = mentity.collect_parents(mainmodule, filter)
		var mentities = new HashSet[MEntity]
		for ancestor in ancestors do
			if not parents.has(ancestor) then mentities.add ancestor
		end
		results = mentities.to_a
		return res
	end
src/doc/commands/commands_model.nit:138,2--158,4

nitc $ CmdParents :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		results = mentity.collect_parents(mainmodule, filter).to_a
		return res
	end
src/doc/commands/commands_model.nit:165,2--174,4

nitc $ CmdChildren :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		results = mentity.collect_children(mainmodule, filter).to_a
		return res
	end
src/doc/commands/commands_model.nit:181,2--190,4

nitc $ CmdDescendants :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		var descendants = mentity.collect_descendants(mainmodule, filter).to_a
		if children then
			results = descendants
			return res
		end

		var children = mentity.collect_children(mainmodule, filter)
		var mentities = new HashSet[MEntity]
		for descendant in descendants do
			if not children.has(descendant) then mentities.add descendant
		end
		results = mentities.to_a
		return res
	end
src/doc/commands/commands_model.nit:202,2--222,4

nitc $ CmdLinearization :: init_results
	# Same states than `CmdEntity::init_mentity`
	#
	# Plus returns `WarningNoLinearization` if no linearization can be computed
	# from the mentity.
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		sorter = null
		results = mentity.collect_linearization(mainmodule)
		if results == null then return new WarningNoLinearization(mentity)
		return res
	end
src/doc/commands/commands_model.nit:231,2--246,4

nitc $ CmdCatalogMaintaining :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess
		var res = super
		if not res isa CmdSuccess then return res
		var person = self.person.as(not null)

		if not catalog.maint2proj.has_key(person) then return res
		results = catalog.maint2proj[person]
		return res
	end
src/doc/commands/commands_catalog.nit:297,2--306,4

nitc $ CmdCatalogContributing :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var person = self.person.as(not null)

		if not catalog.contrib2proj.has_key(person) then return res

		var maint2proj = null
		if catalog.maint2proj.has_key(person) then
			maint2proj = catalog.maint2proj[person]
		end

		var results = new Array[MPackage]
		for mpackage in catalog.contrib2proj[person] do
			if not maintaining and maint2proj != null and maint2proj.has(mpackage) then continue
			results.add mpackage
		end
		self.results = results
		return res
	end
src/doc/commands/commands_catalog.nit:324,2--345,4

nitc $ CmdIntros :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		if mentity isa MModule then
			var mentities = mentity.collect_intro_mclasses(filter).to_a
			self.results = mentities
		else if mentity isa MClass then
			var mentities = mentity.collect_intro_mproperties(filter).to_a
			self.results = mentities
		else if mentity isa MClassDef then
			var mentities = mentity.collect_intro_mpropdefs(filter).to_a
			mainmodule.linearize_mpropdefs(mentities)
			self.results = mentities
		else
			return new WarningNoFeatures(mentity)
		end
		return res
	end
src/doc/commands/commands_model.nit:335,2--356,4

nitc $ CmdRedefs :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		if mentity isa MModule then
			var mentities = mentity.collect_redef_mclassdefs(filter).to_a
			self.results = mentities
		else if mentity isa MClass then
			var mentities = mentity.collect_redef_mpropdefs(filter).to_a
			self.results = mentities
		else if mentity isa MClassDef then
			var mentities = mentity.collect_redef_mpropdefs(filter).to_a
			mainmodule.linearize_mpropdefs(mentities)
			self.results = mentities
		else
			return new WarningNoFeatures(mentity)
		end
		return res
	end
src/doc/commands/commands_model.nit:363,2--384,4

nitc $ CmdAllProps :: init_results
	redef fun init_results do
		if results != null then return new CmdSuccess

		var res = super
		if not res isa CmdSuccess then return res
		var mentity = self.mentity.as(not null)

		if mentity isa MClass then
			results = mentity.collect_accessible_mproperties(mainmodule, filter).to_a
		else
			return new WarningNoFeatures(mentity)
		end
		return res
	end
src/doc/commands/commands_model.nit:391,2--404,4