This commit is contained in:
Andy Bunce 2022-03-07 16:37:26 +00:00
parent 475943053c
commit cfc8ba3817
6 changed files with 164 additions and 158 deletions

View File

@ -2,7 +2,7 @@
"name": "vscode-basex",
"displayName": "BaseX tools",
"description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code",
"version": "0.0.47",
"version": "0.0.48",
"preview": true,
"publisher": "quodatum",
"author": "Andy Bunce (https://github.com/Quodatum)",
@ -72,9 +72,10 @@
"title": "BaseX Tools: Minify XML"
}
],
"configuration": {
"title": "BaseX Tools Configuration",
"type": "object",
"configuration": [
{
"id": "xmltree",
"title": "XML tree view ",
"properties": {
"basexTools.xmlTree.enableTreeView": {
"type": "boolean",
@ -93,13 +94,13 @@
"default": false,
"description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.",
"scope": "window"
}
}
},
"basexTools.enforcePrettySelfClosingTagOnFormat": {
"type": "boolean",
"default": false,
"description": "Enforces a space before the forward slash at the end of a self-closing XML tag.",
"scope": "resource"
},
{
"id": "xpath",
"title": "XPath ",
"properties":{
"basexTools.xpath.ignoreDefaultNamespace": {
"type": "boolean",
"default": true,
@ -111,7 +112,20 @@
"default": true,
"description": "Remember the last XPath query used.",
"scope": "window"
}
}
},
{
"title": "BaseX Tools ",
"type": "object",
"properties": {
"basexTools.enforcePrettySelfClosingTagOnFormat": {
"type": "boolean",
"default": false,
"description": "Enforces a space before the forward slash at the end of a self-closing XML tag.",
"scope": "resource"
},
"basexTools.removeCommentsOnMinify": {
"type": "boolean",
"default": false,
@ -172,7 +186,8 @@
"scope": "window"
}
}
},
}
],
"grammars": [
{
"language": "xquery",

5
src/CHANGELOG.md Normal file
View File

@ -0,0 +1,5 @@
# 0.0.48
* Fix xmlToText #6
* FIX outline all vars
# 0.0.47

View File

@ -1,4 +1,4 @@
export * from "./formatAsXml";
export * from "./minifyXml";
export * from "./xmlToText";
export * from "./textToXml";

View File

@ -1,33 +0,0 @@
import { workspace } from "vscode";
import { ProviderResult, Range, TextEdit, TextEditor, Selection } from "vscode";
import { NativeCommands } from "../../common";
import * as constants from "../../constants";
import { XmlFormatterFactory } from "../xml-formatter";
import { XmlFormattingEditProvider } from "../xml-formatting-edit-provider";
import { XmlFormattingOptionsFactory } from "../xml-formatting-options";
export function textToXml(textEditor: TextEditor): void {
textEditor.edit(textEdit => {
const selections = textEditor.selections;
selections.forEach(selection => {
if (selection.isEmpty) {
selection = new Selection(
textEditor.document.positionAt(0),
textEditor.document.positionAt(textEditor.document.getText().length)
);
}
const txt = textEditor.document.getText(new Range(selection.start, selection.end));
const transformed = txt
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&amp;/g, "&")
// tslint:disable-next-line
.replace(/&quot;/g, '"')
.replace(/&apos;/g, "'");
textEdit.replace(selection, transformed);
});
});
}

View File

@ -1,12 +1,7 @@
import { workspace } from "vscode";
import { ProviderResult, Range, TextEdit, TextEditor, Selection } from "vscode";
import { NativeCommands } from "../../common";
import * as constants from "../../constants";
import { Range, TextEditor, Selection } from "vscode";
import { XmlFormatterFactory } from "../xml-formatter";
import { XmlFormattingEditProvider } from "../xml-formatting-edit-provider";
import { XmlFormattingOptionsFactory } from "../xml-formatting-options";
export function xmlToText(textEditor: TextEditor): void {
textEditor.edit(textEdit => {
@ -20,9 +15,9 @@ export function xmlToText(textEditor: TextEditor): void {
}
const txt = textEditor.document.getText(new Range(selection.start, selection.end));
const transformed = txt
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/&/g, "&amp;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;");
@ -30,3 +25,27 @@ export function xmlToText(textEditor: TextEditor): void {
});
});
}
export function textToXml(textEditor: TextEditor): void {
textEditor.edit(textEdit => {
const selections = textEditor.selections;
selections.forEach(selection => {
if (selection.isEmpty) {
selection = new Selection(
textEditor.document.positionAt(0),
textEditor.document.positionAt(textEditor.document.getText().length)
);
}
const txt = textEditor.document.getText(new Range(selection.start, selection.end));
const transformed = txt
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">")
.replace(/&amp;/g, "&")
// tslint:disable-next-line
.replace(/&quot;/g, '"')
.replace(/&apos;/g, "'");
textEdit.replace(selection, transformed);
});
});
}

View File

@ -5,12 +5,12 @@ import { channel } from "../common/logger";
//
// This class handles Symbols
//
function makeSymbol (name :string,desc :string,icon :vscode.SymbolKind,pos :any) {
function makeSymbol(name: string, description: string, icon: vscode.SymbolKind, pos: any) {
const spos = new vscode.Position(pos.sl, pos.sc);
const epos = new vscode.Position(pos.el, pos.ec);
const fullrange = new vscode.Range(spos, epos);
const selrange = new vscode.Range(spos, spos);
return new vscode.DocumentSymbol(name,"var", vscode.SymbolKind.Variable, fullrange, selrange);
return new vscode.DocumentSymbol(name, description, icon, fullrange, selrange);
}
export class Symbols implements vscode.DocumentSymbolProvider {
@ -24,7 +24,7 @@ export class Symbols implements vscode.DocumentSymbolProvider {
const text = document.getText();
const linter = new (XQLint as any)(text, { "styleCheck": false });
const xqdoc = linter.getXQDoc();
channel.log(xqdoc.variables);
channel.log("got xqdoc");
// type: type,
// pos: pos,
// qname: qname,