for m in super_mmodules do
if declared_annotations[m].has(name) then
- modelbuilder.warning(annot, "Warning: an annotation `{name}` is already declared in module `{m}`")
+ modelbuilder.warning(annot, "multiple-annotation-declarations", "Warning: an annotation `{name}` is already declared in module `{m}`")
break label
end
end
if annots.has(name) then return
- toolcontext.modelbuilder.warning(nat, "Warning: unknown annotation `{name}`")
+ toolcontext.modelbuilder.warning(nat, "unknown-annotation", "Warning: unknown annotation `{name}`")
annots.add(name) # to avoid multiple errors on the same name
end
var toolcontext: ToolContext
- fun warning(node: ANode, msg: String)
+ fun warning(node: ANode, tag, msg: String)
do
- toolcontext.warning(node.hot_location, msg)
+ toolcontext.warning(node.hot_location, tag, msg)
end
init(toolcontext: ToolContext)
redef fun after_simple_misc(v)
do
if self.n_opar != null and self.n_params.is_empty then
- v.warning(self, "Warning: superfluous parentheses.")
+ v.warning(self, "parentheses", "Warning: superfluous parentheses.")
end
end
end
redef class AParExpr
redef fun warn_parentheses(v)
do
- v.warning(self, "Warning: superfluous parentheses.")
+ v.warning(self, "parentheses", "Warning: superfluous parentheses.")
end
end
redef fun after_simple_misc(v)
do
if n_exprs.is_empty then
- v.warning(self, "Warning: superfluous parentheses.")
+ v.warning(self, "parentheses", "Warning: superfluous parentheses.")
end
end
end
redef fun after_simple_misc(v)
do
if n_expr isa ATrueExpr then
- v.warning(self, "Warning: use 'loop' instead of 'while true do'.")
+ v.warning(self, "loop", "Warning: use `loop` instead of `while true do`.")
else
n_expr.warn_parentheses(v)
end
redef fun accept_simple_misc(v)
do
if v.once_count > 0 then
- v.warning(self, "Useless once in a once expression.")
+ v.warning(self, "nested-once", "Warning: useless once in a once expression.")
end
v.once_count = v.once_count + 1
# Helper function to display a warning on a node.
# Alias for: `self.toolcontext.warning(n.hot_location, text)`
- fun warning(n: ANode, text: String)
+ fun warning(n: ANode, tag, text: String)
do
- self.toolcontext.warning(n.hot_location, text)
+ self.toolcontext.warning(n.hot_location, tag, text)
end
# Force to get the primitive method named `name` on the type `recv` or do a fatal error on `n`
return
end
for c in ptname.chars do if c >= 'a' and c<= 'z' then
- warning(nfd, "Warning: lowercase in the formal parameter type {ptname}")
+ warning(nfd, "formal-type-name", "Warning: lowercase in the formal parameter type {ptname}")
break
end
names.add(ptname)
nfd.bound = bound
end
if bound isa MClassType and bound.mclass.kind == enum_kind then
- warning(nfdt, "Warning: Useless formal parameter type since `{bound}` cannnot have subclasses.")
+ warning(nfdt, "useless-bound", "Warning: Useless formal parameter type since `{bound}` cannnot have subclasses.")
end
else if mclass.mclassdefs.is_empty then
# No bound, then implicitely bound by nullable Object
if not parents.has(sc) or sc == objectclass then
# Skip the warning on generated code
if ntype.location.file != null and not ntype.location.file.filename.is_empty then
- warning(ntype, "Warning: superfluous super-class {mtype} in class {mclassdef.mclass}.")
+ warning(ntype, "useless-superclass", "Warning: superfluous super-class {mtype} in class {mclassdef.mclass}.")
end
else if not seen_parents.has_key(sc) then
seen_parents[sc] = ntype
else
- warning(ntype, "Warning: duplicated super-class {mtype} in class {mclassdef.mclass}.")
+ warning(ntype, "useless-superclass", "Warning: duplicated super-class {mtype} in class {mclassdef.mclass}.")
end
end
end
else if mvisibility == private_visibility then
assert nvisibility != null
# Not yet
- # modelbuilder.warning(nvisibility, "Warning: private is unrequired since the only legal visibility for properties in a private class is private.")
+ modelbuilder.warning(nvisibility, "useless-visibility", "Warning: private is superfluous since the only legal visibility for properties in a private class is private.")
end
mvisibility = private_visibility
end
if nexpr isa ANewExpr then
var xmtype = modelbuilder.resolve_mtype(mmodule, mclassdef, nexpr.n_type)
if xmtype == mtype and modelbuilder.toolcontext.opt_warn.value >= 2 then
- modelbuilder.warning(ntype, "Warning: useless type definition")
+ modelbuilder.warning(ntype, "useless-type", "Warning: useless type definition")
end
end
end
var mvisibility = new_property_visibility(modelbuilder, mclassdef, self.n_visibility)
mprop = new MVirtualTypeProp(mclassdef, name, mvisibility)
for c in name.chars do if c >= 'a' and c<= 'z' then
- modelbuilder.warning(n_id, "Warning: lowercase in the virtual type {name}")
+ modelbuilder.warning(n_id, "bad-type-name", "Warning: lowercase in the virtual type {name}")
break
end
if not self.check_redef_keyword(modelbuilder, mclassdef, self.n_kwredef, false, mprop) then return
end
if p.mclassdef.mclass == mclassdef.mclass then
# Still a warning to pass existing bad code
- modelbuilder.warning(n_type, "Redef Error: a virtual type cannot be refined.")
+ modelbuilder.warning(n_type, "refine-type", "Redef Error: a virtual type cannot be refined.")
break
end
if not bound.is_subtype(mmodule, anchor, supbound) then
if sup == null then return null # Forward error
if sup == sub then
- self.modelbuilder.warning(node, "Warning: Expression is already a {sup}.")
+ self.modelbuilder.warning(node, "useless-type-test", "Warning: Expression is already a {sup}.")
else if self.is_subtype(sub, sup) then
- self.modelbuilder.warning(node, "Warning: Expression is already a {sup} since it is a {sub}.")
+ self.modelbuilder.warning(node, "useless-type-test", "Warning: Expression is already a {sup} since it is a {sub}.")
end
return sup
end
if info != null and self.mpropdef.mproperty.deprecation == null then
var mdoc = info.mdoc
if mdoc != null then
- self.modelbuilder.warning(node, "Deprecation Warning: Method '{name}' is deprecated: {mdoc.content.first}")
+ self.modelbuilder.warning(node, "deprecated-method", "Deprecation Warning: Method '{name}' is deprecated: {mdoc.content.first}")
else
- self.modelbuilder.warning(node, "Deprecation Warning: Method '{name}' is deprecated.")
+ self.modelbuilder.warning(node, "deprecated-method", "Deprecation Warning: Method '{name}' is deprecated.")
end
end
else if propdefs.length == 1 then
mpropdef = propdefs.first
else
- self.modelbuilder.warning(node, "Warning: confliting property definitions for property {name} in {unsafe_type}: {propdefs.join(" ")}")
+ self.modelbuilder.warning(node, "property-conflict", "Warning: conflicting property definitions for property {name} in {unsafe_type}: {propdefs.join(" ")}")
mpropdef = mproperty.intro
end
self.mtype = mtype
if mtype isa MClassType then
- v.modelbuilder.warning(self, "Warning: expression is already not null, since it is a `{mtype}`.")
+ v.modelbuilder.warning(self, "useless-type-test", "Warning: expression is already not null, since it is a `{mtype}`.")
return
end
assert mtype.need_anchor
var u = v.anchor_to(mtype)
if not u isa MNullableType then
- v.modelbuilder.warning(self, "Warning: expression is already not null, since it is a `{mtype}: {u}`.")
+ v.modelbuilder.warning(self, "useless-type-test", "Warning: expression is already not null, since it is a `{mtype}: {u}`.")
return
end
end
var mtype = v.resolve_mtype(ntype)
if mtype != null and mtype != expr then
var umtype = v.anchor_to(mtype)
- v.modelbuilder.warning(self, "Found type {expr} (-> {unsafe}), expected {mtype} (-> {umtype})")
+ v.modelbuilder.warning(self, "debug", "Found type {expr} (-> {unsafe}), expected {mtype} (-> {umtype})")
end
self.is_typed = true
end
# We want executable code
if not (ast isa AModule or ast isa ABlockExpr or ast isa AExpr) then
if ndoc != null and n.tag == "pre" and toolcontext.opt_warn.value > 1 then
- toolcontext.warning(ndoc.location, "Warning: There is a block of code that is not valid Nit, thus not considered a nitunit")
- if ast isa AError then toolcontext.warning(ast.location, ast.message)
+ toolcontext.warning(ndoc.location, "invalid-block", "Warning: There is a block of code that is not valid Nit, thus not considered a nitunit")
+ if ast isa AError then toolcontext.warning(ast.location, "syntax-error", ast.message)
ndoc = null # To avoid multiple warning in the same node
end
return
v.enter_visit(ast)
if not v.foundit then
if ndoc != null and n.tag == "pre" and toolcontext.opt_warn.value > 1 then
- toolcontext.warning(ndoc.location, "Warning: There is a block of Nit code without `assert`, thus not considered a nitunit")
+ toolcontext.warning(ndoc.location, "invalid-block", "Warning: There is a block of Nit code without `assert`, thus not considered a nitunit")
ndoc = null # To avoid multiple warning in the same node
end
return
var ne = new HTMLTag("failure")
ne.attr("message", msg)
tc.add ne
- toolcontext.warning(ndoc.location, "FAILURE: {tc.attrs["classname"]}.{tc.attrs["name"]} (in {file}): {msg}")
+ toolcontext.warning(ndoc.location, "failure", "FAILURE: {tc.attrs["classname"]}.{tc.attrs["name"]} (in {file}): {msg}")
toolcontext.modelbuilder.failed_entities += 1
else if res2 != 0 then
var ne = new HTMLTag("error")
ne.attr("message", msg)
tc.add ne
- toolcontext.warning(ndoc.location, "ERROR: {tc.attrs["classname"]}.{tc.attrs["name"]} (in {file}): {msg}")
+ toolcontext.warning(ndoc.location, "error", "ERROR: {tc.attrs["classname"]}.{tc.attrs["name"]} (in {file}): {msg}")
toolcontext.modelbuilder.failed_entities += 1
end
toolcontext.check_errors
var loc = test_method.location
if res != 0 then
failure = msg
- toolcontext.warning(loc, "FAILURE: {test_method.name} (in file {file}.nit): {msg}")
+ toolcontext.warning(loc, "failure", "FAILURE: {test_method.name} (in file {file}.nit): {msg}")
toolcontext.modelbuilder.failed_tests += 1
end
toolcontext.check_errors
var loc = test_method.location
if res != 0 then
error = msg
- toolcontext.warning(loc, "ERROR: {test_method.name} (in file {file}.nit): {msg}")
+ toolcontext.warning(loc, "failure", "ERROR: {test_method.name} (in file {file}.nit): {msg}")
toolcontext.modelbuilder.failed_tests += 1
end
toolcontext.check_errors