|
8 | 8 | from enum import Enum |
9 | 9 | from typing import TYPE_CHECKING |
10 | 10 |
|
11 | | -from natsort import natsorted |
12 | | - |
13 | 11 | from ..template import Template, TemplateList |
14 | | -from ..utils import qualify_type_str |
15 | 12 | from .base_scope_kind import ScopeKind |
16 | 13 | from .extendable import Extendable |
17 | 14 |
|
@@ -45,27 +42,15 @@ def add_template(self, template: Template | [Template]) -> None: |
45 | 42 | self.template_list.add(template) |
46 | 43 |
|
47 | 44 | def close(self, scope: Scope) -> None: |
48 | | - """Qualify base class names and their template arguments.""" |
49 | | - for base in self.base_classes: |
50 | | - base.name = qualify_type_str(base.name, scope) |
| 45 | + self.qualify_base_classes(scope) |
51 | 46 |
|
52 | 47 | def to_string(self, scope: Scope) -> str: |
53 | 48 | result = "" |
54 | 49 |
|
55 | 50 | if self.template_list is not None: |
56 | 51 | result += "\n" + self.template_list.to_string() + "\n" |
57 | 52 |
|
58 | | - inheritance_string = self.get_inheritance_string() |
59 | | - result += f"{self.name} {scope.get_qualified_name()}{inheritance_string} {{" |
60 | | - |
61 | | - stringified_members = [] |
62 | | - for member in scope.get_members(): |
63 | | - stringified_members.append(member.to_string(2)) |
64 | | - stringified_members = natsorted(stringified_members) |
65 | | - result += ("\n" if len(stringified_members) > 0 else "") + "\n".join( |
66 | | - stringified_members |
67 | | - ) |
68 | | - |
69 | | - result += "\n}" |
70 | | - |
| 53 | + inheritance = self.get_inheritance_string() |
| 54 | + result += f"{self.name} {scope.get_qualified_name()}{inheritance} " |
| 55 | + result += self._format_scope_body(scope) |
71 | 56 | return result |
0 commit comments