From 0295b7be397547741ac622cb18ffd348e040f905 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 25 Sep 2014 23:33:27 -0400 Subject: [PATCH] src: update tools to new names in generic parameters Signed-off-by: Jean Privat --- src/doc/doc_model.nit | 16 ++++++++++------ src/highlight.nit | 2 -- src/model_utils.nit | 4 ++-- src/neo.nit | 28 ++++++++++++++-------------- src/nitx.nit | 8 ++++---- src/uml/uml_class.nit | 10 ++++------ src/uml/uml_module.nit | 8 ++++---- 7 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/doc/doc_model.nit b/src/doc/doc_model.nit index 5d666c8..f13d69f 100644 --- a/src/doc/doc_model.nit +++ b/src/doc/doc_model.nit @@ -291,7 +291,11 @@ redef class MClass var tpl = new Template if arity > 0 then tpl.add "[" - tpl.add intro.parameter_names.join(", ") + var parameter_names = new Array[String] + for p in mparameters do + parameter_names.add(p.name) + end + tpl.add parameter_names.join(", ") tpl.add "]" end return tpl @@ -353,12 +357,13 @@ redef class MClassDef fun tpl_signature: Template do var tpl = new Template - if not parameter_names.is_empty then + var mparameters = mclass.mparameters + if not mparameters.is_empty then tpl.add "[" - for i in [0..parameter_names.length[ do - tpl.add "{parameter_names[i]}: " + for i in [0..mparameters.length[ do + tpl.add "{mparameters[i].name}: " tpl.add bound_mtype.arguments[i].tpl_signature - if i < parameter_names.length - 1 then tpl.add ", " + if i < mparameters.length - 1 then tpl.add ", " end tpl.add "]" end @@ -638,7 +643,6 @@ end redef class MParameterType redef fun tpl_link do - var name = mclass.intro.parameter_names[rank] return new TplLink.with_title("{mclass.nitdoc_url}#FT_{name}", name, "formal type") end redef fun tpl_signature do return tpl_link diff --git a/src/highlight.nit b/src/highlight.nit index 4922a79..06075b4 100644 --- a/src/highlight.nit +++ b/src/highlight.nit @@ -473,13 +473,11 @@ redef class MParameterType redef fun infobox(v) do var res = new HInfoBox(v, to_s) - var name = mclass.intro.parameter_names[rank] res.new_field("parameter type").append("{name} from class ").add mclass.intro.linkto return res end redef fun linkto do - var name = mclass.intro.parameter_names[rank] return (new HTMLTag("span")).text(name) end end diff --git a/src/model_utils.nit b/src/model_utils.nit index f184eec..ff1a8d9 100644 --- a/src/model_utils.nit +++ b/src/model_utils.nit @@ -417,8 +417,8 @@ redef class MClass # Get the list of all parameter types in 'self'. fun parameter_types: Map[String, MType] do var res = new HashMap[String, MType] - for i in [0..intro.parameter_names.length[ do - res[intro.parameter_names[i]] = intro.bound_mtype.arguments[i] + for p in mparameters do + res[p.name] = p end return res end diff --git a/src/neo.nit b/src/neo.nit index 70d593e..8da9966 100644 --- a/src/neo.nit +++ b/src/neo.nit @@ -487,10 +487,14 @@ class NeoModel private fun mclass_node(mclass: MClass): NeoNode do var node = make_node(mclass) node.labels.add "MClass" - node["arity"] = mclass.arity node["full_name"] = mclass.full_name node["kind"] = mclass.kind.to_s node["visibility"] = mclass.visibility.to_s + if not mclass.mparameters.is_empty then + var parameter_names = new Array[String] + for p in mclass.mparameters do parameter_names.add(p.name) + node["parameter_names"] = new JsonArray.from(parameter_names) + end node.out_edges.add(new NeoEdge(node, "CLASSTYPE", to_node(mclass.mclass_type))) return node end @@ -503,10 +507,15 @@ class NeoModel assert node.labels.has("MClass") var mmodule = to_mmodule(model, node.in_nodes("INTRODUCES").first) var name = node["name"].to_s - var arity = node["arity"].to_s.to_i var kind = to_kind(node["kind"].to_s) var visibility = to_visibility(node["visibility"].to_s) - var mclass = new MClass(mmodule, name, arity, kind, visibility) + var parameter_names = new Array[String] + if node.has_key("parameter_names") then + for e in node["parameter_names"].as(JsonArray) do + parameter_names.add e.to_s + end + end + var mclass = new MClass(mmodule, name, parameter_names, kind, visibility) mentities[node] = mclass set_doc(node, mclass) return mclass @@ -518,9 +527,6 @@ class NeoModel node.labels.add "MClassDef" node["is_intro"] = mclassdef.is_intro node["location"] = mclassdef.location.to_s - if not mclassdef.parameter_names.is_empty then - node["parameter_names"] = new JsonArray.from(mclassdef.parameter_names) - end node.out_edges.add(new NeoEdge(node, "BOUNDTYPE", to_node(mclassdef.bound_mtype))) node.out_edges.add(new NeoEdge(node, "MCLASS", to_node(mclassdef.mclass))) for mproperty in mclassdef.intro_mproperties do @@ -544,13 +550,7 @@ class NeoModel var mmodule = to_mmodule(model, node.in_nodes("DEFINES").first) var mtype = to_mtype(model, node.out_nodes("BOUNDTYPE").first).as(MClassType) var location = to_location(node["location"].to_s) - var parameter_names = new Array[String] - if node.has_key("parameter_names") then - for e in node["parameter_names"].as(JsonArray) do - parameter_names.add e.to_s - end - end - var mclassdef = new MClassDef(mmodule, mtype, location, parameter_names) + var mclassdef = new MClassDef(mmodule, mtype, location) mentities[node] = mclassdef set_doc(node, mclassdef) var supertypes = new Array[MClassType] @@ -737,7 +737,7 @@ class NeoModel else if node.labels.has("MParameterType") then var mclass = to_mclass(model, node.out_nodes("CLASS").first) var rank = node["rank"].to_s.to_i - var mtype = new MParameterType(mclass, rank) + var mtype = mclass.mparameters[rank] mentities[node] = mtype return mtype else if node.labels.has("MNullableType") then diff --git a/src/nitx.nit b/src/nitx.nit index f71a78e..0353560 100644 --- a/src/nitx.nit +++ b/src/nitx.nit @@ -456,9 +456,9 @@ redef class MClass var res = new FlatBuffer if arity > 0 then res.append("[") - for i in [0..intro.parameter_names.length[ do - res.append(intro.parameter_names[i]) - if i < intro.parameter_names.length - 1 then res.append(", ") + for i in [0..mparameters.length[ do + res.append(mparameters[i].name) + if i < mparameters.length - 1 then res.append(", ") end res.append("]") end @@ -767,7 +767,7 @@ redef class MGenericType end redef class MParameterType - redef fun to_console do return mclass.intro.parameter_names[rank] + redef fun to_console do return name end redef class MVirtualType diff --git a/src/uml/uml_class.nit b/src/uml/uml_class.nit index 7581f2a..205297f 100644 --- a/src/uml/uml_class.nit +++ b/src/uml/uml_class.nit @@ -74,11 +74,10 @@ redef class MClass end if arity > 0 then t.add "[" - var formal = intro.parameter_names - t.add formal.first - for i in [1 .. formal.length[ do + t.add mparameters.first.name + for i in [1 .. mparameters.length[ do t.add ", " - t.add formal[i] + t.add mparameters[i].name end t.add "]" end @@ -211,8 +210,7 @@ end redef class MParameterType redef fun tpl_class(c, m) do - var n = mclass.intro.parameter_names - return n[rank] + return name end end diff --git a/src/uml/uml_module.nit b/src/uml/uml_module.nit index 55d16f3..8485c45 100644 --- a/src/uml/uml_module.nit +++ b/src/uml/uml_module.nit @@ -90,11 +90,11 @@ redef class MClassDef end if mclass.arity > 0 then t.add "[" - var formal = mclass.intro.parameter_names - t.add formal.first - for i in [1 .. formal.length[ do + var mparameters = mclass.mparameters + t.add mparameters.first.name + for i in [1 .. mparameters.length[ do t.add ", " - t.add formal[i] + t.add mparameters[i].name end t.add "]" end -- 1.7.9.5