nitc :: NeoModel :: to_mproperty
MProperty
from a node
.REQUIRE node.labels.has("MProperty")
# Build a new `MProperty` from a `node`.
#
# REQUIRE `node.labels.has("MProperty")`
private fun to_mproperty(model: Model, node: NeoNode): MProperty do
var m = mentities.get_or_null(node.id.as(Int))
if m isa MProperty then return m
assert node.labels.has("MProperty")
var intro_mclassdef = to_mclassdef(model, node.out_nodes("INTRO_CLASSDEF").first)
var name = node["name"].to_s
var location = to_location(node["location"].to_s)
var visibility = to_visibility(node["visibility"].to_s)
var mprop: nullable MProperty = null
if node.labels.has("MMethod") then
mprop = new MMethod(intro_mclassdef, name, location, visibility)
mprop.is_init = node["is_init"].as(Bool)
else if node.labels.has("MAttribute") then
mprop = new MAttribute(intro_mclassdef, name, location, visibility)
else if node.labels.has("MVirtualTypeProp") then
mprop = new MVirtualTypeProp(intro_mclassdef, name, location, visibility)
else if node.labels.has("MInnerClass") then
var inner = to_mclass(model, node.out_nodes("NESTS").first)
mprop = new MInnerClass(intro_mclassdef, name, location, visibility, inner)
end
if mprop == null then
print "not yet implemented to_mproperty for {node.labels.join(",")}"
abort
end
mentities[node.id.as(Int)] = mprop
set_doc(node, mprop)
return mprop
end
src/neo.nit:456,2--487,4