Socket
Socket
Sign inDemoInstall

coc-metals

Package Overview
Dependencies
Maintainers
4
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

coc-metals - npm Package Compare versions

Comparing version 0.8.3 to 0.9.0

LICENSE

30

lib/index.js
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"eojW":[function(require,module,exports) {
"use strict";var o;Object.defineProperty(exports,"__esModule",{value:!0}),function(o){o.RELOAD_WINDOW="workbench.action.reloadWindow",o.OPEN_COC_CONFIG="CocConfig",o.RESTART_COC="CocRestart",o.OPEN_PREVIEW="coc#util#preview_info",o.HAS_PREVIEW="coc#util#has_preview",o.OPEN_LOGS="CocInfo"}(o=exports.Commands||(exports.Commands={}));
"use strict";var o;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Commands=void 0,function(o){o.RELOAD_WINDOW="workbench.action.reloadWindow",o.OPEN_COC_CONFIG="CocConfig",o.RESTART_COC="CocRestart",o.OPEN_PREVIEW="coc#util#preview_info",o.HAS_PREVIEW="coc#util#has_preview",o.OPEN_LOGS="CocCommand workspace.showOutput"}(o=exports.Commands||(exports.Commands={}));
},{}],"p29A":[function(require,module,exports) {
"use strict";var e=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))(function(r,a){function i(e){try{s(n.next(e))}catch(t){a(t)}}function c(e){try{s(n.throw(e))}catch(t){a(t)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(i,c)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const t=require("coc.nvim");class o{constructor(e){this.currentDecorations=[],this.decorationNameSpace=t.workspace.createNameSpace("worksheetDecorations"),this.floatFactory=e}setDecorations(o){return e(this,void 0,void 0,function*(){const e=t.workspace.getDocument(o.uri),{buffer:n}=e;n.clearNamespace(this.decorationNameSpace),this.currentDecorations=[],o.options.forEach(e=>{var t,o,r,a;this.currentDecorations.push(e),n.setVirtualText(this.decorationNameSpace,e.range.end.line,[[null!==(a=null===(r=null===(o=null===(t=e.renderOptions)||void 0===t?void 0:t.after)||void 0===o?void 0:o.contentText)||void 0===r?void 0:r.replace("//","‣"))&&void 0!==a?a:"","test"]])})})}showHover(){return e(this,void 0,void 0,function*(){const{position:e}=yield t.workspace.getCurrentState(),o=this.currentDecorations.find(t=>t.range.end.line===e.line);o&&"string"!=typeof o.hoverMessage&&o.hoverMessage&&(yield this.floatFactory.create([{content:o.hoverMessage.value,filetype:o.hoverMessage.language}],!0,0))})}clearDecorations(e){const o=t.workspace.getDocument(e),{buffer:n}=o;n.clearNamespace(this.decorationNameSpace),this.currentDecorations=[]}}exports.default=o;
"use strict";var e=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))(function(r,i){function a(e){try{s(n.next(e))}catch(t){i(t)}}function c(e){try{s(n.throw(e))}catch(t){i(t)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(a,c)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const t=require("coc.nvim");class o{constructor(e){this.currentDecorations=[],this.decorationNameSpace=t.workspace.createNameSpace("worksheetDecorations"),this.floatFactory=e}setDecorations(o){return e(this,void 0,void 0,function*(){const e=t.workspace.getDocument(o.uri),{buffer:n}=e;n.clearNamespace(this.decorationNameSpace),this.currentDecorations=[],o.options.forEach(e=>{var t,o,r,i;this.currentDecorations.push(e),n.setVirtualText(this.decorationNameSpace,e.range.end.line,[[null!==(i=null===(r=null===(o=null===(t=e.renderOptions)||void 0===t?void 0:t.after)||void 0===o?void 0:o.contentText)||void 0===r?void 0:r.replace("//","‣"))&&void 0!==i?i:"","test"]])})})}showHover(){return e(this,void 0,void 0,function*(){const{position:e}=yield t.workspace.getCurrentState(),o=this.currentDecorations.find(t=>t.range.end.line===e.line);o&&"string"!=typeof o.hoverMessage&&o.hoverMessage&&(yield this.floatFactory.create([{content:o.hoverMessage.value,filetype:o.hoverMessage.kind}],!0,0))})}clearDecorations(e){const o=t.workspace.getDocument(e),{buffer:n}=o;n.clearNamespace(this.decorationNameSpace),this.currentDecorations=[]}}exports.default=o;
},{}],"BTOZ":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("coc.nvim"),t=require("./commands"),r=(e,t)=>{let r;r=0===t?22-e.length:e.length<=2?15+e.length:18-e.length;const s=Math.round(r/2),n=s>0?" ".repeat(s):" ",o=s>0?" ".repeat(r-s):" ";return`${n}${e.toString().replace("\n"," ")}${o}`};function s(s){if(s)if(s.targets){const n=[s.title,"-------------",s.headerText,"",Object.keys(s.targets[0]).map((e,t)=>r(e,t)).join(" | "),"-".repeat(150),...s.targets.map(e=>Object.values(e).map((e,t)=>r(e.trim(),t)).join(" | ")),""];e.workspace.nvim.call(t.Commands.OPEN_PREVIEW,[n,"txt","setl nonumber","setl nowrap"],!0)}else{const r=[s.title,"-------------",s.headerText,"",s.messages[0].title,"",...s.messages[0].recommendations.map(e=>` - ${e}`),""];e.workspace.nvim.call(t.Commands.OPEN_PREVIEW,[r,"txt","setl nonumber","setl nowrap"],!0)}else e.workspace.showMessage("Unable to run Doctor","error")}exports.makeVimDoctor=s;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.makeVimDoctor=void 0;const e=require("coc.nvim"),t=require("./commands"),r=(e,t)=>{let r;r=0===t?22-e.length:e.length<=2?15+e.length:18-e.length;const o=Math.round(r/2),s=o>0?" ".repeat(o):" ",a=o>0?" ".repeat(r-o):" ";return`${s}${e.toString().replace("\n"," ")}${a}`};function o(o){if(o)if(o.targets){const s=[o.title,"-------------",o.headerText,"",Object.keys(o.targets[0]).map((e,t)=>r(e,t)).join(" | "),"-".repeat(150),...o.targets.map(e=>Object.values(e).map((e,t)=>r(e.trim(),t)).join(" | ")),""];e.workspace.nvim.call(t.Commands.OPEN_PREVIEW,[s,"txt","setl nonumber","setl nowrap"],!0)}else{const r=[o.title,"-------------",o.headerText,"",o.messages[0].title,"",...o.messages[0].recommendations.map(e=>` - ${e}`),""];e.workspace.nvim.call(t.Commands.OPEN_PREVIEW,[r,"txt","setl nonumber","setl nowrap"],!0)}else e.workspace.showMessage("Unable to run Doctor","error")}exports.makeVimDoctor=o;
},{"./commands":"eojW"}],"z7J4":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=require("vscode-languageserver-protocol");var t,o,s,n,i,a;!function(t){t.type=new e.NotificationType("metals/executeClientCommand")}(t=exports.ExecuteClientCommand||(exports.ExecuteClientCommand={})),function(t){t.type=new e.RequestType("metals/inputBox")}(o=exports.MetalsInputBox||(exports.MetalsInputBox={})),function(t){t.type=new e.NotificationType("metals/publishDecorations")}(s=exports.DecorationsRangesDidChange||(exports.DecorationsRangesDidChange={})),function(t){t.type=new e.NotificationType("metals/didFocusTextDocument")}(n=exports.MetalsDidFocus||(exports.MetalsDidFocus={})),function(t){t.type=new e.RequestType("metals/quickPick")}(i=exports.MetalsQuickPick||(exports.MetalsQuickPick={})),function(t){t.type=new e.NotificationType("metals/status")}(a=exports.MetalsStatus||(exports.MetalsStatus={}));
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MetalsStatus=exports.MetalsQuickPick=exports.MetalsDidFocus=exports.DecorationsRangesDidChange=exports.MetalsInputBox=exports.ExecuteClientCommand=void 0;const e=require("vscode-languageserver-protocol");var t,o,s,n,i,a;!function(t){t.type=new e.NotificationType("metals/executeClientCommand")}(t=exports.ExecuteClientCommand||(exports.ExecuteClientCommand={})),function(t){t.type=new e.RequestType("metals/inputBox")}(o=exports.MetalsInputBox||(exports.MetalsInputBox={})),function(t){t.type=new e.NotificationType("metals/publishDecorations")}(s=exports.DecorationsRangesDidChange||(exports.DecorationsRangesDidChange={})),function(t){t.type=new e.NotificationType("metals/didFocusTextDocument")}(n=exports.MetalsDidFocus||(exports.MetalsDidFocus={})),function(t){t.type=new e.RequestType("metals/quickPick")}(i=exports.MetalsQuickPick||(exports.MetalsQuickPick={})),function(t){t.type=new e.NotificationType("metals/status")}(a=exports.MetalsStatus||(exports.MetalsStatus={}));
},{}],"Iw8s":[function(require,module,exports) {
"use strict";var t=this&&this.__awaiter||function(t,n,e,o){return new(e||(e=Promise))(function(r,c){function i(t){try{s(o.next(t))}catch(n){c(n)}}function u(t){try{s(o.throw(t))}catch(n){c(n)}}function s(t){var n;t.done?r(t.value):(n=t.value,n instanceof e?n:new e(function(t){t(n)})).then(i,u)}s((o=o.apply(t,n||[])).next())})};function n(n,e){const o=(r,c)=>t(this,void 0,void 0,function*(){if(c<n.length){const t=yield e(n[c],c,n);return o(r.concat(t),c+1)}return r});return o([],0)}function e(t,n){const e=t.length,o=new Map;for(let r=0;r<e;r++){const e=t[r],c=n(e);let i=o.get(c);void 0===i&&(i=[],o.set(c,i)),i.push(e)}return o}Object.defineProperty(exports,"__esModule",{value:!0}),exports.sequence=n,exports.groupBy=e;
"use strict";var t=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))(function(r,c){function u(t){try{s(o.next(t))}catch(e){c(e)}}function i(t){try{s(o.throw(t))}catch(e){c(e)}}function s(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(u,i)}s((o=o.apply(t,e||[])).next())})};function e(e,n){const o=(r,c)=>t(this,void 0,void 0,function*(){if(c<e.length){const t=yield n(e[c],c,e);return o(r.concat(t),c+1)}return r});return o([],0)}function n(t,e){const n=t.length,o=new Map;for(let r=0;r<n;r++){const n=t[r],c=e(n);let u=o.get(c);void 0===u&&(u=[],o.set(c,u)),u.push(n)}return o}Object.defineProperty(exports,"__esModule",{value:!0}),exports.groupBy=exports.sequence=void 0,exports.sequence=e,exports.groupBy=n;
},{}],"Vq4m":[function(require,module,exports) {
"use strict";var e=this&&this.__awaiter||function(e,i,t,n){return new(t||(t=Promise))(function(o,d){function r(e){try{h(n.next(e))}catch(i){d(i)}}function s(e){try{h(n.throw(e))}catch(i){d(i)}}function h(e){var i;e.done?o(e.value):(i=e.value,i instanceof t?i:new t(function(e){e(i)})).then(r,s)}h((n=n.apply(e,i||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const i=require("vscode-jsonrpc"),t=require("./utils");class n{constructor(e,i,t,n,o){this.viewNode=e,this.level=i,this.provider=t,this.emitter=n,this.autoExpand=o,this.lastTouch=Date.now(),this.defunct=!1,this.expanded=!1}expandable(){return void 0!==this.viewNode.collapseState}isExpanded(){return this.expanded}expand(){return e(this,void 0,void 0,function*(){if(this.defunct)return!1;return function i(t,n,o){return e(this,void 0,void 0,function*(){o.viewNode.nodeUri&&o.provider.sendTreeNodeVisibilityNotification(o.viewNode.nodeUri,!1),o.expanded=!0;const e=yield o.getChildren();if(1===e.length&&e[0].expandable()&&o.autoExpand)return i(t,n,e[0]);{const e=yield t.collectVisibleNodes();return n===t.lastTouch&&!t.defunct&&(o.emitter.fire({root:t.makeView(),oldNodes:[t.makeView()],newNodes:e,focusEvent:!1}),!0)}})}(this,yield this.touch(),this)})}collapse(){return e(this,void 0,void 0,function*(){if(this.defunct)return!1;this.viewNode.nodeUri&&this.provider.sendTreeNodeVisibilityNotification(this.viewNode.nodeUri,!0);const e=yield this.touch(),i=yield this.collectVisibleNodes();return this.expanded=!1,e===this.lastTouch&&!this.defunct&&(this.emitter.fire({root:this.makeView(),oldNodes:i,newNodes:[this.makeView()],focusEvent:!1}),!0)})}refreshSubtree(i){return e(this,void 0,void 0,function*(){function n(e,i){return e.expanded===i.expanded&&e.level===i.level&&e.expandable===i.expandable&&e.underlying.nodeUri===i.underlying.nodeUri&&e.underlying.viewId===i.underlying.viewId&&e.underlying.label===i.underlying.label}const o=yield this.collectVisibleNodes();if(this.isExpanded()){const e=yield this.getChildren();yield Promise.resolve(e.map(e=>e.markAsDefunct()))}const d=yield function i(t,n,o){return e(this,void 0,void 0,function*(){return o.isExpanded()?(t.push(n),(yield o.getChildren()).reduce((t,o)=>e(this,void 0,void 0,function*(){return t.then(e=>i(e,o.viewNode.nodeUri?n.concat(o.viewNode.nodeUri):n,o))}),Promise.resolve(t))):t})}([],[],this);this.children=void 0,yield function i(n,o){return e(this,void 0,void 0,function*(){if(0!=o.length){const e=yield n.getChildren(),d=t.groupBy(o.filter(e=>0!=e.length),e=>e[0]);1===e.length&&n.autoExpand&&0===d.size&&e[0].expandable()&&e[0].viewNode.nodeUri&&d.set(e[0].viewNode.nodeUri,[[""]]),yield Promise.all(e.map(e=>{const t=e.viewNode.nodeUri?d.get(e.viewNode.nodeUri):void 0;return void 0===t?Promise.resolve():(e.expanded=!0,i(e,t.map(e=>e.slice(1))))}))}})}(this,d),void 0!==i&&(this.viewNode=i);const r=yield this.collectVisibleNodes(),s=function(e){let i=0;for(;i<e.oldNodes.length&&i<e.newNodes.length&&n(e.oldNodes[i],e.newNodes[i]);)i++;let t=0;for(;i+t<e.oldNodes.length&&i+t<e.newNodes.length&&n(e.oldNodes[e.oldNodes.length-t-1],e.newNodes[e.newNodes.length-t-1]);)t++;const o=0!==t?e.oldNodes.slice(i,-t):e.oldNodes.slice(i),d=0!==t?e.newNodes.slice(i,-t):e.newNodes.slice(i);return 0===o.length&&0===d.length?void 0:d.length>0?{root:d[0],oldNodes:o,newNodes:d,focusEvent:!1}:e}({root:this.makeView(),oldNodes:o,newNodes:r,focusEvent:!1});void 0!==s&&this.emitter.fire(s)})}getChildren(){if(void 0===this.children){const e=this.level,i=Promise.resolve(this.provider.loadNodeChildren(this.viewNode.nodeUri)).then(i=>i.map(i=>new n(i,e+1,this.provider,this.emitter,this.autoExpand)));return this.children=i}return this.children}height(){return e(this,void 0,void 0,function*(){if(this.isExpanded()){const e=yield this.getChildren();return(yield Promise.all(e.map(e=>e.height()))).reduce((e,i)=>e+i,1)}return 1})}collectVisibleNodes(){return e(this,void 0,void 0,function*(){return function i(t,n){return e(this,void 0,void 0,function*(){const e=t.concat(n.makeView());return n.isExpanded()?(yield n.getChildren()).reduce((e,t)=>e.then(e=>i(e,t)),Promise.resolve(e)):e})}([],this)})}touch(){return e(this,void 0,void 0,function*(){const e=this.lastTouch=Date.now();if(this.isExpanded()){const i=yield this.getChildren();return Promise.all(i.map(e=>e.touch())).then(i=>e)}return e})}markAsDefunct(){return e(this,void 0,void 0,function*(){if(this.defunct=!0,this.isExpanded()){const e=yield this.getChildren();yield Promise.all(e.map(e=>e.markAsDefunct()))}})}makeView(){return{underlying:this.viewNode,level:this.level,expandable:this.expandable(),expanded:this.isExpanded()}}}exports.Node=n;class o{constructor(e,t){this.provider=e,this.autoExpand=t,this.emitter=new i.Emitter,this.updateEvents=this.emitter.event,this.visible=!1;const o=e.viewId,d={viewId:o,label:o};this.rootNode=new n(d,0,e,this.emitter,this.autoExpand),e.updatedNodes(e=>{void 0!==e.nodeUri?this.findNodeByUri(e.nodeUri).then(i=>{if(void 0!==i)return i.refreshSubtree(e)}):this.rootNode.refreshSubtree(void 0)})}get viewId(){return this.provider.viewId}show(){if(!this.visible)return this.visible=!0,this.provider.sendTreeViewVisibilityNotification(!0)}hide(){if(this.visible)return this.visible=!1,this.provider.sendTreeViewVisibilityNotification(!1)}findNodeWithOffsetInternal(i,t){return e(this,void 0,void 0,function*(){if(0==t)return i;return(yield i.getChildren()).reduce((i,n)=>e(this,void 0,void 0,function*(){const e=yield i;return e.result?e:n.height().then(i=>e.height+i<=t?{height:e.height+i,result:void 0}:this.findNodeWithOffsetInternal(n,t-e.height).then(e=>({height:0,result:e})))}),Promise.resolve({height:1})).then(e=>e.result)})}findNodeWithOffset(i){return e(this,void 0,void 0,function*(){return this.findNodeWithOffsetInternal(this.rootNode,i)})}findNodeOffset(i){return e(this,void 0,void 0,function*(){return function t(n,o){return e(this,void 0,void 0,function*(){if(o.viewNode.nodeUri===i.underlying.nodeUri||n[1])return[n[0],!0];if(o.isExpanded()){const i=yield o.getChildren(),d=[n[0]+1,n[1]];return i.reduce((i,n)=>e(this,void 0,void 0,function*(){return i.then(e=>t(e,n))}),Promise.resolve(d))}return[n[0]+1,n[1]]})}([0,!1],this.rootNode).then(([e,i])=>i?e:void 0)})}findParentNode(i){return e(this,void 0,void 0,function*(){return function t(n,o){return e(this,void 0,void 0,function*(){return void 0!==n?n:o.isExpanded()?(yield o.getChildren()).reduce((n,d)=>e(this,void 0,void 0,function*(){const e=yield n;return void 0!==e?e:d.viewNode.nodeUri===i.viewNode.nodeUri?o:t(void 0,d)}),Promise.resolve(void 0)):void 0})}(void 0,this.rootNode)})}revealDocument(i,t){return e(this,void 0,void 0,function*(){const e=(yield Promise.resolve(this.provider.loadParentInfo(i,t))).uriChain.reverse(),n=yield this.revealDocumentInternal(e,this.rootNode);return void 0!==n&&this.emitter.fire({root:n.makeView(),oldNodes:[],newNodes:[],focusEvent:!0}),n})}revealByParents(i){return e(this,void 0,void 0,function*(){return this.revealDocumentInternal(i,this.rootNode)})}revealDocumentInternal(i,t){return e(this,void 0,void 0,function*(){if(0==i.length)return t;{const e=i[0];if(!!t.isExpanded()||(yield t.expand())){const n=(yield t.getChildren()).find(i=>i.viewNode.nodeUri===e);return n?this.revealDocumentInternal(i.slice(1),n):void 0}}})}findNodeByUri(i){return e(this,void 0,void 0,function*(){return function t(n,o){return e(this,void 0,void 0,function*(){return void 0!==n?n:o.viewNode.nodeUri===i?o:o.isExpanded()?(yield o.getChildren()).reduce((i,n)=>e(this,void 0,void 0,function*(){return i.then(e=>t(e,n))}),Promise.resolve(void 0)):void 0})}(void 0,this.rootNode)})}dispose(){this.emitter.dispose()}}exports.TreeModel=o;
"use strict";var e=this&&this.__awaiter||function(e,i,t,o){return new(t||(t=Promise))(function(n,d){function r(e){try{h(o.next(e))}catch(i){d(i)}}function s(e){try{h(o.throw(e))}catch(i){d(i)}}function h(e){var i;e.done?n(e.value):(i=e.value,i instanceof t?i:new t(function(e){e(i)})).then(r,s)}h((o=o.apply(e,i||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TreeModel=exports.Node=void 0;const i=require("vscode-jsonrpc"),t=require("./utils");class o{constructor(e,i,t,o,n){this.viewNode=e,this.level=i,this.provider=t,this.emitter=o,this.autoExpand=n,this.lastTouch=Date.now(),this.defunct=!1,this.expanded=!1}expandable(){return void 0!==this.viewNode.collapseState}isExpanded(){return this.expanded}expand(){return e(this,void 0,void 0,function*(){if(this.defunct)return!1;return function i(t,o,n){return e(this,void 0,void 0,function*(){n.viewNode.nodeUri&&n.provider.sendTreeNodeVisibilityNotification(n.viewNode.nodeUri,!1),n.expanded=!0;const e=yield n.getChildren();if(1===e.length&&e[0].expandable()&&n.autoExpand)return i(t,o,e[0]);{const e=yield t.collectVisibleNodes();return o===t.lastTouch&&!t.defunct&&(n.emitter.fire({root:t.makeView(),oldNodes:[t.makeView()],newNodes:e,focusEvent:!1}),!0)}})}(this,yield this.touch(),this)})}collapse(){return e(this,void 0,void 0,function*(){if(this.defunct)return!1;this.viewNode.nodeUri&&this.provider.sendTreeNodeVisibilityNotification(this.viewNode.nodeUri,!0);const e=yield this.touch(),i=yield this.collectVisibleNodes();return this.expanded=!1,e===this.lastTouch&&!this.defunct&&(this.emitter.fire({root:this.makeView(),oldNodes:i,newNodes:[this.makeView()],focusEvent:!1}),!0)})}refreshSubtree(i){return e(this,void 0,void 0,function*(){function o(e,i){return e.expanded===i.expanded&&e.level===i.level&&e.expandable===i.expandable&&e.underlying.nodeUri===i.underlying.nodeUri&&e.underlying.viewId===i.underlying.viewId&&e.underlying.label===i.underlying.label}const n=yield this.collectVisibleNodes();if(this.isExpanded()){const e=yield this.getChildren();yield Promise.resolve(e.map(e=>e.markAsDefunct()))}const d=yield function i(t,o,n){return e(this,void 0,void 0,function*(){return n.isExpanded()?(t.push(o),(yield n.getChildren()).reduce((t,n)=>e(this,void 0,void 0,function*(){return t.then(e=>i(e,n.viewNode.nodeUri?o.concat(n.viewNode.nodeUri):o,n))}),Promise.resolve(t))):t})}([],[],this);this.children=void 0,yield function i(o,n){return e(this,void 0,void 0,function*(){if(0!=n.length){const e=yield o.getChildren(),d=t.groupBy(n.filter(e=>0!=e.length),e=>e[0]);1===e.length&&o.autoExpand&&0===d.size&&e[0].expandable()&&e[0].viewNode.nodeUri&&d.set(e[0].viewNode.nodeUri,[[""]]),yield Promise.all(e.map(e=>{const t=e.viewNode.nodeUri?d.get(e.viewNode.nodeUri):void 0;return void 0===t?Promise.resolve():(e.expanded=!0,i(e,t.map(e=>e.slice(1))))}))}})}(this,d),void 0!==i&&(this.viewNode=i);const r=yield this.collectVisibleNodes(),s=function(e){let i=0;for(;i<e.oldNodes.length&&i<e.newNodes.length&&o(e.oldNodes[i],e.newNodes[i]);)i++;let t=0;for(;i+t<e.oldNodes.length&&i+t<e.newNodes.length&&o(e.oldNodes[e.oldNodes.length-t-1],e.newNodes[e.newNodes.length-t-1]);)t++;const n=0!==t?e.oldNodes.slice(i,-t):e.oldNodes.slice(i),d=0!==t?e.newNodes.slice(i,-t):e.newNodes.slice(i);return 0===n.length&&0===d.length?void 0:d.length>0?{root:d[0],oldNodes:n,newNodes:d,focusEvent:!1}:e}({root:this.makeView(),oldNodes:n,newNodes:r,focusEvent:!1});void 0!==s&&this.emitter.fire(s)})}getChildren(){if(void 0===this.children){const e=this.level,i=Promise.resolve(this.provider.loadNodeChildren(this.viewNode.nodeUri)).then(i=>i.map(i=>new o(i,e+1,this.provider,this.emitter,this.autoExpand)));return this.children=i}return this.children}height(){return e(this,void 0,void 0,function*(){if(this.isExpanded()){const e=yield this.getChildren();return(yield Promise.all(e.map(e=>e.height()))).reduce((e,i)=>e+i,1)}return 1})}collectVisibleNodes(){return e(this,void 0,void 0,function*(){return function i(t,o){return e(this,void 0,void 0,function*(){const e=t.concat(o.makeView());return o.isExpanded()?(yield o.getChildren()).reduce((e,t)=>e.then(e=>i(e,t)),Promise.resolve(e)):e})}([],this)})}touch(){return e(this,void 0,void 0,function*(){const e=this.lastTouch=Date.now();if(this.isExpanded()){const i=yield this.getChildren();return Promise.all(i.map(e=>e.touch())).then(i=>e)}return e})}markAsDefunct(){return e(this,void 0,void 0,function*(){if(this.defunct=!0,this.isExpanded()){const e=yield this.getChildren();yield Promise.all(e.map(e=>e.markAsDefunct()))}})}makeView(){return{underlying:this.viewNode,level:this.level,expandable:this.expandable(),expanded:this.isExpanded()}}}exports.Node=o;class n{constructor(e,t){this.provider=e,this.autoExpand=t,this.emitter=new i.Emitter,this.updateEvents=this.emitter.event,this.visible=!1;const n=e.viewId,d={viewId:n,label:n};this.rootNode=new o(d,0,e,this.emitter,this.autoExpand),e.updatedNodes(e=>{void 0!==e.nodeUri?this.findNodeByUri(e.nodeUri).then(i=>{if(void 0!==i)return i.refreshSubtree(e)}):this.rootNode.refreshSubtree(void 0)})}get viewId(){return this.provider.viewId}show(){if(!this.visible)return this.visible=!0,this.provider.sendTreeViewVisibilityNotification(!0)}hide(){if(this.visible)return this.visible=!1,this.provider.sendTreeViewVisibilityNotification(!1)}findNodeWithOffsetInternal(i,t){return e(this,void 0,void 0,function*(){if(0==t)return i;return(yield i.getChildren()).reduce((i,o)=>e(this,void 0,void 0,function*(){const e=yield i;return e.result?e:o.height().then(i=>e.height+i<=t?{height:e.height+i,result:void 0}:this.findNodeWithOffsetInternal(o,t-e.height).then(e=>({height:0,result:e})))}),Promise.resolve({height:1})).then(e=>e.result)})}findNodeWithOffset(i){return e(this,void 0,void 0,function*(){return this.findNodeWithOffsetInternal(this.rootNode,i)})}findNodeOffset(i){return e(this,void 0,void 0,function*(){return function t(o,n){return e(this,void 0,void 0,function*(){if(n.viewNode.nodeUri===i.underlying.nodeUri||o[1])return[o[0],!0];if(n.isExpanded()){const i=yield n.getChildren(),d=[o[0]+1,o[1]];return i.reduce((i,o)=>e(this,void 0,void 0,function*(){return i.then(e=>t(e,o))}),Promise.resolve(d))}return[o[0]+1,o[1]]})}([0,!1],this.rootNode).then(([e,i])=>i?e:void 0)})}findParentNode(i){return e(this,void 0,void 0,function*(){return function t(o,n){return e(this,void 0,void 0,function*(){return void 0!==o?o:n.isExpanded()?(yield n.getChildren()).reduce((o,d)=>e(this,void 0,void 0,function*(){const e=yield o;return void 0!==e?e:d.viewNode.nodeUri===i.viewNode.nodeUri?n:t(void 0,d)}),Promise.resolve(void 0)):void 0})}(void 0,this.rootNode)})}revealDocument(i,t){return e(this,void 0,void 0,function*(){const e=(yield Promise.resolve(this.provider.loadParentInfo(i,t))).uriChain.reverse(),o=yield this.revealDocumentInternal(e,this.rootNode);return void 0!==o&&this.emitter.fire({root:o.makeView(),oldNodes:[],newNodes:[],focusEvent:!0}),o})}revealByParents(i){return e(this,void 0,void 0,function*(){return this.revealDocumentInternal(i,this.rootNode)})}revealDocumentInternal(i,t){return e(this,void 0,void 0,function*(){if(0==i.length)return t;{const e=i[0];if(!!t.isExpanded()||(yield t.expand())){const o=(yield t.getChildren()).find(i=>i.viewNode.nodeUri===e);return o?this.revealDocumentInternal(i.slice(1),o):void 0}}})}findNodeByUri(i){return e(this,void 0,void 0,function*(){return function t(o,n){return e(this,void 0,void 0,function*(){return void 0!==o?o:n.viewNode.nodeUri===i?n:n.isExpanded()?(yield n.getChildren()).reduce((i,o)=>e(this,void 0,void 0,function*(){return i.then(e=>t(e,o))}),Promise.resolve(void 0)):void 0})}(void 0,this.rootNode)})}dispose(){this.emitter.dispose()}}exports.TreeModel=n;
},{"./utils":"Iw8s"}],"dDyQ":[function(require,module,exports) {
"use strict";var e=this&&this.__awaiter||function(e,i,t,o){return new(t||(t=Promise))(function(n,d){function s(e){try{l(o.next(e))}catch(i){d(i)}}function r(e){try{l(o.throw(e))}catch(i){d(i)}}function l(e){var i;e.done?n(e.value):(i=e.value,i instanceof t?i:new t(function(e){e(i)})).then(s,r)}l((o=o.apply(e,i||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const i=require("coc.nvim"),t=require("./utils");class o{constructor(e,i,t,o,n){this.nvim=e,this.config=i,this.buffer=t,this.model=o,this.logger=n,this.firstUpdate=!0,this.closed="▸",this.open="▾",this.eventQueue=Promise.resolve(1),this.highlightPlaceId=0}init(){return e(this,void 0,void 0,function*(){yield this.nvim.command(`silent file ${this.model.viewId}`);const e="nnoremap <buffer> <silent>";function i(e){return`:<C-u>CocCommand metals.tvp.view ${e} <CR>`}yield this.nvim.command(`${e} ${this.config.get("toggleNode")} ${i("ToggleNode")}`),yield this.nvim.command(`${e} ${this.config.get("forceChildrenReload")} ${i("ForceChildrenReload")}`),yield this.nvim.command(`${e} ${this.config.get("gotoParentNode")} ${i("ParentNode")}`),yield this.nvim.command(`${e} ${this.config.get("gotoFirstChild")} ${i("FirstSibling")}`),yield this.nvim.command(`${e} ${this.config.get("gotoLastChild")} ${i("LastSibling")}`),yield this.nvim.command(`${e} ${this.config.get("gotoPrevSibling")} ${i("PrevSibling")}`),yield this.nvim.command(`${e} ${this.config.get("gotoLastSibling")} ${i("NextSibling")}`),yield this.nvim.command(`${e} ${this.config.get("executeCommand")} ${i("ExecuteCommand")}`),yield this.nvim.command(`${e} ${this.config.get("executeCommandAndOpenSplit")} ${i("ExecuteCommandAndOpenSplit")}`),yield this.nvim.command(`${e} ${this.config.get("executeCommandAndOpenVSplit")} ${i("ExecuteCommandAndOpenVSplit")}`),yield this.nvim.command(`${e} ${this.config.get("executeCommandAndOpenTab")} ${i("ExecuteCommandAndOpenTab")}`),yield this.nvim.command(`au BufWinLeave <buffer> CocCommand metals.tvp.view Hidden ${this.model.viewId}`),yield this.nvim.command("setlocal nonumber norelativenumber nobuflisted nowrap noswapfile winfixwidth winfixheight"),yield this.nvim.command("setlocal statusline=%f buftype=nofile bufhidden=hide"),this.model.updateEvents(e=>this.handleModelUpdates(e));const t=this.config.get("initialViews");yield this.model.rootNode.expand();const o=null==t?void 0:t.find(e=>e.name===this.model.viewId);void 0!==o&&(yield Promise.all(o.expanded.map(e=>this.model.revealByParents(e.concat("")))),yield this.nvim.call("coc#util#jumpTo",[0,1]))})}get bufferId(){return this.buffer.id}restoreCursor(i,t,o){return e(this,void 0,void 0,function*(){yield i.setCursor([t,1]),yield i.setCursor([o,1])})}handleModelUpdates(o){let n;n=void 0===o.root.underlying.nodeUri?{root:o.newNodes[1],oldNodes:o.oldNodes.slice(1),newNodes:o.newNodes.slice(1),focusEvent:o.focusEvent}:o,this.eventQueue=this.eventQueue.then(o=>e(this,void 0,void 0,function*(){const o=void 0!==n.root?yield this.model.findNodeOffset(n.root):1;if(void 0===o)return;const d=o-1,s=yield this.nvim.tabpage,r=yield this.nvim.windows,l=yield s.windows,c=yield this.nvim.call("win_findbuf",this.bufferId),a=r.filter(e=>-1!=c.indexOf(e.id));if(n.focusEvent)void 0!==n.root&&this.logger.debug(`Focus event. Root: ${n.root.underlying.nodeUri}, offset: ${d}.`),yield t.sequence(a,i=>e(this,void 0,void 0,function*(){void 0!==l.find(e=>e.id===i.id)&&(yield this.nvim.call("win_gotoid",[i.id]),yield this.restoreCursor(i,1,d+1),yield this.nvim.command("redraw"))}));else{const o=n.newNodes.map(e=>e.underlying.nodeUri).join(",");void 0!==n.root&&this.logger.debug(`Update event. Root: ${n.root.underlying.nodeUri}, length: ${n.oldNodes.length}, payload: ${o}.`),yield this.modifyBuffer(()=>e(this,void 0,void 0,function*(){const o=yield t.sequence(a,t=>e(this,void 0,void 0,function*(){const e=yield t.cursor;if(i.workspace.isVim&&void 0!==l.find(e=>e.id===t.id)){const e=(yield this.nvim.call("win_execute",[t.id,'echo line(".").":".line("w0")'])).split(":").map(e=>parseInt(e,10));return{window:t,curLine:e[0],topLine:e[1]}}return{window:t,curLine:e[0],topLine:void 0}}));yield this.removeRows(d,n.oldNodes),yield this.insertRows(d,n.newNodes),yield t.sequence(o,({window:i,curLine:t,topLine:o})=>e(this,void 0,void 0,function*(){void 0!==o?(yield this.restoreCursor(i,o,t),yield this.nvim.call("win_execute",[i.id,"redraw"])):yield i.setCursor([t,1])})),this.firstUpdate&&(this.firstUpdate=!1,yield this.buffer.remove(n.newNodes.length,n.newNodes.length+1))}))}}))}removeRows(i,t){return e(this,void 0,void 0,function*(){yield this.buffer.remove(i,i+t.length)})}insertRows(i,t){return e(this,void 0,void 0,function*(){yield this.buffer.insert(this.makeRows(t),i),yield Promise.all(t.map((e,t)=>{let o;switch(e.underlying.icon){case"trait":o="TvpTrait";break;case"class":o="TvpClass";break;case"object":o="TvpObject";break;case"method":o="TvpMethod";break;case"val":o="TvpVal";break;case"command":case"sync":case"connect":case"cascade":case"cancel":case"clean":case"debug-stop":o="TvpCommand";break;default:o="TvpTopLevel"}const n=this.highlightPlaceId++,d=i+t;return this.logger.debug(`signplace id=${n} schema=${o} num=${d} uri=${e.underlying.nodeUri}`),this.buffer.addHighlight({hlGroup:o,line:d})}))})}toggleTreeViewNode(){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();void 0!==e&&e.expandable()&&(yield e.isExpanded()?e.collapse():e.expand())})}forceChildrenReload(){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();void 0!==e&&e.expandable()&&(e.isExpanded()||(yield e.expand()),e.refreshSubtree(void 0))})}gotoParentNode(){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();if(void 0===e)return;const i=yield this.model.findParentNode(e);if(void 0===i)return;const t=yield this.model.findNodeOffset(i.makeView());void 0!==t&&(yield this.nvim.call("coc#util#jumpTo",[t-1,1]))})}gotoEdgeNode(i){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();if(void 0===e)return;const t=yield this.model.findParentNode(e);if(void 0===t)return;const o=yield t.getChildren();if(o.length>0){const e=i?o[0]:o[o.length-1],t=yield this.model.findNodeOffset(e.makeView());if(void 0===t)return;yield this.nvim.call("coc#util#jumpTo",[t-1,1])}})}gotoNeighboringSibling(i){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();if(void 0===e)return;const t=yield this.model.findParentNode(e);if(void 0===t)return;const o=yield t.getChildren(),n=o.findIndex(i=>i.viewNode.nodeUri===e.viewNode.nodeUri);let d;if(void 0===(d=i&&n>0?o[n-1]:!i&&n+1<o.length?o[n+1]:void 0))return;const s=yield this.model.findNodeOffset(d.makeView());void 0!==s&&(yield this.nvim.call("coc#util#jumpTo",[s-1,1]))})}executeCommand(){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();if(void 0===e)return;const t=e.viewNode.command;return void 0!==t?void 0!==t.arguments?i.commands.executeCommand(t.command,...t.arguments):i.commands.executeCommand(t.command):void 0})}revealDocInTreeView(i,t){return e(this,void 0,void 0,function*(){return this.model.revealDocument(i,t)})}makeRows(e){return e.map(e=>{let i;return i=e.expandable?(e.expanded?this.open:this.closed)+" ":" "," ".repeat(e.level-1)+i+e.underlying.label})}nodeUnderCursor(){return e(this,void 0,void 0,function*(){const e=(yield this.nvim.eval("coc#util#cursor()"))[0];return this.model.findNodeWithOffset(e+1)})}modifyBuffer(i){return e(this,void 0,void 0,function*(){try{return yield this.buffer.setOption("readonly",!1),yield this.buffer.setOption("modifiable",!0),yield i()}finally{yield this.buffer.setOption("modifiable",!1),yield this.buffer.setOption("readonly",!0)}})}dispose(){this.nvim.command(`bd ${this.bufferId}`,!0)}}exports.TreeView=o;
"use strict";var e=this&&this.__awaiter||function(e,i,t,o){return new(t||(t=Promise))(function(n,d){function s(e){try{l(o.next(e))}catch(i){d(i)}}function r(e){try{l(o.throw(e))}catch(i){d(i)}}function l(e){var i;e.done?n(e.value):(i=e.value,i instanceof t?i:new t(function(e){e(i)})).then(s,r)}l((o=o.apply(e,i||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TreeView=void 0;const i=require("coc.nvim"),t=require("./utils");class o{constructor(e,i,t,o,n){this.nvim=e,this.config=i,this.buffer=t,this.model=o,this.logger=n,this.firstUpdate=!0,this.closed="▸",this.open="▾",this.eventQueue=Promise.resolve(1),this.highlightPlaceId=0}init(){return e(this,void 0,void 0,function*(){yield this.nvim.command(`silent file ${this.model.viewId}`);const e="nnoremap <buffer> <silent>";function i(e){return`:<C-u>CocCommand metals.tvp.view ${e} <CR>`}yield this.nvim.command(`${e} ${this.config.get("toggleNode")} ${i("ToggleNode")}`),yield this.nvim.command(`${e} ${this.config.get("forceChildrenReload")} ${i("ForceChildrenReload")}`),yield this.nvim.command(`${e} ${this.config.get("gotoParentNode")} ${i("ParentNode")}`),yield this.nvim.command(`${e} ${this.config.get("gotoFirstChild")} ${i("FirstSibling")}`),yield this.nvim.command(`${e} ${this.config.get("gotoLastChild")} ${i("LastSibling")}`),yield this.nvim.command(`${e} ${this.config.get("gotoPrevSibling")} ${i("PrevSibling")}`),yield this.nvim.command(`${e} ${this.config.get("gotoLastSibling")} ${i("NextSibling")}`),yield this.nvim.command(`${e} ${this.config.get("executeCommand")} ${i("ExecuteCommand")}`),yield this.nvim.command(`${e} ${this.config.get("executeCommandAndOpenSplit")} ${i("ExecuteCommandAndOpenSplit")}`),yield this.nvim.command(`${e} ${this.config.get("executeCommandAndOpenVSplit")} ${i("ExecuteCommandAndOpenVSplit")}`),yield this.nvim.command(`${e} ${this.config.get("executeCommandAndOpenTab")} ${i("ExecuteCommandAndOpenTab")}`),yield this.nvim.command(`au BufWinLeave <buffer> CocCommand metals.tvp.view Hidden ${this.model.viewId}`),yield this.nvim.command("setlocal nonumber norelativenumber nobuflisted nowrap noswapfile winfixwidth winfixheight"),yield this.nvim.command("setlocal statusline=%f buftype=nofile bufhidden=hide"),this.model.updateEvents(e=>this.handleModelUpdates(e));const t=this.config.get("initialViews");yield this.model.rootNode.expand();const o=null==t?void 0:t.find(e=>e.name===this.model.viewId);void 0!==o&&(yield Promise.all(o.expanded.map(e=>this.model.revealByParents(e.concat("")))),yield this.nvim.call("coc#util#jumpTo",[0,1]))})}get bufferId(){return this.buffer.id}restoreCursor(i,t,o){return e(this,void 0,void 0,function*(){yield i.setCursor([t,1]),yield i.setCursor([o,1])})}handleModelUpdates(o){let n;n=void 0===o.root.underlying.nodeUri?{root:o.newNodes[1],oldNodes:o.oldNodes.slice(1),newNodes:o.newNodes.slice(1),focusEvent:o.focusEvent}:o,this.eventQueue=this.eventQueue.then(o=>e(this,void 0,void 0,function*(){const o=void 0!==n.root?yield this.model.findNodeOffset(n.root):1;if(void 0===o)return;const d=o-1,s=yield this.nvim.tabpage,r=yield this.nvim.windows,l=yield s.windows,c=yield this.nvim.call("win_findbuf",this.bufferId),a=r.filter(e=>-1!=c.indexOf(e.id));if(n.focusEvent)void 0!==n.root&&this.logger.debug(`Focus event. Root: ${n.root.underlying.nodeUri}, offset: ${d}.`),yield t.sequence(a,i=>e(this,void 0,void 0,function*(){void 0!==l.find(e=>e.id===i.id)&&(yield this.nvim.call("win_gotoid",[i.id]),yield this.restoreCursor(i,1,d+1),yield this.nvim.command("redraw"))}));else{const o=n.newNodes.map(e=>e.underlying.nodeUri).join(",");void 0!==n.root&&this.logger.debug(`Update event. Root: ${n.root.underlying.nodeUri}, length: ${n.oldNodes.length}, payload: ${o}.`),yield this.modifyBuffer(()=>e(this,void 0,void 0,function*(){const o=yield t.sequence(a,t=>e(this,void 0,void 0,function*(){const e=yield t.cursor;if(i.workspace.isVim&&void 0!==l.find(e=>e.id===t.id)){const e=(yield this.nvim.call("win_execute",[t.id,'echo line(".").":".line("w0")'])).split(":").map(e=>parseInt(e,10));return{window:t,curLine:e[0],topLine:e[1]}}return{window:t,curLine:e[0],topLine:void 0}}));yield this.removeRows(d,n.oldNodes),yield this.insertRows(d,n.newNodes),yield t.sequence(o,({window:i,curLine:t,topLine:o})=>e(this,void 0,void 0,function*(){void 0!==o?(yield this.restoreCursor(i,o,t),yield this.nvim.call("win_execute",[i.id,"redraw"])):yield i.setCursor([t,1])})),this.firstUpdate&&(this.firstUpdate=!1,yield this.buffer.remove(n.newNodes.length,n.newNodes.length+1))}))}}))}removeRows(i,t){return e(this,void 0,void 0,function*(){yield this.buffer.remove(i,i+t.length)})}insertRows(i,t){return e(this,void 0,void 0,function*(){yield this.buffer.insert(this.makeRows(t),i),yield Promise.all(t.map((e,t)=>{let o;switch(e.underlying.icon){case"trait":o="TvpTrait";break;case"class":o="TvpClass";break;case"object":o="TvpObject";break;case"method":o="TvpMethod";break;case"val":o="TvpVal";break;case"command":case"sync":case"connect":case"cascade":case"cancel":case"clean":case"debug-stop":o="TvpCommand";break;default:o="TvpTopLevel"}const n=this.highlightPlaceId++,d=i+t;return this.logger.debug(`signplace id=${n} schema=${o} num=${d} uri=${e.underlying.nodeUri}`),this.buffer.addHighlight({hlGroup:o,line:d})}))})}toggleTreeViewNode(){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();void 0!==e&&e.expandable()&&(yield e.isExpanded()?e.collapse():e.expand())})}forceChildrenReload(){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();void 0!==e&&e.expandable()&&(e.isExpanded()||(yield e.expand()),e.refreshSubtree(void 0))})}gotoParentNode(){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();if(void 0===e)return;const i=yield this.model.findParentNode(e);if(void 0===i)return;const t=yield this.model.findNodeOffset(i.makeView());void 0!==t&&(yield this.nvim.call("coc#util#jumpTo",[t-1,1]))})}gotoEdgeNode(i){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();if(void 0===e)return;const t=yield this.model.findParentNode(e);if(void 0===t)return;const o=yield t.getChildren();if(o.length>0){const e=i?o[0]:o[o.length-1],t=yield this.model.findNodeOffset(e.makeView());if(void 0===t)return;yield this.nvim.call("coc#util#jumpTo",[t-1,1])}})}gotoNeighboringSibling(i){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();if(void 0===e)return;const t=yield this.model.findParentNode(e);if(void 0===t)return;const o=yield t.getChildren(),n=o.findIndex(i=>i.viewNode.nodeUri===e.viewNode.nodeUri);let d;if(void 0===(d=i&&n>0?o[n-1]:!i&&n+1<o.length?o[n+1]:void 0))return;const s=yield this.model.findNodeOffset(d.makeView());void 0!==s&&(yield this.nvim.call("coc#util#jumpTo",[s-1,1]))})}executeCommand(){return e(this,void 0,void 0,function*(){const e=yield this.nodeUnderCursor();if(void 0===e)return;const t=e.viewNode.command;return void 0!==t?void 0!==t.arguments?i.commands.executeCommand(t.command,...t.arguments):i.commands.executeCommand(t.command):void 0})}revealDocInTreeView(i,t){return e(this,void 0,void 0,function*(){return this.model.revealDocument(i,t)})}makeRows(e){return e.map(e=>{let i;return i=e.expandable?(e.expanded?this.open:this.closed)+" ":" "," ".repeat(e.level-1)+i+e.underlying.label})}nodeUnderCursor(){return e(this,void 0,void 0,function*(){const e=(yield this.nvim.eval("coc#util#cursor()"))[0];return this.model.findNodeWithOffset(e+1)})}modifyBuffer(i){return e(this,void 0,void 0,function*(){try{return yield this.buffer.setOption("readonly",!1),yield this.buffer.setOption("modifiable",!0),yield i()}finally{yield this.buffer.setOption("modifiable",!1),yield this.buffer.setOption("readonly",!0)}})}dispose(){this.nvim.command(`bd ${this.bufferId}`,!0)}}exports.TreeView=o;
},{"./utils":"Iw8s"}],"GgEX":[function(require,module,exports) {
"use strict";var e=this&&this.__awaiter||function(e,i,t,n){return new(t||(t=Promise))(function(o,r){function s(e){try{d(n.next(e))}catch(i){r(i)}}function l(e){try{d(n.throw(e))}catch(i){r(i)}}function d(e){var i;e.done?o(e.value):(i=e.value,i instanceof t?i:new t(function(e){e(i)})).then(s,l)}d((n=n.apply(e,i||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const i=require("coc.nvim"),t=require("./treeview"),n=require("./utils");var o;!function(e){e[e.Default=0]="Default",e[e.HSplit=1]="HSplit",e[e.VSplit=2]="VSplit",e[e.Tab=3]="Tab"}(o=exports.WindowProp||(exports.WindowProp={}));class r{constructor(e,t){this.nvim=e,this.logger=t,this.view2treemodel=new Map,this.view2treeview=new Map,this.lastWindowProp=[o.Default,0],this.config=i.workspace.configurations.getConfiguration("metals.treeviews"),this.nvim.command("highlight default link TvpClass Constant",!0),this.nvim.command("highlight default link TvpObject PreProc",!0),this.nvim.command("highlight default link TvpTrait Statement",!0),this.nvim.command("highlight default link TvpMethod Identifier",!0),this.nvim.command("highlight default link TvpVal Type",!0),this.nvim.command("highlight default link TvpTopLevel MsgArea",!0),this.nvim.command("highlight default link TvpCommand Directory",!0),this.nvim.command("sign define TvpClass linehl=TvpClass",!0),this.nvim.command("sign define TvpObject linehl=TvpObject",!0),this.nvim.command("sign define TvpTrait linehl=TvpTrait",!0),this.nvim.command("sign define TvpMethod linehl=TvpMethod",!0),this.nvim.command("sign define TvpVal linehl=TvpVal",!0),this.nvim.command("sign define TvpVal linehl=TvpTopLevel",!0),this.nvim.command("sign define TvpVal linehl=TvpCommand",!0)}addTreeModel(e){this.view2treemodel.set(e.viewId,e)}disposeTreeModel(e){this.view2treemodel.delete(e)}allTreeViews(){return[...this.view2treemodel.keys()]}toggleAllTrees(){var i;return e(this,void 0,void 0,function*(){const t=this.allTreeViews();if(!this.checkTreeViewAvailability(t))return;const[o,r]=yield this.getOpenWindows(t);if(r.length>0)yield Promise.all(r.map(({window:e})=>e.close(!0))),t.forEach(e=>o.setVar(e,0,!1));else{const r=null!==(i=this.config.get("initialViews"))&&void 0!==i?i:[],s=yield n.sequence(t.filter(e=>void 0!==r.find(i=>i.name===e)).sort(this.viewsComparator(r)),(i,t)=>e(this,void 0,void 0,function*(){0==t?yield this.makeTreeViewPanel(i):yield this.nvim.command(`new ${i}`);const e=yield this.assignOrCreateTreeView(o,i);return{name:i,window:e}}));yield this.alignWindows(s,r)}})}toggleTreeView(i){var t;return e(this,void 0,void 0,function*(){const e=this.allTreeViews();if(!this.checkTreeViewAvailability(e))return;if(!this.checkTreeViewExistence(e,i))return;const[n,o]=yield this.toggleTreeViewInternal(e,i,!1),r=null!==(t=this.config.get("initialViews"))&&void 0!==t?t:[];return n?this.alignWindows(o,r):void 0})}toggleTreeViewInternal(i,t,n){return e(this,void 0,void 0,function*(){const[e,o]=yield this.getOpenWindows(i),r=o.find(({name:e})=>e==t);if(void 0!==r)return n||(yield r.window.close(!0),yield e.setVar(t,0,!1)),[!1,[]];if(0!=o.length){const i=o[0].window;yield this.nvim.call("win_gotoid",i.id),yield this.nvim.command(`new ${t}`);const n=yield this.assignOrCreateTreeView(e,t);return[!0,o.concat({name:t,window:n})]}{yield this.makeTreeViewPanel(t);const i=yield this.assignOrCreateTreeView(e,t);return[!0,o.concat({name:t,window:i})]}})}revealDocInTreeView(i,t,n){var o;return e(this,void 0,void 0,function*(){const e=this.allTreeViews();if(!this.checkTreeViewAvailability(e))return;if(!this.checkTreeViewExistence(e,i))return;const[r,s]=yield this.toggleTreeViewInternal(e,i,!0),l=null!==(o=this.config.get("initialViews"))&&void 0!==o?o:[];r&&(yield this.alignWindows(s,l));const d=this.view2treeview.get(i);return null==d?void 0:d.revealDocInTreeView(t,n).then(()=>void 0)})}makeTreeViewPanel(e){const i=this.config.get("initialWidth"),t="right"==this.config.get("alignment")?"botright":"topleft";return this.nvim.command(`silent ${t} vertical ${i} new ${e}`)}getOpenWindows(i){return e(this,void 0,void 0,function*(){const t=yield this.nvim.tabpage,n=yield this.nvim.windows,o=yield Promise.all(i.map(i=>e(this,void 0,void 0,function*(){const e=yield t.getVar(i);return{name:i,window:n.find(i=>i.id==e)}}))).then(e=>e.filter(e=>void 0!==e.window));return[t,o]})}assignOrCreateTreeView(i,n){return e(this,void 0,void 0,function*(){const e=this.view2treeview.get(n),o=this.view2treemodel.get(n);if(null==o||o.show(),void 0!==e)yield this.nvim.call("coc#util#jumpTo",[0,1]);else if(void 0!==o){const e=yield this.nvim.buffer,i=new t.TreeView(this.nvim,this.config,e,o,this.logger);yield i.init(),this.view2treeview.set(n,i)}const r=yield this.nvim.window;yield i.setVar(n,r.id,!1);const s=yield i.getVar("alltreeviews");return null===s?yield i.setVar("alltreeviews",n,!1):-1==s.indexOf(n)&&(yield i.setVar("alltreeviews",`${s},${n}`,!1)),r})}checkTreeViewAvailability(e){return void 0!==e&&0!=e.length||(i.workspace.showMessage("Information about Tree Views is not yet loaded. Please try a bit later.","warning"),!1)}checkTreeViewExistence(e,t){return-1!=e.indexOf(t)||(i.workspace.showMessage(`Unknown view name ${t}. Available values: ${e.join(", ")}`,"error"),!1)}alignWindows(i,t){return e(this,void 0,void 0,function*(){const e=(yield Promise.all(i.map(({window:e})=>e.height))).reduce((e,i)=>e+i,0),n=i.map(({name:e,window:i})=>{const n=t.find(i=>i.name===e);let o;return[i,o=void 0===n?0!=t.length?t.reduce((e,i)=>Math.min(e,i.size),Number.MAX_VALUE):10:n.size]}),o=n.map(([e,i])=>i).reduce((e,i)=>e+i);yield Promise.all(n.map(([i,t])=>i.setHeight(Math.floor(t*e/o))))})}toggleTreeViewNode(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.toggleTreeViewNode())})}forceChildrenReload(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.forceChildrenReload())})}gotoParentNode(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoParentNode())})}gotoFirstNode(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoEdgeNode(!0))})}gotoLastNode(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoEdgeNode(!1))})}gotoPrevSibling(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoNeighboringSibling(!0))})}gotoNextSibling(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoNeighboringSibling(!1))})}executeCommand(i){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(t=>e(this,void 0,void 0,function*(){this.lastWindowProp=[i,Date.now()],yield t.executeCommand()}))})}doOnActiveTree(i){return e(this,void 0,void 0,function*(){const e=yield this.nvim.eval('bufnr("%")'),t=[...this.view2treeview.values()].find(i=>i.bufferId==e);return void 0===t?this.nvim.command("echo 'no active tree view'"):i(t)})}viewsComparator(e){return(i,t)=>{const n=e.findIndex(e=>e.name===i),o=e.findIndex(e=>e.name===t);return-1==n&&-1==o?0:-1==n?1:-1==o?-1:o-n}}prepareWindowForGoto(){return e(this,void 0,void 0,function*(){const e=Date.now()-this.lastWindowProp[1]<1e3?this.lastWindowProp[0]:o.Default;if(e===o.Tab)yield this.nvim.command("tabnew");else{const i=yield this.nvim.tabpage,t=(yield i.getVar("alltreeviews"))||"",n=yield Promise.all(t.split(",").map(e=>i.getVar(e))),r=yield i.windows,s=r.map(e=>e.id).sort().find(e=>void 0===n.find(i=>e===i));if(void 0===s){const e=this.config.get("initialWidth"),i="right"==this.config.get("alignment")?"topleft":"botright";if(r.length>0){const t=yield r[0].width;yield this.nvim.command(`silent ${i} vertical new`),yield this.nvim.command(`silent vertical resize ${t-e}`)}else yield this.nvim.command(`silent ${i} vertical new`)}else yield this.nvim.call("win_gotoid",s),e===o.HSplit?yield this.nvim.command("split"):e===o.VSplit&&(yield this.nvim.command("vsplit"))}})}viewHidden(e){const i=this.view2treemodel.get(e);void 0!==i&&i.hide()}dispose(){this.view2treeview.forEach(e=>e.dispose())}}exports.TreeViewsManager=r;
"use strict";var e=this&&this.__awaiter||function(e,i,t,n){return new(t||(t=Promise))(function(o,r){function s(e){try{l(n.next(e))}catch(i){r(i)}}function d(e){try{l(n.throw(e))}catch(i){r(i)}}function l(e){var i;e.done?o(e.value):(i=e.value,i instanceof t?i:new t(function(e){e(i)})).then(s,d)}l((n=n.apply(e,i||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TreeViewsManager=exports.WindowProp=void 0;const i=require("coc.nvim"),t=require("./treeview"),n=require("./utils");var o;!function(e){e[e.Default=0]="Default",e[e.HSplit=1]="HSplit",e[e.VSplit=2]="VSplit",e[e.Tab=3]="Tab"}(o=exports.WindowProp||(exports.WindowProp={}));class r{constructor(e,t){this.nvim=e,this.logger=t,this.view2treemodel=new Map,this.view2treeview=new Map,this.lastWindowProp=[o.Default,0],this.config=i.workspace.configurations.getConfiguration("metals.treeviews"),this.nvim.command("highlight default link TvpClass Constant",!0),this.nvim.command("highlight default link TvpObject PreProc",!0),this.nvim.command("highlight default link TvpTrait Statement",!0),this.nvim.command("highlight default link TvpMethod Identifier",!0),this.nvim.command("highlight default link TvpVal Type",!0),this.nvim.command("highlight default link TvpTopLevel MsgArea",!0),this.nvim.command("highlight default link TvpCommand Directory",!0),this.nvim.command("sign define TvpClass linehl=TvpClass",!0),this.nvim.command("sign define TvpObject linehl=TvpObject",!0),this.nvim.command("sign define TvpTrait linehl=TvpTrait",!0),this.nvim.command("sign define TvpMethod linehl=TvpMethod",!0),this.nvim.command("sign define TvpVal linehl=TvpVal",!0),this.nvim.command("sign define TvpVal linehl=TvpTopLevel",!0),this.nvim.command("sign define TvpVal linehl=TvpCommand",!0)}addTreeModel(e){this.view2treemodel.set(e.viewId,e)}disposeTreeModel(e){this.view2treemodel.delete(e)}allTreeViews(){return[...this.view2treemodel.keys()]}toggleAllTrees(){var i;return e(this,void 0,void 0,function*(){const t=this.allTreeViews();if(!this.checkTreeViewAvailability(t))return;const[o,r]=yield this.getOpenWindows(t);if(r.length>0)yield Promise.all(r.map(({window:e})=>e.close(!0))),t.forEach(e=>o.setVar(e,0,!1));else{const r=null!==(i=this.config.get("initialViews"))&&void 0!==i?i:[],s=yield n.sequence(t.filter(e=>void 0!==r.find(i=>i.name===e)).sort(this.viewsComparator(r)),(i,t)=>e(this,void 0,void 0,function*(){0==t?yield this.makeTreeViewPanel(i):yield this.nvim.command(`new ${i}`);const e=yield this.assignOrCreateTreeView(o,i);return{name:i,window:e}}));yield this.alignWindows(s,r)}})}toggleTreeView(i){var t;return e(this,void 0,void 0,function*(){const e=this.allTreeViews();if(!this.checkTreeViewAvailability(e))return;if(!this.checkTreeViewExistence(e,i))return;const[n,o]=yield this.toggleTreeViewInternal(e,i,!1),r=null!==(t=this.config.get("initialViews"))&&void 0!==t?t:[];return n?this.alignWindows(o,r):void 0})}toggleTreeViewInternal(i,t,n){return e(this,void 0,void 0,function*(){const[e,o]=yield this.getOpenWindows(i),r=o.find(({name:e})=>e==t);if(void 0!==r)return n||(yield r.window.close(!0),yield e.setVar(t,0,!1)),[!1,[]];if(0!=o.length){const i=o[0].window;yield this.nvim.call("win_gotoid",i.id),yield this.nvim.command(`new ${t}`);const n=yield this.assignOrCreateTreeView(e,t);return[!0,o.concat({name:t,window:n})]}{yield this.makeTreeViewPanel(t);const i=yield this.assignOrCreateTreeView(e,t);return[!0,o.concat({name:t,window:i})]}})}revealDocInTreeView(i,t,n){var o;return e(this,void 0,void 0,function*(){const e=this.allTreeViews();if(!this.checkTreeViewAvailability(e))return;if(!this.checkTreeViewExistence(e,i))return;const[r,s]=yield this.toggleTreeViewInternal(e,i,!0),d=null!==(o=this.config.get("initialViews"))&&void 0!==o?o:[];r&&(yield this.alignWindows(s,d));const l=this.view2treeview.get(i);return null==l?void 0:l.revealDocInTreeView(t,n).then(()=>void 0)})}makeTreeViewPanel(e){const i=this.config.get("initialWidth"),t="right"==this.config.get("alignment")?"botright":"topleft";return this.nvim.command(`silent ${t} vertical ${i} new ${e}`)}getOpenWindows(i){return e(this,void 0,void 0,function*(){const t=yield this.nvim.tabpage,n=yield this.nvim.windows,o=yield Promise.all(i.map(i=>e(this,void 0,void 0,function*(){const e=yield t.getVar(i);return{name:i,window:n.find(i=>i.id==e)}}))).then(e=>e.filter(e=>void 0!==e.window));return[t,o]})}assignOrCreateTreeView(i,n){return e(this,void 0,void 0,function*(){const e=this.view2treeview.get(n),o=this.view2treemodel.get(n);if(null==o||o.show(),void 0!==e)yield this.nvim.call("coc#util#jumpTo",[0,1]);else if(void 0!==o){const e=yield this.nvim.buffer,i=new t.TreeView(this.nvim,this.config,e,o,this.logger);yield i.init(),this.view2treeview.set(n,i)}const r=yield this.nvim.window;yield i.setVar(n,r.id,!1);const s=yield i.getVar("alltreeviews");return null===s?yield i.setVar("alltreeviews",n,!1):-1==s.indexOf(n)&&(yield i.setVar("alltreeviews",`${s},${n}`,!1)),r})}checkTreeViewAvailability(e){return void 0!==e&&0!=e.length||(i.workspace.showMessage("Information about Tree Views is not yet loaded. Please try a bit later.","warning"),!1)}checkTreeViewExistence(e,t){return-1!=e.indexOf(t)||(i.workspace.showMessage(`Unknown view name ${t}. Available values: ${e.join(", ")}`,"error"),!1)}alignWindows(i,t){return e(this,void 0,void 0,function*(){const e=(yield Promise.all(i.map(({window:e})=>e.height))).reduce((e,i)=>e+i,0),n=i.map(({name:e,window:i})=>{const n=t.find(i=>i.name===e);let o;return[i,o=void 0===n?0!=t.length?t.reduce((e,i)=>Math.min(e,i.size),Number.MAX_VALUE):10:n.size]}),o=n.map(([e,i])=>i).reduce((e,i)=>e+i);yield Promise.all(n.map(([i,t])=>i.setHeight(Math.floor(t*e/o))))})}toggleTreeViewNode(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.toggleTreeViewNode())})}forceChildrenReload(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.forceChildrenReload())})}gotoParentNode(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoParentNode())})}gotoFirstNode(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoEdgeNode(!0))})}gotoLastNode(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoEdgeNode(!1))})}gotoPrevSibling(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoNeighboringSibling(!0))})}gotoNextSibling(){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(e=>e.gotoNeighboringSibling(!1))})}executeCommand(i){return e(this,void 0,void 0,function*(){return this.doOnActiveTree(t=>e(this,void 0,void 0,function*(){this.lastWindowProp=[i,Date.now()],yield t.executeCommand()}))})}doOnActiveTree(i){return e(this,void 0,void 0,function*(){const e=yield this.nvim.eval('bufnr("%")'),t=[...this.view2treeview.values()].find(i=>i.bufferId==e);return void 0===t?this.nvim.command("echo 'no active tree view'"):i(t)})}viewsComparator(e){return(i,t)=>{const n=e.findIndex(e=>e.name===i),o=e.findIndex(e=>e.name===t);return-1==n&&-1==o?0:-1==n?1:-1==o?-1:o-n}}prepareWindowForGoto(){return e(this,void 0,void 0,function*(){const e=Date.now()-this.lastWindowProp[1]<1e3?this.lastWindowProp[0]:o.Default;if(e===o.Tab)yield this.nvim.command("tabnew");else{const i=yield this.nvim.tabpage,t=(yield i.getVar("alltreeviews"))||"",n=yield Promise.all(t.split(",").map(e=>i.getVar(e))),r=yield i.windows,s=r.map(e=>e.id).sort().find(e=>void 0===n.find(i=>e===i));if(void 0===s){const e=this.config.get("initialWidth"),i="right"==this.config.get("alignment")?"topleft":"botright";if(r.length>0){const t=yield r[0].width;yield this.nvim.command(`silent ${i} vertical new`),yield this.nvim.command(`silent vertical resize ${t-e}`)}else yield this.nvim.command(`silent ${i} vertical new`)}else yield this.nvim.call("win_gotoid",s),e===o.HSplit?yield this.nvim.command("split"):e===o.VSplit&&(yield this.nvim.command("vsplit"))}})}viewHidden(e){const i=this.view2treemodel.get(e);void 0!==i&&i.hide()}dispose(){this.view2treeview.forEach(e=>e.dispose())}}exports.TreeViewsManager=r;
},{"./treeview":"dDyQ","./utils":"Iw8s"}],"bAI2":[function(require,module,exports) {
"use strict";var e=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(i,r){function s(e){try{d(o.next(e))}catch(t){r(t)}}function a(e){try{d(o.throw(e))}catch(t){r(t)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}d((o=o.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const t=require("coc.nvim"),n=require("./model"),o=require("./treeviews"),i=[{title:"Expand/Collapse tree node",action:"ToggleNode"},{title:"Force the reloading of the children of this node.",action:"ForceChildrenReload"},{title:"Go to parent node",action:"ParentNode"},{title:"Go to first child",action:"FirstSibling"},{title:"Go to last child",action:"LastSibling"},{title:"Go to prev sibling",action:"PrevSibling"},{title:"Go to next sibling",action:"NextSibling"},{title:"Execute command for node",action:"ExecuteCommand"},{title:"Execute command and open node under cursor in horizontal split",action:"ExecuteCommandAndOpenSplit"},{title:"Execute command and open node under cursor in vertical split",action:"ExecuteCommandAndOpenVSplit"},{title:"Execute command and open node under cursor in tab",action:"ExecuteCommandAndOpenTab"}];class r{constructor(r,s){this.treeViewsManager=s,this.treeModels=new Map,this.listeners=[],this.listeners.push(r.providerEvents()(e=>{const t=new n.TreeModel(e,!0);this.treeModels.set(e.viewId,t),s.addTreeModel(t)})),this.listeners.push(t.commands.registerCommand("metals.tvp",e=>{void 0===e?s.toggleAllTrees():s.toggleTreeView(e)}));const a=(e,n)=>{switch(e){case"ToggleNode":return s.toggleTreeViewNode();case"ForceChildrenReload":return s.forceChildrenReload();case"ParentNode":return s.gotoParentNode();case"FirstSibling":return s.gotoFirstNode();case"LastSibling":return s.gotoLastNode();case"PrevSibling":return s.gotoPrevSibling();case"NextSibling":return s.gotoNextSibling();case"ExecuteCommand":return s.executeCommand(o.WindowProp.Default);case"ExecuteCommandAndOpenSplit":return s.executeCommand(o.WindowProp.HSplit);case"ExecuteCommandAndOpenVSplit":return s.executeCommand(o.WindowProp.VSplit);case"ExecuteCommandAndOpenTab":return s.executeCommand(o.WindowProp.Tab);case"Hidden":return n&&s.viewHidden(n);default:t.workspace.showQuickpick(i.map(e=>e.title)).then(e=>{-1!==e&&a(i[e].action,void 0)})}};this.listeners.push(t.commands.registerCommand("metals.tvp.view",a)),this.listeners.push(t.commands.registerCommand("metals.revealInTreeView",n=>e(this,void 0,void 0,function*(){const{document:e,position:o}=yield t.workspace.getCurrentState();return this.treeViewsManager.revealDocInTreeView(n,e,o)})))}dispose(){this.treeModels.forEach(e=>e.dispose()),this.treeModels.clear(),this.listeners.forEach(e=>e.dispose())}}exports.TreeViewController=r;
"use strict";var e=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(i,r){function s(e){try{d(o.next(e))}catch(t){r(t)}}function a(e){try{d(o.throw(e))}catch(t){r(t)}}function d(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}d((o=o.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TreeViewController=void 0;const t=require("coc.nvim"),n=require("./model"),o=require("./treeviews"),i=[{title:"Expand/Collapse tree node",action:"ToggleNode"},{title:"Force the reloading of the children of this node.",action:"ForceChildrenReload"},{title:"Go to parent node",action:"ParentNode"},{title:"Go to first child",action:"FirstSibling"},{title:"Go to last child",action:"LastSibling"},{title:"Go to prev sibling",action:"PrevSibling"},{title:"Go to next sibling",action:"NextSibling"},{title:"Execute command for node",action:"ExecuteCommand"},{title:"Execute command and open node under cursor in horizontal split",action:"ExecuteCommandAndOpenSplit"},{title:"Execute command and open node under cursor in vertical split",action:"ExecuteCommandAndOpenVSplit"},{title:"Execute command and open node under cursor in tab",action:"ExecuteCommandAndOpenTab"}];class r{constructor(r,s){this.treeViewsManager=s,this.treeModels=new Map,this.listeners=[],this.listeners.push(r.providerEvents()(e=>{const t=new n.TreeModel(e,!0);this.treeModels.set(e.viewId,t),s.addTreeModel(t)})),this.listeners.push(t.commands.registerCommand("metals.tvp",e=>{void 0===e?s.toggleAllTrees():s.toggleTreeView(e)}));const a=(e,n)=>{switch(e){case"ToggleNode":return s.toggleTreeViewNode();case"ForceChildrenReload":return s.forceChildrenReload();case"ParentNode":return s.gotoParentNode();case"FirstSibling":return s.gotoFirstNode();case"LastSibling":return s.gotoLastNode();case"PrevSibling":return s.gotoPrevSibling();case"NextSibling":return s.gotoNextSibling();case"ExecuteCommand":return s.executeCommand(o.WindowProp.Default);case"ExecuteCommandAndOpenSplit":return s.executeCommand(o.WindowProp.HSplit);case"ExecuteCommandAndOpenVSplit":return s.executeCommand(o.WindowProp.VSplit);case"ExecuteCommandAndOpenTab":return s.executeCommand(o.WindowProp.Tab);case"Hidden":return n&&s.viewHidden(n);default:t.workspace.showQuickpick(i.map(e=>e.title)).then(e=>{-1!==e&&a(i[e].action,void 0)})}};this.listeners.push(t.commands.registerCommand("metals.tvp.view",a)),this.listeners.push(t.commands.registerCommand("metals.revealInTreeView",n=>e(this,void 0,void 0,function*(){const{document:e,position:o}=yield t.workspace.getCurrentState();return this.treeViewsManager.revealDocInTreeView(n,e,o)})))}dispose(){this.treeModels.forEach(e=>e.dispose()),this.treeModels.clear(),this.listeners.forEach(e=>e.dispose())}}exports.TreeViewController=r;
},{"./model":"Vq4m","./treeviews":"GgEX"}],"Y104":[function(require,module,exports) {
"use strict";var e=this&&this.__awaiter||function(e,t,i,s){return new(i||(i=Promise))(function(r,o){function n(e){try{d(s.next(e))}catch(t){o(t)}}function a(e){try{d(s.throw(e))}catch(t){o(t)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(n,a)}d((s=s.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const t=require("coc.nvim"),i=require("metals-languageclient"),s=require("vscode-languageserver-protocol");class r{constructor(e){this._client=e,this.requestType=new s.RequestType("metals/treeView"),this.providerEmitter=new s.Emitter,this.viewUpdaters=new Map,this.mbGotoCommandDisposable=void 0}get messages(){return this.requestType}fillClientCapabilities(e){null==e.experimental&&(e.experimental={}),e.experimental.treeViewProvider=!0}initialize(r){if(!r.experimental.treeViewProvider)return;const o=this._client;o.onNotification(i.MetalsTreeViewDidChange.type,e=>{e.nodes.forEach(e=>{const t=e.viewId,r=this.viewUpdaters.get(t);if(void 0===r){const e=new s.Emitter,r={viewId:t,updatedNodes:e.event,loadNodeChildren:e=>{const s=o.sendRequest(i.MetalsTreeViewChildren.type,{viewId:t,nodeUri:e}).then(e=>e.nodes);return Promise.resolve(s)},loadParentInfo:(e,t)=>{const s={line:t.line+1,character:t.character},r={textDocument:{uri:e.uri},position:s};return Promise.resolve(o.sendRequest(i.MetalsTreeViewReveal.type,r))},sendTreeViewVisibilityNotification:e=>{o.sendNotification(i.MetalsTreeViewVisibilityDidChange.type,{viewId:t,visible:e})},sendTreeNodeVisibilityNotification:(e,s)=>{o.sendNotification(i.MetalsTreeViewNodeCollapseDidChange.type,{viewId:t,nodeUri:e,collapsed:s})}};this.providerEmitter.fire(r),this.viewUpdaters.set(t,e)}else r.fire(e)})}),this.mbGotoCommandDisposable=t.commands.registerCommand("metals.goto",(...t)=>e(this,void 0,void 0,function*(){let e={command:"metals.goto",arguments:t};return o.sendRequest(s.ExecuteCommandRequest.type,e).then(void 0,e=>{o.logFailedRequest(s.ExecuteCommandRequest.type,e)})}),null,!0)}providerEvents(){return this.providerEmitter.event}register(e,t){}unregister(e){}dispose(){this.providerEmitter.dispose(),this.viewUpdaters.forEach(e=>e.dispose()),void 0!==this.mbGotoCommandDisposable&&this.mbGotoCommandDisposable.dispose()}}exports.TreeViewFeature=r;
"use strict";var e=this&&this.__awaiter||function(e,t,i,s){return new(i||(i=Promise))(function(o,r){function n(e){try{d(s.next(e))}catch(t){r(t)}}function a(e){try{d(s.throw(e))}catch(t){r(t)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(n,a)}d((s=s.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.TreeViewFeature=void 0;const t=require("coc.nvim"),i=require("metals-languageclient"),s=require("vscode-languageserver-protocol");class o{constructor(e){this._client=e,this.requestType=new s.RequestType("metals/treeView"),this.providerEmitter=new s.Emitter,this.viewUpdaters=new Map,this.mbGotoCommandDisposable=void 0}get messages(){return this.requestType}fillClientCapabilities(){}initialize(){const o=this._client;o.onNotification(i.MetalsTreeViewDidChange.type,e=>{e.nodes.forEach(e=>{const t=e.viewId,r=this.viewUpdaters.get(t);if(void 0===r){const e=new s.Emitter,r={viewId:t,updatedNodes:e.event,loadNodeChildren:e=>{const s=o.sendRequest(i.MetalsTreeViewChildren.type,{viewId:t,nodeUri:e}).then(e=>e.nodes);return Promise.resolve(s)},loadParentInfo:(e,t)=>{const s={line:t.line+1,character:t.character},r={textDocument:{uri:e.uri},position:s};return Promise.resolve(o.sendRequest(i.MetalsTreeViewReveal.type,r))},sendTreeViewVisibilityNotification:e=>{o.sendNotification(i.MetalsTreeViewVisibilityDidChange.type,{viewId:t,visible:e})},sendTreeNodeVisibilityNotification:(e,s)=>{o.sendNotification(i.MetalsTreeViewNodeCollapseDidChange.type,{viewId:t,nodeUri:e,collapsed:s})}};this.providerEmitter.fire(r),this.viewUpdaters.set(t,e)}else r.fire(e)})}),this.mbGotoCommandDisposable=t.commands.registerCommand("metals.goto",(...t)=>e(this,void 0,void 0,function*(){let e={command:"metals.goto",arguments:t};return o.sendRequest(s.ExecuteCommandRequest.type,e).then(void 0,e=>{o.logFailedRequest(s.ExecuteCommandRequest.type,e)})}),null,!0)}providerEvents(){return this.providerEmitter.event}register(e,t){}unregister(e){}dispose(){this.providerEmitter.dispose(),this.viewUpdaters.forEach(e=>e.dispose()),void 0!==this.mbGotoCommandDisposable&&this.mbGotoCommandDisposable.dispose()}}exports.TreeViewFeature=o;
},{}],"UnXq":[function(require,module,exports) {
"use strict";var e=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(o[n]=e[n]);return o.default=e,o};Object.defineProperty(exports,"__esModule",{value:!0});const o=require("coc.nvim"),n=e(require("metals-languageclient")),r=require("metals-languageclient"),s=require("./commands");function t(e,o,n){return r.downloadProgress({download:o,onProgress:o=>{n.text=e,n.show()},onError:n.dispose,onComplete:n.dispose})}function i(e){n.checkServerVersion({config:e,updateConfig:({configSection:o,latestServerVersion:n})=>{e.update(o,n,!0)},onOutdated:({message:e,upgradeChoice:n,openSettingsChoice:r,dismissChoice:t,upgrade:i})=>{o.workspace.showQuickpick([n,r,t],e).then(e=>{0===e?i():1===e&&o.workspace.nvim.command(s.Commands.OPEN_COC_CONFIG,!0)})}})}function a(){const e=o.workspace.documents.find(e=>e.uri.endsWith("info"));e?o.workspace.nvim.command(`bd ${e.bufnr}`):o.workspace.nvim.command(s.Commands.OPEN_LOGS)}function c(e){return new Promise(o=>{setTimeout(o,e)})}function u(){n.detectLaunchConfigurationChanges(o.workspace,({message:e,reloadWindowChoice:n,dismissChoice:r})=>o.workspace.showQuickpick([n,r],e).then(e=>{0===e&&o.workspace.nvim.command(s.Commands.RESTART_COC,!0)}),["statusBarEnabled","bloopVersion","enable"])}exports.trackDownloadProgress=t,exports.checkServerVersion=i,exports.toggleLogs=a,exports.wait=c,exports.detectLaunchConfigurationChanges=u;
},{"./commands":"eojW"}],"n7Rg":[function(require,module,exports) {
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,o,t,n){void 0===n&&(n=t),Object.defineProperty(e,n,{enumerable:!0,get:function(){return o[t]}})}:function(e,o,t,n){void 0===n&&(n=t),e[n]=o[t]}),o=this&&this.__setModuleDefault||(Object.create?function(e,o){Object.defineProperty(e,"default",{enumerable:!0,value:o})}:function(e,o){e.default=o}),t=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var r in t)"default"!==r&&Object.hasOwnProperty.call(t,r)&&e(n,t,r);return o(n,t),n};Object.defineProperty(exports,"__esModule",{value:!0}),exports.detectLaunchConfigurationChanges=exports.wait=exports.toggleLogs=exports.checkServerVersion=exports.trackDownloadProgress=void 0;const n=require("coc.nvim"),r=t(require("metals-languageclient")),s=require("metals-languageclient"),i=require("./commands");function a(e,o,t){return s.downloadProgress({download:o,onProgress:o=>{t.text=e,t.show()},onError:t.dispose,onComplete:t.dispose})}function c(e){r.checkServerVersion({config:e,updateConfig:({configSection:o,latestServerVersion:t})=>{e.update(o,t,!0)},onOutdated:({message:e,upgradeChoice:o,openSettingsChoice:t,dismissChoice:r,upgrade:s})=>{n.workspace.showQuickpick([o,t,r],e).then(e=>{0===e?s():1===e&&n.workspace.nvim.command(i.Commands.OPEN_COC_CONFIG,!0)})}})}function u(){const e=n.workspace.documents.find(e=>"output:/metals"==e.uri);e?n.workspace.nvim.command(`bd ${e.bufnr}`):n.workspace.nvim.command(i.Commands.OPEN_LOGS)}function d(e){return new Promise(o=>{setTimeout(o,e)})}function p(){r.detectLaunchConfigurationChanges(n.workspace,({message:e,reloadWindowChoice:o,dismissChoice:t})=>n.workspace.showQuickpick([o,t],e).then(e=>{0===e&&n.workspace.nvim.command(i.Commands.RESTART_COC,!0)}),["statusBarEnabled","bloopVersion","enable"])}exports.trackDownloadProgress=a,exports.checkServerVersion=c,exports.toggleLogs=u,exports.wait=d,exports.detectLaunchConfigurationChanges=p;
},{"./commands":"eojW"}],"OSfr":[function(require,module,exports) {
"use strict";var t=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(s,o){function r(t){try{c(n.next(t))}catch(e){o(e)}}function a(t){try{c(n.throw(t))}catch(e){o(e)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,a)}c((n=n.apply(t,e||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DebuggingFeature=void 0;const e=require("vscode-languageserver-protocol"),i=require("coc.nvim");class n{constructor(t,e){this._nvim=t,this._client=e}fillInitializeParams(){}fillClientCapabilities(){}initialize(){const n=(i,...n)=>t(this,void 0,void 0,function*(){let i={command:"debug-adapter-start",arguments:n};return this._client.sendRequest(e.ExecuteCommandRequest.type,i).then(e=>t(this,void 0,void 0,function*(){const t=e.uri.lastIndexOf(":");if(-1!==t){const i=parseInt(e.uri.substr(t+1));yield this._nvim.call("vimspector#LaunchWithSettings",[{configuration:"coc-metals",port:i}])}}),t=>{this._client.logFailedRequest(e.ExecuteCommandRequest.type,t)})});i.commands.registerCommand("metals-run-session-start",n.bind(this,!1),null,!0),i.commands.registerCommand("metals-debug-session-start",n.bind(this,!0),null,!0)}}exports.DebuggingFeature=n;
},{}],"n7Rg":[function(require,module,exports) {
"use strict";var t=this&&this.__awaiter||function(t,s,e,i){return new(e||(e=Promise))(function(r,h){function o(t){try{c(i.next(t))}catch(s){h(s)}}function n(t){try{c(i.throw(t))}catch(s){h(s)}}function c(t){var s;t.done?r(t.value):(s=t.value,s instanceof e?s:new e(function(t){t(s)})).then(o,n)}c((i=i.apply(t,s||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});const s=require("coc.nvim");class e{constructor(t,s,e){this.frames=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],this.counter=0,this.isProgress=!1,this.text="",this.priority=0,this.hide=(()=>this.dispose()),this.show=(()=>this.showText()),this.dispose=(()=>clearInterval(this.interval)),this.update=(t=>this.text=t),this.priority=t,this.isProgress=s,this.text=e,this.interval=setInterval(()=>{this.showText()},1e3)}getText(){let t;return void 0===this.frames[this.counter]&&(this.counter=0),this.isProgress&&""!==this.text.trim()?(t=this.text+this.frames[this.counter],this.counter++):t=this.text,t}showText(){return t(this,void 0,void 0,function*(){s.workspace.showMessage(this.getText())})}}exports.default=e;
},{}],"QCba":[function(require,module,exports) {
"use strict";var e=this&&this.__awaiter||function(e,t,o,a){return new(o||(o=Promise))(function(s,n){function r(e){try{c(a.next(e))}catch(t){n(t)}}function i(e){try{c(a.throw(e))}catch(t){n(t)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(r,i)}c((a=a.apply(e,t||[])).next())})},t=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)Object.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t.default=e,t},o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const a=require("coc.nvim"),s=require("metals-languageclient"),n=t(require("path")),r=require("vscode-languageserver-protocol"),i=require("./commands"),c=o(require("./decoration")),u=require("./embeddedDoctor"),l=require("./metalsProtocol"),d=require("./tvp/controller"),m=require("./tvp/feature"),p=require("./tvp/treeviews"),v=require("./utils"),h=o(require("./WannaBeStatusBarItem"));function g(t){return e(this,void 0,void 0,function*(){const e=a.workspace.getConfiguration("metals");e.get("enable")&&(v.detectLaunchConfigurationChanges(),v.checkServerVersion(e),s.getJavaHome(e.get("javaHome")).then(o=>w(e,t,o),()=>{a.workspace.showQuickpick(["Open Settings","Ignore for now"],"Unable to find a Java 8 or Java 11 installation on this computer. To fix this problem, update the 'Java Home' setting to point to a Java 8 or Java 11 home directory").then(e=>{0===e&&a.workspace.nvim.command(i.Commands.OPEN_COC_CONFIG,!0)})}))})}function w(e,t,o){var n,r;const c=s.checkDottyIde(null===(n=a.workspace.workspaceFolder)||void 0===n?void 0:n.uri);if(c.enabled)return void a.workspace.showMessage("Metals will not start since Dotty is enabled for this workspace. "+`To enable Metals, remove the file ${c.path} and run ':CocCommand metals.restartServer'`,"warning");const u=e.get("serverVersion"),l=e.inspect("serverVersion").defaultValue,d=u||l,m=e.get("serverProperties"),p=e.get("customRepositories"),g=s.getJavaConfig({workspaceRoot:null===(r=a.workspace.workspaceFolder)||void 0===r?void 0:r.uri,javaHome:o,customRepositories:p,extensionPath:t.extensionPath}),w=s.fetchMetals({serverVersion:d,serverProperties:m,javaConfig:g}),k=e.get("statusBarEnabled"),y=k?a.workspace.createStatusBarItem(0,{progress:!0}):new h.default(0,!0,"Preparing Metals"),C=`Downloading Metals v${d}`;v.trackDownloadProgress(C,w,y).then(e=>{f(t,e,m,g,y,k)},()=>{const e=(()=>{const e="See https://scalaeta.org/metals/docs/editors/vscode.html#http-proxy for instructions if you are using an HTTP proxy.";return d===l?"Failed to download Metals, make sure you have an internet connection and "+`the Java Home '${o}' is valid. You can configure the Java Home in the settings.`+e:"Failed to download Metals, make sure you have an internet connection, "+`the Metals version '${d}' is correct and the Java Home '${o}' is valid. `+"You can configure the Metals version and Java Home in the settings."+e})();a.workspace.showPrompt(`${e}\n Open Settings?`).then(e=>{e&&a.workspace.nvim.command(i.Commands.OPEN_COC_CONFIG,!0)})})}function f(t,o,i,h,g,w){const f=s.getServerOptions({metalsClasspath:o,serverProperties:i,javaConfig:h,clientName:"coc-metals"}),k={documentSelector:[{scheme:"file",language:"scala"}],synchronize:{configurationSection:"metals"},revealOutputChannelOn:a.RevealOutputChannelOn.Never,initializationOptions:{decorationProvider:a.workspace.isNvim,didFocusProvider:!0,doctorProvider:"json",executeClientCommandProvider:!0,quickPickProvider:!0,inputBoxProvider:!0,slowTaskProvider:!0,statusBarProvider:w?"on":"show-message"}},y=new a.LanguageClient("metals","Metals",f,k),C=new m.TreeViewFeature(y);y.registerFeature(C);const P=new a.FloatFactory(a.workspace.nvim,a.workspace.env,!1,100,100,!0),b=new c.default(P),q=new p.TreeViewsManager(a.workspace.nvim,t.logger),M=new d.TreeViewController(C,q);function x(e,o){t.subscriptions.push(a.commands.registerCommand(e,o))}t.subscriptions.push(C,q,M),x("metals.restartServer",s.restartServer(y,a.workspace)),t.subscriptions.push(y.start()),y.onReady().then(o=>{g.isProgress=!1,g.text="Metals is Ready!",g.show();if(["build-import","build-connect","build-restart","sources-scan","doctor-run","compile-cascade","compile-cancel","compile-clean"].forEach(t=>{x("metals."+t,()=>e(this,void 0,void 0,function*(){a.workspace.showMessage("metals"+t),y.sendRequest(r.ExecuteCommandRequest.type,{command:t})}))}),x("metals.logs-toggle",()=>{v.toggleLogs()}),a.workspace.isNvim&&t.subscriptions.push(a.workspace.registerKeymap(["n"],"metals-expand-decoration",()=>{b.showHover()},{sync:!1})),x("metals.new-scala-file",()=>e(this,void 0,void 0,function*(){const e=(yield a.workspace.document).uri,t=n.dirname(e);y.sendRequest(r.ExecuteCommandRequest.type,{command:"new-scala-file",arguments:[t]})})),x("metals.go-to-super-method",()=>e(this,void 0,void 0,function*(){const e=yield a.workspace.document,t=yield a.workspace.getCursorPosition();y.sendRequest(r.ExecuteCommandRequest.type,{command:"goto-super-method",arguments:[{document:e.uri,position:t}]})})),x("metals.super-method-hierarchy",()=>e(this,void 0,void 0,function*(){const e=yield a.workspace.document,t=yield a.workspace.getCursorPosition();y.sendRequest(r.ExecuteCommandRequest.type,{command:"super-method-hierarchy",arguments:[{document:e.uri,position:t}]})})),y.onNotification(l.ExecuteClientCommand.type,t=>e(this,void 0,void 0,function*(){switch(t.command){case"metals-goto-location":const e=t.arguments&&t.arguments[0];e&&(yield q.prepareWindowForGoto(),yield v.wait(10),yield a.workspace.jumpTo(e.uri,e.range.start));break;case"metals-doctor-run":const o=t.arguments&&t.arguments[0];u.makeVimDoctor(JSON.parse(o));break;case"metals-doctor-reload":a.workspace.nvim.call("coc#util#has_preview").then(e=>{if(e>0){const e=t.arguments&&t.arguments[0];u.makeVimDoctor(JSON.parse(e))}});break;case"metals-diagnostics-focus":a.workspace.nvim.command("CocList diagnostics");break;case"metals-logs-toggle":v.toggleLogs();break;default:a.workspace.showMessage(`Recieved unknown command: ${t.command}`)}})),a.events.on("BufWinEnter",e=>{const t=a.workspace.documents.find(t=>t.bufnr===e);t&&"scala"===t.filetype&&y.sendNotification(l.MetalsDidFocus.type,t.uri)}),y.onRequest(l.MetalsInputBox.type,t=>e(this,void 0,void 0,function*(){const e=yield a.workspace.callAsync("input",[`${t.prompt}: `,t.value?t.value:""]);return""===e.trim()?{cancelled:!0}:{value:e}})),y.onRequest(l.MetalsQuickPick.type,(e,t)=>a.workspace.showQuickpick(e.items.map(e=>e.label),e.placeHolder).then(t=>-1===t?{cancelled:!0}:{itemId:e.items[t].id})),w){const e=a.workspace.createStatusBarItem(0);y.onNotification(l.MetalsStatus.type,t=>{e.text=t.text,t.show?e.show():t.hide&&e.hide()})}a.workspace.isNvim&&(y.onNotification(l.DecorationsRangesDidChange.type,e=>{a.workspace.uri&&a.workspace.uri===e.uri&&b.setDecorations(e)}),a.events.on("BufWinLeave",e=>{const t=a.workspace.documents.find(t=>t.bufnr===e);t&&t.uri.endsWith(".worksheet.sc")&&b.clearDecorations(e)}))})}exports.activate=g;
},{"./commands":"eojW","./decoration":"p29A","./embeddedDoctor":"BTOZ","./metalsProtocol":"z7J4","./tvp/controller":"bAI2","./tvp/feature":"Y104","./tvp/treeviews":"GgEX","./utils":"UnXq","./WannaBeStatusBarItem":"n7Rg"}]},{},["QCba"], null)
"use strict";var e=this&&this.__createBinding||(Object.create?function(e,t,o,r){void 0===r&&(r=o),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[o]}})}:function(e,t,o,r){void 0===r&&(r=o),e[r]=t[o]}),t=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(o){if(o&&o.__esModule)return o;var r={};if(null!=o)for(var a in o)"default"!==a&&Object.hasOwnProperty.call(o,a)&&e(r,o,a);return t(r,o),r},r=this&&this.__awaiter||function(e,t,o,r){return new(o||(o=Promise))(function(a,n){function s(e){try{c(r.next(e))}catch(t){n(t)}}function i(e){try{c(r.throw(e))}catch(t){n(t)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(s,i)}c((r=r.apply(e,t||[])).next())})},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.activate=void 0;const n=require("coc.nvim"),s=require("metals-languageclient"),i=o(require("path")),c=require("vscode-languageserver-protocol"),u=require("./commands"),l=a(require("./decoration")),d=require("./embeddedDoctor"),m=require("./metalsProtocol"),p=require("./tvp/controller"),v=require("./tvp/feature"),g=require("./tvp/treeviews"),h=require("./utils"),w=require("./DebuggingFeature"),f=a(require("./WannaBeStatusBarItem"));function k(e){return r(this,void 0,void 0,function*(){const t=n.workspace.getConfiguration("metals");t.get("enable")&&(h.detectLaunchConfigurationChanges(),h.checkServerVersion(t),s.getJavaHome(t.get("javaHome")).then(o=>y(t,e,o),()=>{n.workspace.showQuickpick(["Open Settings","Ignore for now"],"Unable to find a Java 8 or Java 11 installation on this computer. To fix this problem, update the 'Java Home' setting to point to a Java 8 or Java 11 home directory").then(e=>{0===e&&n.workspace.nvim.command(u.Commands.OPEN_COC_CONFIG,!0)})}))})}function y(e,t,o){var r,a;const i=s.checkDottyIde(null===(r=n.workspace.workspaceFolder)||void 0===r?void 0:r.uri);if(i.enabled)return void n.workspace.showMessage("Metals will not start since Dotty is enabled for this workspace. "+`To enable Metals, remove the file ${i.path} and run ':CocCommand metals.restartServer'`,"warning");const c=e.get("serverVersion"),l=e.inspect("serverVersion").defaultValue,d=c||l,m=e.get("serverProperties"),p=e.get("customRepositories"),v=s.getJavaConfig({workspaceRoot:null===(a=n.workspace.workspaceFolder)||void 0===a?void 0:a.uri,javaHome:o,customRepositories:p,extensionPath:t.extensionPath}),g=s.fetchMetals({serverVersion:d,serverProperties:m,javaConfig:v}),w=e.get("statusBarEnabled"),k=w?n.workspace.createStatusBarItem(0,{progress:!0}):new f.default(0,!0,"Preparing Metals"),y=`Downloading Metals v${d}`;h.trackDownloadProgress(y,g,k).then(e=>{b(t,e,m,v,k,w)},()=>{const e=(()=>{const e="See https://scalaeta.org/metals/docs/editors/vscode.html#http-proxy for instructions if you are using an HTTP proxy.";return d===l?"Failed to download Metals, make sure you have an internet connection and "+`the Java Home '${o}' is valid. You can configure the Java Home in the settings.`+e:"Failed to download Metals, make sure you have an internet connection, "+`the Metals version '${d}' is correct and the Java Home '${o}' is valid. `+"You can configure the Metals version and Java Home in the settings."+e})();n.workspace.showPrompt(`${e}\n Open Settings?`).then(e=>{e&&n.workspace.nvim.command(u.Commands.OPEN_COC_CONFIG,!0)})})}function b(e,t,o,a,u,f){return r(this,void 0,void 0,function*(){const k=s.getServerOptions({metalsClasspath:t,serverProperties:o,javaConfig:a,clientName:"coc-metals"}),y={documentSelector:[{scheme:"file",language:"scala"}],synchronize:{configurationSection:"metals"},revealOutputChannelOn:n.RevealOutputChannelOn.Never,initializationOptions:{decorationProvider:n.workspace.isNvim,didFocusProvider:!0,doctorProvider:"json",executeClientCommandProvider:!0,quickPickProvider:!0,inputBoxProvider:!0,slowTaskProvider:!0,statusBarProvider:f?"on":"show-message",treeViewProvider:!0,debuggingProvider:n.workspace.isNvim&&1===(yield n.workspace.nvim.getVar("loaded_vimpector"))}},b=new n.LanguageClient("metals","Metals",k,y),C=new v.TreeViewFeature(b);if(b.registerFeature(C),y.initializationOptions.debuggingProvider){const e=new w.DebuggingFeature(n.workspace.nvim,b);b.registerFeature(e)}const P=new n.FloatFactory(n.workspace.nvim,n.workspace.env,!1,100,100,!0),q=new l.default(P),O=new g.TreeViewsManager(n.workspace.nvim,e.logger),M=new p.TreeViewController(C,O);function x(t,o){e.subscriptions.push(n.commands.registerCommand(t,o))}e.subscriptions.push(C,O,M),x("metals.restartServer",s.restartServer(b,n.workspace)),e.subscriptions.push(b.start()),b.onReady().then(t=>{u.isProgress=!1,u.text="Metals is Ready!",u.show();if(["build-import","build-connect","build-restart","sources-scan","doctor-run","compile-cascade","compile-cancel","compile-clean","ammonite-start","ammonite-stop","new-scala-project"].forEach(e=>{x("metals."+e,()=>r(this,void 0,void 0,function*(){n.workspace.showMessage("metals"+e),b.sendRequest(c.ExecuteCommandRequest.type,{command:e})}))}),x("metals.logs-toggle",()=>{h.toggleLogs()}),n.workspace.isNvim&&e.subscriptions.push(n.workspace.registerKeymap(["n"],"metals-expand-decoration",()=>{q.showHover()},{sync:!1})),x("metals.new-scala-file",()=>r(this,void 0,void 0,function*(){const e=(yield n.workspace.document).uri,t=i.dirname(e);b.sendRequest(c.ExecuteCommandRequest.type,{command:"new-scala-file",arguments:[t]})})),x("metals.go-to-super-method",()=>r(this,void 0,void 0,function*(){const e=yield n.workspace.document,t=yield n.workspace.getCursorPosition();b.sendRequest(c.ExecuteCommandRequest.type,{command:"goto-super-method",arguments:[{document:e.uri,position:t}]})})),x("metals.super-method-hierarchy",()=>r(this,void 0,void 0,function*(){const e=yield n.workspace.document,t=yield n.workspace.getCursorPosition();b.sendRequest(c.ExecuteCommandRequest.type,{command:"super-method-hierarchy",arguments:[{document:e.uri,position:t}]})})),b.onNotification(m.ExecuteClientCommand.type,e=>r(this,void 0,void 0,function*(){switch(e.command){case"metals-goto-location":const t=e.arguments&&e.arguments[0];t&&(yield O.prepareWindowForGoto(),yield h.wait(10),yield n.workspace.jumpTo(t.uri,t.range.start));break;case"metals-doctor-run":const o=e.arguments&&e.arguments[0];d.makeVimDoctor(JSON.parse(o));break;case"metals-doctor-reload":n.workspace.nvim.call("coc#util#has_preview").then(t=>{if(t>0){const t=e.arguments&&e.arguments[0];d.makeVimDoctor(JSON.parse(t))}});break;case"metals-diagnostics-focus":n.workspace.nvim.command("CocList diagnostics");break;case"metals-logs-toggle":h.toggleLogs();break;case"metals-model-refresh":n.events.fire("BufEnter",[n.workspace.bufnr]);break;default:n.workspace.showMessage(`Recieved unknown command: ${e.command}`)}})),n.events.on("BufWinEnter",e=>{const t=n.workspace.documents.find(t=>t.bufnr===e);t&&"scala"===t.filetype&&b.sendNotification(m.MetalsDidFocus.type,t.uri)}),b.onRequest(m.MetalsInputBox.type,e=>r(this,void 0,void 0,function*(){const t=yield n.workspace.callAsync("input",[`${e.prompt}: `,e.value?e.value:""]);return""===t.trim()?{cancelled:!0}:{value:t}})),b.onRequest(m.MetalsQuickPick.type,(e,t)=>n.workspace.showQuickpick(e.items.map(e=>e.label),e.placeHolder).then(t=>-1===t?{cancelled:!0}:{itemId:e.items[t].id})),f){const e=n.workspace.createStatusBarItem(0);b.onNotification(m.MetalsStatus.type,t=>{e.text=t.text,t.show?e.show():t.hide&&e.hide()})}n.workspace.isNvim&&(b.onNotification(m.DecorationsRangesDidChange.type,e=>{n.workspace.uri&&n.workspace.uri===e.uri&&q.setDecorations(e)}),n.events.on("BufWinLeave",e=>{const t=n.workspace.documents.find(t=>t.bufnr===e);t&&t.uri.endsWith(".worksheet.sc")&&q.clearDecorations(e)}))})})}exports.activate=k;
},{"./commands":"eojW","./decoration":"p29A","./embeddedDoctor":"BTOZ","./metalsProtocol":"z7J4","./tvp/controller":"bAI2","./tvp/feature":"Y104","./tvp/treeviews":"GgEX","./utils":"UnXq","./DebuggingFeature":"OSfr","./WannaBeStatusBarItem":"n7Rg"}]},{},["QCba"], null)
{
"name": "coc-metals",
"version": "0.8.3",
"version": "0.9.0",
"description": "coc.nvim extension for Metals, the Scala language server",

@@ -76,3 +76,3 @@ "keywords": [

"type": "string",
"default": "0.9.0",
"default": "0.9.1",
"markdownDescription": "The version of the Metals server artifact. Requires reloading the window.\n\n**Change only if you know what you're doing**"

@@ -88,2 +88,10 @@ },

},
"metals.ammoniteJvmProperties": {
"type": "array",
"default": [],
"items": {
"type": "string"
},
"markdownDescription": "Optional list of JVM properties to pass along to the Ammonite server. Each property needs to be a separate item.\n\nExample: `-Xmx1G` or `-Xms100M`"
},
"metals.javaHome": {

@@ -143,2 +151,7 @@ "type": "string",

},
"metals.enableStripMarginOnTypeFormatting": {
"type": "boolean",
"default": true,
"markdownDescription": "When enabled, if you press the return key from the first line of a multiline string containing a pipe, it will automatically add `.stripMargin.`"
},
"metals.treeviews.initialWidth": {

@@ -306,2 +319,7 @@ "type": "number",

{
"command": "metals.new-scala-project",
"category": "Metals",
"title": "Create a new Scala project"
},
{
"command": "metals.go-to-super-method",

@@ -315,2 +333,12 @@ "category": "Metals",

"title": "View super method hierarchy"
},
{
"command": "metals.ammonite-start",
"category": "Metals",
"title": "Start Ammonite build server"
},
{
"command": "metals.ammonite-stop",
"category": "Metals",
"title": "Stop Ammonite build server"
}

@@ -320,3 +348,3 @@ ]

"devDependencies": {
"@types/node": "13.13.4",
"@types/node": "14.0.14",
"npm-run-all": "4.1.5",

@@ -326,11 +354,11 @@ "parcel-bundler": "1.12.4",

"rimraf": "3.0.2",
"ts-loader": "7.0.2",
"typescript": "3.8.3"
"ts-loader": "7.0.5",
"typescript": "3.9.5"
},
"dependencies": {
"coc.nvim": "0.0.77",
"metals-languageclient": "0.2.2",
"promisify-child-process": "3.1.4",
"metals-languageclient": "0.2.7",
"promisify-child-process": "4.1.1",
"vscode-languageserver-protocol": "3.15.3"
}
}

@@ -41,2 +41,3 @@

- [Formatting on save](#formatting-on-save)
- [Debugging](#debugging)
- [Gitignore](#gitignore)

@@ -290,4 +291,7 @@ - [Troubleshooting](#troubleshooting)

- `metals.new-scala-file`
- `metals.new-scala-project`
- `metals.go-to-super-method`
- `metals.super-method-hierarchy`
- `metals.ammonite-start`
- `metals.ammonite-stop`

@@ -317,2 +321,3 @@ ### Show document symbols

`metals.serverProperties` | Optional list of properties to pass along to the Metals server. By default, the environment variable `JAVA_OPTS` and `.jvmopts` file are respected.
`metals.ammoniteJvmProperties` | Optional list of JVM properties to pass along to the Ammonite server. Each property needs to be a separate item. Example: `-Xmx1G` or `-Xms100M`
`metals.javaHome` | Optional path to the Java home directory. Requires reloading the window. Defaults to the most recent Java 8 version computed by the `locate-java-home` npm package.

@@ -330,2 +335,3 @@ `metals.sbtScript` | Optional absolute path to an `sbt` executable to use for running `sbt bloopInstall`. By default, Metals uses `java -jar sbt-launch.jar` with an embedded launcher while respecting `.jvmopts` and `.sbtopts`. Update this setting if your `sbt` script requires more customizations like using environment variables.

`metals.superMethodLensesEnabled` | Enable/disable goto super method code lens (default is true)
`metals.enableStripMarginOnTypeFormatting` | When enabled, if you press the return key from the first line of a multiline string containing a pipe, it will automatically add `.stripMargin.` (default is true)
`metals.treeviews.toggleNode` | Expand / Collapse tree node (default `<CR>`)

@@ -418,2 +424,76 @@ `metals.treeviews.initialWidth` | Initial Tree Views panels (default `40`)

```
### Debugging
coc-metals provides easy integration with the great
[vimspector](https://github.com/puremourning/vimspector) plugin that allows you
to run a Debug Adapter Server and debug your application with minimum manual
steps.
#### Requirements:
- *This is only currently available for Neovim +0.4.3 for now until the
the `launch.json` Metals expects can be mapped to match the `.vimspector.json`
file that vimspector uses. For now, you'll need to trigger the `run` or `debug`
with code lenses provided by Neovim.
- [vimspector](https://github.com/puremourning/vimspector) plugin - Basically you just
need to add vimspector into vim's runtimepath, for example, if you are using vim-plug then
add this line in .vimrc
```vim
Plug 'puremourning/vimspector'
```
#### Configuration:
- Set `codeLens.enable` to `true` in your `:CocConfig`
- Setup your [Vimspector Mappings](https://github.com/puremourning/vimspector#mappings)
The [vimspector documentation](https://github.com/puremourning/vimspector) is
quite robust, so please make sure to read through it.
There are multiple ways to have you base configuration for vimspector to work
with Metals. You can either set this up globally to work with all of your Scala
projects or for an individual project.
_Global Example:_
Put your `coc-metals.json` file in the following directory:
`/path/to/vimspector/configurations/{os}/scala` (where `os` is `linux`, `macos`
or `windows`) with following content:
```json
{
"configurations": {
"coc-metals": {
"adapter": {
"port": "${port}",
"variables": {
}
},
"configuration": {
"request": "launch"
},
"breakpoints": {
"exception": {
"caught": "N",
"uncaught": "N"
}
}
}
}
}
```
You can also just place the same contents above in the root of your local
project in a `.vimspector.json` file, and it will work the same way.
With these configuration parameters the codeLens 'run' and 'debug' appear
against runnable classes (applications or tests) of your project. Then, you will
be able to trigger these codeLens actions (default mapping is `<leader> cl`) and
start Debug Adapter Server. Once Debug Adapter Server is started coc-metals will
transfer necessary information to vimspector to activate debugging.
For now both actions 'run' and 'debug' start vimspector in debug mode. This may
be improved in next versions.
### Gitignore

@@ -420,0 +500,0 @@

@@ -28,3 +28,3 @@ /**

*/
export const OPEN_LOGS = "CocInfo";
export const OPEN_LOGS = "CocCommand workspace.showOutput";
}

@@ -52,3 +52,3 @@ import { FloatFactory, workspace } from "coc.nvim";

content: hoverText.hoverMessage.value,
filetype: hoverText.hoverMessage.language,
filetype: hoverText.hoverMessage.kind,
},

@@ -55,0 +55,0 @@ ],

@@ -51,2 +51,3 @@ import {

} from "./utils";
import { DebuggingFeature } from "./DebuggingFeature";
import WannaBeStatusBarItem from "./WannaBeStatusBarItem";

@@ -163,3 +164,3 @@

function launchMetals(
async function launchMetals(
context: ExtensionContext,

@@ -194,2 +195,6 @@ metalsClasspath: string,

statusBarProvider: statusBarEnabled ? "on" : "show-message",
treeViewProvider: true,
debuggingProvider:
workspace.isNvim &&
(await workspace.nvim.getVar("loaded_vimpector")) === 1,
},

@@ -207,2 +212,6 @@ };

client.registerFeature(treeViewFeature);
if (clientOptions.initializationOptions.debuggingProvider) {
const debuggingFeature = new DebuggingFeature(workspace.nvim, client);
client.registerFeature(debuggingFeature);
}

@@ -252,2 +261,5 @@ const floatFactory = new FloatFactory(

"compile-clean",
"ammonite-start",
"ammonite-stop",
"new-scala-project",
];

@@ -352,2 +364,6 @@

break;
case "metals-model-refresh":
// CodeLensManager from coc.nvim reloads codeLens on this event
events.fire("BufEnter", [workspace.bufnr]);
break;
default:

@@ -354,0 +370,0 @@ workspace.showMessage(`Recieved unknown command: ${params.command}`);

@@ -1,2 +0,2 @@

import { MarkedString, Range } from "vscode-languageserver-protocol";
import { Range, MarkupContent } from "vscode-languageserver-protocol";

@@ -66,3 +66,3 @@ /**

*/
hoverMessage?: MarkedString;
hoverMessage?: MarkupContent;

@@ -69,0 +69,0 @@ /**

@@ -18,3 +18,2 @@ import {

import {
ClientCapabilities,
Disposable,

@@ -27,3 +26,2 @@ Emitter,

RPCMessageType,
ServerCapabilities,
TextDocument,

@@ -49,11 +47,5 @@ TextDocumentPositionParams,

public fillClientCapabilities(capabilities: ClientCapabilities): void {
if (capabilities.experimental == null) {
capabilities.experimental = {};
}
(capabilities.experimental as any).treeViewProvider = true;
}
public fillClientCapabilities(): void {}
public initialize(capabilities: ServerCapabilities): void {
if (!capabilities.experimental!.treeViewProvider) return;
public initialize(): void {
const client = this._client;

@@ -60,0 +52,0 @@

@@ -53,7 +53,7 @@ import { StatusBarItem, workspace, WorkspaceConfiguration } from "coc.nvim";

export function toggleLogs() {
const infoBuffer = workspace.documents.find((doc) =>
doc.uri.endsWith("info")
const logsBuffer = workspace.documents.find(
(doc) => doc.uri == "output:/metals"
);
if (infoBuffer) {
workspace.nvim.command(`bd ${infoBuffer.bufnr}`);
if (logsBuffer) {
workspace.nvim.command(`bd ${logsBuffer.bufnr}`);
} else {

@@ -60,0 +60,0 @@ workspace.nvim.command(Commands.OPEN_LOGS);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc