Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.14.0 #374

Merged
merged 3 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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). (Thanks to @netux)

## 1.13.4 (07-10-2023)

- [UI5 Parser](https://github.com/iljapostnovs/ui5plugin-parser) updated to v1.6.3
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand Down Expand Up @@ -248,7 +249,7 @@ XML Formatter is available.<br/>

![XMLFormatter](/images/XMLFormatter.gif)

> Related preference entries: _ui5.plugin.xmlFormatterTagEndingNewline_<br/>
> Related preference entries: _ui5.plugin.xmlFormatterTagEndingNewline_<br/>_ui5.plugin.xmlFormatterSpaceAfterSelfTagEnd_<br/>

---

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ilja.postnovs@gmail.com>",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": {
Expand Down
13 changes: 9 additions & 4 deletions src/classes/registrators/XMLFormatterRegistrator.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -17,9 +17,14 @@ export class XMLFormatterRegistrator {
const bShouldTagEndingBeOnNewline = vscode.workspace
.getConfiguration("ui5.plugin")
.get<boolean>("xmlFormatterTagEndingNewline");
const sFormattedText = new XMLFormatter(parser, bShouldTagEndingBeOnNewline).formatDocument(
new TextDocumentAdapter(document)
);
const bShouldSelfTagEndingHaveSpaceBeforeIt = vscode.workspace
.getConfiguration("ui5.plugin")
.get<boolean>("xmlFormatterSpaceAfterSelfTagEnd");
const sFormattedText = new XMLFormatter(
parser,
bShouldTagEndingBeOnNewline,
bShouldSelfTagEndingHaveSpaceBeforeIt
).formatDocument(new TextDocumentAdapter(document));
if (!sFormattedText) {
return;
}
Expand Down
13 changes: 9 additions & 4 deletions src/classes/vscommands/generateids/GenerateIDCommand.ts
Original file line number Diff line number Diff line change
@@ -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[];
Expand Down Expand Up @@ -62,9 +62,14 @@ export default class GenerateIDCommand extends AMeaningAssumptionGenerator {
const bShouldTagEndingBeOnNewline = workspace
.getConfiguration("ui5.plugin")
.get<boolean>("xmlFormatterTagEndingNewline");
const sFormattedText = new XMLFormatter(this._parser, bShouldTagEndingBeOnNewline).formatDocument(
this._document
);
const bShouldSelfTagEndingHaveSpaceBeforeIt = workspace
.getConfiguration("ui5.plugin")
.get<boolean>("xmlFormatterSpaceAfterSelfTagEnd");
const sFormattedText = new XMLFormatter(
this._parser,
bShouldTagEndingBeOnNewline,
bShouldSelfTagEndingHaveSpaceBeforeIt
).formatDocument(this._document);
if (!sFormattedText) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/js/suite/data/IDGenerationData.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"data": [{
"className": "com.test.view.IDGenerationTest",
"result": "<mvc:View\n\txmlns:mvc=\"sap.ui.core.mvc\"\n\txmlns=\"sap.m\"\n\tdisplayBlock=\"true\"\n\theight=\"100%\"\n\txmlns:c=\"sap.ui.core\"\n\tbusyIndicatorDelay=\"0\"\n>\n\t<Page id=\"idPage\">\n\t\t<customHeader>\n\t\t\t<Toolbar id=\"idToolbar\">\n\t\t\t\t<Button\n\t\t\t\t\tid=\"idAddOrderButton\"\n\t\t\t\t\ttext=\"Add Order\"\n\t\t\t\t/>\n\t\t\t</Toolbar>\n\t\t</customHeader>\n\t\t<Table\n\t\t\tid=\"idOrdersTable\"\n\t\t\titems=\"{ODataModel>/Orders}\"\n\t\t/>\n\t\t<Table\n\t\t\tid=\"idOrders0Table\"\n\t\t\titems=\"{\n\t\t\t\tpath: 'ODataModel>/Orders'\n\t\t\t}\"\n\t\t/>\n\t\t<Table\n\t\t\tid=\"idOrders1Table\"\n\t\t\titems=\"{\n\t\t\t\tpath: 'ODataModel>/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<Select\n\t\t\tid=\"idVendorsSelect\"\n\t\t\titems=\"{/Vendors}\"\n\t\t>\n\t\t\t<items>\n\t\t\t\t<c:Item id=\"idItem\"/>\n\t\t\t</items>\n\t\t</Select>\n\t\t<Button id=\"idButton\"/>\n\t\t<Button id=\"id0Button\"/>\n\t</Page>\n</mvc:View>"
"result": "<mvc:View\n\txmlns:mvc=\"sap.ui.core.mvc\"\n\txmlns=\"sap.m\"\n\tdisplayBlock=\"true\"\n\theight=\"100%\"\n\txmlns:c=\"sap.ui.core\"\n\tbusyIndicatorDelay=\"0\"\n>\n\t<Page id=\"idPage\">\n\t\t<customHeader>\n\t\t\t<Toolbar id=\"idToolbar\">\n\t\t\t\t<Button\n\t\t\t\t\tid=\"idAddOrderButton\"\n\t\t\t\t\ttext=\"Add Order\"\n\t\t\t\t/>\n\t\t\t</Toolbar>\n\t\t</customHeader>\n\t\t<Table\n\t\t\tid=\"idOrdersTable\"\n\t\t\titems=\"{ODataModel>/Orders}\"\n\t\t/>\n\t\t<Table\n\t\t\tid=\"idOrders0Table\"\n\t\t\titems=\"{\n\t\t\t\tpath: 'ODataModel>/Orders'\n\t\t\t}\"\n\t\t/>\n\t\t<Table\n\t\t\tid=\"idOrders1Table\"\n\t\t\titems=\"{\n\t\t\t\tpath: 'ODataModel>/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<Select\n\t\t\tid=\"idVendorsSelect\"\n\t\t\titems=\"{/Vendors}\"\n\t\t>\n\t\t\t<items>\n\t\t\t\t<c:Item id=\"idItem\" />\n\t\t\t</items>\n\t\t</Select>\n\t\t<Button id=\"idButton\" />\n\t\t<Button id=\"id0Button\" />\n\t</Page>\n</mvc:View>"
}]
}
2 changes: 1 addition & 1 deletion src/test/js/suite/extension.js.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ suite("Extension Test Suite", () => {
if (fsPath) {
const uri = vscode.Uri.file(fsPath);
const document = await vscode.workspace.openTextDocument(uri);
const formattedText = new XMLFormatter(parser).formatDocument(new TextDocumentAdapter(document));
const formattedText = new XMLFormatter(parser, true, false).formatDocument(new TextDocumentAdapter(document));
assert.strictEqual(
formattedText?.replaceAll("\r", ""),
data.formattedText.replaceAll("\r", ""),
Expand Down