|
13 | 13 | from search_query.constants import TokenTypes |
14 | 14 | from search_query.query import Query |
15 | 15 |
|
16 | | -if typing.TYPE_CHECKING: |
| 16 | +if typing.TYPE_CHECKING: # pragma: no cover |
17 | 17 | from search_query.linter_base import QueryStringLinter |
18 | 18 |
|
19 | 19 |
|
@@ -126,51 +126,51 @@ def get_token_str(self, token_nr: str) -> str: |
126 | 126 | "get_token_str method must be implemented by inheriting classes" |
127 | 127 | ) |
128 | 128 |
|
129 | | - def _replace_token_nr_by_query( |
130 | | - self, query_list: list, token_nr: str, token_content: dict |
131 | | - ) -> None: |
132 | | - for i, (content, pos) in enumerate(query_list): |
133 | | - token_str = self.get_token_str(token_nr) |
134 | | - if token_str in content: |
135 | | - query_list.pop(i) |
136 | | - |
137 | | - content_before = content[: content.find(token_str)] |
138 | | - content_before_pos = (pos[0], pos[0] + len(content_before)) |
139 | | - content_after = content[content.find(token_str) + len(token_str) :] |
140 | | - content_after_pos = ( |
141 | | - content_before_pos[1] + len(token_str), |
142 | | - content_before_pos[1] + len(content_after) + len(token_str), |
143 | | - ) |
| 129 | + # def _replace_token_nr_by_query( |
| 130 | + # self, query_list: list, token_nr: str, token_content: dict |
| 131 | + # ) -> None: |
| 132 | + # for i, (content, pos) in enumerate(query_list): |
| 133 | + # token_str = self.get_token_str(token_nr) |
| 134 | + # if token_str in content: |
| 135 | + # query_list.pop(i) |
| 136 | + |
| 137 | + # content_before = content[: content.find(token_str)] |
| 138 | + # content_before_pos = (pos[0], pos[0] + len(content_before)) |
| 139 | + # content_after = content[content.find(token_str) + len(token_str) :] |
| 140 | + # content_after_pos = ( |
| 141 | + # content_before_pos[1] + len(token_str), |
| 142 | + # content_before_pos[1] + len(content_after) + len(token_str), |
| 143 | + # ) |
144 | 144 |
|
145 | | - new_content = token_content["node_content"] |
146 | | - new_pos = token_content["content_pos"] |
| 145 | + # new_content = token_content["node_content"] |
| 146 | + # new_pos = token_content["content_pos"] |
147 | 147 |
|
148 | | - if content_after: |
149 | | - query_list.insert(i, (content_after, content_after_pos)) |
| 148 | + # if content_after: |
| 149 | + # query_list.insert(i, (content_after, content_after_pos)) |
150 | 150 |
|
151 | | - # Insert the sub-query from the list with "artificial parentheses" |
152 | | - # (positions with length 0) |
153 | | - query_list.insert(i, (")", (-1, -1))) |
154 | | - query_list.insert(i, (new_content, new_pos)) |
155 | | - query_list.insert(i, ("(", (-1, -1))) |
| 151 | + # # Insert the sub-query from the list with "artificial parentheses" |
| 152 | + # # (positions with length 0) |
| 153 | + # query_list.insert(i, (")", (-1, -1))) |
| 154 | + # query_list.insert(i, (new_content, new_pos)) |
| 155 | + # query_list.insert(i, ("(", (-1, -1))) |
156 | 156 |
|
157 | | - if content_before: |
158 | | - query_list.insert(i, (content_before, content_before_pos)) |
| 157 | + # if content_before: |
| 158 | + # query_list.insert(i, (content_before, content_before_pos)) |
159 | 159 |
|
160 | | - break |
| 160 | + # break |
161 | 161 |
|
162 | | - def dict_to_positioned_list(self) -> list: |
163 | | - """Convert a node to a positioned list.""" |
| 162 | + # def dict_to_positioned_list(self) -> list: |
| 163 | + # """Convert a node to a positioned list.""" |
164 | 164 |
|
165 | | - root_node = list(self.query_dict.values())[-1] |
166 | | - query_list = [(root_node["node_content"], root_node["content_pos"])] |
| 165 | + # root_node = list(self.query_dict.values())[-1] |
| 166 | + # query_list = [(root_node["node_content"], root_node["content_pos"])] |
167 | 167 |
|
168 | | - for token_nr, token_content in reversed(self.query_dict.items()): |
169 | | - # iterate over query_list if token_nr is in the content, |
170 | | - # split the content and insert the token_content, updating the content_pos |
171 | | - self._replace_token_nr_by_query(query_list, token_nr, token_content) |
| 168 | + # for token_nr, token_content in reversed(self.query_dict.items()): |
| 169 | + # # iterate over query_list if token_nr is in the content, |
| 170 | + # # split the content and insert the token_content, updating the content_pos |
| 171 | + # self._replace_token_nr_by_query(query_list, token_nr, token_content) |
172 | 172 |
|
173 | | - return query_list |
| 173 | + # return query_list |
174 | 174 |
|
175 | 175 | @abstractmethod |
176 | 176 | def parse(self) -> Query: |
|
0 commit comments