nitc :: mclassdef_collect $ MClassDef
A definition (an introduction or a refinement) of a class in a modulenitc :: mclassdef_collect $ MClassDef
A definition (an introduction or a refinement) of a class in a modulenitc :: actors_injection_phase
Injects model for the classes annotated with "is actor" sonitc :: astbuilder
Instantiation and transformation of semantic nodes in the AST of expressions and statementsnitc :: i18n_phase
Basic support of internationalization through the generation of id-to-string tablesSerializable::inspect
to show more useful information
nitc :: modelbuilder
more_collections :: more_collections
Highly specific, but useful, collections-related classes.threaded
annotation
serialization :: serialization_core
Abstract services to serialize Nit objects to different formatsnitc :: serialization_model_phase
Phase generating methods (model-only) to serialize Nit objectsnitc :: toolcontext
Common command-line tool infrastructure than handle options and error messagescore :: union_find
union–find algorithm using an efficient disjoint-set data structure
module mclassdef_collect
# We usualy need specific phases
# NOTE: `frontend` is sufficent in most case (it is often too much)
import frontend
import model_collect
redef class MClassDef
# Collect all mproperties introduced in 'self' with `visibility >= min_visibility`.
fun collect_intro_mproperties(filter: ModelFilter): Set[MProperty] do
var set = new HashSet[MProperty]
for mprop in self.intro_mproperties do
if not filter.accept_mentity(mprop) then continue
set.add(mprop)
end
return set
end
# Collect mmethods introduced in 'self' with `visibility >= min_visibility`.
fun collect_intro_mmethods(filter: ModelFilter): Set[MMethod] do
var res = new HashSet[MMethod]
for mproperty in collect_intro_mproperties(filter) do
if not filter.accept_mentity(mproperty) then continue
if mproperty isa MMethod then res.add(mproperty)
end
return res
end
# Collect mmethods redefined in 'self' with `visibility >= min_visibility`.
fun collect_redef_mmethods(filter: ModelFilter): Set[MMethod] do
var res = new HashSet[MMethod]
for mproperty in collect_redef_mproperties(filter) do
if not filter.accept_mentity(mproperty) then continue
if mproperty isa MMethod then res.add(mproperty)
end
return res
end
# Collect mattributes redefined in 'self' with `visibility >= min_visibility`.
fun collect_redef_mattributes(filter: ModelFilter): Set[MAttribute] do
var res = new HashSet[MAttribute]
for mproperty in collect_redef_mproperties(filter) do
if not filter.accept_mentity(mproperty) then continue
if mproperty isa MAttribute then res.add(mproperty)
end
return res
end
# Collect mattributes introduced in 'self' with `visibility >= min_visibility`.
fun collect_intro_mattributes(filter: ModelFilter): Set[MAttribute] do
var res = new HashSet[MAttribute]
for mproperty in collect_intro_mproperties(filter) do
if not filter.accept_mentity(mproperty) then continue
if mproperty isa MAttribute then res.add(mproperty)
end
return res
end
# Collect all mproperties redefined in 'self' with `visibility >= min_visibility`.
fun collect_redef_mproperties(filter: ModelFilter): Set[MProperty] do
var set = new HashSet[MProperty]
for mpropdef in self.mpropdefs do
if not filter.accept_mentity(mpropdef) then continue
if mpropdef.mproperty.intro_mclassdef.mclass == self then continue
set.add(mpropdef.mproperty)
end
return set
end
# Collect mmethods inherited by 'self' if accepted by `filter`.
fun collect_inherited_mmethods(mainmodule: MModule, filter: ModelFilter): Set[MMethod] do
var res = new HashSet[MMethod]
for mproperty in collect_inherited_mproperties(mainmodule, filter) do
if not filter.accept_mentity(mproperty) then continue
if mproperty isa MMethod then res.add(mproperty)
end
return res
end
# Collect mproperties introduced and redefined in 'self' with `visibility >= min_visibility`.
fun collect_local_mproperties(filter: ModelFilter): Set[MProperty] do
var set = new HashSet[MProperty]
set.add_all collect_intro_mproperties(filter)
set.add_all collect_redef_mproperties(filter)
return set
end
# Collect all mproperties inehrited by 'self' with `visibility >= min_visibility`.
fun collect_inherited_mproperties(mainmodule: MModule, filter: ModelFilter): Set[MProperty] do
var set = new HashSet[MProperty]
for parent in collect_parents(mainmodule, filter) do
set.add_all(parent.collect_intro_mproperties(filter))
set.add_all(parent.collect_inherited_mproperties(mainmodule, filter))
end
return set
end
# Collect mattributes inherited by 'self' with `visibility >= min_visibility`.
fun collect_inherited_mattributes(mainmodule: MModule, filter: ModelFilter): Set[MAttribute] do
var res = new HashSet[MAttribute]
for mproperty in collect_inherited_mproperties(mainmodule, filter) do
if not filter.accept_mentity(mproperty) then continue
if mproperty isa MAttribute then res.add(mproperty)
end
return res
end
# Collect all mmethod inehrited,intro and redef
fun collect_all_methods(mainmodule: MModule, filter: ModelFilter): Set[MMethod] do
var set = new HashSet[MMethod]
set.add_all collect_intro_mmethods(filter)
set.add_all collect_redef_mmethods(filter)
set.add_all collect_inherited_mmethods(mainmodule, filter)
return set
end
# Collect all mattributs inehrited,intro and redef
fun collect_all_mattributes(mainmodule: MModule, filter: ModelFilter): Set[MAttribute] do
var set = new HashSet[MAttribute]
set.add_all collect_redef_mattributes(filter)
set.add_all collect_intro_mattributes(filter)
set.add_all collect_inherited_mattributes(mainmodule, filter)
return set
end
# Collect intro and redef mmethods
fun collect_intro_and_redef_methods(filter: ModelFilter): Set[MMethod] do
var set = new HashSet[MMethod]
set.add_all collect_intro_mmethods(filter)
set.add_all collect_redef_mmethods(filter)
return set
end
# Collect intro and redef mattributs
fun collect_intro_and_redef_mattributes(filter: ModelFilter): Set[MAttribute] do
var set = new HashSet[MAttribute]
set.add_all collect_redef_mattributes(filter)
set.add_all collect_intro_mattributes(filter)
return set
end
# Collect intro and redef mpropdefs
fun collect_intro_and_redef_mpropdefs(filter: ModelFilter): Set[MPropDef] do
var set = new HashSet[MPropDef]
set.add_all collect_intro_mpropdefs(filter)
set.add_all collect_redef_mpropdefs(filter)
return set
end
# Collect intro abstract mmethodDef
fun collect_abstract_methods(filter: ModelFilter): Set[MMethodDef] do
var set = new HashSet[MMethodDef]
var mpropdefs = collect_intro_mpropdefs(filter)
for mpropdef in mpropdefs do
if mpropdef isa MMethodDef then
if mpropdef.is_abstract then set.add(mpropdef)
end
end
return set
end
# Collect not defined properties
fun collect_not_define_properties(filter: ModelFilter):Set[MMethodDef] do
var set = new HashSet[MMethodDef]
for mpropdef in collect_abstract_methods(filter) do
var redef_count = 0
for mprop in mpropdef.mproperty.mpropdefs do
if mprop.is_abstract then continue
redef_count += 1
end
if redef_count == 0 then set.add(mpropdef)
end
return set
end
end
src/metrics/mclassdef_collect.nit:16,1--190,3