From 230406fc9685978f4496c4379ca92819d1cb53d6 Mon Sep 17 00:00:00 2001 From: Ilja Postnovs Date: Thu, 31 Aug 2023 23:39:15 +0300 Subject: [PATCH 1/2] fix formatter --- CHANGELOG.md | 4 ++++ package.json | 2 +- src/classes/utils/XMLFormatter.ts | 6 +++++- .../fragmenttest/view/fragments/FormatterTest.view.xml | 1 + src/test/js/suite/data/XMLFormatterData.json | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afa76472..cb448bce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.13.2 (31-08-2023) + +- XML Formatter doesn't replace `"` with `'` in attribute value anymore for such cases as `\{type: 'sap.ui.model.type.Date', formatOptions: \{UTC: true\}, constraints: \{\} \}` + ## 1.13.1 (13-08-2023) - [UI5 Parser](https://github.com/iljapostnovs/ui5plugin-parser) updated to v1.6.1 diff --git a/package.json b/package.json index 1d5101ca..3d6aed7a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "ui5plugin", "displayName": "SAPUI5 Extension", "description": "Extension for working with UI5 projects", - "version": "1.13.1", + "version": "1.13.2", "publisher": "iljapostnovs", "license": "Apache-2.0", "author": "Ilja Postnovs ", diff --git a/src/classes/utils/XMLFormatter.ts b/src/classes/utils/XMLFormatter.ts index 66743d67..b83e9e19 100644 --- a/src/classes/utils/XMLFormatter.ts +++ b/src/classes/utils/XMLFormatter.ts @@ -183,7 +183,11 @@ export class XMLFormatter extends ParserBearer { } formattedValue = `"${formattedValue}"`; } else { - formattedValue = `'${attributeValue}'`; + if (attributeValue.includes("'")) { + formattedValue = `"${attributeValue}"`; + } else { + formattedValue = `'${attributeValue}'`; + } } return formattedValue; diff --git a/src/test/js/project/extensionapp/fragmenttest/view/fragments/FormatterTest.view.xml b/src/test/js/project/extensionapp/fragmenttest/view/fragments/FormatterTest.view.xml index 7edf9587..3cc183d3 100644 --- a/src/test/js/project/extensionapp/fragmenttest/view/fragments/FormatterTest.view.xml +++ b/src/test/js/project/extensionapp/fragmenttest/view/fragments/FormatterTest.view.xml @@ -2,6 +2,7 @@ xmlns="sap.m" xmlns:c="sap.ui.core" > +