feat(skd-edit): normalize line endings + diagnostics on patch-query not-found

patch-query теперь нормализует CRLF/CR → LF в old/new/query перед поиском,
поэтому многострочные шаблоны с любым стилем переводов строк находятся
корректно (XmlDocument декодирует text-узлы как LF).

При not-found вместо сухого сообщения выводится воронка диагностики:
  1) cross-dataset probe — «Found in dataset 'Y' instead — wrong -DataSet?»
  2) tolerant probe (collapse whitespace + NBSP) — «would match with
     whitespace normalized» + точка расхождения
  3) prefix divergence — «matched N of M chars, expected 'X' (U+...) but
     got 'Y' (U+...)» + короткий контекст

Тесты: 4 новых кейса (positive CRLF-tolerant + 3 диагностических negative).
Регрессия 45/45 PS + 45/45 Python.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Nick Shirokov
2026-05-20 19:53:24 +03:00
parent 6e14f2502e
commit ce1ba0bab1
8 changed files with 398 additions and 11 deletions
@@ -0,0 +1,21 @@
{
"name": "patch-query: CRLF в -Value матчит LF-текст в InnerText",
"preRun": [
{
"script": "skd-compile/scripts/skd-compile",
"input": {
"dataSets": [{
"name": "Основной",
"query": "ВЫБРАТЬ\n\tТ.Поле\nИЗ\n\tРегистр КАК Т",
"fields": ["Поле"]
}]
},
"args": { "-DefinitionFile": "{inputFile}", "-OutputPath": "{workDir}/Template.xml" }
}
],
"params": {
"templatePath": "Template.xml",
"operation": "patch-query",
"value": "ВЫБРАТЬ\r\n\tТ.Поле => ВЫБРАТЬ\r\n\tТ.Имя"
}
}
@@ -0,0 +1,29 @@
{
"name": "patch-query: diagnostic — NBSP в search улавливается tolerant probe",
"preRun": [
{
"script": "skd-compile/scripts/skd-compile",
"input": {
"dataSets": [
{
"name": "Основной",
"query": "ВЫБРАТЬ Т.Поле ИЗ Регистр КАК Т",
"fields": [
"Поле"
]
}
]
},
"args": {
"-DefinitionFile": "{inputFile}",
"-OutputPath": "{workDir}/Template.xml"
}
}
],
"params": {
"templatePath": "Template.xml",
"operation": "patch-query",
"value": "ВЫБРАТЬ Т.Поле => x"
},
"expectError": "whitespace normalized"
}
@@ -0,0 +1,30 @@
{
"name": "patch-query: diagnostic — подстрока в другом dataSet",
"preRun": [
{
"script": "skd-compile/scripts/skd-compile",
"input": {
"dataSets": [
{
"name": "Первый",
"query": "ВЫБРАТЬ 1 КАК Поле",
"fields": ["Поле"]
},
{
"name": "Второй",
"query": "ВЫБРАТЬ Т.УникальныйМаркер ИЗ Регистр КАК Т",
"fields": ["УникальныйМаркер: string"]
}
]
},
"args": { "-DefinitionFile": "{inputFile}", "-OutputPath": "{workDir}/Template.xml" }
}
],
"params": {
"templatePath": "Template.xml",
"operation": "patch-query",
"value": "УникальныйМаркер => Новый"
},
"args_extra": ["-DataSet", "Первый"],
"expectError": "Found in dataset 'Второй' instead"
}
@@ -0,0 +1,22 @@
{
"name": "patch-query: diagnostic — опечатка показывает точку расхождения",
"preRun": [
{
"script": "skd-compile/scripts/skd-compile",
"input": {
"dataSets": [{
"name": "Основной",
"query": "ВЫБРАТЬ Т.Наименование ИЗ Регистр КАК Т",
"fields": ["Наименование: string"]
}]
},
"args": { "-DefinitionFile": "{inputFile}", "-OutputPath": "{workDir}/Template.xml" }
}
],
"params": {
"templatePath": "Template.xml",
"operation": "patch-query",
"value": "Т.Наеменование => Т.Имя"
},
"expectError": "diverged"
}
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<DataCompositionSchema xmlns="http://v8.1c.ru/8.1/data-composition-system/schema"
xmlns:dcscom="http://v8.1c.ru/8.1/data-composition-system/common"
xmlns:dcscor="http://v8.1c.ru/8.1/data-composition-system/core"
xmlns:dcsset="http://v8.1c.ru/8.1/data-composition-system/settings"
xmlns:v8="http://v8.1c.ru/8.1/data/core"
xmlns:v8ui="http://v8.1c.ru/8.1/data/ui"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dataSource>
<name>ИсточникДанных1</name>
<dataSourceType>Local</dataSourceType>
</dataSource>
<dataSet xsi:type="DataSetQuery">
<name>Основной</name>
<field xsi:type="DataSetFieldField">
<dataPath>Поле</dataPath>
<field>Поле</field>
</field>
<dataSource>ИсточникДанных1</dataSource>
<query>ВЫБРАТЬ
Т.Имя
ИЗ
Регистр КАК Т</query>
</dataSet>
<settingsVariant>
<dcsset:name>Основной</dcsset:name>
<dcsset:presentation xsi:type="v8:LocalStringType">
<v8:item>
<v8:lang>ru</v8:lang>
<v8:content>Основной</v8:content>
</v8:item>
</dcsset:presentation>
<dcsset:settings xmlns:style="http://v8.1c.ru/8.1/data/ui/style" xmlns:sys="http://v8.1c.ru/8.1/data/ui/fonts/system" xmlns:web="http://v8.1c.ru/8.1/data/ui/colors/web" xmlns:win="http://v8.1c.ru/8.1/data/ui/colors/windows">
<dcsset:selection>
</dcsset:selection>
<dcsset:item xsi:type="dcsset:StructureItemGroup">
<dcsset:order>
<dcsset:item xsi:type="dcsset:OrderItemAuto"/>
</dcsset:order>
<dcsset:selection>
<dcsset:item xsi:type="dcsset:SelectedItemAuto"/>
</dcsset:selection>
</dcsset:item>
</dcsset:settings>
</settingsVariant>
</DataCompositionSchema>