mentity
nitc :: CmdMains :: defaultinit
nitc :: CmdMains :: mmodule_has_main
Doesmmodule
has a main
method?
nitc :: json_commands $ CmdMains :: to_json
Return a JSON Serializable representation ofself
results
nitc :: CmdEntity :: _mentity_name
Name of the mentity this command is aboutnitc :: CmdEntities :: _sorter
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: DocCommand :: cmd_filter
Return a new filter for that command execution.nitc :: CmdEntityList :: defaultinit
nitc :: CmdMains :: defaultinit
nitc :: CmdList :: defaultinit
nitc :: DocCommand :: defaultinit
nitc :: CmdEntity :: defaultinit
nitc :: CmdEntities :: defaultinit
core :: Object :: defaultinit
nitc :: DocCommand :: execute
nitc :: DocCommand :: filter=
ModelFilter to apply if anynitc :: DocCommand :: http_init
Init the command from an HTTPRequestcore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: CmdEntity :: mentity_name
Name of the mentity this command is aboutnitc :: CmdEntity :: mentity_name=
Name of the mentity this command is aboutnitc :: CmdMains :: mmodule_has_main
Doesmmodule
has a main
method?
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: DocCommand :: parser_init
Initialize the command from the CommandParser datanitc :: CmdList :: print_list
nitc :: DocCommand :: to_json
Return a JSON Serializable representation ofself
results
# Cmd that finds the mains of an `mentity`
class CmdMains
super CmdEntityList
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
# Does `mmodule` has a `main` method?
private fun mmodule_has_main(mmodule: MModule): Bool do
for mclassdef in mmodule.collect_redef_mclassdefs(filter) do
if mclassdef.name != "Sys" then continue
for mpropdef in mclassdef.collect_redef_mpropdefs(filter) do
if mpropdef.name == "main" then return true
end
end
return false
end
end
src/doc/commands/commands_main.nit:19,1--61,3