From cf904edc8d19003d41722ea8df5860287528fcdf Mon Sep 17 00:00:00 2001 From: Ilja Postnovs Date: Sun, 8 Oct 2023 18:16:18 +0300 Subject: [PATCH 1/3] update linter --- CHANGELOG.md | 5 +++++ README.md | 3 ++- package-lock.json | 12 ++++++------ package.json | 9 +++++++-- src/classes/registrators/XMLFormatterRegistrator.ts | 13 +++++++++---- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c96e1580..ec28d521 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.14.0 (08-10-2023) + +- [UI5 Linter](https://github.com/iljapostnovs/ui5plugin-linter) updated to v1.10.0 +- `xmlFormatterSpaceAfterSelfTagEnd` preference entry for XML formatter added. [Readme](https://github.com/iljapostnovs/ui5plugin-linter/blob/master/README.md#add-space-before-a-self-closing-tag) + ## 1.13.4 (07-10-2023) - [UI5 Parser](https://github.com/iljapostnovs/ui5plugin-parser) updated to v1.6.3 diff --git a/README.md b/README.md index a65f458a..06b06817 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ VSCode extension is using [UI5 Parser](https://github.com/iljapostnovs/ui5plugin | ui5.plugin.insertManagedObjectModule | Module which will be used for automatic insertion on custom class creation | | ui5.plugin.insertControllerModule | Module which will be used for automatic insertion on custom controller creation | | ui5.plugin.xmlFormatterTagEndingNewline | Should XML Formatter put tag ending (">", "/>") in newline | +| ui5.plugin.xmlFormatterSpaceAfterSelfTagEnd | Should XML Formatter leave a space between the last attribute and the self tag end ("/>") | | ui5.plugin.umlGenerationPath | Path for file generated by `UI5: Generate UML Class diagram for whole project` command. Relative to project folder. Example: `../diagram/ClassDiagram.pu` | | ui5.plugin.XMLFileInterfacePath | Path for file generated by `UI5: (TS) Generate types for XML files (id to class mapping)` command. Relative to project folder. Example: `./types/ViewFragmentIds.d.ts` | | ui5.plugin.generateXMLFileInterfacesOnSave | Should `UI5: (TS) Generate types for XML files (id to class mapping)` command be executed on XML file save or not. Works only if `ui5.plugin.XMLFileInterfacePath` is set. Works only for TS projects. | @@ -248,7 +249,7 @@ XML Formatter is available.
![XMLFormatter](/images/XMLFormatter.gif) -> Related preference entries: _ui5.plugin.xmlFormatterTagEndingNewline_
+> Related preference entries: _ui5.plugin.xmlFormatterTagEndingNewline_
_ui5.plugin.xmlFormatterSpaceAfterSelfTagEnd_
--- diff --git a/package-lock.json b/package-lock.json index 75986daf..0f126cc4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ui5plugin", - "version": "1.13.4", + "version": "1.14.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ui5plugin", - "version": "1.13.4", + "version": "1.14.0", "funding": [ { "type": "paypal", @@ -23,7 +23,7 @@ ], "license": "Apache-2.0", "dependencies": { - "ui5plugin-linter": "^1.9.1", + "ui5plugin-linter": "^1.10.0", "ui5plugin-parser": "^1.6.3" }, "devDependencies": { @@ -3783,9 +3783,9 @@ } }, "node_modules/ui5plugin-linter": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ui5plugin-linter/-/ui5plugin-linter-1.9.1.tgz", - "integrity": "sha512-fHJaIl2UcF8lcPRe5NMQYRANyTNaie8I4T2OxtQ0Em2DSnJrAHuPKzU9G+X0x78x1z5gBliovvOYJWQKuUs8Nw==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/ui5plugin-linter/-/ui5plugin-linter-1.10.0.tgz", + "integrity": "sha512-jhuomUd3d9MhGH43FGfSgCnZ9R96ve+kWZj/KgO4t/2oDPe30brb2YtYPIQ889OxBWqLZ4TZvYv7+DMoI7Glwg==", "funding": [ { "type": "paypal", diff --git a/package.json b/package.json index 25239cbf..16169e07 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.4", + "version": "1.14.0", "publisher": "iljapostnovs", "license": "Apache-2.0", "author": "Ilja Postnovs ", @@ -237,6 +237,11 @@ "default": true, "description": "Should XML Formatter put tag ending (\">\", \"/>\") on newline" }, + "ui5.plugin.xmlFormatterSpaceAfterSelfTagEnd": { + "type": "boolean", + "default": true, + "description": "Should XML Formatter leave a space between the last attribute and the self tag end (\"/>\")" + }, "ui5.plugin.umlGenerationPath": { "type": "string", "default": "", @@ -535,7 +540,7 @@ "webpack-cli": "^5.1.4" }, "dependencies": { - "ui5plugin-linter": "^1.9.1", + "ui5plugin-linter": "^1.10.0", "ui5plugin-parser": "^1.6.3" }, "__metadata": { diff --git a/src/classes/registrators/XMLFormatterRegistrator.ts b/src/classes/registrators/XMLFormatterRegistrator.ts index 2a6cb49d..f00c998a 100644 --- a/src/classes/registrators/XMLFormatterRegistrator.ts +++ b/src/classes/registrators/XMLFormatterRegistrator.ts @@ -1,8 +1,8 @@ +import { XMLFormatter } from "ui5plugin-linter/dist/classes/formatter/xml/XMLFormatter"; import { ParserPool } from "ui5plugin-parser"; import * as vscode from "vscode"; import { UI5Plugin } from "../../UI5Plugin"; import { TextDocumentAdapter } from "../adapters/vscode/TextDocumentAdapter"; -import { XMLFormatter } from "ui5plugin-linter/dist/classes/formatter/xml/XMLFormatter"; export class XMLFormatterRegistrator { static register() { const disposable = vscode.languages.registerDocumentFormattingEditProvider( @@ -17,9 +17,14 @@ export class XMLFormatterRegistrator { const bShouldTagEndingBeOnNewline = vscode.workspace .getConfiguration("ui5.plugin") .get("xmlFormatterTagEndingNewline"); - const sFormattedText = new XMLFormatter(parser, bShouldTagEndingBeOnNewline).formatDocument( - new TextDocumentAdapter(document) - ); + const bShouldSelfTagEndingHaveSpaceBeforeIt = vscode.workspace + .getConfiguration("ui5.plugin") + .get("xmlFormatterSpaceAfterSelfTagEnd"); + const sFormattedText = new XMLFormatter( + parser, + bShouldTagEndingBeOnNewline, + bShouldSelfTagEndingHaveSpaceBeforeIt + ).formatDocument(new TextDocumentAdapter(document)); if (!sFormattedText) { return; } From 8d04f584ce4b04542df4ed4bae45dc3e62d44c19 Mon Sep 17 00:00:00 2001 From: Ilja Postnovs Date: Sun, 8 Oct 2023 18:23:02 +0300 Subject: [PATCH 2/3] update tests --- .../vscommands/generateids/GenerateIDCommand.ts | 13 +++++++++---- src/test/js/suite/data/IDGenerationData.json | 2 +- src/test/js/suite/extension.js.test.ts | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/classes/vscommands/generateids/GenerateIDCommand.ts b/src/classes/vscommands/generateids/GenerateIDCommand.ts index a25948b6..b1c6ebb9 100644 --- a/src/classes/vscommands/generateids/GenerateIDCommand.ts +++ b/src/classes/vscommands/generateids/GenerateIDCommand.ts @@ -1,11 +1,11 @@ import { PackageLinterConfigHandler } from "ui5plugin-linter"; +import { XMLFormatter } from "ui5plugin-linter/dist/classes/formatter/xml/XMLFormatter"; import AMeaningAssumptionGenerator from "ui5plugin-linter/dist/classes/xml/linters/pattern/AMeaningAssumptionGenerator"; import { ITag } from "ui5plugin-parser/dist/classes/parsing/util/xml/XMLParser"; import { IUI5Parser } from "ui5plugin-parser/dist/parser/abstraction/IUI5Parser"; import { Range, TextEdit, WorkspaceEdit, window, workspace } from "vscode"; import { TextDocumentAdapter } from "../../adapters/vscode/TextDocumentAdapter"; import { VSCodeTextDocumentTransformer } from "../../utils/VSCodeTextDocumentTransformer"; -import { XMLFormatter } from "ui5plugin-linter/dist/classes/formatter/xml/XMLFormatter"; export interface GenerateIDCommandConfig { excludeClasses?: string[]; @@ -62,9 +62,14 @@ export default class GenerateIDCommand extends AMeaningAssumptionGenerator { const bShouldTagEndingBeOnNewline = workspace .getConfiguration("ui5.plugin") .get("xmlFormatterTagEndingNewline"); - const sFormattedText = new XMLFormatter(this._parser, bShouldTagEndingBeOnNewline).formatDocument( - this._document - ); + const bShouldSelfTagEndingHaveSpaceBeforeIt = workspace + .getConfiguration("ui5.plugin") + .get("xmlFormatterSpaceAfterSelfTagEnd"); + const sFormattedText = new XMLFormatter( + this._parser, + bShouldTagEndingBeOnNewline, + bShouldSelfTagEndingHaveSpaceBeforeIt + ).formatDocument(this._document); if (!sFormattedText) { return; } diff --git a/src/test/js/suite/data/IDGenerationData.json b/src/test/js/suite/data/IDGenerationData.json index 94d4c697..2144a788 100644 --- a/src/test/js/suite/data/IDGenerationData.json +++ b/src/test/js/suite/data/IDGenerationData.json @@ -1,6 +1,6 @@ { "data": [{ "className": "com.test.view.IDGenerationTest", - "result": "\n\t\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t/Orders}\"\n\t\t/>\n\t\t/Orders'\n\t\t\t}\"\n\t\t/>\n\t\t/Orders',\n\t\t\t\tsorter: {\n\t\t\t\t\tpath: 'OrderID',\n\t\t\t\t\tdescending: false\n\t\t\t\t}\n\t\t\t}\"\n\t\t/>\n\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\n\t\t