File: imports.py

package info (click to toggle)
fortran-language-server 3.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,268 kB
  • sloc: python: 9,688; f90: 1,195; fortran: 30; makefile: 28; ansic: 20
file content (45 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from __future__ import annotations

from typing import TYPE_CHECKING

from .use import Use

if TYPE_CHECKING:
    from .module import Module
    from .scope import Scope


class ImportTypes:
    DEFAULT = -1
    NONE = 0
    ALL = 1
    ONLY = 2


class Import(Use):
    """AST node for IMPORT statement"""

    def __init__(
        self,
        name: str,
        import_type: ImportTypes = ImportTypes.DEFAULT,
        only_list: set[str] = None,
        rename_map: dict[str, str] = None,
        line_number: int = 0,
    ):
        if only_list is None:
            only_list = set()
        if rename_map is None:
            rename_map = {}
        super().__init__(name, only_list, rename_map, line_number)
        self.import_type = import_type
        self._scope: Scope | Module | None = None

    @property
    def scope(self):
        """Parent scope of IMPORT statement i.e. parent of the interface"""
        return self._scope

    @scope.setter
    def scope(self, scope: Scope):
        self._scope = scope