vscode-basex #9
					 6 changed files with 164 additions and 158 deletions
				
			
		
							
								
								
									
										37
									
								
								package.json
									
										
									
									
									
								
							
							
						
						
									
										37
									
								
								package.json
									
										
									
									
									
								
							|  | @ -2,7 +2,7 @@ | ||||||
|   "name": "vscode-basex", |   "name": "vscode-basex", | ||||||
|   "displayName": "BaseX tools", |   "displayName": "BaseX tools", | ||||||
|   "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code", |   "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code", | ||||||
|   "version": "0.0.47", |   "version": "0.0.48", | ||||||
|   "preview": true, |   "preview": true, | ||||||
|   "publisher": "quodatum", |   "publisher": "quodatum", | ||||||
|   "author": "Andy Bunce (https://github.com/Quodatum)", |   "author": "Andy Bunce (https://github.com/Quodatum)", | ||||||
|  | @ -72,9 +72,10 @@ | ||||||
|         "title": "BaseX Tools: Minify XML" |         "title": "BaseX Tools: Minify XML" | ||||||
|       } |       } | ||||||
|     ], |     ], | ||||||
|     "configuration": { |     "configuration": [ | ||||||
|       "title": "BaseX Tools Configuration", |       { | ||||||
|       "type": "object", |         "id": "xmltree", | ||||||
|  |         "title": "XML tree view ", | ||||||
|         "properties": { |         "properties": { | ||||||
|           "basexTools.xmlTree.enableTreeView": { |           "basexTools.xmlTree.enableTreeView": { | ||||||
|             "type": "boolean", |             "type": "boolean", | ||||||
|  | @ -93,13 +94,13 @@ | ||||||
|             "default": false, |             "default": false, | ||||||
|             "description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.", |             "description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.", | ||||||
|             "scope": "window" |             "scope": "window" | ||||||
|  |           } | ||||||
|  |         } | ||||||
|       }, |       }, | ||||||
|         "basexTools.enforcePrettySelfClosingTagOnFormat": { |       { | ||||||
|           "type": "boolean", |         "id": "xpath", | ||||||
|           "default": false, |         "title": "XPath ", | ||||||
|           "description": "Enforces a space before the forward slash at the end of a self-closing XML tag.", |         "properties":{ | ||||||
|           "scope": "resource" |  | ||||||
|         }, |  | ||||||
|           "basexTools.xpath.ignoreDefaultNamespace": { |           "basexTools.xpath.ignoreDefaultNamespace": { | ||||||
|             "type": "boolean", |             "type": "boolean", | ||||||
|             "default": true, |             "default": true, | ||||||
|  | @ -111,7 +112,20 @@ | ||||||
|             "default": true, |             "default": true, | ||||||
|             "description": "Remember the last XPath query used.", |             "description": "Remember the last XPath query used.", | ||||||
|             "scope": "window" |             "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": { |           "basexTools.removeCommentsOnMinify": { | ||||||
|             "type": "boolean", |             "type": "boolean", | ||||||
|             "default": false, |             "default": false, | ||||||
|  | @ -172,7 +186,8 @@ | ||||||
|             "scope": "window" |             "scope": "window" | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
|     }, |       } | ||||||
|  |     ], | ||||||
|     "grammars": [ |     "grammars": [ | ||||||
|       { |       { | ||||||
|         "language": "xquery", |         "language": "xquery", | ||||||
|  |  | ||||||
							
								
								
									
										5
									
								
								src/CHANGELOG.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								src/CHANGELOG.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | ||||||
|  | # 0.0.48 | ||||||
|  | * Fix xmlToText #6 | ||||||
|  | * FIX outline all vars | ||||||
|  | 
 | ||||||
|  | # 0.0.47  | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| export * from "./formatAsXml"; | export * from "./formatAsXml"; | ||||||
| export * from "./minifyXml"; | export * from "./minifyXml"; | ||||||
| export * from "./xmlToText"; | export * from "./xmlToText"; | ||||||
| export * from "./textToXml"; | 
 | ||||||
|  |  | ||||||
|  | @ -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(/</g, "<") |  | ||||||
|                 .replace(/>/g, ">") |  | ||||||
|                 .replace(/&/g, "&") |  | ||||||
|                 // tslint:disable-next-line
 |  | ||||||
|                 .replace(/"/g, '"') |  | ||||||
|                 .replace(/'/g, "'"); |  | ||||||
| 
 |  | ||||||
|             textEdit.replace(selection, transformed); |  | ||||||
|         }); |  | ||||||
|     }); |  | ||||||
| } |  | ||||||
|  | @ -1,12 +1,7 @@ | ||||||
| import { workspace } from "vscode"; |  | ||||||
| import { ProviderResult, Range, TextEdit, TextEditor, Selection } from "vscode"; |  | ||||||
| 
 | 
 | ||||||
| import { NativeCommands } from "../../common"; | import {  Range,  TextEditor, Selection } from "vscode"; | ||||||
| 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 xmlToText(textEditor: TextEditor): void { | export function xmlToText(textEditor: TextEditor): void { | ||||||
|     textEditor.edit(textEdit => { |     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 txt = textEditor.document.getText(new Range(selection.start, selection.end)); | ||||||
|             const transformed = txt |             const transformed = txt | ||||||
|  |                 .replace(/&/g, "&") | ||||||
|                 .replace(/</g, "<") |                 .replace(/</g, "<") | ||||||
|                 .replace(/>/g, ">") |                 .replace(/>/g, ">") | ||||||
|                 .replace(/&/g, "&") |  | ||||||
|                 .replace(/"/g, """) |                 .replace(/"/g, """) | ||||||
|                 .replace(/'/g, "'"); |                 .replace(/'/g, "'"); | ||||||
| 
 | 
 | ||||||
|  | @ -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(/</g, "<") | ||||||
|  |                 .replace(/>/g, ">") | ||||||
|  |                 .replace(/&/g, "&") | ||||||
|  |                 // tslint:disable-next-line
 | ||||||
|  |                 .replace(/"/g, '"') | ||||||
|  |                 .replace(/'/g, "'"); | ||||||
|  | 
 | ||||||
|  |             textEdit.replace(selection, transformed); | ||||||
|  |         }); | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -5,12 +5,12 @@ import { channel } from "../common/logger"; | ||||||
| //
 | //
 | ||||||
| // This class handles Symbols
 | // 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 spos = new vscode.Position(pos.sl, pos.sc); | ||||||
|   const epos = new vscode.Position(pos.el, pos.ec); |   const epos = new vscode.Position(pos.el, pos.ec); | ||||||
|   const fullrange=new vscode.Range(spos,epos); |   const fullrange = new vscode.Range(spos, epos); | ||||||
|   const selrange=new vscode.Range(spos,spos); |   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 { | export class Symbols implements vscode.DocumentSymbolProvider { | ||||||
|  | @ -23,23 +23,23 @@ export class Symbols implements vscode.DocumentSymbolProvider { | ||||||
|     const symbols: vscode.DocumentSymbol[] = []; |     const symbols: vscode.DocumentSymbol[] = []; | ||||||
|     const text = document.getText(); |     const text = document.getText(); | ||||||
|     const linter = new (XQLint as any)(text, { "styleCheck": false }); |     const linter = new (XQLint as any)(text, { "styleCheck": false }); | ||||||
|     const xqdoc= linter.getXQDoc(); |     const xqdoc = linter.getXQDoc(); | ||||||
|     channel.log(xqdoc.variables); |     channel.log("got xqdoc"); | ||||||
|     // type: type,
 |     // type: type,
 | ||||||
|     // pos: pos,
 |     // pos: pos,
 | ||||||
|     // qname: qname,
 |     // qname: qname,
 | ||||||
|     // annotations: {}
 |     // annotations: {}
 | ||||||
|     xqdoc.variables.forEach(v => { |     xqdoc.variables.forEach(v => { | ||||||
|       const name = v.name; |       const name = v.name; | ||||||
|         const info =makeSymbol(name,"var", vscode.SymbolKind.Variable,v.pos) |       const info = makeSymbol(name, "var", vscode.SymbolKind.Variable, v.pos) | ||||||
|       symbols.push(info); |       symbols.push(info); | ||||||
|     }); |     }); | ||||||
|     xqdoc.functions.forEach(v => { |     xqdoc.functions.forEach(v => { | ||||||
|       const name = v.name; |       const name = v.name; | ||||||
|         const info =makeSymbol(name,"Fu", vscode.SymbolKind.Function,v.pos) |       const info = makeSymbol(name, "Fu", vscode.SymbolKind.Function, v.pos) | ||||||
|       symbols.push(info); |       symbols.push(info); | ||||||
|     }); |     }); | ||||||
|     channel.log("Symbols done" + document.uri); |     channel.log("Symbols done " + document.uri); | ||||||
|     return symbols; |     return symbols; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue