Model 1C modules as object parts
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-17 18:43:43 +03:00
parent 1ad103b6dc
commit 35dd134ebc
7 changed files with 298 additions and 32 deletions
@@ -1095,9 +1095,15 @@ def _attach_bsl_modules(root: Path, normalized: NormalizedProject) -> None:
"original_hash": source.original_hash,
"source_text": source.text,
"module_role": role,
"owner_qualified_name": owner.qualified_name,
"owner_kind": owner.object_kind,
"object_part": _module_object_part(role, form_name),
}
if form_name:
attributes["form_name"] = form_name
form = _find_owner_form(owner, form_name)
if form is not None:
attributes["form_qualified_name"] = form.qualified_name
owner.modules.append(
Module(
name=source_file.stem,
@@ -1189,6 +1195,29 @@ def _module_qualified_name(owner: MetadataObject, role: str, form_name: str, mod
return f"{owner.qualified_name}.{role_suffix}"
def _module_object_part(role: str, form_name: str = "") -> str:
return {
"OBJECT_MODULE": "object.module",
"MANAGER_MODULE": "object.manager",
"RECORD_SET_MODULE": "object.record_set",
"FORM_MODULE": f"form.{form_name}.module" if form_name else "form.module",
"MODULE": "module",
}.get(role, "module")
def _find_owner_form(owner: MetadataObject, form_name: str) -> Form | None:
normalized = form_name.casefold()
return next(
(
form
for form in owner.forms
if form.name.casefold() == normalized
or str(form.qualified_name or "").casefold().endswith(f".{normalized}")
),
None,
)
def _form_name_for_module(root: Path, source_file: Path) -> str:
parts = list(_relative_path(source_file, root).parts)
normalized_parts = [_normalize_path_part(part) for part in parts]
@@ -354,7 +354,7 @@ def index_project(path: str | Path, *, project_id: str | None = None, structure_
}:
parent_by_prefix[node.qualified_name] = node
edges.extend(_link_metadata_to_modules(root, module_nodes, metadata_nodes))
edges.extend(_link_metadata_to_modules(root, module_nodes, metadata_nodes, form_nodes))
edges.extend(_link_role_rights(nodes, role_rights))
edges.extend(_link_scheduled_jobs_to_routines(scheduled_job_nodes, routine_by_name))
edges.extend(_link_commands_to_handlers(command_nodes, routine_by_name))
@@ -1025,6 +1025,7 @@ def _link_metadata_to_modules(
root: Path,
module_nodes: dict[str, SemanticNode],
metadata_nodes: list[SemanticNode],
form_nodes: list[SemanticNode],
) -> list[SemanticEdge]:
if not metadata_nodes:
return []
@@ -1034,6 +1035,7 @@ def _link_metadata_to_modules(
(node.kind, _normalize_lookup_key(node.name)): node
for node in metadata_nodes
}
forms_by_qualified = {_normalize_lookup_key(node.qualified_name): node for node in form_nodes}
edges: list[SemanticEdge] = []
for source_path, module in module_nodes.items():
@@ -1042,6 +1044,26 @@ def _link_metadata_to_modules(
if owner is None:
continue
line = module.source_ref.line_start or 1
module_role = _module_role(source_file)
form_name = _form_name_for_module(root, source_file)
object_part = _module_object_part(module_role, form_name)
module.attributes.update(
{
"owner_lineage_id": owner.lineage_id,
"owner_qualified_name": owner.qualified_name,
"owner_kind": owner.kind.value,
"object_part": object_part,
"module_role": module_role,
}
)
if form_name:
module.attributes["form_name"] = form_name
edge_attributes = {
"link_type": "METADATA_MODULE",
"module_role": module_role,
"object_part": object_part,
"form_name": form_name,
}
edges.append(
_edge(
EdgeKind.CONTAINS,
@@ -1049,16 +1071,61 @@ def _link_metadata_to_modules(
module,
source_path,
line,
{
"link_type": "METADATA_MODULE",
"module_role": _module_role(source_file),
"form_name": _form_name_for_module(root, source_file),
},
edge_attributes,
)
)
if module_role == "FORM_MODULE" and form_name:
form_node = _find_form_node_for_module(owner, form_name, forms_by_qualified)
if form_node is not None:
module.attributes["form_lineage_id"] = form_node.lineage_id
module.attributes["form_qualified_name"] = form_node.qualified_name
edges.append(
_edge(
EdgeKind.CONTAINS,
form_node,
module,
source_path,
line,
{**edge_attributes, "link_type": "FORM_MODULE"},
)
)
return edges
def _find_form_node_for_module(
owner: SemanticNode,
form_name: str,
forms_by_qualified: dict[str, SemanticNode],
) -> SemanticNode | None:
candidates = [
f"{owner.qualified_name}.{form_name}",
f"{owner.qualified_name}.Форма.{form_name}",
]
for candidate in candidates:
form = forms_by_qualified.get(_normalize_lookup_key(candidate))
if form is not None:
return form
suffix = f".{form_name}".casefold()
return next(
(
form
for key, form in forms_by_qualified.items()
if key.endswith(suffix) and key.startswith(_normalize_lookup_key(owner.qualified_name))
),
None,
)
def _module_object_part(module_role: str, form_name: str = "") -> str:
return {
"OBJECT_MODULE": "object.module",
"MANAGER_MODULE": "object.manager",
"RECORD_SET_MODULE": "object.record_set",
"FORM_MODULE": f"form.{form_name}.module" if form_name else "form.module",
"MODULE": "module",
}.get(module_role, "module")
def _link_role_rights(nodes: list[SemanticNode], role_rights: list[dict]) -> list[SemanticEdge]:
if not role_rights:
return []
@@ -207,6 +207,7 @@ def render_html5_source(node: object | None, *, oob: bool = False) -> str:
name = "source" if node is None else getattr(node, "qualified_name", None) or getattr(node, "name", "source")
kind = "" if node is None else _enum_text(getattr(node, "kind", ""))
lineage_id = "" if node is None else str(getattr(node, "lineage_id", ""))
attributes = {} if node is None else getattr(node, "attributes", {}) or {}
source_path = "" if node is None else str(
getattr(node, "source_path", None) or getattr(getattr(node, "source_ref", None), "source_path", None) or ""
)
@@ -218,30 +219,68 @@ def render_html5_source(node: object | None, *, oob: bool = False) -> str:
line_count = len(source_text.splitlines()) or 1
source_size = len(source_text)
oob_attr = ' hx-swap-oob="outerHTML"' if oob else ""
owner_name = str(attributes.get("owner_qualified_name") or "")
owner_kind = str(attributes.get("owner_kind") or "")
object_part = str(attributes.get("object_part") or attributes.get("module_role") or "")
form_name = str(attributes.get("form_name") or "")
cache_attrs = (
f'data-html5-object-cache="warm" data-html5-owner="{escape(owner_name)}" '
f'data-html5-object-part="{escape(object_part)}"'
if owner_name
else 'data-html5-object-cache="cold"'
)
return f"""
<article
class="source-panel"
data-html5-source
data-html5-source-name="{escape(str(name))}"
data-html5-lineage-id="{escape(lineage_id)}"
{cache_attrs}
{oob_attr}
>
<header class="source-head">
<div>
<strong>{escape(str(name))}</strong>
<small>{escape(kind or "source")}</small>
<small>{escape(_source_kind_label(kind or "source", owner_name, object_part, form_name))}</small>
</div>
<dl>
{_metric("Lines", line_count)}
{_metric("Location", location)}
</dl>
</header>
{_source_object_cache_summary(owner_name, owner_kind, object_part, form_name)}
{_source_summary(kind or "source", line_count, source_size, location)}
<pre class="code">{escape(source_text)}</pre>
</article>
"""
def _source_kind_label(kind: str, owner_name: str, object_part: str, form_name: str) -> str:
if not owner_name:
return kind
if object_part.startswith("form."):
return f"{kind} · часть формы {form_name or 'форма'}"
if object_part == "object.manager":
return f"{kind} · менеджер объекта"
if object_part == "object.record_set":
return f"{kind} · набор записей объекта"
if object_part == "object.module":
return f"{kind} · модуль объекта"
return f"{kind} · часть объекта"
def _source_object_cache_summary(owner_name: str, owner_kind: str, object_part: str, form_name: str) -> str:
if not owner_name:
return ""
form_text = f" · форма {form_name}" if form_name else ""
return f"""
<p class="object-cache" data-html5-object-cache-summary>
Открыт программный текст части объекта 1С: {escape(owner_name)} · {escape(owner_kind or "OBJECT")} · {escape(object_part)}{escape(form_text)}.
Объектный контекст подгружен сервером в cache-warm режим для быстрых переходов по формам, модулям и обработчикам.
</p>
"""
def _source_summary(kind: str, line_count: int, source_size: int, location: str) -> str:
return f"""
<p class="source-summary" data-html5-source-summary>
@@ -18,6 +18,7 @@ _HTML5_OBJECT_CONTEXT_KINDS = {
NodeKind.ENUM.value,
NodeKind.REPORT.value,
NodeKind.DATA_PROCESSOR.value,
NodeKind.FORM.value,
NodeKind.CHART_OF_CHARACTERISTIC_TYPES.value,
NodeKind.CHART_OF_ACCOUNTS.value,
NodeKind.CHART_OF_CALCULATION_TYPES.value,
@@ -512,17 +513,7 @@ def _object_action_links(
quoted_project = quote(project_id)
quoted_object = quote(object_name, safe="")
lineage = str(lineage_id or "")
first_module = next(iter(modules), None)
module_lineage = str(getattr(first_module, "lineage_id", "") or "")
source_link = (
f'<a class="button" href="/html5/projects/{quoted_project}/source/{quote(module_lineage, safe="")}" '
'hx-get="/html5/projects/{project}/source/{module}" hx-target="[data-html5-source]" hx-swap="outerHTML">Source</a>'.format(
project=quoted_project,
module=quote(module_lineage, safe=""),
)
if module_lineage
else ""
)
module_links = "".join(_module_action_link(quoted_project, module) for module in _sorted_object_modules(modules))
symbol_link = (
f'<a class="button" href="/html5/projects/{quoted_project}/symbols/{quote(lineage, safe="")}/detail" '
'hx-get="/html5/projects/{project}/symbols/{lineage}/detail" hx-target="[data-html5-symbol-detail]" hx-swap="outerHTML">Symbol</a>'.format(
@@ -576,12 +567,68 @@ def _object_action_links(
hx-target="[data-html5-flowchart]"
hx-swap="outerHTML"
>Flowchart</a>
{source_link}
{module_links}
{symbol_link}
</nav>
"""
def _sorted_object_modules(modules: Iterable[object]) -> list[object]:
priority = {
"OBJECT_MODULE": 0,
"MANAGER_MODULE": 1,
"RECORD_SET_MODULE": 2,
"FORM_MODULE": 3,
"MODULE": 9,
}
return sorted(
list(modules),
key=lambda module: (
priority.get(_module_role(module), 8),
str((getattr(module, "attributes", {}) or {}).get("form_name") or ""),
str(getattr(module, "qualified_name", "") or getattr(module, "name", "")),
),
)
def _module_action_link(quoted_project: str, module: object) -> str:
lineage = str(getattr(module, "lineage_id", "") or "")
if not lineage:
return ""
quoted_lineage = quote(lineage, safe="")
label = _module_action_label(module)
return f"""
<a
class="button"
href="/html5/projects/{quoted_project}/source/{quoted_lineage}"
hx-get="/html5/projects/{quoted_project}/source/{quoted_lineage}"
hx-target="[data-html5-source]"
hx-swap="outerHTML"
data-html5-module-action="{escape(_module_role(module))}"
>{escape(label)}</a>
"""
def _module_action_label(module: object) -> str:
attributes = getattr(module, "attributes", {}) or {}
role = _module_role(module)
if role == "OBJECT_MODULE":
return "Модуль объекта"
if role == "MANAGER_MODULE":
return "Модуль менеджера"
if role == "RECORD_SET_MODULE":
return "Модуль набора"
if role == "FORM_MODULE":
form_name = str(attributes.get("form_name") or "")
return f"Модуль формы {form_name}" if form_name else "Модуль формы"
return str(getattr(module, "name", None) or "Модуль")
def _module_role(module: object) -> str:
attributes = getattr(module, "attributes", {}) or {}
return str(attributes.get("module_role") or attributes.get("role") or getattr(module, "module_role", "") or "MODULE")
def _tabular_section_item(section: object) -> str:
tabular_section = getattr(section, "tabular_section", None)
columns = getattr(section, "columns", []) or []
+56 -10
View File
@@ -962,6 +962,11 @@ class ModuleSourceResponse(BaseModel):
name: str
qualified_name: str
module_role: str = "MODULE"
owner_qualified_name: str | None = None
owner_kind: str | None = None
object_part: str | None = None
form_name: str | None = None
form_qualified_name: str | None = None
source_path: str
source_text: str
routines_count: int = 0
@@ -1167,6 +1172,7 @@ class NamedNode(BaseModel):
kind: str
name: str
qualified_name: str
attributes: dict = Field(default_factory=dict)
class ImpactResponse(BaseModel):
@@ -5041,7 +5047,7 @@ def _metadata_child_group_children(
for edge in snapshot.edges
if edge.source_lineage == owner_id
and edge.kind in edge_kinds
and (edge.kind != EdgeKind.CONTAINS or edge.attributes.get("link_type") == "METADATA_MODULE")
and (edge.kind != EdgeKind.CONTAINS or edge.attributes.get("link_type") in {"METADATA_MODULE", "FORM_MODULE"})
]
nodes_by_id = {node.lineage_id: node for node in snapshot.nodes}
child_nodes = sorted(
@@ -5366,7 +5372,7 @@ def _flowchart_owner_index(snapshot: SirSnapshot, nodes_by_lineage: dict[str, ob
target = nodes_by_lineage.get(edge.target_lineage)
if source is None or target is None:
continue
if edge.kind == EdgeKind.CONTAINS and edge.attributes.get("link_type") == "METADATA_MODULE":
if edge.kind == EdgeKind.CONTAINS and edge.attributes.get("link_type") in {"METADATA_MODULE", "FORM_MODULE"}:
owner_by_lineage[target.lineage_id] = source
elif edge.kind in {EdgeKind.HAS_COMMAND, EdgeKind.HAS_ROLE, EdgeKind.HAS_ATTRIBUTE, EdgeKind.HAS_TABULAR_SECTION, EdgeKind.HAS_FORM, EdgeKind.HAS_ELEMENT}:
owner_by_lineage[target.lineage_id] = source
@@ -5424,13 +5430,16 @@ def _metadata_tree_path_for_node(snapshot: SirSnapshot, node_id: str) -> list[st
return ["main-configuration", "common", f"common.{common_branch}", node.lineage_id]
return ["main-configuration", f"branch.{spec.code}", node.lineage_id]
parent_edge = next((edge for edge in snapshot.edges if edge.target_lineage == node.lineage_id), None)
parent_edges = [edge for edge in snapshot.edges if edge.target_lineage == node.lineage_id]
parent_edge = next((edge for edge in parent_edges if edge.attributes.get("link_type") == "FORM_MODULE"), None)
if parent_edge is None:
parent_edge = next(iter(parent_edges), None)
if parent_edge is None:
return [node.lineage_id]
owner_node = _find_snapshot_node(snapshot, parent_edge.source_lineage)
if owner_node is None:
return [node.lineage_id]
group_name = _metadata_group_name_for_edge(parent_edge.kind)
group_name = _metadata_group_name_for_edge(parent_edge)
return [*_metadata_tree_path_for_node(snapshot, owner_node.lineage_id), f"{owner_node.lineage_id}.{group_name}", node.lineage_id]
@@ -5539,7 +5548,10 @@ def _common_branch_label_for_spec(spec_code: str) -> str | None:
return None
def _metadata_group_name_for_edge(edge_kind: EdgeKind) -> str:
def _metadata_group_name_for_edge(edge) -> str:
edge_kind = getattr(edge, "kind", edge)
if edge_kind == EdgeKind.CONTAINS and getattr(edge, "attributes", {}).get("link_type") == "FORM_MODULE":
return "Модуль формы"
return {
EdgeKind.HAS_ATTRIBUTE: "Реквизиты",
EdgeKind.HAS_TABULAR_SECTION: "Табличные части",
@@ -5591,7 +5603,7 @@ def _metadata_child_group_count(snapshot: SirSnapshot, owner_id: str, group_name
for edge in snapshot.edges
if edge.source_lineage == owner_id
and edge.kind in edge_kinds
and (edge.kind != EdgeKind.CONTAINS or edge.attributes.get("link_type") == "METADATA_MODULE")
and (edge.kind != EdgeKind.CONTAINS or edge.attributes.get("link_type") in {"METADATA_MODULE", "FORM_MODULE"})
)
@@ -5614,7 +5626,7 @@ def _metadata_child_count_index(snapshot: SirSnapshot, owner_ids: list[str]) ->
result: dict[str, Counter[EdgeKind]] = {owner_id: Counter() for owner_id in owner_set}
for edge in snapshot.edges:
if edge.source_lineage in owner_set and (
edge.kind != EdgeKind.CONTAINS or edge.attributes.get("link_type") == "METADATA_MODULE"
edge.kind != EdgeKind.CONTAINS or edge.attributes.get("link_type") in {"METADATA_MODULE", "FORM_MODULE"}
):
result[edge.source_lineage][edge.kind] += 1
return result
@@ -9017,10 +9029,16 @@ def _normalized_module_source_response(module, owner) -> ModuleSourceResponse:
attributes = module.attributes or {}
source_text = str(attributes.get("source_text", ""))
routines = _normalized_module_routines(source_text)
module_role = str(module.module_kind or attributes.get("module_role") or "MODULE")
return ModuleSourceResponse(
name=module.name,
qualified_name=module.qualified_name or module.name,
module_role=str(module.module_kind or attributes.get("module_role") or "MODULE"),
module_role=module_role,
owner_qualified_name=str(attributes.get("owner_qualified_name") or getattr(owner, "qualified_name", "") or "") or None,
owner_kind=str(attributes.get("owner_kind") or getattr(owner, "object_kind", "") or "") or None,
object_part=str(attributes.get("object_part") or _module_object_part_for_response(module_role, str(attributes.get("form_name") or ""))),
form_name=str(attributes.get("form_name") or "") or None,
form_qualified_name=str(attributes.get("form_qualified_name") or "") or None,
source_path=module.source_path or "",
source_text=source_text,
routines_count=len(routines),
@@ -9028,6 +9046,16 @@ def _normalized_module_source_response(module, owner) -> ModuleSourceResponse:
)
def _module_object_part_for_response(module_role: str, form_name: str = "") -> str:
return {
"OBJECT_MODULE": "object.module",
"MANAGER_MODULE": "object.manager",
"RECORD_SET_MODULE": "object.record_set",
"FORM_MODULE": f"form.{form_name}.module" if form_name else "form.module",
"MODULE": "module",
}.get(module_role, "module")
def _normalized_module_routines(source_text: str) -> list[ModuleRoutineResponse]:
if not source_text:
return []
@@ -9150,11 +9178,17 @@ def _module_sources_for_object(snapshot: SirSnapshot, qualified_name: str) -> li
if module is None or module.kind != NodeKind.MODULE:
continue
routines = _module_routines(snapshot, module.lineage_id, nodes_by_lineage)
module_role = str(edge.attributes.get("module_role") or module.attributes.get("module_role") or "MODULE")
modules.append(
ModuleSourceResponse(
name=module.name,
qualified_name=module.qualified_name,
module_role=str(edge.attributes.get("module_role", "MODULE")),
module_role=module_role,
owner_qualified_name=str(module.attributes.get("owner_qualified_name") or owner.qualified_name or "") or None,
owner_kind=str(module.attributes.get("owner_kind") or owner.kind.value or "") or None,
object_part=str(edge.attributes.get("object_part") or module.attributes.get("object_part") or _module_object_part_for_response(module_role, str(module.attributes.get("form_name") or ""))),
form_name=str(edge.attributes.get("form_name") or module.attributes.get("form_name") or "") or None,
form_qualified_name=str(module.attributes.get("form_qualified_name") or "") or None,
source_path=module.source_ref.source_path,
source_text=str(module.attributes.get("source_text", "")),
routines_count=len(routines),
@@ -9180,11 +9214,22 @@ def _module_source_response(
None,
)
routines = _module_routines(snapshot, module.lineage_id, nodes_by_lineage)
owner = nodes_by_lineage.get(owner_edge.source_lineage) if owner_edge else None
module_role = str((owner_edge.attributes.get("module_role") if owner_edge else None) or module.attributes.get("module_role") or "MODULE")
return [
ModuleSourceResponse(
name=module.name,
qualified_name=module.qualified_name,
module_role=str(owner_edge.attributes.get("module_role", "MODULE")) if owner_edge else "MODULE",
module_role=module_role,
owner_qualified_name=str(module.attributes.get("owner_qualified_name") or getattr(owner, "qualified_name", "") or "") or None,
owner_kind=str(module.attributes.get("owner_kind") or getattr(getattr(owner, "kind", None), "value", "") or "") or None,
object_part=str(
(owner_edge.attributes.get("object_part") if owner_edge else None)
or module.attributes.get("object_part")
or _module_object_part_for_response(module_role, str(module.attributes.get("form_name") or ""))
),
form_name=str((owner_edge.attributes.get("form_name") if owner_edge else None) or module.attributes.get("form_name") or "") or None,
form_qualified_name=str(module.attributes.get("form_qualified_name") or "") or None,
source_path=module.source_ref.source_path,
source_text=str(module.attributes.get("source_text", "")),
routines_count=len(routines),
@@ -10676,4 +10721,5 @@ def _named_node(node) -> NamedNode:
kind=node.kind.value,
name=node.name,
qualified_name=node.qualified_name,
attributes=getattr(node, "attributes", {}) or {},
)
@@ -4,7 +4,7 @@
.band,.panel,.editor{border:1px solid var(--line);background:var(--card)}.band{max-width:1180px;margin:auto;padding:18px}.section-title,.topbar,.editor-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.button,button{display:inline-flex;align-items:center;justify-content:center;height:32px;border:1px solid var(--line);background:#fff;padding:0 12px;text-decoration:none;font-weight:700;cursor:pointer}table{width:100%;border-collapse:collapse}th,td{border-top:1px solid var(--line);padding:12px;text-align:left}td small{display:block;color:var(--muted)}td .button,td form{margin-right:6px}.delete-project{display:inline-flex;gap:4px;vertical-align:middle}.delete-project input{height:32px;width:120px;border:1px solid var(--line);padding:0 6px}
.workspace{min-height:100vh;padding-bottom:34px}.topbar{position:sticky;top:0;z-index:2;height:54px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.94);padding:0 14px}.brand{font-weight:900;text-decoration:none;color:var(--brand)}.project-nav{display:flex;gap:6px;overflow:auto;flex:1}.project-link{white-space:nowrap;text-decoration:none;border:1px solid var(--line);padding:6px 10px;background:#fff}.project-link.active{background:var(--brand);border-color:var(--brand);color:#fff}
.layout{display:grid;grid-template-columns:280px minmax(0,1fr)320px;height:calc(100vh - 88px)}.panel{overflow:auto}.panel-title{padding:12px;border-bottom:1px solid var(--line);font-size:12px;font-weight:900;text-transform:uppercase;color:var(--muted)}.tree-item{display:block;padding:10px 12px;border-bottom:1px solid var(--line);text-decoration:none}.tree-item span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tree-item small{color:var(--muted)}
.editor{min-width:0;overflow:hidden;border-top:0;border-bottom:0}.editor-head{height:72px;border-bottom:1px solid var(--line);padding:0 14px}.editor-head h1{margin:0;font-size:18px}.search{display:flex;gap:6px}.search input{height:32px;width:260px;border:1px solid var(--line);padding:0 10px}.source-panel{height:calc(100% - 72px);display:grid;grid-template-rows:auto auto minmax(0,1fr);overflow:hidden}.source-head{display:flex;justify-content:space-between;gap:12px;align-items:center;min-height:54px;padding:10px 14px;border-bottom:1px solid var(--line);background:#fff}.source-head strong,.source-head small{display:block}.source-head small{color:var(--muted)}.source-head dl{display:flex;gap:12px;margin:0}.source-head div div{padding:0}.source-head dt{font-size:11px;color:var(--muted)}.source-head dd{margin:0;font-weight:800}.source-summary{margin:0;padding:8px 14px;border-bottom:1px solid var(--line);background:#fffdf8;color:var(--muted);font-size:12px;font-weight:800}.code{height:100%;margin:0;overflow:auto;padding:16px;background:#fbfaf7;font:13px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap}
.editor{min-width:0;overflow:hidden;border-top:0;border-bottom:0}.editor-head{height:72px;border-bottom:1px solid var(--line);padding:0 14px}.editor-head h1{margin:0;font-size:18px}.search{display:flex;gap:6px}.search input{height:32px;width:260px;border:1px solid var(--line);padding:0 10px}.source-panel{height:calc(100% - 72px);display:grid;grid-template-rows:auto auto auto minmax(0,1fr);overflow:hidden}.source-head{display:flex;justify-content:space-between;gap:12px;align-items:center;min-height:54px;padding:10px 14px;border-bottom:1px solid var(--line);background:#fff}.source-head strong,.source-head small{display:block}.source-head small{color:var(--muted)}.source-head dl{display:flex;gap:12px;margin:0}.source-head div div{padding:0}.source-head dt{font-size:11px;color:var(--muted)}.source-head dd{margin:0;font-weight:800}.source-summary,.object-cache{margin:0;padding:8px 14px;border-bottom:1px solid var(--line);background:#fffdf8;color:var(--muted);font-size:12px;font-weight:800;line-height:1.45}.object-cache{background:#f8fbff}.code{height:100%;margin:0;overflow:auto;padding:16px;background:#fbfaf7;font:13px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap}
.metrics{display:grid;grid-template-columns:1fr 1fr;margin:0}.metrics div{padding:12px;border-bottom:1px solid var(--line)}.metrics dt{color:var(--muted);font-size:12px}.metrics dd{margin:2px 0 0;font-size:22px;font-weight:800}.compact{list-style:none;margin:0;padding:0}.compact li{display:flex;justify-content:space-between;padding:8px 12px;border-bottom:1px solid var(--line)}.object-actions{display:flex;gap:6px;flex-wrap:wrap;padding:10px 12px;border-bottom:1px solid var(--line);background:#fbfcfe}.object-actions .button{height:28px;padding:0 9px;font-size:12px}.object-actions .button[data-html5-object-action-active="true"],.object-actions .button[aria-current="page"]{background:var(--brand);border-color:var(--brand);color:#fff}.object-breadcrumb{display:flex;gap:6px;flex-wrap:wrap;padding:9px 12px;border-bottom:1px solid var(--line);background:#fff;font-size:12px;font-weight:800;color:var(--muted)}.object-breadcrumb span:not(:last-child)::after{content:"/";margin-left:6px;color:#98a2b3}.object-breadcrumb span:last-child{color:var(--ink)}.object-summary,.symbol-summary,.review-summary,.project-summary,.object-report-summary,.authoring-summary{margin:0;padding:10px 12px;border-bottom:1px solid var(--line);background:#f8fbff;color:var(--muted);font-size:12px;font-weight:800;line-height:1.45}.symbol{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line);cursor:pointer}.symbol:hover{background:#f8fbff}.symbol span,.symbol small{color:var(--muted)}.symbol-focus,.symbol-reference,.object-focus,.object-context-item{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.symbol-focus small,.symbol-reference span,.symbol-reference small,.object-focus span,.object-context-item small{color:var(--muted)}.inline-actions{display:flex;gap:8px;flex-wrap:wrap;font-size:12px;font-weight:800}.inline-actions a{color:var(--brand);text-decoration:none}.report-grid{display:grid;grid-template-columns:1fr 1fr;margin:0}.report-grid div{padding:10px 12px;border-bottom:1px solid var(--line)}.report-grid dt{color:var(--muted);font-size:12px}.report-grid dd{margin:2px 0 0;font-size:20px;font-weight:900}.review-item,.authoring-change{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.authoring-change[hx-get]{cursor:pointer}.authoring-change[hx-get]:hover{background:#f8fbff}.review-item span,.review-item small,.authoring-change span,.authoring-change small{color:var(--muted)}.diff-item{display:grid;grid-template-columns:72px minmax(0,1fr);gap:8px;padding:8px 12px;border-bottom:1px solid var(--line)}.diff-item span{color:var(--muted);font-weight:800}.diff-item code{white-space:pre-wrap;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px}.status{position:fixed;bottom:0;left:0;right:0;display:flex;gap:18px;overflow:auto;height:34px;align-items:center;border-top:1px solid var(--line);background:#fff;padding:0 12px;color:var(--muted);font-size:12px}.empty-state{max-width:720px;margin:80px auto;background:#fff;border:1px solid var(--line);padding:28px}
.setup-layout{display:grid;grid-template-columns:340px minmax(0,1fr);gap:16px;max-width:1180px;margin:18px auto;padding:0 16px}.setup-workspace{background:#f3f6fb}.setup-card{padding:16px;border-bottom:1px solid var(--line)}.setup-card h1{margin:0;font-size:24px}.setup-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}.setup-main{min-height:620px}.settings-form{display:grid;grid-template-columns:2fr 1fr 1fr auto;gap:8px;align-items:end;padding:12px 16px;border-bottom:1px solid var(--line);background:#fff}.settings-form label{display:grid;gap:4px;font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase}.settings-form input{height:32px;border:1px solid var(--line);padding:0 8px}.saved{float:right;color:var(--ok);font-weight:900}.setup-actions-panel,.ops-filter{display:flex;gap:8px;flex-wrap:wrap;align-items:end;padding:12px 16px;border-bottom:1px solid var(--line);background:#fbfcfe}.ops-filter input{height:32px;min-width:180px;border:1px solid var(--line);padding:0 8px}.inline-form{display:flex;gap:8px;align-items:end}.inline-form label{display:grid;gap:4px;font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase}.inline-form select{height:32px;min-width:240px;border:1px solid var(--line);background:#fff;padding:0 8px}.rollback-form,.authoring-preview-form{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:12px;border-bottom:1px solid var(--line);background:#fbfcfe}.rollback-form input,.authoring-preview-form input,.authoring-preview-form textarea{min-width:0;border:1px solid var(--line);padding:0 8px}.rollback-form input,.authoring-preview-form input{height:32px}.authoring-preview-form textarea{grid-column:1/-1;min-height:88px;padding:8px;resize:vertical;font:12px/1.45 ui-monospace,SFMono-Regular,Consolas,monospace}.rollback-form button,.authoring-preview-form button{grid-column:1/-1}.setup-summary{display:grid;gap:0}.compact-lead{margin:0;padding:0 16px 16px}.setup-metrics,.ops-summary{display:grid;grid-template-columns:repeat(4,1fr);margin:0;border-top:1px solid var(--line)}.ops-summary{grid-template-columns:repeat(5,1fr);margin:12px 0}.setup-metrics div,.ops-summary div{padding:16px;border-right:1px solid var(--line);border-bottom:1px solid var(--line);background:#fff}.setup-metrics div:last-child,.ops-summary div:last-child{border-right:0}.setup-metrics dt,.ops-summary dt{font-size:12px;color:var(--muted)}.setup-metrics dd,.ops-summary dd{margin:4px 0 0;font-size:28px;font-weight:900}.status-pill{border:1px solid var(--line);padding:6px 10px;background:#eef6f1;color:var(--ok);font-weight:800}.flush{border-top:1px solid var(--line)}.padded{padding:12px 16px;margin:0}.setup-detail,.history-item,.source-card,.check-item{display:grid;gap:3px;padding:12px 16px;border-bottom:1px solid var(--line)}.setup-detail span,.setup-detail small,.history-item span,.history-item small,.source-card span,.source-card small,.check-item span,.check-item small,.check-head span,.check-head small{color:var(--muted)}.source-list,.history-list,.check-list{display:grid}.check-head{display:flex;gap:10px;align-items:center;padding:12px 16px;border-bottom:1px solid var(--line);background:#fff}.job-log{margin:0;padding:0;list-style:none}.job-log li{padding:8px 16px;border-bottom:1px solid var(--line);color:var(--muted);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px}
@media(max-width:980px){.layout{grid-template-columns:1fr;height:auto}.tree,.inspector{max-height:320px}.editor{min-height:520px}.hero{display:block}.shell{padding:16px}}
+40 -2
View File
@@ -552,6 +552,16 @@ def test_html5_object_context_fragment(tmp_path: Path):
Процедура ПроверитьКонтрагента()
КонецПроцедуры
""",
encoding="utf-8",
)
form_module = tmp_path / "Documents" / "ЗаказПокупателя" / "Forms" / "ФормаДокумента" / "Ext" / "Form" / "Module.bsl"
form_module.parent.mkdir(parents=True)
form_module.write_text(
"""
Процедура ПриОткрытии()
Сообщить("Форма готова");
КонецПроцедуры
""",
encoding="utf-8",
)
@@ -630,6 +640,10 @@ def test_html5_object_context_fragment(tmp_path: Path):
assert 'hx-target="[data-html5-flowchart]"' in context.text
assert f"/html5/projects/{project_id}/flowchart?focus=%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82.%D0%97%D0%B0%D0%BA%D0%B0%D0%B7%D0%9F%D0%BE%D0%BA%D1%83%D0%BF%D0%B0%D1%82%D0%B5%D0%BB%D1%8F&depth=1" in context.text
assert 'hx-target="[data-html5-source]"' in context.text
assert 'data-html5-module-action="OBJECT_MODULE"' in context.text
assert 'data-html5-module-action="FORM_MODULE"' in context.text
assert "Модуль объекта" in context.text
assert "Модуль формы ФормаДокумента" in context.text
assert 'hx-target="[data-html5-symbol-detail]"' in context.text
assert "Контрагент" in context.text
assert "Товары" in context.text
@@ -647,6 +661,10 @@ def test_html5_object_context_fragment(tmp_path: Path):
assert 'hx-swap-oob="outerHTML"' in context.text
assert "Карта связей · focus" in context.text
assert "data-html5-source" in context.text
assert 'data-html5-object-cache="warm"' in context.text
assert 'data-html5-owner="Документ.ЗаказПокупателя"' in context.text
assert 'data-html5-object-part="object.module"' in context.text
assert "data-html5-object-cache-summary" in context.text
assert "data-html5-source-summary" in context.text
assert "ObjectModule.bsl" in context.text
assert "Соединение = Новый HTTPСоединение" in context.text
@@ -1626,6 +1644,9 @@ def test_import_edt_full_replace_includes_object_bsl_modules_in_normalized_model
"""
<mdclass:Catalog xmlns:mdclass="http://g5.1c.ru/v8/dt/metadata/mdclass">
<name>Контрагенты</name>
<forms>
<name>ФормаЭлемента</name>
</forms>
</mdclass:Catalog>
""",
encoding="utf-8",
@@ -1641,6 +1662,15 @@ def test_import_edt_full_replace_includes_object_bsl_modules_in_normalized_model
"""
Процедура Создать() Экспорт
КонецПроцедуры
""",
encoding="utf-8",
)
form_module_dir = catalog_dir / "Forms" / "ФормаЭлемента" / "Ext" / "Form"
form_module_dir.mkdir(parents=True)
(form_module_dir / "Module.bsl").write_text(
"""
Процедура ПриОткрытии()
КонецПроцедуры
""",
encoding="utf-8",
)
@@ -1653,15 +1683,20 @@ def test_import_edt_full_replace_includes_object_bsl_modules_in_normalized_model
)
assert imported.status_code == 200
assert imported.json()["normalized_summary"]["module_count"] == 2
assert imported.json()["normalized_summary"]["module_count"] == 3
detail = client.get(
f"/projects/{project_id}/normalized/object",
params={"qualified_name": "Справочник.Контрагенты"},
)
assert detail.status_code == 200
modules = detail.json()["object"]["modules"]
assert [module["module_kind"] for module in modules] == ["MANAGER_MODULE", "OBJECT_MODULE"]
assert {module["module_kind"] for module in modules} == {"FORM_MODULE", "MANAGER_MODULE", "OBJECT_MODULE"}
assert all(module["attributes"]["source_hash"] for module in modules)
form_module = next(module for module in modules if module["module_kind"] == "FORM_MODULE")
assert form_module["attributes"]["owner_qualified_name"] == "Справочник.Контрагенты"
assert form_module["attributes"]["object_part"] == "form.ФормаЭлемента.module"
assert form_module["attributes"]["form_name"] == "ФормаЭлемента"
assert form_module["attributes"]["form_qualified_name"] == "Справочник.Контрагенты.ФормаЭлемента"
def test_import_edt_full_replace_keeps_tabular_section_columns_nested(tmp_path: Path):
@@ -2176,6 +2211,9 @@ def test_normalized_object_modules_returns_linked_bsl_source(tmp_path: Path):
assert modules.status_code == 200
payload = modules.json()
assert payload[0]["module_role"] == "OBJECT_MODULE"
assert payload[0]["owner_qualified_name"] == "Справочник.Контрагенты"
assert payload[0]["owner_kind"] == "CATALOG"
assert payload[0]["object_part"] == "object.module"
assert "ПередЗаписью" in payload[0]["source_text"]
assert payload[0]["routines_count"] == 2
assert payload[0]["routines"][0]["name"] == "ПередЗаписью"