fix(skd-edit): add-total identity expression для не-аггрегатных функций

Раньше "DataPath: X" всегда заворачивалось в X(DataPath). Если X не
аггрегатная функция (например, имя другого ресурса или сам DataPath),
получалось некорректное выражение типа Проверка(Проверка).

Зеркалю логику из skd-compile: whitelist аггрегатных функций
(Сумма, Количество, Минимум, Максимум, Среднее + EN-варианты).
Для остального — identity (использовать funcPart как есть).

Сообщение [OK] теперь показывает фактически записанный expression.

Регресс: 32/32 PS, 32/32 PY, 32/32 платформенный verify.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-05-15 16:16:27 +03:00
co-authored by Claude Opus 4.7
parent f0f1e88aaa
commit 28a2a34c84
4 changed files with 93 additions and 4 deletions
+13 -2
View File
@@ -1,4 +1,4 @@
# skd-edit v1.16 — Atomic 1C DCS editor
# skd-edit v1.17 — Atomic 1C DCS editor
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
param(
[Parameter(Mandatory)]
@@ -238,14 +238,25 @@ function Read-FieldProperties($fieldEl) {
function Parse-TotalShorthand {
param([string]$s)
# "DataPath: Func" or "DataPath: Func(expr)" or "DataPath: ИмяРесурса" (identity)
$parts = $s -split ':', 2
$dataPath = $parts[0].Trim()
$funcPart = $parts[1].Trim()
# Known DCS aggregate functions (ru + en)
$aggFuncs = @('Сумма','Количество','Минимум','Максимум','Среднее',
'Sum','Count','Min','Max','Avg',
'Minimum','Maximum','Average')
if ($funcPart -match '^\w+\(') {
# Already has expression form: Func(expr)
return @{ dataPath = $dataPath; expression = $funcPart }
} else {
} elseif ($funcPart -in $aggFuncs) {
# Short: Func → Func(DataPath)
return @{ dataPath = $dataPath; expression = "$funcPart($dataPath)" }
} else {
# Identity or custom expression — use as-is
return @{ dataPath = $dataPath; expression = $funcPart }
}
}
+10 -2
View File
@@ -1,4 +1,4 @@
# skd-edit v1.16 — Atomic 1C DCS editor (Python port)
# skd-edit v1.17 — Atomic 1C DCS editor (Python port)
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
import argparse
import os
@@ -250,13 +250,21 @@ def read_field_properties(field_el):
def parse_total_shorthand(s):
# "DataPath: Func" or "DataPath: Func(expr)" or "DataPath: ИмяРесурса" (identity)
parts = s.split(":", 1)
data_path = parts[0].strip()
func_part = parts[1].strip()
agg_funcs = {'Сумма', 'Количество', 'Минимум', 'Максимум', 'Среднее',
'Sum', 'Count', 'Min', 'Max', 'Avg',
'Minimum', 'Maximum', 'Average'}
if re.match(r'^\w+\(', func_part):
return {"dataPath": data_path, "expression": func_part}
else:
elif func_part in agg_funcs:
return {"dataPath": data_path, "expression": f"{func_part}({data_path})"}
else:
return {"dataPath": data_path, "expression": func_part}
def parse_calc_shorthand(s):