+# A query to search signatures using a specific `MType` as parameter.
+class ParamQuery
+ super MetaQuery
+
+ redef fun perform(nitx, doc) do
+ var res = new Array[NitxMatch]
+ var mtype_name = args.first
+ for mproperty in doc.mproperties do
+ if not mproperty isa MMethod then continue
+ var msignature = mproperty.intro.msignature
+ if msignature != null then
+ for mparam in msignature.mparameters do
+ if mparam.mtype.name == mtype_name then
+ res.add new MEntityMatch(self, mproperty)
+ end
+ end
+ end
+ end
+ return res
+ end
+end
+
+# A query to search signatures using a specific `MType` as return.
+class ReturnQuery
+ super MetaQuery
+
+ redef fun perform(nitx, doc) do
+ var res = new Array[NitxMatch]
+ var mtype_name = args.first
+ for mproperty in doc.mproperties do
+ if not mproperty isa MMethod then continue
+ var msignature = mproperty.intro.msignature
+ if msignature != null then
+ var mreturn = msignature.return_mtype
+ if mreturn != null and mreturn.name == mtype_name then
+ res.add new MEntityMatch(self, mproperty)
+ end
+ end
+ end
+ return res
+ end
+end
+
+# A query to search methods creating new instances of a specific `MType`.
+class NewQuery
+ super MetaQuery
+
+ redef fun perform(nitx, doc) do
+ var res = new Array[NitxMatch]
+ var mtype_name = args.first
+ for mpropdef in doc.mpropdefs do
+ var visitor = new TypeInitVisitor(mtype_name)
+ var npropdef = nitx.ctx.modelbuilder.mpropdef2node(mpropdef)
+ if npropdef == null then continue
+ visitor.enter_visit(npropdef)
+ for i in visitor.inits do
+ res.add new MEntityMatch(self, mpropdef)
+ end
+ end
+ return res
+ end
+end
+
+# A query to search methods calling a specific `MProperty`.
+class CallQuery
+ super MetaQuery
+
+ redef fun perform(nitx, doc) do
+ var res = new Array[NitxMatch]
+ var mprop_name = args.first
+ for mpropdef in doc.mpropdefs do
+ var visitor = new MPropertyCallVisitor
+ var npropdef = nitx.ctx.modelbuilder.mpropdef2node(mpropdef)
+ if npropdef == null then continue
+ visitor.enter_visit(npropdef)
+ for mprop in visitor.calls do
+ if mprop.name != mprop_name then continue
+ res.add new MEntityMatch(self, mpropdef)
+ end
+ end
+ return res
+ end
+end
+