Property definitions

nitc $ SerializationPhaseRename :: defaultinit
private class SerializationPhaseRename
	super Phase

	redef fun process_annotated_node(node, nat)
	do
		var text = nat.n_atid.n_id.text
		if text != "serialize_as" then return

		if not node isa AAttrPropdef then
			toolcontext.error(node.location,
				"Syntax Error: annotation `{text}` applies only to attributes.")
			return
		end

		# Can't use `arg_as_string` because it needs the literal phase
		var args = nat.n_args
		if args.length != 1 or not args.first isa AStringFormExpr then
			toolcontext.error(node.location,
				"Syntax Error: annotation `{text}` expects a single string literal as argument.")
			return
		end

		var t = args.first.collect_text
		var val = t.substring(1, t.length-2)
		node.serialize_name = val
	end
end
src/frontend/serialization_model_phase.nit:57,1--83,3