11from __future__ import annotations
22
33import weakref
4+ from abc import abstractmethod , ABC
45from dataclasses import dataclass , replace
56from enum import Enum , auto
6- from functools import cached_property
7- from typing import List , Optional , Protocol , TypeVar , Generic , ClassVar , Dict , runtime_checkable , Any , cast , \
8- TYPE_CHECKING , Iterable
7+ from typing import List , Optional , TypeVar , Generic , ClassVar , Dict , Any , TYPE_CHECKING , Iterable
98from uuid import UUID
109
11- from rewrite import Tree , SourceFile , TreeVisitor
1210from rewrite import Markers
11+ from rewrite import Tree , SourceFile , TreeVisitor
1312
1413if TYPE_CHECKING :
1514 from .visitor import JavaVisitor
1615
1716P = TypeVar ('P' )
1817
1918
20- @runtime_checkable
21- class J (Tree , Protocol ):
19+ class J (Tree ):
2220 @property
21+ @abstractmethod
2322 def prefix (self ) -> Space :
2423 ...
2524
25+ @abstractmethod
2626 def with_prefix (self , prefix : Space ) -> 'J' :
2727 ...
2828
@@ -39,8 +39,9 @@ def accept_java(self, v: 'JavaVisitor[P]', p: P) -> Optional['J']:
3939
4040
4141@dataclass (frozen = True )
42- class Comment (Protocol ):
42+ class Comment (ABC ):
4343 @property
44+ @abstractmethod
4445 def multiline (self ) -> bool :
4546 ...
4647
@@ -288,47 +289,39 @@ class Location(Enum):
288289Space .SINGLE_SPACE = Space ([], ' ' )
289290
290291
291- @runtime_checkable
292- class JavaSourceFile (SourceFile , Protocol ):
292+ class JavaSourceFile (SourceFile ):
293293 pass
294294
295295
296- @runtime_checkable
297- class Expression (J , Protocol ):
296+ class Expression (J ):
298297 pass
299298
300299
301- @runtime_checkable
302- class Statement (J , Protocol ):
300+ class Statement (J ):
303301 pass
304302
305303
306- @runtime_checkable
307- class TypedTree (J , Protocol ):
304+ class TypedTree (J ):
308305 pass
309306
310307
311- @runtime_checkable
312- class NameTree (TypedTree , Protocol ):
308+ class NameTree (TypedTree ):
313309 pass
314310
315311
316- @runtime_checkable
317- class TypeTree (NameTree , Protocol ):
312+ class TypeTree (NameTree ):
318313 pass
319314
320315
321- @runtime_checkable
322- class Loop (Statement , Protocol ):
316+ class Loop (Statement ):
323317 pass
324318
325319
326- @runtime_checkable
327- class MethodCall (Expression , Protocol ):
320+ class MethodCall (Expression ):
328321 pass
329322
330323
331- class JavaType (Protocol ):
324+ class JavaType (ABC ):
332325 class FullyQualified :
333326 pass
334327
0 commit comments