The last XPath query is being persisted and can be reused with the next query.
This commit is contained in:
parent
eeb0ed8d4c
commit
f3ea33a522
@ -9,7 +9,8 @@ let resultChannel: OutputChannel = null;
|
||||
export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
|
||||
window.showInputBox({
|
||||
placeHolder: 'XPath Query',
|
||||
prompt: 'Please enter an XPath query to evaluate.'
|
||||
prompt: 'Please enter an XPath query to evaluate.',
|
||||
value: Singleton.getXPathValue()
|
||||
|
||||
}).then((query) => {
|
||||
if (query === undefined) return;
|
||||
@ -17,6 +18,8 @@ export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
|
||||
let xml = editor.document.getText();
|
||||
let doc = new dom().parseFromString(xml);
|
||||
|
||||
Singleton.setXPathValue(query);
|
||||
|
||||
try {
|
||||
var nodes = xpath.select(query, doc);
|
||||
}
|
||||
@ -42,4 +45,22 @@ export function evaluateXPath(editor: TextEditor, edit: TextEditorEdit): void {
|
||||
|
||||
resultChannel.show(ViewColumn.Three);
|
||||
});
|
||||
}
|
||||
|
||||
namespace Singleton {
|
||||
|
||||
class XPathContext
|
||||
{
|
||||
static _lastXPathValue:string = '';
|
||||
}
|
||||
|
||||
export function getXPathValue():string
|
||||
{
|
||||
return XPathContext._lastXPathValue;
|
||||
}
|
||||
|
||||
export function setXPathValue(val:string):void
|
||||
{
|
||||
XPathContext._lastXPathValue = val;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user