nitc :: CmdEntityCode :: defaultinit
# Cmd that finds the source code related to an `mentity`
class CmdEntityCode
super CmdEntity
super CmdCode
autoinit(model, modelbuilder, filter, mentity, mentity_name, format)
# ModelBuilder used to get AST nodes from entities
var modelbuilder: ModelBuilder
# Same as `CmdEntity::init_mentity`
#
# Plus `WarningNoCode` if no code/AST node is found for `mentity`.
redef fun init_command do
if node != 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 mentity = mentity.intro
if mentity isa MProperty then mentity = mentity.intro
node = modelbuilder.mentity2node(mentity)
if node == null then return new WarningNoCode(mentity)
return res
end
end
src/doc/commands/commands_model.nit:443,1--469,3