Skip to content

Commit

Permalink
wmlscope: allow reporting deprecated macro calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Elvish-Hunter committed Mar 1, 2022
1 parent 38eb7df commit 0da1ea4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions data/tools/wesnoth/wmltools3.py
Expand Up @@ -805,6 +805,7 @@ def __init__(self, dirpath=[], exclude="", warnlevel=0, progress=False):
# Next, decorate definitions with all references from the filelist.
self.unresolved = []
self.missing = []
self.deprecated = []
formals = []
optional_formals = []
state = "outside"
Expand Down Expand Up @@ -881,6 +882,8 @@ def __init__(self, dirpath=[], exclude="", warnlevel=0, progress=False):
if self.visible_from(defn, fn, n+1):
defn.append(fn, n+1, args, optional_args)
candidates.append(str(defn))
if defn.deprecated:
self.deprecated.append((name,Reference(ns,fn,n+1)))
if len(candidates) > 1:
print("%s: more than one definition of %s is visible here (%s)." % (Reference(ns, fn, n), name, "; ".join(candidates)))
if len(candidates) == 0:
Expand Down
11 changes: 11 additions & 0 deletions data/tools/wmlscope
Expand Up @@ -175,6 +175,7 @@ class CrossRefLister(CrossRef):
if len(self.unresolved) == 0 and len(self.missing) == 0:
print("# No unresolved references")
else:
print("# Unresolved references:")
#print(list(self.fileref.keys()))
for (name, reference) in self.unresolved + self.missing:
print("%s: Unresolved reference -> %s" % (reference, name))
Expand Down Expand Up @@ -206,6 +207,15 @@ class CrossRefLister(CrossRef):
", " if optional_args else "",
", ".join(["{}=optional {}".format(f, actualtype(oa)) for f,oa in optional_args.items()])))

def deprecateddump(self):
"Report calls to deprecated macros"
if not self.deprecated:
print("# No calls to deprecated macros")
return
print("# Calls to deprecated macros:")
for (name, reference) in self.deprecated:
print("%s: Deprecated macro call -> %s" % (reference, name))

def incorrectlysized(self):
"Report incorrectly sized images that cannot be safely used for their intended purpose"
for (namespace, filename) in xref.filelist.generator():
Expand Down Expand Up @@ -552,6 +562,7 @@ directories are given, all files under the current directory are checked.""")
xref.deflist(predicate)
if unresolved:
xref.incorrectlysized()
xref.deprecateddump()
xref.unresdump()
xref.duplicates(exportonly=True)
except KeyboardInterrupt:
Expand Down

0 comments on commit 0da1ea4

Please sign in to comment.