Skip to content

Commit

Permalink
update linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilja Postnovs authored and Ilja Postnovs committed Nov 9, 2023
1 parent eac9c56 commit d0931f1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.16.3 (09-11-2023)

- [UI5 Linter](https://github.com/iljapostnovs/ui5plugin-linter) updated to v1.12.0

## 1.16.2 (19-10-2023)

- Fix OData Edm types mapping to TS types
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.

4 changes: 2 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.16.2",
"version": "1.16.3",
"publisher": "iljapostnovs",
"license": "Apache-2.0",
"author": "Ilja Postnovs <ilja.postnovs@gmail.com>",
Expand Down Expand Up @@ -540,7 +540,7 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"ui5plugin-linter": "^1.11.1",
"ui5plugin-linter": "^1.12.0",
"ui5plugin-parser": "^1.6.4"
},
"__metadata": {
Expand Down
22 changes: 15 additions & 7 deletions src/classes/registrators/XMLFormatterRegistrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,25 @@ export class XMLFormatterRegistrator {
return;
}
if (document.uri.fsPath.endsWith(".view.xml") || document.uri.fsPath.endsWith(".fragment.xml")) {
const bShouldTagEndingBeOnNewline = vscode.workspace
const shouldXmlFormatterTagEndByNewline = vscode.workspace
.getConfiguration("ui5.plugin")
.get<boolean>("xmlFormatterTagEndingNewline");
const bShouldSelfTagEndingHaveSpaceBeforeIt = vscode.workspace
const shouldXmlFormatterTagSpaceBeforeSelfClose = vscode.workspace
.getConfiguration("ui5.plugin")
.get<boolean>("xmlFormatterSpaceAfterSelfTagEnd");
const sFormattedText = new XMLFormatter(
parser,
bShouldTagEndingBeOnNewline,
bShouldSelfTagEndingHaveSpaceBeforeIt
).formatDocument(new TextDocumentAdapter(document));

let indentation = "\t";
if (vscode.window.activeTextEditor?.options.insertSpaces) {
const tabSize = vscode.window.activeTextEditor?.options.tabSize;
if (typeof tabSize === "number") {
indentation = " ".repeat(tabSize);
}
}
const sFormattedText = new XMLFormatter(parser, {
shouldXmlFormatterTagEndByNewline,
shouldXmlFormatterTagSpaceBeforeSelfClose,
indentation
}).formatDocument(new TextDocumentAdapter(document));
if (!sFormattedText) {
return;
}
Expand Down
23 changes: 16 additions & 7 deletions src/classes/vscommands/generateids/GenerateIDCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { XMLFormatter } from "ui5plugin-linter/dist/classes/formatter/xml/XMLFor
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 * as vscode from "vscode";
import { Range, TextEdit, WorkspaceEdit, window, workspace } from "vscode";
import { TextDocumentAdapter } from "../../adapters/vscode/TextDocumentAdapter";
import { VSCodeTextDocumentTransformer } from "../../utils/VSCodeTextDocumentTransformer";
Expand Down Expand Up @@ -59,17 +60,25 @@ export default class GenerateIDCommand extends AMeaningAssumptionGenerator {
if (workspaceEdit.size > 0) {
await workspace.applyEdit(workspaceEdit);

const bShouldTagEndingBeOnNewline = workspace
const shouldXmlFormatterTagEndByNewline = workspace
.getConfiguration("ui5.plugin")
.get<boolean>("xmlFormatterTagEndingNewline");
const bShouldSelfTagEndingHaveSpaceBeforeIt = workspace
const shouldXmlFormatterTagSpaceBeforeSelfClose = workspace
.getConfiguration("ui5.plugin")
.get<boolean>("xmlFormatterSpaceAfterSelfTagEnd");
const sFormattedText = new XMLFormatter(
this._parser,
bShouldTagEndingBeOnNewline,
bShouldSelfTagEndingHaveSpaceBeforeIt
).formatDocument(this._document);

let indentation = "\t";
if (vscode.window.activeTextEditor?.options.insertSpaces) {
const tabSize = vscode.window.activeTextEditor?.options.tabSize;
if (typeof tabSize === "number") {
indentation = " ".repeat(tabSize);
}
}
const sFormattedText = new XMLFormatter(this._parser, {
shouldXmlFormatterTagEndByNewline,
shouldXmlFormatterTagSpaceBeforeSelfClose,
indentation
}).formatDocument(this._document);
if (!sFormattedText) {
return;
}
Expand Down
6 changes: 5 additions & 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,11 @@ suite("Extension Test Suite", () => {
if (fsPath) {
const uri = vscode.Uri.file(fsPath);
const document = await vscode.workspace.openTextDocument(uri);
const formattedText = new XMLFormatter(parser, true, false).formatDocument(new TextDocumentAdapter(document));
const formattedText = new XMLFormatter(parser, {
shouldXmlFormatterTagSpaceBeforeSelfClose: false,
shouldXmlFormatterTagEndByNewline: true,
indentation: "\t"
}).formatDocument(new TextDocumentAdapter(document));
assert.strictEqual(
formattedText?.replaceAll("\r", ""),
data.formattedText.replaceAll("\r", ""),
Expand Down

0 comments on commit d0931f1

Please sign in to comment.