Debian Codegraph @

fortls/parsers/internal/imports.py

raw symbols SCIP
1 from __future__ import annotations
2
3 from typing import TYPE_CHECKING
4
5 from .use import Use
6
7 if TYPE_CHECKING:
8 from .module import Module
9 from .scope import Scope
10
11
12 class ImportTypes:
13 DEFAULT = -1
14 NONE = 0
15 ALL = 1
16 ONLY = 2
17
18
19 class Import(Use):
20 """AST node for IMPORT statement"""
21
22 def __init__(
23 self,
24 name: str,
25 import_type: ImportTypes = ImportTypes.DEFAULT,
26 only_list: set[str] = None,
27 rename_map: dict[str, str] = None,
28 line_number: int = 0,
29 ):
30 if only_list is None:
31 only_list = set()
32 if rename_map is None:
33 rename_map = {}
34 super().__init__(name, only_list, rename_map, line_number)
35 self.import_type = import_type
36 self._scope: Scope | Module | None = None
37
38 @property
39 def scope(self):
40 """Parent scope of IMPORT statement i.e. parent of the interface"""
41 return self._scope
42
43 @scope.setter
44 def scope(self, scope: Scope):
45 self._scope = scope