mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-05 16:09:07 -04:00
Add warning for unused imports
This commit is contained in:
parent
729939ad93
commit
6a078ee075
13 changed files with 53 additions and 5 deletions
|
@ -88,6 +88,17 @@ class Import(AstNode):
|
|||
def namespace_exists(self):
|
||||
gir.get_namespace(self.tokens["namespace"], self.tokens["version"])
|
||||
|
||||
@validate()
|
||||
def unused(self):
|
||||
if self.namespace not in self.root.used_imports:
|
||||
raise UnusedWarning(
|
||||
f"Unused import: {self.namespace}",
|
||||
self.range,
|
||||
actions=[
|
||||
CodeAction("Remove import", "", self.range.with_trailing_newline)
|
||||
],
|
||||
)
|
||||
|
||||
@property
|
||||
def gir_namespace(self):
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue