ai-editor-tree-engine-dev 1.0.176__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ai_editor_tree_engine_dev-1.0.176.dist-info/METADATA +35 -0
- ai_editor_tree_engine_dev-1.0.176.dist-info/RECORD +121 -0
- ai_editor_tree_engine_dev-1.0.176.dist-info/WHEEL +5 -0
- ai_editor_tree_engine_dev-1.0.176.dist-info/licenses/LICENSE +21 -0
- ai_editor_tree_engine_dev-1.0.176.dist-info/top_level.txt +1 -0
- tree_engine/PUBLIC_API.md +161 -0
- tree_engine/__init__.py +327 -0
- tree_engine/checks/__init__.py +60 -0
- tree_engine/checks/builtin/__init__.py +5 -0
- tree_engine/checks/builtin/compile_check.py +53 -0
- tree_engine/checks/builtin/csv_syntax.py +51 -0
- tree_engine/checks/builtin/docstrings.py +211 -0
- tree_engine/checks/builtin/encoding.py +55 -0
- tree_engine/checks/builtin/fleet_rules.py +227 -0
- tree_engine/checks/builtin/format_syntax.py +82 -0
- tree_engine/checks/builtin/jsonl_syntax.py +49 -0
- tree_engine/checks/builtin/shipped.py +52 -0
- tree_engine/checks/builtin/syntax.py +118 -0
- tree_engine/checks/builtin/xml_wellformed.py +51 -0
- tree_engine/checks/chain.py +332 -0
- tree_engine/checks/external/__init__.py +5 -0
- tree_engine/checks/external/_base.py +61 -0
- tree_engine/checks/external/bandit.py +53 -0
- tree_engine/checks/external/black.py +48 -0
- tree_engine/checks/external/flake8.py +38 -0
- tree_engine/checks/external/isort.py +38 -0
- tree_engine/checks/external/mypy.py +45 -0
- tree_engine/checks/external/ruff.py +45 -0
- tree_engine/checks/external/runner.py +197 -0
- tree_engine/checks/model.py +110 -0
- tree_engine/checks/options.py +73 -0
- tree_engine/checks/plugin.py +171 -0
- tree_engine/checks/registry.py +349 -0
- tree_engine/core/address.py +376 -0
- tree_engine/core/identifier_map.py +266 -0
- tree_engine/core/identity.py +226 -0
- tree_engine/core/instrumentation.py +399 -0
- tree_engine/core/integrity.py +341 -0
- tree_engine/core/integrity_full.py +382 -0
- tree_engine/core/journal.py +260 -0
- tree_engine/core/journal_compose.py +571 -0
- tree_engine/core/live_tree.py +785 -0
- tree_engine/core/locking.py +188 -0
- tree_engine/core/move.py +585 -0
- tree_engine/core/move_references.py +323 -0
- tree_engine/core/node_types.py +408 -0
- tree_engine/core/nodes.py +348 -0
- tree_engine/core/offsets.py +24 -0
- tree_engine/core/operations.py +825 -0
- tree_engine/core/plugin_boundary.py +160 -0
- tree_engine/core/position_map.py +263 -0
- tree_engine/core/position_transfer.py +512 -0
- tree_engine/core/range_refresh.py +366 -0
- tree_engine/core/reference_cache.py +360 -0
- tree_engine/core/references.py +223 -0
- tree_engine/core/reparse.py +378 -0
- tree_engine/core/short_id.py +296 -0
- tree_engine/core/subtree_apply.py +397 -0
- tree_engine/core/subtree_copy.py +399 -0
- tree_engine/core/transactions.py +397 -0
- tree_engine/core/trivia.py +396 -0
- tree_engine/core/updates.py +398 -0
- tree_engine/core/validation.py +377 -0
- tree_engine/errors.py +104 -0
- tree_engine/exceptions.py +376 -0
- tree_engine/facade.py +4524 -0
- tree_engine/plugins/_statements.py +369 -0
- tree_engine/plugins/bsl/block_edit.py +449 -0
- tree_engine/plugins/bsl/blocks.py +127 -0
- tree_engine/plugins/bsl/checker.py +297 -0
- tree_engine/plugins/bsl/dialects.py +303 -0
- tree_engine/plugins/bsl/generator.py +481 -0
- tree_engine/plugins/bsl/import_map.py +995 -0
- tree_engine/plugins/bsl/plugin.py +452 -0
- tree_engine/plugins/contract.py +355 -0
- tree_engine/plugins/cpp/import_map.py +505 -0
- tree_engine/plugins/cpp/languages.py +99 -0
- tree_engine/plugins/cpp/plugin.py +501 -0
- tree_engine/plugins/csv_format.py +676 -0
- tree_engine/plugins/detachable.py +156 -0
- tree_engine/plugins/fallback.py +421 -0
- tree_engine/plugins/ini_format.py +330 -0
- tree_engine/plugins/json_format.py +813 -0
- tree_engine/plugins/json_pointer.py +203 -0
- tree_engine/plugins/jsonl_format.py +392 -0
- tree_engine/plugins/markdown_format.py +748 -0
- tree_engine/plugins/onec_query_format.py +61 -0
- tree_engine/plugins/parse_position.py +54 -0
- tree_engine/plugins/plain_text.py +1543 -0
- tree_engine/plugins/python/export_map.py +306 -0
- tree_engine/plugins/python/import_map.py +429 -0
- tree_engine/plugins/python/plugin.py +1710 -0
- tree_engine/plugins/registry.py +497 -0
- tree_engine/plugins/scan.py +87 -0
- tree_engine/plugins/selection.py +228 -0
- tree_engine/plugins/sql_format.py +61 -0
- tree_engine/plugins/toml_format.py +1072 -0
- tree_engine/plugins/xml_format.py +911 -0
- tree_engine/plugins/yaml/builder.py +49 -0
- tree_engine/plugins/yaml/emitter.py +225 -0
- tree_engine/plugins/yaml/flow.py +227 -0
- tree_engine/plugins/yaml/plugin.py +458 -0
- tree_engine/plugins/yaml/ranges.py +52 -0
- tree_engine/plugins/yaml/reader.py +359 -0
- tree_engine/plugins/yaml/scanner.py +298 -0
- tree_engine/query/adapter.py +283 -0
- tree_engine/query/engine.py +853 -0
- tree_engine/query/inspection.py +498 -0
- tree_engine/query/outline.py +288 -0
- tree_engine/query/predicates.py +263 -0
- tree_engine/query/rendered_lines.py +46 -0
- tree_engine/query/results.py +206 -0
- tree_engine/query/selector.py +400 -0
- tree_engine/query/xml_query.py +747 -0
- tree_engine/storage/codec.py +400 -0
- tree_engine/storage/document_bridge.py +579 -0
- tree_engine/storage/file_txn.py +459 -0
- tree_engine/storage/history.py +106 -0
- tree_engine/storage/lifecycle.py +622 -0
- tree_engine/storage/schema.py +403 -0
- tree_engine/storage/session_guard.py +398 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""Lossless 1C query language format plugin for the tree engine (``format_id='onec_query'``, extension ``.q1c``).
|
|
2
|
+
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
|
|
6
|
+
Model (decision D-CD): a ``onec_query:document`` root with one ``onec_query:statement`` child per query of a
|
|
7
|
+
query package. A ``;`` ends a statement unless a ``//`` comment or a ``"..."`` string (a doubled quote is an
|
|
8
|
+
escaped quote; a string may continue over lines) protects it. ``--`` and ``/* */`` are NOT comments in this
|
|
9
|
+
language, and there is no dollar quoting. The model and the byte-exact round trip are in
|
|
10
|
+
:mod:`tree_engine.plugins._statements`. The syntax checker ``onec_query_syntax`` (code
|
|
11
|
+
``SYNTAX-ONEC_QUERY``) is declared through ``checker_plugin``.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
from tree_engine.plugins._statements import Dialect, StatementFormatPlugin
|
|
19
|
+
from tree_engine.plugins.contract import FormatPluginMetadata
|
|
20
|
+
|
|
21
|
+
__all__ = ["FORMAT_ID", "ONEC_QUERY_DIALECT", "OnecQueryFormatPlugin", "ONEC_QUERY_FORMAT_PLUGIN"]
|
|
22
|
+
|
|
23
|
+
FORMAT_ID = "onec_query"
|
|
24
|
+
ONEC_QUERY_DIALECT = Dialect(
|
|
25
|
+
line_comment="//",
|
|
26
|
+
block_comment=False,
|
|
27
|
+
quotes=(('"', "string literal"),),
|
|
28
|
+
dollar_quote=False,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class OnecQueryFormatPlugin(StatementFormatPlugin):
|
|
33
|
+
"""Registered lossless ``format_id='onec_query'`` plugin."""
|
|
34
|
+
|
|
35
|
+
FORMAT_ID = FORMAT_ID
|
|
36
|
+
DIALECT = ONEC_QUERY_DIALECT
|
|
37
|
+
_META = FormatPluginMetadata(
|
|
38
|
+
format_id=FORMAT_ID,
|
|
39
|
+
aliases=(),
|
|
40
|
+
file_extensions=("q1c",),
|
|
41
|
+
plugin_version="1.0.0",
|
|
42
|
+
contract_version="1.0.0",
|
|
43
|
+
capabilities={
|
|
44
|
+
"ca_save_supported": True,
|
|
45
|
+
# A statement list has no query language: the editor answers a search with UNKNOWN_FORMAT (Q-SQL-6 b).
|
|
46
|
+
"search_supported": False,
|
|
47
|
+
"semantic_role_mapping": True,
|
|
48
|
+
"byte_identical_round_trip": True,
|
|
49
|
+
"navigable": True,
|
|
50
|
+
"editable": True,
|
|
51
|
+
},
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
@staticmethod
|
|
55
|
+
def checker_plugin() -> Any:
|
|
56
|
+
from tree_engine.checks.builtin.format_syntax import OnecQuerySyntaxChecker
|
|
57
|
+
|
|
58
|
+
return OnecQuerySyntaxChecker()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
ONEC_QUERY_FORMAT_PLUGIN = OnecQueryFormatPlugin()
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Shared helpers that turn a parse-failure offset into the 1-based ``line`` / ``column`` details.
|
|
2
|
+
|
|
3
|
+
Every format plugin that raises ``FormatContentParseFailed`` for malformed content carries the
|
|
4
|
+
mapping ``{"line": int >= 1, "column": int >= 1, "message": str}`` in the exception ``details``
|
|
5
|
+
(TODO 15a86bcb, decision D-BM). The helpers here are the only place that arithmetic lives.
|
|
6
|
+
|
|
7
|
+
Author: Vasiliy Zdanovskiy
|
|
8
|
+
email: vasilyvz@gmail.com
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import re
|
|
14
|
+
from typing import Any, Dict, Optional
|
|
15
|
+
|
|
16
|
+
__all__ = ["line_column", "position_details", "offset_in_message", "utf8_failure_details"]
|
|
17
|
+
|
|
18
|
+
_POSITION_RE = re.compile(r"position (\d+)")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def line_column(text: str, offset: int) -> "tuple[int, int]":
|
|
22
|
+
"""Return the 1-based ``(line, column)`` of character ``offset`` in ``text``.
|
|
23
|
+
|
|
24
|
+
``offset`` is clamped to ``[0, len(text)]``; a position past the last line break is column 1 of the
|
|
25
|
+
next line, which is how an end-of-input error is reported.
|
|
26
|
+
"""
|
|
27
|
+
offset = max(0, min(int(offset), len(text)))
|
|
28
|
+
line = text.count("\n", 0, offset) + 1
|
|
29
|
+
column = offset - (text.rfind("\n", 0, offset) + 1) + 1
|
|
30
|
+
return line, column
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def position_details(text: str, offset: int, message: str) -> Dict[str, Any]:
|
|
34
|
+
"""Details mapping for a failure at character ``offset`` of ``text``."""
|
|
35
|
+
line, column = line_column(text, offset)
|
|
36
|
+
return {"line": line, "column": column, "message": str(message) or "parse error"}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def offset_in_message(message: str) -> Optional[int]:
|
|
40
|
+
"""The ``position N`` offset quoted in ``message``, or ``None``."""
|
|
41
|
+
found = _POSITION_RE.search(message)
|
|
42
|
+
return int(found.group(1)) if found else None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def utf8_failure_details(data: bytes, exc: UnicodeDecodeError) -> Dict[str, Any]:
|
|
46
|
+
"""Details mapping (1-based ``line`` / ``column``, ``message``) of an undecodable UTF-8 byte string.
|
|
47
|
+
|
|
48
|
+
The position is that of the first bad byte; the column counts characters, not bytes, within its line.
|
|
49
|
+
"""
|
|
50
|
+
start = max(0, min(int(exc.start), len(data)))
|
|
51
|
+
line = data.count(b"\n", 0, start) + 1
|
|
52
|
+
line_start = data.rfind(b"\n", 0, start) + 1
|
|
53
|
+
column = len(data[line_start:start].decode("utf-8", errors="replace")) + 1
|
|
54
|
+
return {"line": line, "column": column, "message": f"invalid UTF-8: {exc.reason} at byte {start}"}
|