- # Add `super Serializable`
- var sc = toolcontext.parse_superclass("Serializable")
- sc.location = nat.location
- nclassdef.n_propdefs.add sc
+ # Check the `serialize` state of the parent
+ if not node isa AModuledecl then
+ var up_serialize = false
+ var up: nullable ANode = node
+ loop
+ up = up.parent
+ if up == null then
+ break
+ else if up.is_serialize then
+ up_serialize = true
+ break
+ else if up.is_noserialize then
+ break
+ end
+ end
+
+ # Check for useless double declarations
+ if serialize and up_serialize then
+ toolcontext.warning(node.location, "useless-serialize",
+ "Warning: superfluous use of `{text}`.")
+ else if noserialize and not up_serialize then
+ toolcontext.warning(node.location, "useless-noserialize",
+ "Warning: superfluous use of `{text}`.")
+ end
+ end
+ end
+
+ redef fun process_nclassdef(nclassdef)
+ do
+ if not nclassdef isa AStdClassdef then return
+
+ # Is there a declaration on the classdef or the module?
+ var serialize = nclassdef.is_serialize
+
+ if not serialize and not nclassdef.is_noserialize then
+ # Is the module marked serialize?
+ serialize = nclassdef.parent.as(AModule).is_serialize
+ end
+
+ var per_attribute = false
+ if not serialize then
+ # Is there an attribute marked serialize?
+ for npropdef in nclassdef.n_propdefs do
+ if npropdef.is_serialize then
+ serialize = true
+ per_attribute = true
+ break
+ end
+ end
+ end