diff --git a/.travis.yml b/.travis.yml index 6395148be..5b151b3f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ script: - chmod u+x build-package.sh - ./build-package.sh - npm run build - - git diff --quiet + - git diff --quiet -- dist/ - npm test notifications: @@ -42,7 +42,7 @@ dist: trusty addons: apt: packages: - - build-essential - - fakeroot - - git - - libsecret-1-dev + - build-essential + - fakeroot + - git + - libsecret-1-dev diff --git a/dist/client/callbacks.js b/dist/client/callbacks.js index 4c1dbefd8..3897066dc 100644 --- a/dist/client/callbacks.js +++ b/dist/client/callbacks.js @@ -2,44 +2,51 @@ Object.defineProperty(exports, "__esModule", { value: true }); // Callbacks keeps track of all the outstanding requests class Callbacks { - constructor(onPendingChange) { - this.onPendingChange = onPendingChange; + constructor(reportBusyWhile) { + this.reportBusyWhile = reportBusyWhile; this.callbacks = new Map(); } - add(seq, command) { - return new Promise((resolve, reject) => { - this.callbacks.set(seq, { - name: command, - resolve, - reject, - started: Date.now(), + async add(seq, command) { + try { + const promise = new Promise((resolve, reject) => { + this.callbacks.set(seq, { + resolve, + reject, + started: Date.now(), + }); }); - this.onPendingChange(this.pending()); - }); + return await this.reportBusyWhile(command, () => promise); + } + finally { + this.callbacks.delete(seq); + } } rejectAll(error) { for (const { reject } of this.callbacks.values()) { reject(error); } this.callbacks.clear(); - this.onPendingChange(this.pending()); } - // Remove and return a Request object, if one exists - remove(seq) { + resolve(seq, res) { const req = this.callbacks.get(seq); - this.callbacks.delete(seq); if (req) { - this.onPendingChange(this.pending()); + if (window.atom_typescript_debug) { + console.log("received response for", res.command, "in", Date.now() - req.started, "ms", "with data", res.body); + } + if (res.success) + req.resolve(res); + else + req.reject(new Error(res.message)); } - return req; + else + console.warn("unexpected response:", res); } - // pending returns names of requests waiting for a response - pending() { - const pending = []; - for (const { name } of this.callbacks.values()) { - pending.push(name); - } - return pending; + error(seq, err) { + const req = this.callbacks.get(seq); + if (req) + req.reject(err); + else + console.error(err); } } exports.Callbacks = Callbacks; diff --git a/dist/client/callbacks.js.map b/dist/client/callbacks.js.map index d2aaed903..c30bd3ea4 100644 --- a/dist/client/callbacks.js.map +++ b/dist/client/callbacks.js.map @@ -1 +1 @@ -{"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../lib/client/callbacks.ts"],"names":[],"mappings":";;AASA,wDAAwD;AACxD,MAAa,SAAS;IAGpB,YAAoB,eAA4C;QAA5C,oBAAe,GAAf,eAAe,CAA6B;QAFxD,cAAS,GAAyB,IAAI,GAAG,EAAE,CAAA;IAEgB,CAAC;IAE7D,GAAG,CAAC,GAAW,EAAE,OAAe;QACrC,OAAO,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE;gBACtB,IAAI,EAAE,OAAO;gBACb,OAAO;gBACP,MAAM;gBACN,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;aACpB,CAAC,CAAA;YAEF,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;QACtC,CAAC,CAAC,CAAA;IACJ,CAAC;IAEM,SAAS,CAAC,KAAY;QAC3B,KAAK,MAAM,EAAC,MAAM,EAAC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE;YAC9C,MAAM,CAAC,KAAK,CAAC,CAAA;SACd;QAED,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QACtB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IACtC,CAAC;IAED,oDAAoD;IAC7C,MAAM,CAAC,GAAW;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAC1B,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;SACrC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,2DAA2D;IACnD,OAAO;QACb,MAAM,OAAO,GAAa,EAAE,CAAA;QAE5B,KAAK,MAAM,EAAC,IAAI,EAAC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE;YAC5C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;SACnB;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AA/CD,8BA+CC"} \ No newline at end of file +{"version":3,"file":"callbacks.js","sourceRoot":"","sources":["../../lib/client/callbacks.ts"],"names":[],"mappings":";;AASA,wDAAwD;AACxD,MAAa,SAAS;IAGpB,YAAoB,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAF5C,cAAS,GAAyB,IAAI,GAAG,EAAE,CAAA;IAEI,CAAC;IAEjD,KAAK,CAAC,GAAG,CACd,GAAW,EACX,OAAU;QAEV,IAAI;YACF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE;oBACtB,OAAO;oBACP,MAAM;oBACN,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE;iBACpB,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;YACF,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,CAAA;SAC1D;gBAAS;YACR,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;SAC3B;IACH,CAAC;IAEM,SAAS,CAAC,KAAY;QAC3B,KAAK,MAAM,EAAC,MAAM,EAAC,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE;YAC9C,MAAM,CAAC,KAAK,CAAC,CAAA;SACd;QAED,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;IACxB,CAAC;IAEM,OAAO,CAAiC,GAAW,EAAE,GAAkB;QAC5E,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,GAAG,EAAE;YACP,IAAI,MAAM,CAAC,qBAAqB,EAAE;gBAChC,OAAO,CAAC,GAAG,CACT,uBAAuB,EACvB,GAAG,CAAC,OAAO,EACX,IAAI,EACJ,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,OAAO,EACxB,IAAI,EACJ,WAAW,EACX,GAAG,CAAC,IAAI,CACT,CAAA;aACF;YACD,IAAI,GAAG,CAAC,OAAO;gBAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;;gBAC5B,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;SACxC;;YAAM,OAAO,CAAC,IAAI,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA;IAClD,CAAC;IAEM,KAAK,CAAC,GAAW,EAAE,GAAU;QAClC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,GAAG;YAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;;YACnB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;CACF;AAvDD,8BAuDC"} \ No newline at end of file diff --git a/dist/client/client.js b/dist/client/client.js index ccb18c9ef..3857b3f43 100644 --- a/dist/client/client.js +++ b/dist/client/client.js @@ -1,9 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +// tslint:disable:max-classes-per-file const atom_1 = require("atom"); -const callbacks_1 = require("./callbacks"); -const stream_1 = require("stream"); const byline = require("byline"); +const stream_1 = require("stream"); +const callbacks_1 = require("./callbacks"); // Set this to true to start tsserver with node --inspect const INSPECT_TSSERVER = false; const commandWithResponseMap = { @@ -26,100 +27,123 @@ const commandWithResponseMap = { navto: true, getApplicableRefactors: true, getEditsForRefactor: true, - ping: true, organizeImports: true, + signatureHelp: true, }; const commandWithResponse = new Set(Object.keys(commandWithResponseMap)); +function isCommandWithResponse(command) { + return commandWithResponse.has(command); +} class TypescriptServiceClient { - constructor(tsServerPath, version) { + constructor(tsServerPath, version, reportBusyWhile) { this.tsServerPath = tsServerPath; this.version = version; + this.reportBusyWhile = reportBusyWhile; this.emitter = new atom_1.Emitter(); this.seq = 0; - this.running = false; this.lastStderrOutput = ""; - this.exitHandler = (reject) => (err) => { - console.error("tsserver: ", err); + // tslint:disable-next-line:member-ordering + this.on = this.emitter.on.bind(this.emitter); + this.exitHandler = (err, report = true) => { this.callbacks.rejectAll(err); - this.emitter.dispose(); - reject(err); - this.running = false; + if (report) + console.error("tsserver: ", err); + this.server = undefined; setImmediate(() => { - let detail = err.message; - if (this.lastStderrOutput) { - detail = `Last output from tsserver:\n${this.lastStderrOutput}\n\n${detail}`; + if (report) { + let detail = err.message; + if (this.lastStderrOutput) { + detail = `Last output from tsserver:\n${this.lastStderrOutput}\n\n${detail}`; + } + atom.notifications.addError("TypeScript quit unexpectedly", { + detail, + stack: err.stack, + dismissable: true, + }); + } + if (this.lastStartAttempt === undefined || Date.now() - this.lastStartAttempt > 5000) { + this.server = this.startServer(); + this.emitter.emit("restarted", undefined); + } + else { + atom.notifications.addWarning("Not restarting tsserver", { + detail: "Restarting too fast", + }); } - atom.notifications.addError("TypeScript quit unexpectedly", { - detail, - stack: err.stack, - dismissable: true, - }); }); }; - this.emitPendingRequests = (pending) => { - this.emitter.emit("pendingRequestsChange", pending); - }; this.onMessage = (res) => { if (res.type === "response") this.onResponse(res); else this.onEvent(res); }; - this.callbacks = new callbacks_1.Callbacks(this.emitPendingRequests); - this.serverPromise = this.startServer(); + this.callbacks = new callbacks_1.Callbacks(this.reportBusyWhile); + this.server = this.startServer(); } - async execute(command, args) { - if (!this.running) { + async execute(command, ...args) { + if (!this.server) { throw new Error("Server is not running"); } - return this.sendRequest(await this.serverPromise, command, args); + const req = { + seq: this.seq++, + command, + arguments: args[0], + }; + if (window.atom_typescript_debug) { + console.log("sending request", command, "with args", args); + } + const result = isCommandWithResponse(command) + ? this.callbacks.add(req.seq, command) + : undefined; + try { + this.server.stdin.write(JSON.stringify(req) + "\n"); + } + catch (error) { + this.callbacks.error(req.seq, error); + } + return result; } - on(name, listener) { - return this.emitter.on(name, listener); + async restartServer() { + if (this.server) { + this.lastStartAttempt = undefined; // reset auto-restart loop guard + const server = this.server; + const graceTimer = setTimeout(() => server.kill(), 10000); + await this.execute("exit"); + clearTimeout(graceTimer); + } + else { + this.server = this.startServer(); + this.emitter.emit("restarted", undefined); + } } startServer() { - return new Promise((resolve, reject) => { - this.running = true; - if (window.atom_typescript_debug) { - console.log("starting", this.tsServerPath); - } - const cp = startServer(this.tsServerPath); - const h = this.exitHandler(reject); - if (!cp) { - h(new Error("ChildProcess failed to start")); - return; - } - cp.once("error", h); - cp.once("exit", (code, signal) => { - if (code !== null) - h(new Error(`exited with code: ${code}`)); - else if (signal !== null) - h(new Error(`terminated on signal: ${signal}`)); - }); - // Pipe both stdout and stderr appropriately - messageStream(cp.stdout).on("data", this.onMessage); - cp.stderr.on("data", data => { - console.warn("tsserver stderr:", (this.lastStderrOutput = data.toString())); - }); - this.sendRequest(cp, "ping", undefined).then(() => resolve(cp), () => resolve(cp)); + if (window.atom_typescript_debug) { + console.log("starting", this.tsServerPath); + } + this.lastStartAttempt = Date.now(); + const cp = startServer(this.tsServerPath); + if (!cp) + throw new Error("ChildProcess failed to start"); + const h = this.exitHandler; + cp.once("error", h); + cp.once("exit", (code, signal) => { + if (code === 0) + h(new Error("Server stopped normally"), false); + else if (code !== null) + h(new Error(`exited with code: ${code}`)); + else if (signal !== null) + h(new Error(`terminated on signal: ${signal}`)); }); + // Pipe both stdout and stderr appropriately + messageStream(cp.stdout).on("data", this.onMessage); + cp.stderr.on("data", data => { + console.warn("tsserver stderr:", (this.lastStderrOutput = data.toString())); + }); + return cp; } onResponse(res) { - const req = this.callbacks.remove(res.request_seq); - if (req) { - if (window.atom_typescript_debug) { - console.log("received response for", res.command, "in", Date.now() - req.started, "ms", "with data", res.body); - } - if (res.success) { - req.resolve(res); - } - else { - req.reject(new Error(res.message)); - } - } - else { - console.warn("unexpected response:", res); - } + this.callbacks.resolve(res.request_seq, res); } onEvent(res) { if (window.atom_typescript_debug) { @@ -129,41 +153,10 @@ class TypescriptServiceClient { if (res.body) this.emitter.emit(res.event, res.body); } - async sendRequest(cp, command, args) { - const expectResponse = commandWithResponse.has(command); - const req = { - seq: this.seq++, - command, - arguments: args, - }; - if (window.atom_typescript_debug) { - console.log("sending request", command, "with args", args); - } - setImmediate(() => { - try { - cp.stdin.write(JSON.stringify(req) + "\n"); - } - catch (error) { - const callback = this.callbacks.remove(req.seq); - if (callback) { - callback.reject(error); - } - else { - console.error(error); - } - } - }); - if (expectResponse) { - return this.callbacks.add(req.seq, command); - } - else { - return undefined; - } - } } exports.TypescriptServiceClient = TypescriptServiceClient; function startServer(tsServerPath) { - const locale = atom.config.get("atom-typescript.locale"); + const locale = atom.config.get("atom-typescript").locale; const tsServerArgs = locale ? ["--locale", locale] : []; if (INSPECT_TSSERVER) { return new atom_1.BufferedProcess({ diff --git a/dist/client/client.js.map b/dist/client/client.js.map index 929c50f43..e9cb15438 100644 --- a/dist/client/client.js.map +++ b/dist/client/client.js.map @@ -1 +1 @@ -{"version":3,"file":"client.js","sourceRoot":"","sources":["../../lib/client/client.ts"],"names":[],"mappings":";;AAGA,+BAAkE;AAClE,2CAAqC;AAErC,mCAA0C;AAC1C,iCAAiC;AAGjC,yDAAyD;AACzD,MAAM,gBAAgB,GAAG,KAAK,CAAA;AAM9B,MAAM,sBAAsB,GAA2D;IACrF,6BAA6B,EAAE,IAAI;IACnC,qBAAqB,EAAE,IAAI;IAC3B,sBAAsB,EAAE,IAAI;IAC5B,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf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;YAC7B,OAAO,EAAE,YAAY;YACrB,IAAI,EAAE,YAAY;SACnB,CAAC,CAAC,OAAO,CAAA;KACX;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAe;IACpC,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,aAAa,EAAE,CAAC,CAAA;AACvD,CAAC;AAED,sEAAsE;AACtE,MAAM,aAAc,SAAQ,kBAAS;IACnC;QACE,KAAK,CAAC,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC,CAAA;IAC3B,CAAC;IAEM,UAAU,CAAC,GAAW,EAAE,SAAiB,EAAE,QAA2B;QAC3E,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAA;QAE3B,IAAI;YACF,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACxB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;aAC5B;iBAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;gBAC9C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACnB;SACF;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAA;SACjD;gBAAS;YACR,QAAQ,CAAC,IAAI,CAAC,CAAA;SACf;IACH,CAAC;CACF"} \ No newline at end of file +{"version":3,"file":"client.js","sourceRoot":"","sources":["../../lib/client/client.ts"],"names":[],"mappings":";;AAAA,sCAAsC;AACtC,+BAAkE;AAClE,iCAAiC;AAEjC,mCAA0C;AAG1C,2CAAqC;AASrC,yDAAyD;AACzD,MAAM,gBAAgB,GAAG,KAAK,CAAA;AAE9B,MAAM,sBAAsB,GAAiD;IAC3E,6BAA6B,EAAE,IAAI;IACnC,qBAAqB,EAAE,IAAI;IAC3B,sBAAsB,EAAE,IAAI;IAC5B,WAAW,E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EAAE,CAAC,CAAA;AACvD,CAAC;AAED,sEAAsE;AACtE,MAAM,aAAc,SAAQ,kBAAS;IACnC;QACE,KAAK,CAAC,EAAC,UAAU,EAAE,IAAI,EAAC,CAAC,CAAA;IAC3B,CAAC;IAEM,UAAU,CAAC,GAAW,EAAE,SAAiB,EAAE,QAA2B;QAC3E,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAA;QAE3B,IAAI;YACF,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACxB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;aAC5B;iBAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;gBAC9C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACnB;SACF;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAA;SACjD;gBAAS;YACR,QAAQ,CAAC,IAAI,CAAC,CAAA;SACf;IACH,CAAC;CACF"} \ No newline at end of file diff --git a/dist/client/clientResolver.js b/dist/client/clientResolver.js index dc2b5b1b6..7541994ef 100644 --- a/dist/client/clientResolver.js +++ b/dist/client/clientResolver.js @@ -1,55 +1,62 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const client_1 = require("./client"); +const atom_1 = require("atom"); +const fs = require("fs"); const path = require("path"); const Resolve = require("resolve"); -const atom_1 = require("atom"); +const client_1 = require("./client"); /** * ClientResolver takes care of finding the correct tsserver for a source file based on how a * require("typescript") from the same source file would resolve. */ class ClientResolver { - constructor() { + constructor(reportBusyWhile) { + this.reportBusyWhile = reportBusyWhile; this.clients = new Map(); this.emitter = new atom_1.Emitter(); - } - // This is just here so TypeScript can infer the types of the callbacks when using "on" method - on(event, callback) { - return this.emitter.on(event, callback); - } - async get(pFilePath) { - const { pathToBin, version } = await resolveBinary(pFilePath, "tsserver"); - const clientRec = this.clients.get(pathToBin); - if (clientRec) - return clientRec.client; - const newClientRec = { - client: new client_1.TypescriptServiceClient(pathToBin, version), - pending: [], - }; - this.clients.set(pathToBin, newClientRec); - newClientRec.client.on("pendingRequestsChange", pending => { - newClientRec.pending = pending; - this.emitter.emit("pendingRequestsChange", pending); - }); - const diagnosticHandler = (type) => (result) => { + this.subscriptions = new atom_1.CompositeDisposable(); + // This is just here so TypeScript can infer the types of the callbacks when using "on" method + // tslint:disable-next-line:member-ordering + this.on = this.emitter.on.bind(this.emitter); + this.diagnosticHandler = (serverPath, type) => (result) => { const filePath = isConfDiagBody(result) ? result.configFile : result.file; if (filePath) { this.emitter.emit("diagnostics", { type, - serverPath: pathToBin, + serverPath, filePath, diagnostics: result.diagnostics, }); } }; - newClientRec.client.on("configFileDiag", diagnosticHandler("configFileDiag")); - newClientRec.client.on("semanticDiag", diagnosticHandler("semanticDiag")); - newClientRec.client.on("syntaxDiag", diagnosticHandler("syntaxDiag")); - newClientRec.client.on("suggestionDiag", diagnosticHandler("suggestionDiag")); - return newClientRec.client; + } + async restartAllServers() { + await Promise.all(Array.from(this.getAllClients()).map(client => client.restartServer())); + } + async get(pFilePath) { + const { pathToBin, version } = await resolveBinary(pFilePath, "tsserver"); + const tsconfigPath = await resolveTsConfig(pFilePath); + let tsconfigMap = this.clients.get(pathToBin); + if (!tsconfigMap) { + tsconfigMap = new Map(); + this.clients.set(pathToBin, tsconfigMap); + } + const client = tsconfigMap.get(tsconfigPath); + if (client) + return client; + const newClient = new client_1.TypescriptServiceClient(pathToBin, version, this.reportBusyWhile); + tsconfigMap.set(tsconfigPath, newClient); + this.subscriptions.add(newClient.on("configFileDiag", this.diagnosticHandler(pathToBin, "configFileDiag")), newClient.on("semanticDiag", this.diagnosticHandler(pathToBin, "semanticDiag")), newClient.on("syntaxDiag", this.diagnosticHandler(pathToBin, "syntaxDiag")), newClient.on("suggestionDiag", this.diagnosticHandler(pathToBin, "suggestionDiag"))); + return newClient; } dispose() { this.emitter.dispose(); + this.subscriptions.dispose(); + } + *getAllClients() { + for (const tsconfigMap of this.clients.values()) { + yield* tsconfigMap.values(); + } } } exports.ClientResolver = ClientResolver; @@ -80,6 +87,23 @@ async function resolveBinary(sourcePath, binName) { }; } exports.resolveBinary = resolveBinary; +async function fsexists(filePath) { + return new Promise(resolve => { + fs.exists(filePath, resolve); + }); +} +async function resolveTsConfig(sourcePath) { + let parentDir = path.dirname(sourcePath); + let tsconfigPath = path.join(parentDir, "tsconfig.json"); + while (!(await fsexists(tsconfigPath))) { + const oldParentDir = parentDir; + parentDir = path.dirname(parentDir); + if (oldParentDir === parentDir) + return undefined; + tsconfigPath = path.join(parentDir, "tsconfig.json"); + } + return tsconfigPath; +} function isConfDiagBody(body) { // tslint:disable-next-line:no-unsafe-any return body && body.triggerFile && body.configFile; diff --git a/dist/client/clientResolver.js.map b/dist/client/clientResolver.js.map index f58b80c2c..4d406d095 100644 --- a/dist/client/clientResolver.js.map +++ b/dist/client/clientResolver.js.map @@ -1 +1 @@ -{"version":3,"file":"clientResolver.js","sourceRoot":"","sources":["../../lib/client/clientResolver.ts"],"names":[],"mappings":";;AAAA,qCAA0D;AAC1D,6BAA4B;AAC5B,mCAAkC;AAMlC,+BAA4B;AA0B5B;;;GAGG;AACH,MAAa,cAAc;IAA3B;QACS,YAAO,GAAG,IAAI,GAAG,EAAqB,CAAA;QACrC,YAAO,GAAG,IAAI,cAAO,EAAkB,CAAA;IAkDjD,CAAC;IAhDC,8FAA8F;IACvF,EAAE,CAA6B,KAAQ,EAAE,QAAyC;QACvF,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;IACzC,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,SAAiB;QAChC,MAAM,EAAC,SAAS,EAAE,OAAO,EAAC,GAAG,MAAM,aAAa,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;QAEvE,MAAM,SAAS,GAAG,IAAI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,GAAW,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAA;IAEpD,OAAO;QACL,OAAO;QACP,SAAS,EAAE,YAAY;KACxB,CAAA;AACH,CAAC;AAjBD,sCAiBC;AAED,SAAS,cAAc,CAAC,IAAS;IAC/B,yCAAyC;IACzC,OAAO,IAAI,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,CAAA;AACpD,CAAC"} \ No newline at end of file +{"version":3,"file":"clientResolver.js","sourceRoot":"","sources":["../../lib/client/clientResolver.ts"],"names":[],"mappings":";;AAAA,+BAAiD;AACjD,yBAAwB;AACxB,6BAA4B;AAC5B,mCAAkC;AAOlC,qCAA0D;AAoB1D;;;GAGG;AACH,MAAa,cAAc;IAQzB,YAAoB,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAP5C,YAAO,GAAG,IAAI,GAAG,EAA2C,CAAA;QAC5D,YAAO,GAAG,IAAI,cAAO,EAAkB,CAAA;QACvC,kBAAa,GAAG,IAAI,0BAAmB,EAAE,CAAA;QACjD,8FAA8F;QAC9F,2CAA2C;QACpC,OAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QA4CtC,sBAAiB,GAAG,CAAC,UAAkB,EAAE,IAAqB,EAAE,EAAE,CAAC,CACzE,MAA2D,EAC3D,EAAE;YACF,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAA;YAEzE,IAAI,QAAQ,EAAE;gBACZ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;oBAC/B,IAAI;oBACJ,UAAU;oBACV,QAAQ;oBACR,WAAW,EAAE,MAAM,CAAC,WAAW;iBAChC,CAAC,CAAA;aACH;QACH,CAAC,CAAA;IAvDsD,CAAC;IAEjD,KAAK,CAAC,iBAA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000000..6bb90fb9c --- /dev/null +++ b/dist/client/index.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var clientResolver_1 = require("./clientResolver"); +exports.ClientResolver = clientResolver_1.ClientResolver; +exports.resolveBinary = clientResolver_1.resolveBinary; +const client_1 = require("./client"); +exports.TSClient = client_1.TypescriptServiceClient; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/client/index.js.map b/dist/client/index.js.map new file mode 100644 index 000000000..c4ca64fb8 --- /dev/null +++ b/dist/client/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/client/index.ts"],"names":[],"mappings":";;AAAA,mDAA8D;AAAtD,0CAAA,cAAc,CAAA;AAAE,yCAAA,aAAa,CAAA;AAErC,qCAAgD;AAEb,mBAF3B,gCAAuB,CAEY"} \ No newline at end of file diff --git a/dist/main/atom-ide/codeActionsProvider.js b/dist/main/atom-ide/codeActionsProvider.js new file mode 100644 index 000000000..4b0354583 --- /dev/null +++ b/dist/main/atom-ide/codeActionsProvider.js @@ -0,0 +1,20 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("../atom/utils"); +function getCodeActionsProvider(codefixProvider) { + return { + grammarScopes: utils_1.typeScriptScopes(), + priority: 0, + async getCodeActions(textEditor, range, _diagnostics) { + return (await codefixProvider.runCodeFix(textEditor, range.start)).map(fix => ({ + getTitle: async () => fix.description, + dispose: () => { }, + apply: async () => { + await codefixProvider.applyFix(fix); + }, + })); + }, + }; +} +exports.getCodeActionsProvider = getCodeActionsProvider; +//# sourceMappingURL=codeActionsProvider.js.map \ No newline at end of file diff --git a/dist/main/atom-ide/codeActionsProvider.js.map b/dist/main/atom-ide/codeActionsProvider.js.map new file mode 100644 index 000000000..f35c49673 --- /dev/null +++ b/dist/main/atom-ide/codeActionsProvider.js.map @@ -0,0 +1 @@ +{"version":3,"file":"codeActionsProvider.js","sourceRoot":"","sources":["../../../lib/main/atom-ide/codeActionsProvider.ts"],"names":[],"mappings":";;AAIA,yCAA8C;AAE9C,SAAgB,sBAAsB,CAAC,eAAgC;IACrE,OAAO;QACL,aAAa,EAAE,wBAAgB,EAAE;QACjC,QAAQ,EAAE,CAAC;QACX,KAAK,CAAC,cAAc,CAClB,UAA2B,EAC3B,KAAiB,EACjB,YAAuB;YAEvB,OAAO,CAAC,MAAM,eAAe,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC7E,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,WAAW;gBACrC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;gBACjB,KAAK,EAAE,KAAK,IAAI,EAAE;oBAChB,MAAM,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;gBACrC,CAAC;aACF,CAAC,CAAC,CAAA;QACL,CAAC;KACF,CAAA;AACH,CAAC;AAlBD,wDAkBC"} \ No newline at end of file diff --git a/dist/main/atom-ide/codeHighlightProvider.js b/dist/main/atom-ide/codeHighlightProvider.js new file mode 100644 index 000000000..997b37904 --- /dev/null +++ b/dist/main/atom-ide/codeHighlightProvider.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("../atom/utils"); +function getCodeHighlightProvider(getClient) { + return { + grammarScopes: utils_1.typeScriptScopes(), + priority: 100, + async highlight(editor, position) { + if (!utils_1.isTypescriptEditorWithPath(editor)) + return; + const location = utils_1.getFilePathPosition(editor, position); + if (!location) + return; + const client = await getClient(location.file); + const result = await client.execute("occurrences", location); + if (!result.body) + return; + return result.body.map(utils_1.spanToRange); + }, + }; +} +exports.getCodeHighlightProvider = getCodeHighlightProvider; +//# sourceMappingURL=codeHighlightProvider.js.map \ No newline at end of file diff --git a/dist/main/atom-ide/codeHighlightProvider.js.map b/dist/main/atom-ide/codeHighlightProvider.js.map new file mode 100644 index 000000000..aa60fcc60 --- /dev/null +++ b/dist/main/atom-ide/codeHighlightProvider.js.map @@ -0,0 +1 @@ +{"version":3,"file":"codeHighlightProvider.js","sourceRoot":"","sources":["../../../lib/main/atom-ide/codeHighlightProvider.ts"],"names":[],"mappings":";;AAEA,yCAKsB;AAEtB,SAAgB,wBAAwB,CAAC,SAA4B;IACnE,OAAO;QACL,aAAa,EAAE,wBAAgB,EAAE;QACjC,QAAQ,EAAE,GAAG;QACb,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ;YAC9B,IAAI,CAAC,kCAA0B,CAAC,MAAM,CAAC;gBAAE,OAAM;YAC/C,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;YACtD,IAAI,CAAC,QAAQ;gBAAE,OAAM;YACrB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YAC7C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAA;YAC5D,IAAI,CAAC,MAAM,CAAC,IAAI;gBAAE,OAAM;YACxB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAW,CAAC,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC;AAdD,4DAcC"} \ No newline at end of file diff --git a/dist/main/atom-ide/datatipProvider.js b/dist/main/atom-ide/datatipProvider.js new file mode 100644 index 000000000..cc207bdd9 --- /dev/null +++ b/dist/main/atom-ide/datatipProvider.js @@ -0,0 +1,109 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Atom = require("atom"); +const utils_1 = require("../atom/utils"); +// Note: a horrible hack to avoid dependency on React +const REACT_ELEMENT_SYMBOL = Symbol.for("react.element"); +const etch = { + dom(type, props, ...children) { + if (children.length > 0) { + return { + $$typeof: REACT_ELEMENT_SYMBOL, + type, + ref: null, + props: Object.assign({}, props, { children }), + }; + } + else { + return { + $$typeof: REACT_ELEMENT_SYMBOL, + type, + ref: null, + props: Object.assign({}, props), + }; + } + }, +}; +class TSDatatipProvider { + constructor(getClient) { + this.getClient = getClient; + this.providerName = "TypeScript type tooltips"; + this.priority = 100; + this.grammarScopes = utils_1.typeScriptScopes(); + } + async datatip(editor, bufferPt) { + try { + const filePath = editor.getPath(); + if (filePath === undefined) + return; + const client = await this.getClient(filePath); + const result = await client.execute("quickinfo", { + file: filePath, + line: bufferPt.row + 1, + offset: bufferPt.column + 1, + }); + const data = result.body; + const code = await highlightCode(data.displayString.replace(/^\(.+?\)\s+/, "")); + const kind = (etch.dom("div", { class: "atom-typescript-datatip-tooltip-kind" }, + data.kind, + data.kindModifiers ? etch.dom("i", null, + " (", + data.kindModifiers, + ")") : null)); + const docs = etch.dom("div", { class: "atom-typescript-datatip-tooltip-doc" }, data.documentation); + return { + component: () => (etch.dom("div", { class: "atom-typescript-datatip-tooltip" }, + code, + kind, + docs)), + range: Atom.Range.fromObject([utils_1.locationToPoint(data.start), utils_1.locationToPoint(data.end)]), + }; + } + catch (e) { + return; + } + } +} +exports.TSDatatipProvider = TSDatatipProvider; +async function highlightCode(code) { + const fontFamily = atom.config.get("editor.fontFamily"); + const ed = new Atom.TextEditor({ + readonly: true, + keyboardInputEnabled: false, + showInvisibles: false, + tabLength: atom.config.get("editor.tabLength"), + }); + const el = atom.views.getView(ed); + try { + el.setUpdatedSynchronously(true); + el.style.pointerEvents = "none"; + el.style.position = "absolute"; + el.style.width = "0px"; + el.style.height = "1px"; + atom.views.getView(atom.workspace).appendChild(el); + atom.grammars.assignLanguageMode(ed.getBuffer(), "source.ts"); + ed.setText(code.replace(/\r?\n$/, "")); + await editorTokenized(ed); + const html = Array.from(el.querySelectorAll(".line:not(.dummy)")); + return (etch.dom("div", { style: { fontFamily }, class: "atom-typescript-datatip-tooltip-code", + // @ts-ignore + dangerouslySetInnerHTML: { __html: html.map(x => x.innerHTML).join("\n") } })); + } + finally { + el.remove(); + } +} +async function editorTokenized(editor) { + return new Promise(resolve => { + if (editor.getBuffer().getLanguageMode().fullyTokenized) { + resolve(); + } + else { + const disp = editor.onDidTokenize(() => { + disp.dispose(); + resolve(); + }); + } + }); +} +//# sourceMappingURL=datatipProvider.js.map \ No newline at end of file diff --git a/dist/main/atom-ide/datatipProvider.js.map b/dist/main/atom-ide/datatipProvider.js.map new file mode 100644 index 000000000..e30424366 --- /dev/null +++ b/dist/main/atom-ide/datatipProvider.js.map @@ -0,0 +1 @@ +{"version":3,"file":"datatipProvider.js","sourceRoot":"","sources":["../../../lib/main/atom-ide/datatipProvider.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAG5B,yCAA+D;AAE/D,qDAAqD;AACrD,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AACxD,MAAM,IAAI,GAAG;IACX,GAAG,CAAC,IAAY,EAAE,KAAU,EAAE,GAAG,QAAe;QAC9C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,OAAO;gBACL,QAAQ,EAAE,oBAAoB;gBAC9B,IAAI;gBACJ,GAAG,EAAE,IAAI;gBACT,KAAK,oBAAM,KAAK,IAAE,QAAQ,GAAC;aAC5B,CAAA;SACF;aAAM;YACL,OAAO;gBACL,QAAQ,EAAE,oBAAoB;gBAC9B,IAAI;gBACJ,GAAG,EAAE,IAAI;gBACT,KAAK,oBAAM,KAAK,CAAC;aAClB,CAAA;SACF;IACH,CAAC;CACF,CAAA;AAED,MAAa,iBAAiB;IAK5B,YAAoB,SAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;QAJhC,iBAAY,GAAG,0BAA0B,CAAA;QACzC,aAAQ,GAAG,GAAG,CAAA;QACd,kBAAa,GAAG,wBAAgB,EAAE,CAAA;IAEC,CAAC;IAE7C,KAAK,CAAC,OAAO,CAClB,MAAuB,EACvB,QAAoB;QAEpB,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,C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C,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAC,GACxE,CACH,CAAA;KACF;YAAS;QACR,EAAE,CAAC,MAAM,EAAE,CAAA;KACZ;AACH,CAAC;AAED,KAAK,UAAU,eAAe,CAAC,MAAuB;IACpD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC,eAAe,EAAE,CAAC,cAAc,EAAE;YACvD,OAAO,EAAE,CAAA;SACV;aAAM;YACL,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE;gBACrC,IAAI,CAAC,OAAO,EAAE,CAAA;gBACd,OAAO,EAAE,CAAA;YACX,CAAC,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"} \ No newline at end of file diff --git a/dist/main/atom-ide/definitionsProvider.js b/dist/main/atom-ide/definitionsProvider.js new file mode 100644 index 000000000..41b1f8af2 --- /dev/null +++ b/dist/main/atom-ide/definitionsProvider.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("../atom/utils"); +function getDefinitionProvider(getClient) { + return { + priority: 0, + grammarScopes: utils_1.typeScriptScopes(), + wordRegExp: /([A-Za-z0-9_])+|['"`](\\.|[^'"`\\\\])*['"`]/g, + async getDefinition(editor, position) { + if (!utils_1.isTypescriptEditorWithPath(editor)) + return; + const location = utils_1.getFilePathPosition(editor, position); + if (!location) + return; + const client = await getClient(location.file); + const result = await client.execute("definition", location); + if (!result.body) + return; + if (result.body.length === 0) + return; + return { + queryRange: undefined, + definitions: result.body.map(fileSpanToDefinition), + }; + }, + }; +} +exports.getDefinitionProvider = getDefinitionProvider; +function fileSpanToDefinition(span) { + const range = utils_1.spanToRange(span); + return { + path: span.file, + position: range.start, + range, + language: "TypeScript", + }; +} +//# sourceMappingURL=definitionsProvider.js.map \ No newline at end of file diff --git a/dist/main/atom-ide/definitionsProvider.js.map b/dist/main/atom-ide/definitionsProvider.js.map new file mode 100644 index 000000000..4a11de4c4 --- /dev/null +++ b/dist/main/atom-ide/definitionsProvider.js.map @@ -0,0 +1 @@ +{"version":3,"file":"definitionsProvider.js","sourceRoot":"","sources":["../../../lib/main/atom-ide/definitionsProvider.ts"],"names":[],"mappings":";;AAGA,yCAKsB;AAEtB,SAAgB,qBAAqB,CAAC,SAA4B;IAChE,OAAO;QACL,QAAQ,EAAE,CAAC;QACX,aAAa,EAAE,wBAAgB,EAAE;QACjC,UAAU,EAAE,8CAA8C;QAC1D,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,QAAQ;YAClC,IAAI,CAAC,kCAA0B,CAAC,MAAM,CAAC;gBAAE,OAAM;YAC/C,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;YACtD,IAAI,CAAC,QAAQ;gBAAE,OAAM;YACrB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YAC7C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;YAC3D,IAAI,CAAC,MAAM,CAAC,IAAI;gBAAE,OAAM;YACxB,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAM;YAEpC,OAAO;gBACL,UAAU,EAAE,SAAS;gBACrB,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC;aACnD,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AApBD,sDAoBC;AAED,SAAS,oBAAoB,CAAC,IAAc;IAC1C,MAAM,KAAK,GAAG,mBAAW,CAAC,IAAI,CAAC,CAAA;IAC/B,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,KAAK,CAAC,KAAK;QACrB,KAAK;QACL,QAAQ,EAAE,YAAY;KACvB,CAAA;AACH,CAAC"} \ No newline at end of file diff --git a/dist/main/atom-ide/findReferencesProvider.js b/dist/main/atom-ide/findReferencesProvider.js new file mode 100644 index 000000000..c8286a43c --- /dev/null +++ b/dist/main/atom-ide/findReferencesProvider.js @@ -0,0 +1,34 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("../atom/utils"); +function getFindReferencesProvider(getClient) { + return { + async isEditorSupported(editor) { + return utils_1.isTypescriptEditorWithPath(editor); + }, + async findReferences(editor, position) { + const location = utils_1.getFilePathPosition(editor, position); + if (!location) + return; + const client = await getClient(location.file); + const result = await client.execute("references", location); + if (!result.body) + return; + return { + type: "data", + baseUri: location.file, + referencedSymbolName: result.body.symbolDisplayString, + references: result.body.refs.map(refTsToIde), + }; + }, + }; +} +exports.getFindReferencesProvider = getFindReferencesProvider; +function refTsToIde(ref) { + return { + uri: ref.file, + range: utils_1.locationsToRange(ref.start, ref.end), + name: undefined, + }; +} +//# sourceMappingURL=findReferencesProvider.js.map \ No newline at end of file diff --git a/dist/main/atom-ide/findReferencesProvider.js.map b/dist/main/atom-ide/findReferencesProvider.js.map new file mode 100644 index 000000000..4e8e9bfc9 --- /dev/null +++ b/dist/main/atom-ide/findReferencesProvider.js.map @@ -0,0 +1 @@ +{"version":3,"file":"findReferencesProvider.js","sourceRoot":"","sources":["../../../lib/main/atom-ide/findReferencesProvider.ts"],"names":[],"mappings":";;AAEA,yCAA+F;AAE/F,SAAgB,yBAAyB,CAAC,SAA4B;IACpE,OAAO;QACL,KAAK,CAAC,iBAAiB,CAAC,MAAM;YAC5B,OAAO,kCAA0B,CAAC,MAAM,CAAC,CAAA;QAC3C,CAAC;QACD,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ;YACnC,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;YACtD,IAAI,CAAC,QAAQ;gBAAE,OAAM;YAErB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YAC7C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;YAC3D,IAAI,CAAC,MAAM,CAAC,IAAI;gBAAE,OAAM;YACxB,OAAO;gBACL,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,QAAQ,CAAC,IAAI;gBACtB,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,mBAAmB;gBACrD,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;aAC7C,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AApBD,8DAoBC;AAED,SAAS,UAAU,CAAC,GAAoC;IACtD,OAAO;QACL,GAAG,EAAE,GAAG,CAAC,IAAI;QACb,KAAK,EAAE,wBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC;QAC3C,IAAI,EAAE,SAAS;KAChB,CAAA;AACH,CAAC"} \ No newline at end of file diff --git a/dist/main/atom/hyperclickProvider.js b/dist/main/atom-ide/hyperclickProvider.js similarity index 57% rename from dist/main/atom/hyperclickProvider.js rename to dist/main/atom-ide/hyperclickProvider.js index f9ace4674..bd19fee90 100644 --- a/dist/main/atom/hyperclickProvider.js +++ b/dist/main/atom-ide/hyperclickProvider.js @@ -1,19 +1,18 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const goToDeclaration_1 = require("./commands/goToDeclaration"); -const utils_1 = require("./utils"); -function getHyperclickProvider(clientResolver, editorPosHist) { +const goToDeclaration_1 = require("../atom/commands/goToDeclaration"); +const utils_1 = require("../atom/utils"); +function getHyperclickProvider(getClient, histGoForward) { return { + priority: 0, providerName: "typescript-hyperclick-provider", wordRegExp: /([A-Za-z0-9_])+|['"`](\\.|[^'"`\\\\])*['"`]/g, - getSuggestionForWord(editor, _text, range) { - if (!utils_1.isTypescriptEditorWithPath(editor)) { - return null; - } + async getSuggestionForWord(editor, _text, range) { + if (!utils_1.isTypescriptEditorWithPath(editor)) + return; const filePath = editor.getPath(); - if (filePath === undefined) { - return null; - } + if (filePath === undefined) + return; return { range, callback: async () => { @@ -22,9 +21,9 @@ function getHyperclickProvider(clientResolver, editorPosHist) { line: range.start.row + 1, offset: range.start.column + 1, }; - const client = await clientResolver.get(location.file); + const client = await getClient(location.file); const result = await client.execute("definition", location); - goToDeclaration_1.handleDefinitionResult(result, editor, editorPosHist); + await goToDeclaration_1.handleDefinitionResult(result, editor, histGoForward); }, }; }, diff --git a/dist/main/atom-ide/hyperclickProvider.js.map b/dist/main/atom-ide/hyperclickProvider.js.map new file mode 100644 index 000000000..eca6b07b3 --- /dev/null +++ b/dist/main/atom-ide/hyperclickProvider.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hyperclickProvider.js","sourceRoot":"","sources":["../../../lib/main/atom-ide/hyperclickProvider.ts"],"names":[],"mappings":";;AAGA,sEAAuE;AAEvE,yCAAwD;AAExD,SAAgB,qBAAqB,CACnC,SAA4B,EAC5B,aAA4C;IAE5C,OAAO;QACL,QAAQ,EAAE,CAAC;QACX,YAAY,EAAE,gCAAgC;QAC9C,UAAU,EAAE,8CAA8C;QAC1D,KAAK,CAAC,oBAAoB,CAAC,MAAuB,EAAE,KAAa,EAAE,KAAiB;YAClF,IAAI,CAAC,kCAA0B,CAAC,MAAM,CAAC;gBAAE,OAAM;YAC/C,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;YACjC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAM;YAElC,OAAO;gBACL,KAAK;gBACL,QAAQ,EAAE,KAAK,IAAI,EAAE;oBACnB,MAAM,QAAQ,GAAG;wBACf,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;wBACzB,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;qBAC/B,CAAA;oBACD,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;oBAC7C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;oBAC3D,MAAM,wCAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,CAAA;gBAC7D,CAAC;aACF,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AA5BD,sDA4BC"} \ No newline at end of file diff --git a/dist/main/atom-ide/outlineProvider.js b/dist/main/atom-ide/outlineProvider.js new file mode 100644 index 000000000..753cc278f --- /dev/null +++ b/dist/main/atom-ide/outlineProvider.js @@ -0,0 +1,91 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("../atom/utils"); +function getOutlineProvider(getClient) { + return { + name: "Atom-TypeScript", + grammarScopes: utils_1.typeScriptScopes(), + priority: 100, + updateOnEdit: true, + async getOutline(editor) { + const filePath = editor.getPath(); + if (filePath === undefined) + return; + const client = await getClient(filePath); + const navTreeResult = await client.execute("navtree", { file: filePath }); + const navTree = navTreeResult.body; + if (!navTree) + return; + return { outlineTrees: [navTreeToOutline(navTree)] }; + }, + }; +} +exports.getOutlineProvider = getOutlineProvider; +function navTreeToOutline(navTree) { + const ranges = navTree.spans.map(utils_1.spanToRange); + const range = ranges.reduce((prev, cur) => cur.union(prev)); + return { + kind: kindMap[navTree.kind], + plainText: navTree.text, + startPosition: range.start, + endPosition: range.end, + landingPosition: navTree.nameSpan ? utils_1.spanToRange(navTree.nameSpan).start : undefined, + children: navTree.childItems ? navTree.childItems.map(navTreeToOutline) : [], + }; +} +const kindMap = { + // | "file" + directory: "file", + // | "module" + module: "module", + "external module name": "module", + // | "namespace" + // | "package" + // | "class" + class: "class", + "local class": "class", + // | "method" + method: "method", + // | "property" + property: "property", + getter: "property", + setter: "property", + // | "field" + "JSX attribute": "field", + // | "constructor" + constructor: "constructor", + // | "enum" + enum: "enum", + // | "interface" + interface: "interface", + type: "interface", + // | "function" + function: "function", + "local function": "function", + // | "variable" + label: "variable", + alias: "variable", + var: "variable", + let: "variable", + "local var": "variable", + parameter: "variable", + // | "constant" + "enum member": "constant", + const: "constant", + // | "string" + string: "string", + // | "number" + // | "boolean" + // | "array" + // ??? + "": undefined, + warning: undefined, + keyword: undefined, + script: undefined, + call: undefined, + index: undefined, + construct: undefined, + "type parameter": undefined, + "primitive type": undefined, +}; +//# sourceMappingURL=outlineProvider.js.map \ No newline at end of file diff --git a/dist/main/atom-ide/outlineProvider.js.map b/dist/main/atom-ide/outlineProvider.js.map new file mode 100644 index 000000000..398d85f4b --- /dev/null +++ b/dist/main/atom-ide/outlineProvider.js.map @@ -0,0 +1 @@ +{"version":3,"file":"outlineProvider.js","sourceRoot":"","sources":["../../../lib/main/atom-ide/outlineProvider.ts"],"names":[],"mappings":";;AAGA,yCAA2D;AAE3D,SAAgB,kBAAkB,CAAC,SAA4B;IAC7D,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,aAAa,EAAE,wBAAgB,EAAE;QACjC,QAAQ,EAAE,GAAG;QACb,YAAY,EAAE,IAAI;QAClB,KAAK,CAAC,UAAU,CAAC,MAAM;YACrB,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;YACjC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAM;YAClC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAA;YACxC,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAA;YACvE,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAA;YAClC,IAAI,CAAC,OAAO;gBAAE,OAAM;YACpB,OAAO,EAAC,YAAY,EAAE,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAAC,CAAA;QACpD,CAAC;KACF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AI,EAAE,WAAW;IACjB,eAAe;IACf,QAAQ,EAAE,UAAU;IACpB,gBAAgB,EAAE,UAAU;IAC5B,eAAe;IACf,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,UAAU;IACjB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,UAAU;IACf,WAAW,EAAE,UAAU;IACvB,SAAS,EAAE,UAAU;IACrB,eAAe;IACf,aAAa,EAAE,UAAU;IACzB,KAAK,EAAE,UAAU;IACjB,aAAa;IACb,MAAM,EAAE,QAAQ;IAChB,aAAa;IACb,cAAc;IACd,YAAY;IACZ,MAAM;IACN,EAAE,EAAE,SAAS;IACb,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,SAAS;IACpB,gBAAgB,EAAE,SAAS;IAC3B,gBAAgB,EAAE,SAAS;CAC5B,CAAA"} \ No newline at end of file diff --git a/dist/main/atom-ide/sigHelpProvider.js b/dist/main/atom-ide/sigHelpProvider.js new file mode 100644 index 000000000..c7c221cef --- /dev/null +++ b/dist/main/atom-ide/sigHelpProvider.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("../atom/utils"); +class TSSigHelpProvider { + constructor(getClient, flushTypescriptBuffer) { + this.getClient = getClient; + this.flushTypescriptBuffer = flushTypescriptBuffer; + this.triggerCharacters = new Set(["(", ","]); + this.grammarScopes = utils_1.typeScriptScopes(); + this.priority = 100; + } + async getSignatureHelp(editor, pos) { + try { + const filePath = editor.getPath(); + if (filePath === undefined) + return; + const client = await this.getClient(filePath); + await this.flushTypescriptBuffer(filePath); + const result = await client.execute("signatureHelp", { + file: filePath, + line: pos.row + 1, + offset: pos.column + 1, + }); + const data = result.body; + const signatures = data.items.map(utils_1.signatureHelpItemToSignature); + return { + signatures, + activeParameter: data.argumentIndex, + activeSignature: data.selectedItemIndex, + }; + } + catch (e) { + return; + } + } +} +exports.TSSigHelpProvider = TSSigHelpProvider; +//# sourceMappingURL=sigHelpProvider.js.map \ No newline at end of file diff --git a/dist/main/atom-ide/sigHelpProvider.js.map b/dist/main/atom-ide/sigHelpProvider.js.map new file mode 100644 index 000000000..229392549 --- /dev/null +++ b/dist/main/atom-ide/sigHelpProvider.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sigHelpProvider.js","sourceRoot":"","sources":["../../../lib/main/atom-ide/sigHelpProvider.ts"],"names":[],"mappings":";;AAGA,yCAA4E;AAG5E,MAAa,iBAAiB;IAK5B,YACU,SAA4B,EAC5B,qBAA4C;QAD5C,cAAS,GAAT,SAAS,CAAmB;QAC5B,0BAAqB,GAArB,qBAAqB,CAAuB;QAN/C,sBAAiB,GAAG,IAAI,GAAG,CAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;QAC/C,kBAAa,GAAG,wBAAgB,EAAE,CAAA;QAClC,aAAQ,GAAG,GAAG,CAAA;IAKlB,CAAC;IAEG,KAAK,CAAC,gBAAgB,CAC3B,MAAkB,EAClB,GAAU;QAEV,IAAI;YACF,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;YACjC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAM;YAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;YAC7C,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAA;YAC1C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE;gBACnD,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;gBACjB,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC;aACvB,CAAC,CAAA;YACF,MAAM,IAAI,GAAG,MAAM,CAAC,IAAK,CAAA;YACzB,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,oCAA4B,CAAC,CAAA;YAC/D,OAAO;gBACL,UAAU;gBACV,eAAe,EAAE,IAAI,CAAC,aAAa;gBACnC,eAAe,EAAE,IAAI,CAAC,iBAAiB;aACxC,CAAA;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAM;SACP;IACH,CAAC;CACF;AAnCD,8CAmCC"} \ No newline at end of file diff --git a/dist/main/atom/autoCompleteProvider.js b/dist/main/atom/autoCompleteProvider.js index 034607fa3..18c901172 100644 --- a/dist/main/atom/autoCompleteProvider.js +++ b/dist/main/atom/autoCompleteProvider.js @@ -1,20 +1,21 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("./utils"); +// more: https://github.com/atom-community/autocomplete-plus/wiki/Provider-API const Atom = require("atom"); const fuzzaldrin = require("fuzzaldrin"); +const utils_1 = require("./utils"); const importPathScopes = ["meta.import", "meta.import-equals", "triple-slash-directive"]; class AutocompleteProvider { - constructor(clientResolver, opts) { + constructor(getClient, flushTypescriptBuffer) { + this.getClient = getClient; + this.flushTypescriptBuffer = flushTypescriptBuffer; this.selector = utils_1.typeScriptScopes() .map(x => (x.includes(".") ? `.${x}` : x)) .join(", "); this.disableForSelector = ".comment"; this.inclusionPriority = 3; - this.suggestionPriority = atom.config.get("atom-typescript.autocompletionSuggestionPriority"); + this.suggestionPriority = atom.config.get("atom-typescript").autocompletionSuggestionPriority; this.excludeLowerPriority = false; - this.clientResolver = clientResolver; - this.opts = opts; } async getSuggestions(opts) { const location = getLocationQuery(opts); @@ -41,9 +42,7 @@ class AutocompleteProvider { } } // Flush any pending changes for this buffer to get up to date completions - await this.opts.withTypescriptBuffer(location.file, async (buffer) => { - await buffer.flush(); - }); + await this.flushTypescriptBuffer(location.file); try { let suggestions = await this.getSuggestionsWithCache(prefix, location, opts.activatedManually); const alphaPrefix = prefix.replace(/\W/g, ""); @@ -94,7 +93,7 @@ class AutocompleteProvider { } } } - const client = await this.clientResolver.get(location.file); + const client = await this.getClient(location.file); const completions = await client.execute("completions", Object.assign({ prefix, includeExternalModuleExports: false, includeInsertTextCompletions: true }, location)); const suggestions = completions.body.map(completionEntryToSuggestion); this.lastSuggestions = { @@ -159,36 +158,43 @@ function completionEntryToSuggestion(entry) { text: entry.insertText !== undefined ? entry.insertText : entry.name, leftLabel: entry.kind, replacementRange: entry.replacementSpan ? utils_1.spanToRange(entry.replacementSpan) : undefined, - type: kindToType(entry.kind), + type: kindMap[entry.kind], }; } -/** See types : - * https://github.com/atom-community/autocomplete-plus/pull/334#issuecomment-85697409 - */ -function kindToType(kind) { - // variable, constant, property, value, method, function, class, type, keyword, tag, snippet, import, require - switch (kind) { - case "const": - return "constant"; - case "interface": - return "type"; - case "identifier": - return "variable"; - case "local function": - return "function"; - case "local var": - return "variable"; - case "let": - case "var": - case "parameter": - return "variable"; - case "alias": - return "import"; - case "type parameter": - return "type"; - default: - return kind.split(" ")[0]; - } -} -exports.kindToType = kindToType; +const kindMap = { + directory: "require", + module: "import", + "external module name": "import", + class: "class", + "local class": "class", + method: "method", + property: "property", + getter: "property", + setter: "property", + "JSX attribute": "property", + constructor: "method", + enum: "type", + interface: "type", + type: "type", + "type parameter": "type", + "primitive type": "type", + function: "function", + "local function": "function", + label: "variable", + alias: "import", + var: "variable", + let: "variable", + "local var": "variable", + parameter: "variable", + "enum member": "constant", + const: "constant", + string: "value", + keyword: "keyword", + "": undefined, + warning: undefined, + script: undefined, + call: undefined, + index: undefined, + construct: undefined, +}; //# sourceMappingURL=autoCompleteProvider.js.map \ No newline at end of file diff --git a/dist/main/atom/autoCompleteProvider.js.map b/dist/main/atom/autoCompleteProvider.js.map index b0c71d2c5..9bf8c4574 100644 --- a/dist/main/atom/autoCompleteProvider.js.map +++ b/dist/main/atom/autoCompleteProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"autoCompleteProvider.js","sourceRoot":"","sources":["../../../lib/main/atom/autoCompleteProvider.ts"],"names":[],"mappings":";;AAEA,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AAU,CAAA;QACnB,KAAK,KAAK,CAAC;QACX,KAAK,KAAK,CAAC;QACX,KAAK,WAAW;YACd,OAAO,UAAU,CAAA;QACnB,KAAK,OAAO;YACV,OAAO,QAAQ,CAAA;QACjB,KAAK,gBAAgB;YACnB,OAAO,MAAM,CAAA;QACf;YACE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;KAC5B;AACH,CAAC;AAxBD,gCAwBC"} \ No newline at end of file +{"version":3,"file":"autoCompleteProvider.js","sourceRoot":"","sources":["../../../lib/main/atom/autoCompleteProvider.ts"],"names":[],"mappings":";;AAAA,8EAA8E;AAC9E,6BAA4B;AAE5B,yCAAwC;AAGxC,mCAAwE;AAExE,MAAM,gBAAgB,GAAG,CAAC,aAAa,EAAE,oBAAoB,EAAE,wBAAwB,CAAC,CAAA;AAOxF,MAAa,oBAAoB;IAyB/B,YACU,SAA4B,EAC5B,qBAA4C;QAD5C,cAAS,GAAT,SAAS,CAAmB;QAC5B,0BAAqB,GAArB,qBAAqB,CAAuB;QA1B/C,aAAQ,GAAG,wBAAgB,EAAE;aACjC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aACzC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEN,uBAAkB,GAAG,UAAU,CAAA;QAE/B,sBAAiB,GAAG,CAAC,CAAA;QACrB,uBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,gCAAgC,CAAA;QACxF,yBAAoB,GAAG,KAAK,CAAA;IAmBhC,CAAC;IAEG,KAAK,CAAC,cAAc,CAAC,IAAmC;QAC7D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;QACvC,MAAM,EAAC,MAAM,EAAC,GAAG,IAA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KAC1B,CAAA;AACH,CAAC;AAoBD,MAAM,OAAO,GAAyE;IACpF,SAAS,EAAE,SAAS;IACpB,MAAM,EAAE,QAAQ;IAChB,sBAAsB,EAAE,QAAQ;IAChC,KAAK,EAAE,OAAO;IACd,aAAa,EAAE,OAAO;IACtB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,UAAU;IAClB,eAAe,EAAE,UAAU;IAC3B,WAAW,EAAE,QAAQ;IACrB,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,MAAM;IACjB,IAAI,EAAE,MAAM;IACZ,gBAAgB,EAAE,MAAM;IACxB,gBAAgB,EAAE,MAAM;IACxB,QAAQ,EAAE,UAAU;IACpB,gBAAgB,EAAE,UAAU;IAC5B,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,QAAQ;IACf,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,UAAU;IACf,WAAW,EAAE,UAAU;IACvB,SAAS,EAAE,UAAU;IACrB,aAAa,EAAE,UAAU;IACzB,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,OAAO;IACf,OAAO,EAAE,SAAS;IAClB,EAAE,EAAE,SAAS;IACb,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,SAAS,EAAE,SAAS;CACrB,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/codefix/codeActionsProvider.js b/dist/main/atom/codefix/codeActionsProvider.js deleted file mode 100644 index 3b809ff9f..000000000 --- a/dist/main/atom/codefix/codeActionsProvider.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const utils_1 = require("../utils"); -class CodeActionsProvider { - constructor(codefixProvider) { - this.codefixProvider = codefixProvider; - this.grammarScopes = utils_1.typeScriptScopes(); - this.priority = 0; - } - async getCodeActions(textEditor, range, _diagnostics) { - return (await this.codefixProvider.runCodeFix(textEditor, range.start)).map(fix => ({ - getTitle: async () => fix.description, - dispose: () => { }, - apply: async () => { - await this.codefixProvider.applyFix(fix); - }, - })); - } -} -exports.CodeActionsProvider = CodeActionsProvider; -//# sourceMappingURL=codeActionsProvider.js.map \ No newline at end of file diff --git a/dist/main/atom/codefix/codeActionsProvider.js.map b/dist/main/atom/codefix/codeActionsProvider.js.map deleted file mode 100644 index 79349b9fd..000000000 --- a/dist/main/atom/codefix/codeActionsProvider.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"codeActionsProvider.js","sourceRoot":"","sources":["../../../../lib/main/atom/codefix/codeActionsProvider.ts"],"names":[],"mappings":";;AAEA,oCAAyC;AAwBzC,MAAa,mBAAmB;IAI9B,YAAoB,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAH7C,kBAAa,GAAG,wBAAgB,EAAE,CAAA;QAClC,aAAQ,GAAG,CAAC,CAAA;IAEoC,CAAC;IAEjD,KAAK,CAAC,cAAc,CACzB,UAA2B,EAC3B,KAAiB,EACjB,YAAuB;QAEvB,OAAO,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAClF,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,WAAW;YACrC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;YACjB,KAAK,EAAE,KAAK,IAAI,EAAE;gBAChB,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;YAC1C,CAAC;SACF,CAAC,CAAC,CAAA;IACL,CAAC;CACF;AAnBD,kDAmBC"} \ No newline at end of file diff --git a/dist/main/atom/codefix/codefixProvider.js b/dist/main/atom/codefix/codefixProvider.js index cf1bcd36d..6d95ca218 100644 --- a/dist/main/atom/codefix/codefixProvider.js +++ b/dist/main/atom/codefix/codefixProvider.js @@ -8,14 +8,25 @@ class CodefixProvider { this.applyEdits = applyEdits; this.supportedFixes = new WeakMap(); } + async getFixableRanges(textEditor, range) { + const filePath = textEditor.getPath(); + if (filePath === undefined) + return []; + const errors = this.errorPusher.getErrorsInRange(filePath, range); + const client = await this.clientResolver.get(filePath); + const supportedCodes = await this.getSupportedFixes(client); + const ranges = Array.from(errors) + .filter(error => error.code !== undefined && supportedCodes.has(error.code)) + .map(error => utils_1.spanToRange(error)); + return ranges; + } async runCodeFix(textEditor, bufferPosition) { const filePath = textEditor.getPath(); if (filePath === undefined) return []; const client = await this.clientResolver.get(filePath); const supportedCodes = await this.getSupportedFixes(client); - const requests = this.errorPusher - .getErrorsAt(filePath, utils_1.pointToLocation(bufferPosition)) + const requests = Array.from(this.errorPusher.getErrorsAt(filePath, bufferPosition)) .filter(error => error.code !== undefined && supportedCodes.has(error.code)) .map(error => client.execute("getCodeFixes", { file: filePath, @@ -47,7 +58,7 @@ class CodefixProvider { if (codes) { return codes; } - const result = await client.execute("getSupportedCodeFixes", undefined); + const result = await client.execute("getSupportedCodeFixes"); if (!result.body) { throw new Error("No code fixes are supported"); } diff --git a/dist/main/atom/codefix/codefixProvider.js.map b/dist/main/atom/codefix/codefixProvider.js.map index 8ff7efba4..cca1ab3b6 100644 --- a/dist/main/atom/codefix/codefixProvider.js.map +++ b/dist/main/atom/codefix/codefixProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"codefixProvider.js","sourceRoot":"","sources":["../../../../lib/main/atom/codefix/codefixProvider.ts"],"names":[],"mappings":";;AAGA,oCAAwC;AAIxC,MAAa,eAAe;IAG1B,YACU,cAA8B,EAC9B,WAAwB,EACxB,UAAsB;QAFtB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;QALxB,mBAAc,GAAkD,IAAI,OAAO,EAAE,CAAA;IAMlF,CAAC;IAEG,KAA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F;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,GAAwB;QAC5C,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACrC,CAAC;IAEM,OAAO;QACZ,OAAO;IACT,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAC,MAA+B;QAC7D,IAAI,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAC3C,IAAI,KAAK,EAAE;YACT,OAAO,KAAK,CAAA;SACb;QAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAA;QAEvE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;SAC/C;QAED,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;QAC5D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QACtC,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAxED,0CAwEC"} \ No newline at end of file +{"version":3,"file":"codefixProvider.js","sourceRoot":"","sources":["../../../../lib/main/atom/codefix/codefixProvider.ts"],"names":[],"mappings":";;AAIA,oCAAoC;AAEpC,MAAa,eAAe;IAG1B,YACU,cAA8B,EAC9B,WAAwB,EACxB,UAAsB;QAFtB,mBAAc,GAAd,cAAc,CAAgB;QAC9B,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;QALxB,mBAAc,GAAmC,IAAI,OAAO,EAAE,CAAA;IAMnE,CAAC;IAEG,KAAK,CAAC,gBAAgB,CAAC,UAA2B,EAAE,KAAiB;QAC1E,MAAM,Q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K,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;QAC5D,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;QACtC,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AArFD,0CAqFC"} \ No newline at end of file diff --git a/dist/main/atom/codefix/index.js b/dist/main/atom/codefix/index.js index 8c0881a44..fba477584 100644 --- a/dist/main/atom/codefix/index.js +++ b/dist/main/atom/codefix/index.js @@ -1,9 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var codeActionsProvider_1 = require("./codeActionsProvider"); -exports.CodeActionsProvider = codeActionsProvider_1.CodeActionsProvider; -var intentionsProvider_1 = require("./intentionsProvider"); -exports.IntentionsProvider = intentionsProvider_1.IntentionsProvider; var codefixProvider_1 = require("./codefixProvider"); exports.CodefixProvider = codefixProvider_1.CodefixProvider; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/main/atom/codefix/index.js.map b/dist/main/atom/codefix/index.js.map index c78325eaf..f52443065 100644 --- a/dist/main/atom/codefix/index.js.map +++ b/dist/main/atom/codefix/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/main/atom/codefix/index.ts"],"names":[],"mappings":";;AAAA,6DAAyD;AAAjD,oDAAA,mBAAmB,CAAA;AAC3B,2DAAuD;AAA/C,kDAAA,kBAAkB,CAAA;AAC1B,qDAAiD;AAAzC,4CAAA,eAAe,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/main/atom/codefix/index.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AAAzC,4CAAA,eAAe,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/codefix/intentionsProvider.js b/dist/main/atom/codefix/intentionsProvider.js index 9dd2ec848..9888218a5 100644 --- a/dist/main/atom/codefix/intentionsProvider.js +++ b/dist/main/atom/codefix/intentionsProvider.js @@ -1,19 +1,33 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -class IntentionsProvider { - constructor(codefixProvider) { - this.codefixProvider = codefixProvider; - this.grammarScopes = ["*"]; - } - async getIntentions({ bufferPosition, textEditor, }) { - return (await this.codefixProvider.runCodeFix(textEditor, bufferPosition)).map(fix => ({ - priority: 100, - title: fix.description, - selected: () => { - this.codefixProvider.applyFix(fix); - }, - })); - } +const utils_1 = require("../../../utils"); +function getIntentionsProvider(codefixProvider) { + return { + grammarScopes: ["*"], + async getIntentions({ bufferPosition, textEditor }) { + return (await codefixProvider.runCodeFix(textEditor, bufferPosition)).map(fix => ({ + priority: 100, + title: fix.description, + selected: () => { + utils_1.handlePromise(codefixProvider.applyFix(fix)); + }, + })); + }, + }; } -exports.IntentionsProvider = IntentionsProvider; +exports.getIntentionsProvider = getIntentionsProvider; +function getIntentionsHighlightsProvider(codefixProvider) { + return { + grammarScopes: ["*"], + async getIntentions({ visibleRange, textEditor }) { + return (await codefixProvider.getFixableRanges(textEditor, visibleRange)).map(range => ({ + range, + created: (_opts) => { + // NOOP + }, + })); + }, + }; +} +exports.getIntentionsHighlightsProvider = getIntentionsHighlightsProvider; //# sourceMappingURL=intentionsProvider.js.map \ No newline at end of file diff --git a/dist/main/atom/codefix/intentionsProvider.js.map b/dist/main/atom/codefix/intentionsProvider.js.map index 9d7d9c4e2..5b1647fc3 100644 --- a/dist/main/atom/codefix/intentionsProvider.js.map +++ b/dist/main/atom/codefix/intentionsProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"intentionsProvider.js","sourceRoot":"","sources":["../../../../lib/main/atom/codefix/intentionsProvider.ts"],"names":[],"mappings":";;AAqBA,MAAa,kBAAkB;IAG7B,YAAoB,eAAgC;QAAhC,oBAAe,GAAf,eAAe,CAAiB;QAF7C,kBAAa,GAAG,CAAC,GAAG,CAAC,CAAA;IAE2B,CAAC;IAEjD,KAAK,CAAC,aAAa,CAAC,EACzB,cAAc,EACd,UAAU,GACW;QACrB,OAAO,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACrF,QAAQ,EAAE,GAAG;YACb,KAAK,EAAE,GAAG,CAAC,WAAW;YACtB,QAAQ,EAAE,GAAG,EAAE;gBACb,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;YACpC,CAAC;SACF,CAAC,CAAC,CAAA;IACL,CAAC;CACF;AAjBD,gDAiBC"} \ No newline at end of file +{"version":3,"file":"intentionsProvider.js","sourceRoot":"","sources":["../../../../lib/main/atom/codefix/intentionsProvider.ts"],"names":[],"mappings":";;AACA,0CAA4C;AA6C5C,SAAgB,qBAAqB,CACnC,eAAgC;IAEhC,OAAO;QACL,aAAa,EAAE,CAAC,GAAG,CAAC;QACpB,KAAK,CAAC,aAAa,CAAC,EAAC,cAAc,EAAE,UAAU,EAAC;YAC9C,OAAO,CAAC,MAAM,eAAe,CAAC,UAAU,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAChF,QAAQ,EAAE,GAAG;gBACb,KAAK,EAAE,GAAG,CAAC,WAAW;gBACtB,QAAQ,EAAE,GAAG,EAAE;oBACb,qBAAa,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;gBAC9C,CAAC;aACF,CAAC,CAAC,CAAA;QACL,CAAC;KACF,CAAA;AACH,CAAC;AAfD,sDAeC;AAED,SAAgB,+BAA+B,CAC7C,eAAgC;IAEhC,OAAO;QACL,aAAa,EAAE,CAAC,GAAG,CAAC;QACpB,KAAK,CAAC,aAAa,CAAC,EAAC,YAAY,EAAE,UAAU,EAAC;YAC5C,OAAO,CAAC,MAAM,eAAe,CAAC,gBAAgB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBACtF,KAAK;gBACL,OAAO,EAAE,CAAC,KAA0B,EAAE,EAAE;oBACtC,OAAO;gBACT,CAAC;aACF,CAAC,CAAC,CAAA;QACL,CAAC;KACF,CAAA;AACH,CAAC;AAdD,0EAcC"} \ No newline at end of file diff --git a/dist/main/atom/commands/build.js b/dist/main/atom/commands/build.js index 6d75cd0b6..81c8145b6 100644 --- a/dist/main/atom/commands/build.js +++ b/dist/main/atom/commands/build.js @@ -8,6 +8,7 @@ registry_1.addCommand("atom-text-editor", "typescript:build", deps => ({ if (file === undefined) return; const client = await deps.getClient(file); + deps.reportBuildStatus(undefined); const projectInfo = await client.execute("projectInfo", { file, needFileNameList: true, @@ -15,23 +16,21 @@ registry_1.addCommand("atom-text-editor", "typescript:build", deps => ({ const files = new Set(projectInfo.body.fileNames); files.delete(projectInfo.body.configFileName); let filesSoFar = 0; - const stp = deps.getStatusPanel(); const promises = [...files.values()].map(f => _finally(client.execute("compileOnSaveEmitFile", { file: f, forced: true }), () => { - stp.update({ progress: { max: files.size, value: (filesSoFar += 1) } }); - if (files.size <= filesSoFar) - stp.update({ progress: undefined }); + filesSoFar += 1; + deps.reportProgress({ max: files.size, value: filesSoFar }); })); try { const results = await Promise.all(promises); if (results.some(result => result.body === false)) { throw new Error("Emit failed"); } - stp.update({ buildStatus: { success: true } }); + deps.reportBuildStatus({ success: true }); } catch (error) { const err = error; console.error(err); - stp.update({ buildStatus: { success: false, message: err.message } }); + deps.reportBuildStatus({ success: false, message: err.message }); } }, })); diff --git a/dist/main/atom/commands/build.js.map b/dist/main/atom/commands/build.js.map index 433424580..b1228c73a 100644 --- a/dist/main/atom/commands/build.js.map +++ b/dist/main/atom/commands/build.js.map @@ -1 +1 @@ -{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/build.ts"],"names":[],"mapp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,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAC,CAAC,CAAA;SAC/D;IACH,CAAC;CACF,CAAC,CAAC,CAAA;AAEH,SAAS,QAAQ,CAAI,OAAmB,EAAE,QAA6B;IACrE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAChC,OAAO,OAAO,CAAA;AAChB,CAAC"} \ No newline at end of file diff --git a/dist/main/atom/commands/checkAllFiles.js b/dist/main/atom/commands/checkAllFiles.js index 921418a2d..c78081a03 100644 --- a/dist/main/atom/commands/checkAllFiles.js +++ b/dist/main/atom/commands/checkAllFiles.js @@ -22,25 +22,20 @@ registry_1.addCommand("atom-text-editor", "typescript:check-all-files", deps => const disp = client.on("syntaxDiag", evt => { if (cancelTimeout !== undefined) window.clearTimeout(cancelTimeout); - cancelTimeout = window.setTimeout(cancel, 500); + cancelTimeout = window.setTimeout(cancel, 2000); files.delete(evt.file); updateStatus(); }); - const stp = deps.getStatusPanel(); - stp.update({ progress: { max, value: 0 } }); - client.execute("geterrForProject", { file, delay: 0 }); + deps.reportProgress({ max, value: 0 }); + await client.execute("geterrForProject", { file, delay: 0 }); function cancel() { files.clear(); updateStatus(); } function updateStatus() { - if (files.size === 0) { + if (files.size === 0) disp.dispose(); - stp.update({ progress: undefined }); - } - else { - stp.update({ progress: { max, value: max - files.size } }); - } + deps.reportProgress({ max, value: max - files.size }); } }, })); diff --git a/dist/main/atom/commands/checkAllFiles.js.map b/dist/main/atom/commands/checkAllFiles.js.map index db12aea85..55ffdb87d 100644 --- a/dist/main/atom/commands/checkAllFiles.js.map +++ b/dist/main/atom/commands/checkAllFiles.js.map @@ -1 +1 @@ -{"version":3,"file":"checkAllFiles.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/checkAllFiles.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,4BAA4B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,WAAW,E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AE,CAAA;QAChB,CAAC;QAED,SAAS,YAAY;YACnB,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE;gBACpB,IAAI,CAAC,OAAO,EAAE,CAAA;gBACd,GAAG,CAAC,MAAM,CAAC,EAAC,QAAQ,EAAE,SAAS,EAAC,CAAC,CAAA;aAClC;iBAAM;gBACL,GAAG,CAAC,MAAM,CAAC,EAAC,QAAQ,EAAE,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,CAAC,IAAI,EAAC,EAAC,CAAC,CAAA;aACvD;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"checkAllFiles.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/checkAllFiles.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,4BAA4B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,sEAAsE;IACnF,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;QAC7B,IAAI,IAAI,KAAK,SAAS;YAAE,OAAM;QAC9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QAEzC,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE;YACtD,IAAI;YACJ,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAA;QAEF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,IAAK,CAAC,SAAS,CAAC,CAAA;QAClD,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAA;QAEtB,gGAAgG;QAChG,iGAAiG;QACjG,kGAAkG;QAClG,2BAA2B;QAC3B,IAAI,aAAiC,CAAA;QAErC,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,CAAC,EAAE;YACzC,IAAI,aAAa,KAAK,SAAS;gBAAE,MAAM,CAAC,YAAY,CAAC,aAAa,CAAC,CAAA;YACnE,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YAE/C,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;YACtB,YAAY,EAAE,CAAA;QAChB,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,cAAc,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC,CAAA;QACpC,MAAM,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAAC,CAAC,CAAA;QAE1D,SAAS,MAAM;YACb,KAAK,CAAC,KAAK,EAAE,CAAA;YACb,YAAY,EAAE,CAAA;QAChB,CAAC;QAED,SAAS,YAAY;YACnB,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC;gBAAE,IAAI,CAAC,OAAO,EAAE,CAAA;YACpC,IAAI,CAAC,cAAc,CAAC,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,KAAK,CAAC,IAAI,EAAC,CAAC,CAAA;QACrD,CAAC;IACH,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/clearErrors.js b/dist/main/atom/commands/clearErrors.js index dacb14e80..30c18c4fa 100644 --- a/dist/main/atom/commands/clearErrors.js +++ b/dist/main/atom/commands/clearErrors.js @@ -7,14 +7,4 @@ registry_1.addCommand("atom-workspace", "typescript:clear-errors", deps => ({ deps.clearErrors(); }, })); -registry_1.addCommand("atom-text-editor", "typescript:reload-projects", deps => ({ - description: "Reload projects", - async didDispatch(editor) { - const path = editor.getPath(); - if (path === undefined) - return; - const client = await deps.getClient(path); - client.execute("reloadProjects", undefined); - }, -})); //# sourceMappingURL=clearErrors.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/clearErrors.js.map b/dist/main/atom/commands/clearErrors.js.map index 3d7198756..3d23f055f 100644 --- a/dist/main/atom/commands/clearErrors.js.map +++ b/dist/main/atom/commands/clearErrors.js.map @@ -1 +1 @@ -{"version":3,"file":"clearErrors.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/clearErrors.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,gBAAgB,EAAE,yBAAyB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/D,WAAW,EAAE,sBAAsB;IACnC,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,CAAA;IACpB,CAAC;CACF,CAAC,CAAC,CAAA;AAEH,qBAAU,CAAC,kBAAkB,EAAE,4BAA4B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,iBAAiB;IAC9B,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;QAC7B,IAAI,IAAI,KAAK,SAAS;YAAE,OAAM;QAC9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACzC,MAAM,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAA;IAC7C,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"clearErrors.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/clearErrors.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,gBAAgB,EAAE,yBAAyB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/D,WAAW,EAAE,sBAAsB;IACnC,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,CAAA;IACpB,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/findReferences.js b/dist/main/atom/commands/findReferences.js index 061ed1227..9d6683d86 100644 --- a/dist/main/atom/commands/findReferences.js +++ b/dist/main/atom/commands/findReferences.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const registry_1 = require("./registry"); -const utils_1 = require("../utils"); -const simpleSelectionView_1 = require("../views/simpleSelectionView"); const etch = require("etch"); const tsView_1 = require("../components/tsView"); +const utils_1 = require("../utils"); const highlightComponent_1 = require("../views/highlightComponent"); +const simpleSelectionView_1 = require("../views/simpleSelectionView"); +const registry_1 = require("./registry"); registry_1.addCommand("atom-text-editor", "typescript:find-references", deps => ({ description: "Find where symbol under text cursor is referenced", async didDispatch(editor) { @@ -27,7 +27,7 @@ registry_1.addCommand("atom-text-editor", "typescript:find-references", deps => itemFilterKey: "file", }); if (res) - deps.getEditorPositionHistoryManager().goForward(editor, res); + await deps.histGoForward(editor, res); }, })); //# sourceMappingURL=findReferences.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/findReferences.js.map b/dist/main/atom/commands/findReferences.js.map index 6ba1073ad..b8ffb67c5 100644 --- a/dist/main/atom/commands/findReferences.js.map +++ b/dist/main/atom/commands/findReferences.js.map @@ -1 +1 @@ -{"version":3,"file":"findReferences.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/findReferences.tsx"],"names":[],"mappings":";;AAAA,yCAAqC;AACrC,oCAA4C;AAC5C,sEAA2D;AAC3D,6BAA4B;AAC5B,iDAA2C;AAC3C,oEAA8D;AAE9D,qBAAU,CAAC,kBAAkB,EAAE,4BAA4B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,mDAAmD;IAChE,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAM;QAErB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;QAE3D,MAAM,GAAG,GAAG,MAAM,oCAAc,CAAC;YAC/B,KAAK,EAAE,MAAM,CAAC,IAAK,CAAC,IAAI;YACxB,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;gBAC1B,OAAO,CACL;oBACE,SAAC,uCAAkB,IACjB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EACzC,KAAK,EAAE,GAAG,CAAC,cAAc,EAAE,GAC3B;oBACF,kBAAK,KAAK,EAAC,YAAY;;wBAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAO;oBACrD,SAAC,eAAM,IAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAI,CACnC,CACN,CAAA;YACH,CAAC;YACD,aAAa,EAAE,MAAM;SACtB,CAAC,CAAA;QACF,IAAI,GAAG;YAAE,IAAI,CAAC,+BAA+B,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxE,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"findReferences.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/findReferences.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,iDAA2C;AAC3C,oCAA4C;AAC5C,oEAA8D;AAC9D,sEAA2D;AAC3D,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,4BAA4B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,mDAAmD;IAChE,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAM;QAErB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;QAE3D,MAAM,GAAG,GAAG,MAAM,oCAAc,CAAC;YAC/B,KAAK,EAAE,MAAM,CAAC,IAAK,CAAC,IAAI;YACxB,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;gBAC1B,OAAO,CACL;oBACE,SAAC,uCAAkB,IACjB,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EACzC,KAAK,EAAE,GAAG,CAAC,cAAc,EAAE,GAC3B;oBACF,kBAAK,KAAK,EAAC,YAAY;;wBAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAO;oBACrD,SAAC,eAAM,IAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAI,CACnC,CACN,CAAA;YACH,CAAC;YACD,aAAa,EAAE,MAAM;SACtB,CAAC,CAAA;QACF,IAAI,GAAG;YAAE,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChD,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/formatCode.js b/dist/main/atom/commands/formatCode.js index 72f004e9a..dac5ac691 100644 --- a/dist/main/atom/commands/formatCode.js +++ b/dist/main/atom/commands/formatCode.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const registry_1 = require("./registry"); const utils_1 = require("../utils"); +const registry_1 = require("./registry"); registry_1.addCommand("atom-text-editor", "typescript:format-code", deps => ({ description: "Format code in currently active text editor", async didDispatch(editor) { diff --git a/dist/main/atom/commands/formatCode.js.map b/dist/main/atom/commands/formatCode.js.map index 56f1ee2db..008d8b121 100644 --- a/dist/main/atom/commands/formatCode.js.map +++ b/dist/main/atom/commands/formatCode.js.map @@ -1 +1 @@ -{"version":3,"file":"formatCode.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands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,CAAC,CAAA;aAC3B;SACF;QAED,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACpB,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE;gBACnB,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;YAC3B,CAAC,CAAC,CAAA;SACH;IACH,CAAC;CACF,CAAC,CAAC,CAAA;AAEH,SAAS,UAAU,CAAC,MAAkB,EAAE,KAAiB;IACvD,qDAAqD;IACrD,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1C,MAAM,CAAC,oBAAoB,CAAC,mBAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;KACrE;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"formatCode.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/formatCode.ts"],"names":[],"mappings":";;AACA,oCAAwF;AACxF,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,wBAAwB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAChE,WAAW,EAAE,6CAA6C;IAC1D,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;QACjC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAM;QAElC,MAAM,MAAM,GAAyB,EAAE,CAAA;QAEvC,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,uBAAuB,EAAE,EAAE;YACxD,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE;gBACxB,MAAM,CAAC,IAAI,CAAC,4BAAoB,CAAC,SAAS,CAAC,CAAC,CAAA;aAC7C;SACF;QAED,yDAAyD;QACzD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM,GAAG,GAAG,MAAM,CAAC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9105e9d33 100644 --- a/dist/main/atom/commands/goToDeclaration.js +++ b/dist/main/atom/commands/goToDeclaration.js @@ -1,10 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const registry_1 = require("./registry"); -const utils_1 = require("../utils"); -const simpleSelectionView_1 = require("../views/simpleSelectionView"); const etch = require("etch"); +const utils_1 = require("../utils"); const highlightComponent_1 = require("../views/highlightComponent"); +const simpleSelectionView_1 = require("../views/simpleSelectionView"); +const registry_1 = require("./registry"); registry_1.addCommand("atom-text-editor", "typescript:go-to-declaration", deps => ({ description: "Go to declaration of symbol under text cursor", async didDispatch(editor) { @@ -13,10 +13,10 @@ registry_1.addCommand("atom-text-editor", "typescript:go-to-declaration", deps = return; const client = await deps.getClient(location.file); const result = await client.execute("definition", location); - handleDefinitionResult(result, editor, deps.getEditorPositionHistoryManager()); + await handleDefinitionResult(result, editor, deps.histGoForward); }, })); -async function handleDefinitionResult(result, editor, hist) { +async function handleDefinitionResult(result, editor, histGoForward) { if (!result.body) { return; } @@ -33,10 +33,10 @@ async function handleDefinitionResult(result, editor, hist) { itemFilterKey: "file", }); if (res) - hist.goForward(editor, res); + await histGoForward(editor, res); } else if (result.body.length > 0) { - hist.goForward(editor, result.body[0]); + await histGoForward(editor, result.body[0]); } } exports.handleDefinitionResult = handleDefinitionResult; diff --git a/dist/main/atom/commands/goToDeclaration.js.map b/dist/main/atom/commands/goToDeclaration.js.map index 36a72d9d3..6b9c04e1b 100644 --- a/dist/main/atom/commands/goToDeclaration.js.map +++ b/dist/main/atom/commands/goToDeclaration.js.map @@ -1 +1 @@ -{"version":3,"file":"goToDeclaration.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/goToDeclaration.tsx"],"names":[],"mappings":";;AAAA,yCAAqC;AACrC,oCAA4C;AAC5C,sEAA2D;AAC3D,6BAA4B;AAC5B,oEAA8D;AAI9D,qBAAU,CAAC,kBAAkB,EAAE,8BAA8B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;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,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;KACvC;AACH,CAAC;AAxBD,wDAwBC"} \ No newline at end of file +{"version":3,"file":"goToDeclaration.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/goToDeclaration.tsx"],"names":[],"mappings":";;AACA,6BAA4B;AAC5B,oCAA4C;AAC5C,oEAA8D;AAC9D,sEAA2D;AAC3D,yCAAmD;AAEnD,qBAAU,CAAC,kBAAkB,EAAE,8BAA8B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,WAAW,EAAE,+CAA+C;IAC5D,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAM;QAErB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;QAC3D,MAAM,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;IAClE,CAAC;CACF,CAAC,CAAC,CAAA;AAEI,KAAK,UAAU,sBAAsB,CAC1C,MAAmC,EACnC,MAAkB,EAClB,aAA4C;IAE5C,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;QAChB,OAAM;KACP;SAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACjC,MAAM,GAAG,GAAG,MAAM,oCAAc,CAAC;YAC/B,KAAK,EAAE,MAAM,CAAC,IAAI;YAClB,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;gBAC1B,OAAO,CACL;oBACE,SAAC,uCAAkB,IAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,cAAc,EAAE,GAAI;oBACrE,kBAAK,KAAK,EAAC,YAAY;;wBAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAO,CAClD,CACN,CAAA;YACH,CAAC;YACD,aAAa,EAAE,MAAM;SACtB,CAAC,CAAA;QACF,IAAI,GAAG;YAAE,MAAM,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAC1C;SAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QACjC,MAAM,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;KAC5C;AACH,CAAC;AAxBD,wDAwBC"} \ No newline at end of file diff --git a/dist/main/atom/commands/hideSigHelp.js b/dist/main/atom/commands/hideSigHelp.js new file mode 100644 index 000000000..4f42c83ff --- /dev/null +++ b/dist/main/atom/commands/hideSigHelp.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const registry_1 = require("./registry"); +registry_1.addCommand("atom-text-editor", "typescript:hide-signature-help", deps => ({ + description: "Hide the currently visible signature help", + async didDispatch(ed, ignore) { + if (!deps.hideSigHelpAt(ed)) + ignore(); + }, +})); +//# sourceMappingURL=hideSigHelp.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/hideSigHelp.js.map b/dist/main/atom/commands/hideSigHelp.js.map new file mode 100644 index 000000000..326b3e59e --- /dev/null +++ b/dist/main/atom/commands/hideSigHelp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hideSigHelp.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/hideSigHelp.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,gCAAgC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACxE,WAAW,EAAE,2CAA2C;IACxD,KAAK,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM;QAC1B,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;YAAE,MAAM,EAAE,CAAA;IACvC,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/index.js b/dist/main/atom/commands/index.js index f0acf1601..e51d44d92 100644 --- a/dist/main/atom/commands/index.js +++ b/dist/main/atom/commands/index.js @@ -1,23 +1,27 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const registry_1 = require("./registry"); const atom_1 = require("atom"); const utils_1 = require("../utils"); +const registry_1 = require("./registry"); // Import all of the command files for their side effects require("./build"); require("./checkAllFiles"); require("./clearErrors"); -require("./formatCode"); require("./findReferences"); +require("./formatCode"); require("./goToDeclaration"); -require("./returnFromDeclaration"); -require("./renameRefactor"); -require("./showTooltip"); +require("./hideSigHelp"); require("./initializeConfig"); +require("./organizeImports"); +require("./refactorCode"); +require("./reloadProjects"); +require("./renameRefactor"); +require("./restartAllServers"); +require("./returnFromDeclaration"); require("./semanticView"); +require("./showSigHelp"); +require("./showTooltip"); require("./symbolsView"); -require("./refactorCode"); -require("./organizeImports"); function registerCommands(deps) { const disp = new atom_1.CompositeDisposable(); for (const cmd of registry_1.getCommands()) { @@ -48,14 +52,14 @@ function registerCommands(deps) { } else { const d = cmd.desc(deps); - atom.commands.add(cmd.selector, cmd.command, Object.assign({}, d, { async didDispatch() { + disp.add(atom.commands.add(cmd.selector, cmd.command, Object.assign({}, d, { async didDispatch() { try { await d.didDispatch(); } catch (error) { handle(error); } - } })); + } }))); } } return disp; diff --git a/dist/main/atom/commands/index.js.map b/dist/main/atom/commands/index.js.map index 37238f3b9..04ee7851b 100644 --- a/dist/main/atom/commands/index.js.map +++ b/dist/main/atom/commands/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/index.ts"],"names":[],"mappings":";;AAAA,yCAAoD;AACpD,+BAAwC;AACxC,oCAAwE;AAExE,yDAAyD;AACzD,mBAAgB;AAChB,2BAAwB;AACxB,yBAAsB;AACtB,wBAAqB;AACrB,4BA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CAAC,IAAI,CAAC,CAAA;YACxB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,oBACtC,CAAC,IACJ,KAAK,CAAC,WAAW;oBACf,IAAI;wBACF,MAAM,CAAC,CAAC,WAAW,EAAE,CAAA;qBACtB;oBAAC,OAAO,KAAK,EAAE;wBACd,MAAM,CAAC,KAAc,CAAC,CAAA;qBACvB;gBACH,CAAC,IACD,CAAA;SACH;KACF;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAjDD,4CAiDC;AAED,SAAS,MAAM,CAAC,GAAU;IACxB,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,0CAA0C,EAAE;QAC3E,MAAM,EAAE,GAAG,CAAC,OAAO;QACnB,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,GAAG,CAAC,KAAK;KACjB,CAAC,CAAA;AACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/index.ts"],"names":[],"mappings":";;AAAA,+BAAwD;AACxD,oCAAwE;AACxE,yCAAoD;AAEpD,yDAAyD;AACzD,mBAAgB;AAChB,2BAAwB;AACxB,yBAAsB;AACtB,4BAAyB;AACzB,wBAAqB;AACrB,6BAA0B;AAC1B,yBAAsB;AACtB,8BAA2B;AAC3B,6BAA0B;AAC1B,0BAAuB;AACvB,4BAAyB;AACzB,4BAAyB;AACzB,+BAA4B;AAC5B,mCAAgC;AAChC,0BAAuB;AACvB,yBAAsB;AACtB,yBAAsB;AACtB,yBAAsB;AAEtB,SAAgB,gBAAgB,CAAC,IAAkB;IACjD,MAAM,IAAI,GAAG,IAAI,0BAAmB,EAAE,CAAA;IACtC,KAAK,MAAM,GAAG,IAAI,sBAAW,EAAE,EAAE;QAC/B,IAAI,GAAG,CAAC,QAAQ,KAAK,kBAAkB,EAAE;YACvC,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,C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AAED,SAAS,MAAM,CAAC,GAAU;IACxB,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,0CAA0C,EAAE;QAC3E,MAAM,EAAE,GAAG,CAAC,OAAO;QACnB,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,GAAG,CAAC,KAAK;KACjB,CAAC,CAAA;AACJ,CAAC"} \ No newline at end of file diff --git a/dist/main/atom/commands/initializeConfig.js b/dist/main/atom/commands/initializeConfig.js index b3b66aab9..cebf27cbc 100644 --- a/dist/main/atom/commands/initializeConfig.js +++ b/dist/main/atom/commands/initializeConfig.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const registry_1 = require("./registry"); -const clientResolver_1 = require("../../../client/clientResolver"); const atom_1 = require("atom"); +const client_1 = require("../../../client"); +const registry_1 = require("./registry"); registry_1.addCommand("atom-text-editor", "typescript:initialize-config", () => ({ description: "Create tsconfig.json in the project related to currently-active text edtior", async didDispatch(editor, abort) { @@ -12,7 +12,7 @@ registry_1.addCommand("atom-text-editor", "typescript:initialize-config", () => const currentPath = editor.getPath(); if (currentPath === undefined) return; - const pathToTsc = (await clientResolver_1.resolveBinary(currentPath, "tsc")).pathToBin; + const pathToTsc = (await client_1.resolveBinary(currentPath, "tsc")).pathToBin; for (const projectDir of projectDirs) { if (projectDir.contains(currentPath)) { await initConfig(pathToTsc, projectDir.getPath()); @@ -21,25 +21,32 @@ registry_1.addCommand("atom-text-editor", "typescript:initialize-config", () => } }, })); -function initConfig(tsc, projectRoot) { - return new Promise((resolve, reject) => { - try { - const bnp = new atom_1.BufferedNodeProcess({ - command: tsc, - args: ["--init"], - options: { cwd: projectRoot }, - exit: code => { - if (code === 0) - resolve(); - else - reject(new Error(`Tsc ended with nonzero exit code ${code}`)); - }, - }); - bnp.onWillThrowError(reject); - } - catch (e) { - reject(e); - } - }); +async function initConfig(tsc, projectRoot) { + let disp; + try { + return await new Promise((resolve, reject) => { + try { + const bnp = new atom_1.BufferedNodeProcess({ + command: tsc, + args: ["--init"], + options: { cwd: projectRoot }, + exit: code => { + if (code === 0) + resolve(); + else + reject(new Error(`Tsc ended with nonzero exit code ${code}`)); + }, + }); + disp = bnp.onWillThrowError(reject); + } + catch (e) { + reject(e); + } + }); + } + finally { + if (disp) + disp.dispose(); + } } //# sourceMappingURL=initializeConfig.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/initializeConfig.js.map b/dist/main/atom/commands/initializeConfig.js.map index 2b932818e..ad84cea4f 100644 --- a/dist/main/atom/commands/initializeConfig.js.map +++ b/dist/main/atom/commands/initializeConfig.js.map @@ -1 +1 @@ -{"version":3,"file":"initializeConfig.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/initializeConfig.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AACrC,mEAA4D;AAC5D,+BAAwC;AAExC,qBAAU,CAAC,kBAAkB,EAAE,8BAA8B,EAAE,GAAG,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,6EAA6E;IAC1F,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK;QAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;QACjD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,EAAE,CAAA;QAE5C,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;QACpC,IAAI,WAAW,KAAK,SAAS;YAAE,OAAM;QAErC,MAAM,SAAS,GAAG,CAAC,MAAM,8BAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;QAErE,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;YACpC,IAAI,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACpC,MAAM,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAA;gBACjD,IAAI,CAAC,aAAa,CAAC,UAAU,CAC3B,yCAAyC,UAAU,CAAC,OAAO,EAAE,EAAE,CAChE,CAAA;aACF;SACF;IACH,CAAC;CACF,CAAC,CAAC,CAAA;AAEH,SAAS,UAAU,CAAC,GAAW,EAAE,WAAmB;IAClD,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI;YACF,MAAM,GAAG,GAAG,IAAI,0BAAmB,CAAC;gBAClC,OAAO,EAAE,GAAG;gBACZ,IAAI,EAAE,CAAC,QAAQ,CAAC;gBAChB,OAAO,EAAE,EAAC,GAAG,EAAE,WAAW,EAAC;gBAC3B,IAAI,EAAE,IAAI,CAAC,EAAE;oBACX,IAAI,IAAI,KAAK,CAAC;wBAAE,OAAO,EAAE,CAAA;;wBACpB,MAAM,CAAC,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAC,CAAA;gBACpE,CAAC;aACF,CAAC,CAAA;YACF,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;SAC7B;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAC,CAAC,CAAA;SACV;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"initializeConfig.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/initializeConfig.ts"],"names":[],"mappings":";;AAAA,+BAAwC;AACxC,4CAA6C;AAC7C,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,8BAA8B,EAAE,GAAG,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,6EAA6E;IAC1F,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK;QAC7B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;QACjD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,EAAE,CAAA;QAE5C,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;QACpC,IAAI,WAAW,KAAK,SAAS;YAAE,OAAM;Q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orCode.js index 6e62766e7..429e89af1 100644 --- a/dist/main/atom/commands/refactorCode.js +++ b/dist/main/atom/commands/refactorCode.js @@ -1,10 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const registry_1 = require("./registry"); -const utils_1 = require("../utils"); -const simpleSelectionView_1 = require("../views/simpleSelectionView"); const etch = require("etch"); +const utils_1 = require("../utils"); const highlightComponent_1 = require("../views/highlightComponent"); +const simpleSelectionView_1 = require("../views/simpleSelectionView"); +const registry_1 = require("./registry"); registry_1.addCommand("atom-text-editor", "typescript:refactor-selection", deps => ({ description: "Get a list of applicable refactors to selected code", async didDispatch(editor) { diff --git a/dist/main/atom/commands/refactorCode.js.map b/dist/main/atom/commands/refactorCode.js.map index 8ff3de29e..39f2929db 100644 --- a/dist/main/atom/commands/refactorCode.js.map +++ b/dist/main/atom/commands/refactorCode.js.map @@ -1 +1 @@ -{"version":3,"file":"refactorCode.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/refactorCode.tsx"],"names":[],"mappings":";;AAAA,yCAAmD;AACnD,oCAA4C;AAC5C,sEAA2D;AAC3D,6BAA4B;AAC5B,oEAA8D;AAY9D,qBAAU,CAAC,kBAAkB,EAAE,+BAA+B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACvE,WAAW,EAAE,qDAAqD;IAClE,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAM;QAErB,MAAM,SAAS,GAAG,MAAM,CAAC,sBAAsB,EAAE,CAAA;QACjD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAElD,MAAM,SAAS,GAA4C,SAAS,CAAC,OAAO,EAAE;YAC5E,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC;gBACE,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,S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cAAc,KAAK,SAAS;QAAE,OAAM;IAExE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,cAAc,EAAE;QACvD,cAAc,EAAE,IAAI;QACpB,WAAW,EAAE,cAAc,CAAC,IAAI,GAAG,CAAC;QACpC,aAAa,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC;KACzC,CAAC,CAAA;IACF,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,4BAA4B,CAAC,CAAA;AACxF,CAAC"} \ No newline at end of file +{"version":3,"file":"refactorCode.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/refactorCode.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAG5B,oCAA4C;AAC5C,oEAA8D;AAC9D,sEAA2D;AAC3D,yCAAmD;AAUnD,qBAAU,CAAC,kBAAkB,EAAE,+BAA+B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACvE,WAAW,EAAE,qDAAqD;IAClE,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAM;QAErB,MAAM,SAAS,GAAG,MAAM,CAAC,sBAAsB,EAAE,CAAA;QACjD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAElD,MAAM,SAAS,GAA4C,SAAS,CAAC,OAAO,EAAE;YAC5E,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC;gBACE,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;gBAClC,WAAW,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;gBACvC,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,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,IAAI,GAAG,CAAC;QACpC,aAAa,EAAE,cAAc,CAAC,MAAM,GAAG,CAAC;KACzC,CAAC,CAAA;IACF,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,4BAA4B,CAAC,CAAA;AACxF,CAAC"} \ No newline at end of file diff --git a/dist/main/atom/commands/registry.js.map b/dist/main/atom/commands/registry.js.map index caa2f0a36..e5ba07bfa 100644 --- a/dist/main/atom/commands/registry.js.map +++ b/dist/main/atom/commands/registry.js.map @@ -1 +1 @@ -{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/registry.ts"],"names":[],"mappings":";;AA6CA,kGAAkG;AAClG,mGAAmG;AACnG,gFAAgF;AAChF,MAAM,QAAQ,GAA4D,EAAE,CAAA;AAE5E,SAAgB,UAAU,CACxB,QAAkB,EAClB,OAAe,EACf,IAAkC;IAElC,QAAQ,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAA6C,CAAC,CAAA;AACtF,CAAC;AAND,gCAMC;AAED,SAAgB,WAAW;IACzB,OAAO,QAAQ,CAAA;AACjB,CAAC;AAFD,kCAEC"} \ No newline at end of file +{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/registry.ts"],"names":[],"mappings":";;AAmDA,kGAAkG;AAClG,mGAAmG;AACnG,gFAAgF;AAChF,MAAM,QAAQ,GAA4D,EAAE,CAAA;AAE5E,SAAgB,UAAU,CACxB,QAAkB,EAClB,OAAe,EACf,IAAkC;IAElC,QAAQ,CAAC,IAAI,CAAC,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAA6C,CAAC,CAAA;AACtF,CAAC;AAND,gCAMC;AAED,SAAgB,WAAW;IACzB,OAAO,QAAQ,CAAA;AACjB,CAAC;AAFD,kCAEC"} \ No newline at end of file diff --git a/dist/main/atom/commands/reloadProjects.js b/dist/main/atom/commands/reloadProjects.js new file mode 100644 index 000000000..a30796294 --- /dev/null +++ b/dist/main/atom/commands/reloadProjects.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const registry_1 = require("./registry"); +registry_1.addCommand("atom-text-editor", "typescript:reload-projects", deps => ({ + description: "Reload projects", + async didDispatch(editor) { + const path = editor.getPath(); + if (path === undefined) + return; + const client = await deps.getClient(path); + await client.execute("reloadProjects"); + }, +})); +//# sourceMappingURL=reloadProjects.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/reloadProjects.js.map b/dist/main/atom/commands/reloadProjects.js.map new file mode 100644 index 000000000..7f006d4a2 --- /dev/null +++ b/dist/main/atom/commands/reloadProjects.js.map @@ -0,0 +1 @@ +{"version":3,"file":"reloadProjects.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/reloadProjects.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,4BAA4B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,iBAAiB;IAC9B,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;QAC7B,IAAI,IAAI,KAAK,SAAS;YAAE,OAAM;QAC9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACzC,MAAM,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IACxC,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/renameRefactor.js b/dist/main/atom/commands/renameRefactor.js index e9f2a7c4c..efb54132f 100644 --- a/dist/main/atom/commands/renameRefactor.js +++ b/dist/main/atom/commands/renameRefactor.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const registry_1 = require("./registry"); const utils_1 = require("../utils"); const renameView_1 = require("../views/renameView"); +const registry_1 = require("./registry"); registry_1.addCommand("atom-text-editor", "typescript:rename-refactor", deps => ({ description: "Rename symbol under text cursor everywhere it is used", async didDispatch(editor) { diff --git a/dist/main/atom/commands/renameRefactor.js.map b/dist/main/atom/commands/renameRefactor.js.map index ae45d51c3..0bd6f8270 100644 --- a/dist/main/atom/commands/renameRefactor.js.map +++ b/dist/main/atom/commands/renameRefactor.js.map @@ -1 +1 @@ -{"version":3,"file":"renameRefactor.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/renameRefactor.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AACrC,oCAA4C;AAC5C,oDAAoD;AAEpD,qBAAU,CAAC,kBAAkB,EAAE,4BAA4B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,uDAAuD;IACpE,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAM;QAErB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QACzD,MAAM,EAAC,IAAI,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC,IAAK,CAAA;QAEnC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,iDAAiD,CAAC,CAAA;YAC7E,OAAM;SACP;QAED,MAAM,OAAO,GAAG,MAAM,6BAAgB,CAAC;YACrC,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,UAAU,EAAE,CAAC,OAAO,EAAU,EAAE;gBAC9B,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,EAAE,EAAE;oBACjD,OAAO,2CAA2C,CAAA;iBACnD;gBACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE;oBACnB,OAAO,0CAA0C,CAAA;iBAClD;gBACD,OAAO,EAAE,CAAA;YACX,CAAC;SACF,CAAC,CAAA;QAEF,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,CAAC,UAAU,CACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAChB,QAAQ,EAAE,IAAI,CAAC,IAAI;gBACnB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,mBAAK,GAAG,IAAE,OAAO,EAAE,OAAO,IAAE,CAAC;aAChE,CAAC,CAAC,CACJ,CAAA;SACF;IACH,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"renameRefactor.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/renameRefactor.ts"],"names":[],"mappings":";;AAAA,oCAA4C;AAC5C,oDAAoD;AACpD,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,4BAA4B,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,WAAW,EAAE,uDAAuD;IACpE,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,MAAM,QAAQ,GAAG,2BAAmB,CAAC,MAAM,CAAC,CAAA;QAC5C,IAAI,CAAC,QAAQ;YAAE,OAAM;QAErB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAClD,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QACzD,MAAM,EAAC,IAAI,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC,IAAK,CAAA;QAEnC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACnB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,iDAAiD,CAAC,CAAA;YAC7E,OAAM;SACP;QAED,MAAM,OAAO,GAAG,MAAM,6BAAgB,CAAC;YACrC,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,UAAU,EAAE,CAAC,OAAO,EAAU,EAAE;gBAC9B,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,EAAE,EAAE;oBACjD,OAAO,2CAA2C,CAAA;iBACnD;gBACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE;oBACnB,OAAO,0CAA0C,CAAA;iBAClD;gBACD,OAAO,EAAE,CAAA;YACX,CAAC;SACF,CAAC,CAAA;QAEF,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,CAAC,UAAU,CACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAChB,QAAQ,EAAE,IAAI,CAAC,IAAI;gBACnB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,mBAAK,GAAG,IAAE,OAAO,EAAE,OAAO,IAAE,CAAC;aAChE,CAAC,CAAC,CACJ,CAAA;SACF;IACH,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/restartAllServers.js b/dist/main/atom/commands/restartAllServers.js new file mode 100644 index 000000000..cf22198a1 --- /dev/null +++ b/dist/main/atom/commands/restartAllServers.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const registry_1 = require("./registry"); +registry_1.addCommand("atom-workspace", "typescript:restart-all-servers", deps => ({ + description: "Kill all tsserver instances. They will be auto-restarted", + async didDispatch() { + deps.killAllServers(); + }, +})); +//# sourceMappingURL=restartAllServers.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/restartAllServers.js.map b/dist/main/atom/commands/restartAllServers.js.map new file mode 100644 index 000000000..10196fafd --- /dev/null +++ b/dist/main/atom/commands/restartAllServers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"restartAllServers.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/restartAllServers.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,gBAAgB,EAAE,gCAAgC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,WAAW,EAAE,0DAA0D;IACvE,KAAK,CAAC,WAAW;QACf,IAAI,CAAC,cAAc,EAAE,CAAA;IACvB,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/returnFromDeclaration.js b/dist/main/atom/commands/returnFromDeclaration.js index fbc1858e6..9b417ea60 100644 --- a/dist/main/atom/commands/returnFromDeclaration.js +++ b/dist/main/atom/commands/returnFromDeclaration.js @@ -1,37 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const registry_1 = require("./registry"); -const simpleSelectionView_1 = require("../views/simpleSelectionView"); -const etch = require("etch"); -const highlightComponent_1 = require("../views/highlightComponent"); registry_1.addCommand("atom-workspace", "typescript:return-from-declaration", deps => ({ description: "If used `go-to-declaration`, return to previous text cursor position", async didDispatch() { - deps.getEditorPositionHistoryManager().goBack(); + await deps.histGoBack(); }, })); registry_1.addCommand("atom-workspace", "typescript:show-editor-position-history", deps => ({ description: "If used `go-to-declaration`, return to previous text cursor position", async didDispatch() { - const ehm = deps.getEditorPositionHistoryManager(); - const res = await simpleSelectionView_1.selectListView({ - items: ehm - .getHistory() - .slice() - .reverse() - .map((item, idx) => (Object.assign({}, item, { idx }))), - itemTemplate: (item, ctx) => (etch.dom("li", { class: "two-lines" }, - etch.dom("div", { class: "primary-line" }, - etch.dom(highlightComponent_1.HighlightComponent, { label: item.file, query: ctx.getFilterQuery() })), - etch.dom("div", { class: "secondary-line" }, - "Line: ", - item.line, - ", column: ", - item.offset))), - itemFilterKey: "file", - }); - if (res) - ehm.goHistory(res.idx + 1); + await deps.histShowHistory(); }, })); //# sourceMappingURL=returnFromDeclaration.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/returnFromDeclaration.js.map b/dist/main/atom/commands/returnFromDeclaration.js.map index 1db7eb46b..3bc038c59 100644 --- a/dist/main/atom/commands/returnFromDeclaration.js.map +++ b/dist/main/atom/commands/returnFromDeclaration.js.map @@ -1 +1 @@ -{"version":3,"file":"returnFromDeclaration.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/returnFromDeclaration.tsx"],"names":[],"mappings":";;AAAA,yCAAqC;AACrC,sEAA2D;AAC3D,6BAA4B;AAC5B,oEAA8D;AAE9D,qBAAU,CAAC,gBAAgB,EAAE,oCAAoC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1E,WAAW,EAAE,sEAAsE;IACnF,KAAK,CAAC,WAAW;QACf,IAAI,CAAC,+BAA+B,EAAE,CAAC,MAAM,EAAE,CAAA;IACjD,CAAC;CACF,CAAC,CAAC,CAAA;AAEH,qBAAU,CAAC,gBAAgB,EAAE,yCAAyC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/E,WAAW,EAAE,sEAAsE;IACnF,KAAK,CAAC,WAAW;QACf,MAAM,GAAG,GAAG,IAAI,CAAC,+BAA+B,EAAE,CAAA;QAClD,MAAM,GAAG,GAAG,MAAM,oCAAc,CAAC;YAC/B,KAAK,EAAE,GAAG;iBACP,UAAU,EAAE;iBACZ,KAAK,EAAE;iBACP,OAAO,EAAE;iBACT,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,mBAAK,IAAI,IAAE,GAAG,IAAE,CAAC;YACvC,YAAY,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,CAC3B,iBAAI,KAAK,EAAC,WAAW;gBACnB,kBAAK,KAAK,EAAC,cAAc;oBACvB,SAAC,uCAAkB,IAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,cAAc,EAAE,GAAI,CACjE;gBACN,kBAAK,KAAK,EAAC,gBAAgB;;oBAClB,IAAI,CAAC,IAAI;;oBAAY,IAAI,CAAC,MAAM,CACnC,CACH,CACN;YACD,aAAa,EAAE,MAAM;SACtB,CAAC,CAAA;QACF,IAAI,GAAG;YAAE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;IACrC,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"returnFromDeclaration.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/returnFromDeclaration.tsx"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,gBAAgB,EAAE,oCAAoC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1E,WAAW,EAAE,sEAAsE;IACnF,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;IACzB,CAAC;CACF,CAAC,CAAC,CAAA;AAEH,qBAAU,CAAC,gBAAgB,EAAE,yCAAyC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/E,WAAW,EAAE,sEAAsE;IACnF,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,eAAe,EAAE,CAAA;IAC9B,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/semanticView.js b/dist/main/atom/commands/semanticView.js index 76f8619ec..b3e284bb5 100644 --- a/dist/main/atom/commands/semanticView.js +++ b/dist/main/atom/commands/semanticView.js @@ -4,7 +4,7 @@ const registry_1 = require("./registry"); registry_1.addCommand("atom-text-editor", "typescript:toggle-semantic-view", deps => ({ description: "Toggle semantic view outline", didDispatch() { - deps.getSemanticViewController().toggle(); + deps.toggleSemanticViewController(); }, })); //# sourceMappingURL=semanticView.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/semanticView.js.map b/dist/main/atom/commands/semanticView.js.map index be610b136..1d48bc9ab 100644 --- a/dist/main/atom/commands/semanticView.js.map +++ b/dist/main/atom/commands/semanticView.js.map @@ -1 +1 @@ -{"version":3,"file":"semanticView.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/semanticView.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,iCAAiC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,WAAW,EAAE,8BAA8B;IAC3C,WAAW;QACT,IAAI,CAAC,yBAAyB,EAAE,CAAC,MAAM,EAAE,CAAA;IAC3C,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"semanticView.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/semanticView.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,iCAAiC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACzE,WAAW,EAAE,8BAA8B;IAC3C,WAAW;QACT,IAAI,CAAC,4BAA4B,EAAE,CAAA;IACrC,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/showSigHelp.js b/dist/main/atom/commands/showSigHelp.js new file mode 100644 index 000000000..677915ee5 --- /dev/null +++ b/dist/main/atom/commands/showSigHelp.js @@ -0,0 +1,10 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const registry_1 = require("./registry"); +registry_1.addCommand("atom-text-editor", "typescript:show-signature-help", deps => ({ + description: "Show signature help tooltip at current text cursor position", + async didDispatch(ed) { + return deps.showSigHelpAt(ed); + }, +})); +//# sourceMappingURL=showSigHelp.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/showSigHelp.js.map b/dist/main/atom/commands/showSigHelp.js.map new file mode 100644 index 000000000..10e57c9f2 --- /dev/null +++ b/dist/main/atom/commands/showSigHelp.js.map @@ -0,0 +1 @@ +{"version":3,"file":"showSigHelp.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/showSigHelp.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,gCAAgC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACxE,WAAW,EAAE,6DAA6D;IAC1E,KAAK,CAAC,WAAW,CAAC,EAAE;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IAC/B,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/showTooltip.js b/dist/main/atom/commands/showTooltip.js index 592fc9d36..de151e5ae 100644 --- a/dist/main/atom/commands/showTooltip.js +++ b/dist/main/atom/commands/showTooltip.js @@ -1,11 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const registry_1 = require("./registry"); -const tooltipManager_1 = require("../tooltipManager"); -registry_1.addCommand("atom-text-editor", "typescript:show-tooltip", () => ({ +registry_1.addCommand("atom-text-editor", "typescript:show-tooltip", deps => ({ description: "Show type tooltip at current text cursor position", async didDispatch(ed) { - return tooltipManager_1.showExpressionAt(ed, ed.getLastCursor().getBufferPosition()); + return deps.showTooltipAt(ed); }, })); //# sourceMappingURL=showTooltip.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/showTooltip.js.map b/dist/main/atom/commands/showTooltip.js.map index ce87113eb..7246214ee 100644 --- a/dist/main/atom/commands/showTooltip.js.map +++ b/dist/main/atom/commands/showTooltip.js.map @@ -1 +1 @@ -{"version":3,"file":"showTooltip.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/showTooltip.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AACrC,sDAAkD;AAElD,qBAAU,CAAC,kBAAkB,EAAE,yBAAyB,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/D,WAAW,EAAE,mDAAmD;IAChE,KAAK,CAAC,WAAW,CAAC,EAAE;QAClB,OAAO,iCAAgB,CAAC,EAAE,EAAE,EAAE,CAAC,aAAa,EAAE,CAAC,iBAAiB,EAAE,CAAC,CAAA;IACrE,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"showTooltip.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/showTooltip.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,yBAAyB,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACjE,WAAW,EAAE,mDAAmD;IAChE,KAAK,CAAC,WAAW,CAAC,EAAE;QAClB,OAAO,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IAC/B,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/commands/symbolsView.js b/dist/main/atom/commands/symbolsView.js index 627440f7d..f99bf4eab 100644 --- a/dist/main/atom/commands/symbolsView.js +++ b/dist/main/atom/commands/symbolsView.js @@ -4,13 +4,13 @@ const registry_1 = require("./registry"); registry_1.addCommand("atom-text-editor", "typescript:toggle-file-symbols", deps => ({ description: "Toggle view for finding file symbols", async didDispatch(editor) { - deps.getSymbolsViewController().toggleFileView(editor); + deps.toggleFileSymbolsView(editor); }, })); registry_1.addCommand("atom-text-editor", "typescript:toggle-project-symbols", deps => ({ description: "Toggle view for finding file symbols", async didDispatch(editor) { - deps.getSymbolsViewController().toggleProjectView(editor); + deps.toggleProjectSymbolsView(editor); }, })); //# sourceMappingURL=symbolsView.js.map \ No newline at end of file diff --git a/dist/main/atom/commands/symbolsView.js.map b/dist/main/atom/commands/symbolsView.js.map index ab2a3b65e..e33b8262b 100644 --- a/dist/main/atom/commands/symbolsView.js.map +++ b/dist/main/atom/commands/symbolsView.js.map @@ -1 +1 @@ -{"version":3,"file":"symbolsView.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/symbolsView.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,gCAAgC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACxE,WAAW,EAAE,sCAAsC;IACnD,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,IAAI,CAAC,wBAAwB,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;IACxD,CAAC;CACF,CAAC,CAAC,CAAA;AAEH,qBAAU,CAAC,kBAAkB,EAAE,mCAAmC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3E,WAAW,EAAE,sCAAsC;IACnD,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,IAAI,CAAC,wBAAwB,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAC3D,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"symbolsView.js","sourceRoot":"","sources":["../../../../lib/main/atom/commands/symbolsView.ts"],"names":[],"mappings":";;AAAA,yCAAqC;AAErC,qBAAU,CAAC,kBAAkB,EAAE,gCAAgC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACxE,WAAW,EAAE,sCAAsC;IACnD,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;IACpC,CAAC;CACF,CAAC,CAAC,CAAA;AAEH,qBAAU,CAAC,kBAAkB,EAAE,mCAAmC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3E,WAAW,EAAE,sCAAsC;IACnD,KAAK,CAAC,WAAW,CAAC,MAAM;QACtB,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAA;IACvC,CAAC;CACF,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel.js b/dist/main/atom/components/statusPanel.js deleted file mode 100644 index cb7cc022f..000000000 --- a/dist/main/atom/components/statusPanel.js +++ /dev/null @@ -1,146 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const etch = require("etch"); -const path_1 = require("path"); -const atom_1 = require("atom"); -class StatusPanel { - constructor(props) { - this.disposables = new atom_1.CompositeDisposable(); - this.buildStatusClicked = () => { - if (this.props.buildStatus && !this.props.buildStatus.success) { - atom.notifications.addError("Build failed", { - detail: this.props.buildStatus.message, - dismissable: true, - }); - } - }; - this.handlePendingRequests = () => { - this.update({ - pending: [].concat(...Array.from(this.props.clientResolver.clients.values()).map(el => el.pending)), - }); - }; - this.props = Object.assign({ visible: true }, props); - etch.initialize(this); - this.resetBuildStatusTimeout(); - this.disposables.add(this.props.clientResolver.on("pendingRequestsChange", this.handlePendingRequests)); - } - async update(props) { - this.props = Object.assign({}, this.props, props); - this.resetBuildStatusTimeout(); - await etch.update(this); - } - render() { - return (etch.dom("ts-status-panel", { className: this.props.visible ? "" : "hide" }, - this.renderVersion(), - this.renderPending(), - this.renderConfigPath(), - this.renderStatus(), - this.renderProgress())); - } - async destroy() { - await etch.destroy(this); - this.disposables.dispose(); - } - dispose() { - this.destroy(); - } - show() { - this.update({ visible: true }); - } - hide() { - this.update({ visible: false }); - } - resetBuildStatusTimeout() { - if (this.buildStatusTimeout !== undefined) { - window.clearTimeout(this.buildStatusTimeout); - this.buildStatusTimeout = undefined; - } - if (this.props.buildStatus && this.props.buildStatus.success) { - const timeout = atom.config.get("atom-typescript.buildStatusTimeout"); - if (timeout > 0) { - this.buildStatusTimeout = window.setTimeout(() => { - this.update({ buildStatus: undefined }); - }, timeout * 1000); - } - else if (timeout === 0) { - this.update({ buildStatus: undefined }); - } - } - } - openConfigPath() { - if (this.props.tsConfigPath !== undefined && !this.props.tsConfigPath.startsWith("/dev/null")) { - atom.workspace.open(this.props.tsConfigPath); - } - else { - atom.notifications.addInfo("No tsconfig for current file"); - } - } - showPendingRequests() { - if (this.props.pending) { - atom.notifications.addInfo("Pending Requests:
- " + this.props.pending.join("
- ")); - } - } - renderVersion() { - if (this.props.version !== undefined) { - return (etch.dom("div", { ref: "version", className: "inline-block" }, this.props.version)); - } - return null; - } - renderPending() { - if (this.props.pending && this.props.pending.length > 0) { - return (etch.dom("a", { ref: "pendingContainer", className: "inline-block", href: "", on: { - click: evt => { - evt.preventDefault(); - this.showPendingRequests(); - }, - } }, - etch.dom("span", { ref: "pendingCounter" }, this.props.pending.length.toString()), - etch.dom("span", { ref: "pendingSpinner", className: "loading loading-spinner-tiny inline-block", style: { marginLeft: "5px", opacity: "0.5", verticalAlign: "sub" } }))); - } - return null; - } - renderConfigPath() { - if (this.props.tsConfigPath !== undefined) { - return (etch.dom("a", { ref: "configPathContainer", className: "inline-block", href: "", on: { - click: evt => { - evt.preventDefault(); - this.openConfigPath(); - }, - } }, this.props.tsConfigPath.startsWith("/dev/null") - ? "No project" - : path_1.dirname(getFilePathRelativeToAtomProject(this.props.tsConfigPath)))); - } - return null; - } - renderStatus() { - if (this.props.buildStatus) { - let cls; - let text; - if (this.props.buildStatus.success) { - cls = "highlight-success"; - text = "Emit Success"; - } - else { - cls = "highlight-error"; - text = "Emit Failed"; - } - return (etch.dom("div", { ref: "statusContainer", className: "inline-block" }, - etch.dom("span", { ref: "statusText", class: cls, on: { click: this.buildStatusClicked } }, text))); - } - return null; - } - renderProgress() { - if (this.props.progress) { - return (etch.dom("progress", { ref: "progress", style: { verticalAlign: "baseline" }, className: "inline-block", max: this.props.progress.max, value: this.props.progress.value })); - } - return null; - } -} -exports.StatusPanel = StatusPanel; -/** - * converts "c:\dev\somethin\bar.ts" to "~something\bar". - */ -function getFilePathRelativeToAtomProject(filePath) { - return "~" + atom.project.relativize(filePath); -} -//# sourceMappingURL=statusPanel.js.map \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel.js.map b/dist/main/atom/components/statusPanel.js.map deleted file mode 100644 index 96fa3cf66..000000000 --- a/dist/main/atom/components/statusPanel.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"statusPanel.js","sourceRoot":"","sources":["../../../../lib/main/atom/components/statusPanel.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,+BAA4B;AAE5B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G,GAAG,iBAAiB,CAAA;gBACvB,IAAI,GAAG,aAAa,CAAA;aACrB;YACD,OAAO,CACL,kBAAK,GAAG,EAAC,iBAAiB,EAAC,SAAS,EAAC,cAAc;gBACjD,mBAAM,GAAG,EAAC,YAAY,EAAC,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,EAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAC,IACpE,IAAI,CACA,CACH,CACP,CAAA;SACF;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAWO,cAAc;QACpB,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACvB,OAAO,CACL,uBACE,GAAG,EAAC,UAAU,EACd,KAAK,EAAE,EAAC,aAAa,EAAE,UAAU,EAAC,EAClC,SAAS,EAAC,cAAc,EACxB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAC5B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,GAChC,CACH,CAAA;SACF;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CASF;AAlMD,kCAkMC;AAED;;GAEG;AACH,SAAS,gCAAgC,CAAC,QAAgB;IACxD,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;AAChD,CAAC"} \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel/buildStatus.js b/dist/main/atom/components/statusPanel/buildStatus.js new file mode 100644 index 000000000..44cfdfe68 --- /dev/null +++ b/dist/main/atom/components/statusPanel/buildStatus.js @@ -0,0 +1,81 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const atom_1 = require("atom"); +const etch = require("etch"); +const lodash_1 = require("lodash"); +const utils_1 = require("../../../../utils"); +const tooltip_1 = require("./tooltip"); +class BuildStatus { + constructor(props) { + this.hiddenBuildStatus = false; + this.disposables = new atom_1.CompositeDisposable(); + this.buildStatusClicked = () => { + if (!this.props.buildStatus.success) { + atom.notifications.addError("Build failed", { + detail: this.props.buildStatus.message, + dismissable: true, + }); + } + }; + this.props = Object.assign({}, props); + this.setHideBuildStatus(atom.config.get("atom-typescript").buildStatusTimeout); + this.resetBuildStatusTimeout(); + etch.initialize(this); + this.disposables.add(atom.config.onDidChange("atom-typescript.buildStatusTimeout", ({ newValue }) => { + this.setHideBuildStatus(newValue); + utils_1.handlePromise(this.update({})); + })); + } + async update(props) { + const successStateChanged = props.buildStatus !== undefined && + props.buildStatus.success !== this.props.buildStatus.success; + this.props = Object.assign({}, this.props, props); + if (successStateChanged) + this.resetBuildStatusTimeout(); + await etch.update(this); + } + render() { + if (this.hiddenBuildStatus) + return etch.dom("span", null); + let cls; + let text; + if (this.props.buildStatus.success) { + cls = "highlight-success"; + text = "Emit Success"; + } + else { + cls = "highlight-error"; + text = "Emit Failed"; + } + return (etch.dom(tooltip_1.Tooltip, { title: this.props.buildStatus.success + ? "Build was successful" + : "Build failed; click to show error message" }, + etch.dom("span", { class: cls, on: { click: this.buildStatusClicked } }, text))); + } + async destroy() { + await etch.destroy(this); + } + resetBuildStatusTimeout() { + this.hiddenBuildStatus = false; + if (this.props.buildStatus.success) { + this.hideBuildStatus(); + } + } + setHideBuildStatus(value) { + if (value > 0) { + this.hideBuildStatus = lodash_1.debounce(() => { + this.hiddenBuildStatus = true; + utils_1.handlePromise(etch.update(this)); + }, value * 1000); + } + else if (value === 0) { + this.hideBuildStatus = () => { + this.hiddenBuildStatus = true; + }; + } + else + this.hideBuildStatus = () => { }; + } +} +exports.BuildStatus = BuildStatus; +//# sourceMappingURL=buildStatus.js.map \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel/buildStatus.js.map b/dist/main/atom/components/statusPanel/buildStatus.js.map new file mode 100644 index 000000000..c4ceef7b9 --- /dev/null +++ b/dist/main/atom/components/statusPanel/buildStatus.js.map @@ -0,0 +1 @@ +{"version":3,"file":"buildStatus.js","sourceRoot":"","sources":["../../../../../lib/main/atom/components/statusPanel/buildStatus.tsx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CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;YAClC,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,CAAA;SACjB;aAAM,IAAI,KAAK,KAAK,CAAC,EAAE;YACtB,IAAI,CAAC,eAAe,GAAG,GAAG,EAAE;gBAC1B,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAA;YAC/B,CAAC,CAAA;SACF;;YAAM,IAAI,CAAC,eAAe,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;IACxC,CAAC;CACF;AAxFD,kCAwFC"} \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel/configPath.js b/dist/main/atom/components/statusPanel/configPath.js new file mode 100644 index 000000000..0f844db00 --- /dev/null +++ b/dist/main/atom/components/statusPanel/configPath.js @@ -0,0 +1,48 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const etch = require("etch"); +const path_1 = require("path"); +const utils_1 = require("../../../../utils"); +const tooltip_1 = require("./tooltip"); +class ConfigPath { + constructor(props) { + this.props = Object.assign({}, props); + etch.initialize(this); + } + async update(props) { + this.props = Object.assign({}, this.props, props); + await etch.update(this); + } + render() { + return (etch.dom(tooltip_1.Tooltip, { title: () => this.props.tsConfigPath.startsWith("/dev/null") + ? "No tsconfig.json" + : `Click to open ${atom.project.relativize(this.props.tsConfigPath)}` }, + etch.dom("a", { className: "inline-block", href: "", on: { + click: evt => { + evt.preventDefault(); + this.openConfigPath(); + }, + } }, this.props.tsConfigPath.startsWith("/dev/null") + ? "No project" + : path_1.dirname(getFilePathRelativeToAtomProject(this.props.tsConfigPath))))); + } + async destroy() { + await etch.destroy(this); + } + openConfigPath() { + if (!this.props.tsConfigPath.startsWith("/dev/null")) { + utils_1.handlePromise(atom.workspace.open(this.props.tsConfigPath)); + } + else { + atom.notifications.addInfo("No tsconfig for current file"); + } + } +} +exports.ConfigPath = ConfigPath; +/** + * converts "c:\dev\somethin\bar.ts" to "~something\bar". + */ +function getFilePathRelativeToAtomProject(filePath) { + return "~" + atom.project.relativize(filePath); +} +//# sourceMappingURL=configPath.js.map \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel/configPath.js.map b/dist/main/atom/components/statusPanel/configPath.js.map new file mode 100644 index 000000000..0973a949d --- /dev/null +++ b/dist/main/atom/components/statusPanel/configPath.js.map @@ -0,0 +1 @@ +{"version":3,"file":"configPath.js","sourceRoot":"","sources":["../../../../../lib/main/atom/components/statusPanel/configPath.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,+BAA4B;AAC5B,6CAA+C;AAC/C,uCAAiC;AAMjC,MAAa,UAAU;IAIrB,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,qBACL,KAAK,CACT,CAAA;QACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB;QACvC,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAEM,MAAM;QACX,OAAO,CACL,SAAC,iBAAO,IACN,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC;gBAC7C,CAAC,CAAC,kBAAkB;gBACpB,CAAC,CAAC,iBAAiB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE;YAEzE,gBACE,SAAS,EAAC,cAAc,EACxB,IAAI,EAAC,EAAE,EACP,EAAE,EAAE;oBACF,KAAK,EAAE,GAAG,CAAC,EAAE;wBACX,GAAG,CAAC,cAAc,EAAE,CAAA;wBACpB,IAAI,CAAC,cAAc,EAAE,CAAA;oBACvB,CAAC;iBACF,IACA,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC;gBAC9C,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,cAAO,CAAC,gCAAgC,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CACpE,CACI,CACX,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAEO,cAAc;QACpB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;YACpD,qBAAa,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAA;SAC5D;aAAM;YACL,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAA;SAC3D;IACH,CAAC;CACF;AApDD,gCAoDC;AAED;;GAEG;AACH,SAAS,gCAAgC,CAAC,QAAgB;IACxD,OAAO,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;AAChD,CAAC"} \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel/index.js b/dist/main/atom/components/statusPanel/index.js new file mode 100644 index 000000000..12b9e932c --- /dev/null +++ b/dist/main/atom/components/statusPanel/index.js @@ -0,0 +1,74 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const etch = require("etch"); +const utils_1 = require("../../../../utils"); +const buildStatus_1 = require("./buildStatus"); +const configPath_1 = require("./configPath"); +const tooltip_1 = require("./tooltip"); +class StatusPanel { + constructor(props = {}) { + this.props = Object.assign({ visible: true, pending: [], progress: { max: 0, value: 0 } }, props); + etch.initialize(this); + } + async update(props) { + this.props = Object.assign({}, this.props, props); + await etch.update(this); + } + render() { + return (etch.dom("ts-status-panel", { className: this.props.visible ? "" : "hide" }, + this.renderVersion(), + this.renderPending(), + this.renderConfigPath(), + this.renderStatus(), + this.renderProgress())); + } + async destroy() { + await etch.destroy(this); + } + dispose() { + utils_1.handlePromise(this.destroy()); + } + async show() { + await this.update({ visible: true }); + } + async hide() { + await this.update({ visible: false }); + } + renderVersion() { + if (this.props.clientVersion !== undefined) { + return etch.dom(tooltip_1.Tooltip, { title: "Active TypeScript version" }, this.props.clientVersion); + } + return null; + } + renderPending() { + if (this.props.pending.length > 0) { + return (etch.dom(tooltip_1.Tooltip, { title: `Pending Requests: `, html: true }, + etch.dom("span", { ref: "pendingCounter" }, this.props.pending.length.toString()), + etch.dom("span", { ref: "pendingSpinner", className: "loading loading-spinner-tiny inline-block", style: { marginLeft: "5px", opacity: "0.5", verticalAlign: "sub" } }))); + } + else + return null; + } + renderConfigPath() { + if (this.props.tsConfigPath !== undefined) { + return etch.dom(configPath_1.ConfigPath, { tsConfigPath: this.props.tsConfigPath }); + } + return null; + } + renderStatus() { + if (this.props.buildStatus) { + return etch.dom(buildStatus_1.BuildStatus, { buildStatus: this.props.buildStatus }); + } + return null; + } + renderProgress() { + if (this.props.progress.value < this.props.progress.max) { + return (etch.dom("progress", { style: { verticalAlign: "baseline" }, className: "inline-block", max: this.props.progress.max, value: this.props.progress.value })); + } + return null; + } +} +exports.StatusPanel = StatusPanel; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel/index.js.map b/dist/main/atom/components/statusPanel/index.js.map new file mode 100644 index 000000000..857e3ea8b --- /dev/null +++ b/dist/main/atom/components/statusPanel/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../lib/main/atom/components/statusPanel/index.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,6CAA+C;AAC/C,+CAAuD;AACvD,6CAAuC;AACvC,uCAAiC;AAiBjC,MAAa,WAAW;IAGtB,YAAY,QAAwB,EAAE;QACpC,IAAI,CAAC,KAAK,mBACR,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,EAAE,EACX,QAAQ,EAAE,EAAC,GAAG,EAAE,CAAC,EAAE,KAAK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I,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAC5B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,GAChC,CACH,CAAA;SACF;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAnGD,kCAmGC"} \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel/tooltip.js b/dist/main/atom/components/statusPanel/tooltip.js new file mode 100644 index 000000000..e0a6a6166 --- /dev/null +++ b/dist/main/atom/components/statusPanel/tooltip.js @@ -0,0 +1,27 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const etch = require("etch"); +class Tooltip { + constructor(props, children) { + this.children = children; + this.props = Object.assign({}, props, { delay: { show: 0, hide: 0 } }); + etch.initialize(this); + this.tooltipDisposable = atom.tooltips.add(this.element, this.props); + } + async update(props, children) { + this.props = Object.assign({}, this.props, props); + this.children = children; + await etch.update(this); + this.tooltipDisposable.dispose(); + this.tooltipDisposable = atom.tooltips.add(this.element, this.props); + } + render() { + return etch.dom("div", { className: "inline-block" }, this.children ? this.children : null); + } + async destroy() { + await etch.destroy(this); + this.tooltipDisposable.dispose(); + } +} +exports.Tooltip = Tooltip; +//# sourceMappingURL=tooltip.js.map \ No newline at end of file diff --git a/dist/main/atom/components/statusPanel/tooltip.js.map b/dist/main/atom/components/statusPanel/tooltip.js.map new file mode 100644 index 000000000..070aa7ae2 --- /dev/null +++ b/dist/main/atom/components/statusPanel/tooltip.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tooltip.js","sourceRoot":"","sources":["../../../../../lib/main/atom/components/statusPanel/tooltip.tsx"],"names":[],"mappings":";;AACA,6BAA4B;AAa5B,MAAa,OAAO;IAKlB,YAAY,KAAY,EAAU,QAAwB;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;QACxD,IAAI,CAAC,KAAK,qBACL,KAAK,IACR,KAAK,EAAE,EAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAC,GAC1B,CAAA;QACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAErB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IACtE,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB,EAAE,QAAuB;QAChE,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QACvB,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAA;QAChC,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IACtE,CAAC;IAEM,MAAM;QACX,OAAO,kBAAK,SAAS,EAAC,cAAc,IAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAO,CAAA;IACnF,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACxB,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAA;IAClC,CAAC;CACF;AA/BD,0BA+BC"} \ No newline at end of file diff --git a/dist/main/atom/editorPositionHistoryManager.js b/dist/main/atom/editorPositionHistoryManager.js index ba3d5f7a2..90cf2ae76 100644 --- a/dist/main/atom/editorPositionHistoryManager.js +++ b/dist/main/atom/editorPositionHistoryManager.js @@ -1,6 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const etch = require("etch"); const utils_1 = require("./utils"); +const highlightComponent_1 = require("./views/highlightComponent"); +const simpleSelectionView_1 = require("./views/simpleSelectionView"); class EditorPositionHistoryManager { constructor(prevCursorPositions = []) { this.prevCursorPositions = prevCursorPositions; @@ -32,6 +35,25 @@ class EditorPositionHistoryManager { } return this.open(item); } + async showHistory() { + const res = await simpleSelectionView_1.selectListView({ + items: this.getHistory() + .slice() + .reverse() + .map((item, idx) => (Object.assign({}, item, { idx }))), + itemTemplate: (item, ctx) => (etch.dom("li", { class: "two-lines" }, + etch.dom("div", { class: "primary-line" }, + etch.dom(highlightComponent_1.HighlightComponent, { label: item.file, query: ctx.getFilterQuery() })), + etch.dom("div", { class: "secondary-line" }, + "Line: ", + item.line, + ", column: ", + item.offset))), + itemFilterKey: "file", + }); + if (res) + await this.goHistory(res.idx + 1); + } getHistory() { return this.prevCursorPositions; } diff --git a/dist/main/atom/editorPositionHistoryManager.js.map b/dist/main/atom/editorPositionHistoryManager.js.map index a48a54dbf..d328b2447 100644 --- a/dist/main/atom/editorPositionHistoryManager.js.map +++ b/dist/main/atom/editorPositionHistoryManager.js.map @@ -1 +1 @@ -{"version":3,"file":"editorPositionHistoryManager.js","sourceRoot":"","sources":["../../../lib/main/atom/editorPositionHistoryManager.ts"],"names":[],"mappings":";;AAAA,mCAA8D;AAQ9D,MAAa,4BAA4B;IACvC,YAAoB,sBAA2C,EAAE;QAA7C,wBAAmB,GAAnB,mBAAmB,CAA0B;IAAG,CAAC;IAE9D,KAAK,CAAC,MAAM;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,KAAa;QAClC,IAAI,QAAQ,CAAA;QACZ,OAAO,KAAK,EAAE,GAAG,CAAC;YAAE,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAA;QAC7D,IAAI,CAAC,QAAQ,EAAE;YACb,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAA;YAClE,OAAM;SACP;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;YACf,IAAI,EA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AC9C;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAvDD,oEAuDC"} \ No newline at end of file +{"version":3,"file":"editorPositionHistoryManager.js","sourceRoot":"","sources":["../../../lib/main/atom/editorPositionHistoryManager.tsx"],"names":[],"mappings":";;AACA,6BAA4B;AAC5B,mCAA8D;AAC9D,mEAA6D;AAC7D,qEAA0D;AAO1D,MAAa,4BAA4B;IACvC,YAAoB,sBAA2C,EAAE;QAA7C,wBAAmB,GAAnB,mBAAmB,CAA0B;IAAG,CAAC;IAE9D,KAAK,CAAC,MAAM;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;IAC1B,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,KAAa;QAClC,IAAI,QAAQ,CAAA;QACZ,OAAO,KAAK,EAAE,GAAG,CAAC;YAAE,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAA;QAC7D,IAAI,CAAC,QAAQ,EAAE;YACb,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAA;YAClE,OAAM;SACP;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;YACf,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAC;SACtD,CAAC,CAAA;IACJ,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,aAAyB,EAAE,IAAgB;QAChE,MAAM,QAAQ,GAAG,2BAAmB,CAAC,aAAa,CAAC,CAAA;QACnD,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACvC,MAAM,QAAQ,GAAG,GAAG,CAAA;YACpB,IAAI,IAAI,CAAC,mBAAmB,CAAC,MAAM,GAAG,QAAQ,EAAE;gBAC9C,IAAI,CAAC,mBAAmB,CAAC,MAAM,CA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ChC,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;YACpC,cAAc,EAAE,IAAI;SACrB,CAAC,CAAA;QACF,IAAI,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE;YACvC,MAAM,CAAC,sBAAsB,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAA;SAC9C;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AA5ED,oEA4EC"} \ No newline at end of file diff --git a/dist/main/atom/hyperclickProvider.js.map b/dist/main/atom/hyperclickProvider.js.map deleted file mode 100644 index c3138aad0..000000000 --- a/dist/main/atom/hyperclickProvider.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"hyperclickProvider.js","sourceRoot":"","sources":["../../../lib/main/atom/hyperclickProvider.ts"],"names":[],"mappings":";;AAEA,gEAAiE;AACjE,mCAAkD;AAGlD,SAAgB,qBAAqB,CACnC,cAA8B,EAC9B,aAA2C;IAE3C,OAAO;QACL,YAAY,EAAE,gCAAgC;QAC9C,UAAU,EAAE,8CAA8C;QAC1D,oBAAoB,CAAC,MAAuB,EAAE,KAAa,EAAE,KAAiB;YAC5E,IAAI,CAAC,kCAA0B,CAAC,MAAM,CAAC,EAAE;gBACvC,OAAO,IAAI,CAAA;aACZ;YACD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;YACjC,IAAI,QAAQ,KAAK,SAAS,EAAE;gBAC1B,OAAO,IAAI,CAAA;aACZ;YAED,OAAO;gBACL,KAAK;gBACL,QAAQ,EAAE,KAAK,IAAI,EAAE;oBACnB,MAAM,QAAQ,GAAG;wBACf,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;wBACzB,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;qBAC/B,CAAA;oBACD,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;oBACtD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;oBAC3D,wCAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,CAAA;gBACvD,CAAC;aACF,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC;AA/BD,sDA+BC"} \ No newline at end of file diff --git a/dist/main/atom/occurrence/controller.js b/dist/main/atom/occurrence/controller.js new file mode 100644 index 000000000..3a9782de1 --- /dev/null +++ b/dist/main/atom/occurrence/controller.js @@ -0,0 +1,81 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const atom_1 = require("atom"); +const lodash_1 = require("lodash"); +const utils_1 = require("../../../utils"); +const utils_2 = require("../utils"); +class OccurenceController { + constructor(getClient, editor) { + this.getClient = getClient; + this.editor = editor; + this.disposables = new atom_1.CompositeDisposable(); + this.occurrenceMarkers = []; + this.disposed = false; + const debouncedUpdate = lodash_1.debounce(() => { + utils_1.handlePromise(this.update()); + }, 100); + this.disposables.add(editor.onDidChangeCursorPosition(debouncedUpdate), editor.onDidChangePath(debouncedUpdate), editor.onDidChangeGrammar(debouncedUpdate)); + } + dispose() { + if (this.disposed) + return; + this.disposed = true; + this.disposables.dispose(); + this.clearMarkers(); + } + clearMarkers() { + for (const marker of this.occurrenceMarkers) { + marker.destroy(); + } + this.occurrenceMarkers = []; + } + async update() { + if (this.disposed) + return; + if (!utils_2.isTypescriptEditorWithPath(this.editor)) { + this.clearMarkers(); + return; + } + const filePath = this.editor.getPath(); + if (filePath === undefined) + return; + const client = await this.getClient(filePath); + if (this.disposed) + return; + const pos = this.editor.getLastCursor().getBufferPosition(); + try { + const result = await client.execute("occurrences", { + file: filePath, + line: pos.row + 1, + offset: pos.column + 1, + }); + if (this.disposed) + return; + const ranges = result.body.map(utils_2.spanToRange); + const newOccurrenceMarkers = ranges.map(range => { + const oldMarker = this.occurrenceMarkers.find(m => m.getBufferRange().isEqual(range)); + if (oldMarker) + return oldMarker; + else { + const marker = this.editor.markBufferRange(range); + this.editor.decorateMarker(marker, { + type: "highlight", + class: "atom-typescript-occurrence", + }); + return marker; + } + }); + for (const m of this.occurrenceMarkers) { + if (!newOccurrenceMarkers.includes(m)) + m.destroy(); + } + this.occurrenceMarkers = newOccurrenceMarkers; + } + catch (e) { + if (window.atom_typescript_debug) + console.error(e); + } + } +} +exports.OccurenceController = OccurenceController; +//# sourceMappingURL=controller.js.map \ No newline at end of file diff --git a/dist/main/atom/occurrence/controller.js.map b/dist/main/atom/occurrence/controller.js.map new file mode 100644 index 000000000..d711845bb --- /dev/null +++ b/dist/main/atom/occurrence/controller.js.map @@ -0,0 +1 @@ +{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../lib/main/atom/occurrence/controller.ts"],"names":[],"mappings":";;AAAA,+BAAmE;AACnE,mCAA+B;AAE/B,0CAA4C;AAC5C,oCAAgE;AAEhE,MAAa,mBAAmB;IAK9B,YAAoB,SAA4B,EAAU,MAAkB;QAAxD,cAAS,GAAT,SAAS,CAAmB;QAAU,WAAM,GAAN,MAAM,CAAY;QAJ3D,gBAAW,GAAG,IAAI,0BAAmB,EAAE,CAAA;QAChD,sBAAiB,GAAoB,EAAE,CAAA;QACvC,aAAQ,GAAG,KAAK,CAAA;QAGtB,MAAM,eAAe,GAAG,iBAAQ,CAAC,GAAG,EAAE;YACpC,qBAAa,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;QAC9B,CAAC,EAAE,GAAG,CAAC,CAAA;QACP,IAAI,CAAC,WAAW,CAAC,GAAG,CAClB,MAAM,CAAC,yBAAyB,CAAC,eAAe,CAAC,EACjD,MAAM,CAAC,eAAe,CAAC,eAAe,CAAC,EACvC,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAC3C,CAAA;IACH,CAAC;IAEM,OAAO;QACZ,IAAI,IAAI,CAAC,QAAQ;YAAE,OA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C,MAAM,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;gBACrF,IAAI,SAAS;oBAAE,OAAO,SAAS,CAAA;qBAC1B;oBACH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;oBACjD,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE;wBACjC,IAAI,EAAE,WAAW;wBACjB,KAAK,EAAE,4BAA4B;qBACpC,CAAC,CAAA;oBACF,OAAO,MAAM,CAAA;iBACd;YACH,CAAC,CAAC,CAAA;YACF,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,iBAAiB,EAAE;gBACtC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC;oBAAE,CAAC,CAAC,OAAO,EAAE,CAAA;aACnD;YACD,IAAI,CAAC,iBAAiB,GAAG,oBAAoB,CAAA;SAC9C;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,MAAM,CAAC,qBAAqB;gBAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;SACnD;IACH,CAAC;CACF;AAzED,kDAyEC"} \ No newline at end of file diff --git a/dist/main/atom/occurrence/manager.js b/dist/main/atom/occurrence/manager.js new file mode 100644 index 000000000..33ab5446a --- /dev/null +++ b/dist/main/atom/occurrence/manager.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const atom_1 = require("atom"); +const controller_1 = require("./controller"); +class OccurrenceManager { + constructor(getClient) { + this.disposables = new atom_1.CompositeDisposable(); + this.disposables.add(atom.workspace.observeTextEditors(editor => { + const controller = new controller_1.OccurenceController(getClient, editor); + this.disposables.add(controller, editor.onDidDestroy(() => { + this.disposables.remove(controller); + controller.dispose(); + })); + })); + } + dispose() { + this.disposables.dispose(); + } +} +exports.OccurrenceManager = OccurrenceManager; +//# sourceMappingURL=manager.js.map \ No newline at end of file diff --git a/dist/main/atom/occurrence/manager.js.map b/dist/main/atom/occurrence/manager.js.map new file mode 100644 index 000000000..447505245 --- /dev/null +++ b/dist/main/atom/occurrence/manager.js.map @@ -0,0 +1 @@ +{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../../lib/main/atom/occurrence/manager.ts"],"names":[],"mappings":";;AAAA,+BAAwC;AAExC,6CAAgD;AAEhD,MAAa,iBAAiB;IAG5B,YAAY,SAA4B;QAFvB,gBAAW,GAAG,IAAI,0BAAmB,EAAE,CAAA;QAGtD,IAAI,CAAC,WAAW,CAAC,GAAG,CAClB,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;YACzC,MAAM,UAAU,GAAG,IAAI,gCAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;YAC7D,IAAI,CAAC,WAAW,CAAC,GAAG,CAClB,UAAU,EACV,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE;gBACvB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;gBACnC,UAAU,CAAC,OAAO,EAAE,CAAA;YACtB,CAAC,CAAC,CACH,CAAA;QACH,CAAC,CAAC,CACH,CAAA;IACH,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;IAC5B,CAAC;CACF;AArBD,8CAqBC"} \ No newline at end of file diff --git a/dist/main/atom/sigHelp/controller.js b/dist/main/atom/sigHelp/controller.js new file mode 100644 index 000000000..e34e95dc5 --- /dev/null +++ b/dist/main/atom/sigHelp/controller.js @@ -0,0 +1,96 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Atom = require("atom"); +const lodash_1 = require("lodash"); +const utils_1 = require("../../../utils"); +const utils_2 = require("../utils"); +const tooltipView_1 = require("./tooltipView"); +class TooltipController { + constructor(deps, editor, bufferPt) { + this.deps = deps; + this.editor = editor; + this.cancelled = false; + this.disposables = new Atom.CompositeDisposable(); + const rawView = atom.views.getView(this.editor); + this.view = new tooltipView_1.TooltipView(rawView); + rawView.appendChild(this.view.element); + const debouncedUpdate = lodash_1.debounce(this.updateTooltip.bind(this), 100, { leading: true }); + this.disposables.add(this.editor.onDidChangeCursorPosition(evt => { + bufferPt = evt.newBufferPosition; + utils_1.handlePromise(debouncedUpdate(bufferPt)); + }), rawView.onDidChangeScrollTop(() => { + setImmediate(() => this.updateTooltipPosition(bufferPt)); + }), rawView.onDidChangeScrollLeft(() => { + setImmediate(() => this.updateTooltipPosition(bufferPt)); + })); + utils_1.handlePromise(this.updateTooltip(bufferPt)); + } + isDisposed() { + return this.cancelled; + } + dispose() { + if (this.cancelled) + return; + this.cancelled = true; + this.disposables.dispose(); + utils_1.handlePromise(this.view.destroy()); + } + async updateTooltip(bufferPt) { + if (this.cancelled) + return; + const tooltipRect = this.computeTooltipPosition(bufferPt); + const msg = await this.getMessage(bufferPt); + if (this.cancelled) + return; + if (!msg) { + this.dispose(); + return; + } + await this.view.update(Object.assign({}, tooltipRect, { sigHelp: msg })); + } + updateTooltipPosition(bufferPt) { + if (this.cancelled) + return; + const tooltipRect = this.computeTooltipPosition(bufferPt); + utils_1.handlePromise(this.view.update(Object.assign({}, tooltipRect))); + } + computeTooltipPosition(bufferPt) { + const rawView = atom.views.getView(this.editor); + const pixelPos = rawView.pixelPositionForBufferPosition(bufferPt); + const lines = rawView.querySelector(".lines"); + const linesRect = lines.getBoundingClientRect(); + const lineH = this.editor.getLineHeightInPixels(); + const parentRect = rawView.getBoundingClientRect(); + const Y = pixelPos.top + linesRect.top - parentRect.top + lineH / 2; + const X = pixelPos.left + linesRect.left - parentRect.left; + const offset = lineH * 0.7; + return { + left: X, + right: X, + top: Y - offset, + bottom: Y + offset, + }; + } + async getMessage(bufferPt) { + if (!utils_2.isTypescriptEditorWithPath(this.editor)) + return; + const filePath = this.editor.getPath(); + if (filePath === undefined) + return; + const client = await this.deps.getClient(filePath); + try { + await this.deps.flushTypescriptBuffer(filePath); + const result = await client.execute("signatureHelp", { + file: filePath, + line: bufferPt.row + 1, + offset: bufferPt.column + 1, + }); + return result.body; + } + catch (e) { + return; + } + } +} +exports.TooltipController = TooltipController; +//# sourceMappingURL=controller.js.map \ No newline at end of file diff --git a/dist/main/atom/sigHelp/controller.js.map b/dist/main/atom/sigHelp/controller.js.map new file mode 100644 index 000000000..0e0c01e08 --- /dev/null +++ b/dist/main/atom/sigHelp/controller.js.map @@ -0,0 +1 @@ +{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../lib/main/atom/sigHelp/controller.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,mCAA+B;AAE/B,0CAA4C;AAE5C,oCAAmD;AACnD,+CAAyC;AAEzC,MAAa,iBAAiB;IAI5B,YACU,IAGP,EACO,MAAuB,EAC/B,QAAoB;QALZ,SAAI,GAAJ,IAAI,CAGX;QACO,WAAM,GAAN,MAAM,CAAiB;QARzB,cAAS,GAAG,KAAK,CAAA;QAEjB,gBAAW,GAAG,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAA;QASlD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAW,CAAC,OAAO,CAAC,CAAA;QACpC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACtC,MAAM,eAAe,GAAG,iBAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAA;QACrF,IAAI,CAAC,WAAW,CAAC,GAAG,CAClB,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,GAAG,CAAC,EAAE;YAC1C,QAAQ,GAAG,GAAG,CAAC,iBAAiB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,OAAO,EAAE,CAAA;QACtC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAM;QAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;QAClD,IAAI;YACF,MAAM,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAA;YAC/C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE;gBACnD,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC;gBACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC;aAC5B,CAAC,CAAA;YACF,OAAO,MAAM,CAAC,IAAI,CAAA;SACnB;QAAC,OAAO,CAAC,EAAE;YACV,OAAM;SACP;IACH,CAAC;CACF;AAhGD,8CAgGC"} \ No newline at end of file diff --git a/dist/main/atom/sigHelp/manager.js b/dist/main/atom/sigHelp/manager.js new file mode 100644 index 000000000..3e6b371b2 --- /dev/null +++ b/dist/main/atom/sigHelp/manager.js @@ -0,0 +1,65 @@ +"use strict"; +// Inspiration : https://atom.io/packages/ide-haskell +// and https://atom.io/packages/ide-flow +Object.defineProperty(exports, "__esModule", { value: true }); +const Atom = require("atom"); +const utils_1 = require("../../../utils"); +const controller_1 = require("./controller"); +class SigHelpManager { + constructor(deps) { + this.deps = deps; + this.subscriptions = new Atom.CompositeDisposable(); + this.editorMap = new WeakMap(); + this.stoppedChanging = (editor) => (event) => { + const filePath = editor.getPath(); + if (filePath === undefined) + return; + const pos = editor.getLastCursor().getBufferPosition(); + const [ch] = event.changes.filter(x => x.newRange.containsPoint(pos)); + if (ch && ch.newText.match(/[(,]/) !== null) { + utils_1.handlePromise(this.showTooltip(editor, pos)); + } + }; + this.subscriptions.add(atom.workspace.observeTextEditors(editor => { + const disp = new Atom.CompositeDisposable(); + disp.add(editor.onDidDestroy(() => { + disp.dispose(); + this.subscriptions.remove(disp); + const controller = this.editorMap.get(editor); + if (controller) + controller.dispose(); + }), editor.onDidStopChanging(this.stoppedChanging(editor))); + this.subscriptions.add(disp); + })); + } + dispose() { + this.subscriptions.dispose(); + for (const editor of atom.workspace.getTextEditors()) { + const controller = this.editorMap.get(editor); + if (controller) + controller.dispose(); + } + } + async showTooltipAt(editor) { + const pt = editor.getLastCursor().getBufferPosition(); + return this.showTooltip(editor, pt); + } + hideTooltipAt(editor) { + const controller = this.editorMap.get(editor); + if (controller && !controller.isDisposed()) { + controller.dispose(); + return true; + } + else { + return false; + } + } + async showTooltip(editor, pos) { + const controller = this.editorMap.get(editor); + if (!controller || controller.isDisposed()) { + this.editorMap.set(editor, new controller_1.TooltipController(this.deps, editor, pos)); + } + } +} +exports.SigHelpManager = SigHelpManager; +//# sourceMappingURL=manager.js.map \ No newline at end of file diff --git a/dist/main/atom/sigHelp/manager.js.map b/dist/main/atom/sigHelp/manager.js.map new file mode 100644 index 000000000..84ad998da --- /dev/null +++ b/dist/main/atom/sigHelp/manager.js.map @@ -0,0 +1 @@ +{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../../lib/main/atom/sigHelp/manager.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,wCAAwC;;AAExC,6BAA4B;AAE5B,0CAA4C;AAE5C,6CAA8C;AAE9C,MAAa,cAAc;IAIzB,YACU,IAGP;QAHO,SAAI,GAAJ,IAAI,CAGX;QAPK,kBAAa,GAAG,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAC9C,cAAS,GAAG,IAAI,OAAO,EAAsC,CAAA;QAuD7D,oBAAe,GAAG,CAAC,MAAuB,EAAE,EAAE,CAAC,CACrD,KAAsC,EACtC,EAAE;YACF,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;YACjC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAM;YAClC,MAAM,GAAG,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,iBAAiB,EAAE,CAAA;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;YAC7C,IAAI,UAAU;gBAAE,UAAU,CAAC,OAAO,EAAE,CAAA;SACrC;IACH,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,MAAuB;QAChD,MAAM,EAAE,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC,iBAAiB,EAAE,CAAA;QACrD,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;IAEM,aAAa,CAAC,MAAuB;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAC7C,IAAI,UAAU,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,EAAE;YAC1C,UAAU,CAAC,OAAO,EAAE,CAAA;YACpB,OAAO,IAAI,CAAA;SACZ;aAAM;YACL,OAAO,KAAK,CAAA;SACb;IACH,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,MAAuB,EAAE,GAAe;QAChE,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAC7C,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,UAAU,EAAE,EAAE;YAC1C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,8BAAiB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;SAC1E;IACH,CAAC;CAeF;AAtED,wCAsEC"} \ No newline at end of file diff --git a/dist/main/atom/sigHelp/tooltipView.js b/dist/main/atom/sigHelp/tooltipView.js new file mode 100644 index 000000000..cd1161e5c --- /dev/null +++ b/dist/main/atom/sigHelp/tooltipView.js @@ -0,0 +1,81 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const etch = require("etch"); +const utils_1 = require("../utils"); +class TooltipView { + constructor(parent) { + this.parent = parent; + this.props = { + left: 0, + right: 0, + top: 0, + bottom: 0, + }; + etch.initialize(this); + } + async destroy() { + return etch.destroy(this); + } + async update(props) { + this.props = Object.assign({}, this.props, props); + await etch.update(this); + } + writeAfterUpdate() { + const offset = 10; + let left = this.props.right; + let right = false; + let whiteSpace = ""; + const clientWidth = this.parent.clientWidth; + const offsetWidth = this.element.offsetWidth; + const offsetHeight = this.element.offsetHeight; + let top = this.props.top - offsetHeight; + // X axis adjust + if (left + offsetWidth >= clientWidth) { + left = clientWidth - offsetWidth - offset; + } + if (left < 0) { + whiteSpace = "pre-wrap"; + left = offset; + right = offset; + } + // Y axis adjust + if (top < 0) { + top = this.props.bottom; + } + this.element.style.left = `${left}px`; + this.element.style.top = `${top}px`; + if (right !== false) + this.element.style.right = `${right}px`; + if (whiteSpace) + this.element.style.whiteSpace = whiteSpace; + } + render() { + return (etch.dom("div", { class: "atom-typescript-tooltip tooltip", key: this.sigHelpHash() }, + etch.dom("div", { class: "tooltip-inner" }, this.tooltipContents()))); + } + sigHelpHash() { + if (!this.props.sigHelp) + return undefined; + const { start, end } = this.props.sigHelp.applicableSpan; + return `${start.line}:${start.offset}-${end.line}:${end.offset}`; + } + tooltipContents() { + if (!this.props.sigHelp) + return "â€Ĥ"; + const { sigHelp } = this.props; + return sigHelp.items.map((sig, idx) => (etch.dom("div", { class: `atom-typescript-tooltip-signature-help${idx === sigHelp.selectedItemIndex + ? " atom-typescript-tooltip-signature-help-selected" + : ""}` }, + utils_1.partsToStr(sig.prefixDisplayParts), + this.renderSigHelpParams(sig.parameters, sigHelp.argumentIndex), + utils_1.partsToStr(sig.suffixDisplayParts), + etch.dom("div", { class: "atom-typescript-tooltip-signature-help-documentation" }, utils_1.partsToStr(sig.documentation))))); + } + renderSigHelpParams(params, selIdx) { + return params.map((p, i) => (etch.dom("span", { class: `atom-typescript-tooltip-signature-help-parameter` }, + i > 0 ? ", " : null, + etch.dom("span", { class: i === selIdx ? "atom-typescript-tooltip-signature-help-selected" : undefined }, utils_1.partsToStr(p.displayParts))))); + } +} +exports.TooltipView = TooltipView; +//# sourceMappingURL=tooltipView.js.map \ No newline at end of file diff --git a/dist/main/atom/sigHelp/tooltipView.js.map b/dist/main/atom/sigHelp/tooltipView.js.map new file mode 100644 index 000000000..b18a16002 --- /dev/null +++ b/dist/main/atom/sigHelp/tooltipView.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tooltipView.js","sourceRoot":"","sources":["../../../../lib/main/atom/sigHelp/tooltipView.tsx"],"names":[],"mappings":";;AACA,6BAA4B;AAC5B,oCAAmC;AAUnC,MAAa,WAAW;IAItB,YAAoB,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QAC3C,IAAI,CAAC,KAAK,GAAG;YACX,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,CAAC;YACR,GAAG,EAAE,CAAC;YACN,MAAM,EAAE,CAAC;SACV,CAAA;QACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB;QACvC,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAEM,gBAAgB;QACrB,MAAM,MAAM,GAAG,EAAE,CAAA;QACjB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;QAC3B,IAAI,KAAK,GAAmB,KAAK,CAAA;QAEjC,IAAI,UAAU,GAAG,EAAE,CAAA;QAEnB,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAA;QAC3C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAA;QAC5C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAA;QAE9C,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC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AAE,CAAA;IAClE,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO;YAAE,OAAO,GAAG,CAAA;QACnC,MAAM,EAAC,OAAO,EAAC,GAAG,IAAI,CAAC,KAAK,CAAA;QAC5B,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CACrC,kBACE,KAAK,EAAE,yCACL,GAAG,KAAK,OAAO,CAAC,iBAAiB;gBAC/B,CAAC,CAAC,kDAAkD;gBACpD,CAAC,CAAC,EACN,EAAE;YACD,kBAAU,CAAC,GAAG,CAAC,kBAAkB,CAAC;YAClC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC;YAC/D,kBAAU,CAAC,GAAG,CAAC,kBAAkB,CAAC;YACnC,kBAAK,KAAK,EAAC,sDAAsD,IAC9D,kBAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAC1B,CACF,CACP,CAAC,CAAA;IACJ,CAAC;IAEO,mBAAmB,CAAC,MAAyC,EAAE,MAAc;QACnF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAC1B,mBAAM,KAAK,EAAE,kDAAkD;YAC5D,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;YACpB,mBAAM,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,iDAAiD,CAAC,CAAC,CAAC,SAAS,IACtF,kBAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CACtB,CACF,CACR,CAAC,CAAA;IACJ,CAAC;CACF;AArGD,kCAqGC"} \ No newline at end of file diff --git a/dist/main/atom/sigHelp/util.js b/dist/main/atom/sigHelp/util.js new file mode 100644 index 000000000..cac843fa4 --- /dev/null +++ b/dist/main/atom/sigHelp/util.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// screen position from mouse event -- with <3 from Atom-Haskell +function bufferPositionFromMouseEvent(editor, event) { + const sp = atom.views + .getView(editor) + .getComponent() + .screenPositionForMouseEvent(event); + if (isNaN(sp.row) || isNaN(sp.column)) { + return; + } + return editor.bufferPositionForScreenPosition(sp); +} +exports.bufferPositionFromMouseEvent = bufferPositionFromMouseEvent; +//# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/dist/main/atom/sigHelp/util.js.map b/dist/main/atom/sigHelp/util.js.map new file mode 100644 index 000000000..70298f99a --- /dev/null +++ b/dist/main/atom/sigHelp/util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../lib/main/atom/sigHelp/util.ts"],"names":[],"mappings":";;AAEA,gEAAgE;AAChE,SAAgB,4BAA4B,CAC1C,MAAkB,EAClB,KAAyC;IAEzC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK;SAClB,OAAO,CAAC,MAAM,CAAC;SACf,YAAY,EAAE;SACd,2BAA2B,CAAC,KAAK,CAAC,CAAA;IACrC,IAAI,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE;QACrC,OAAM;KACP;IACD,OAAO,MAAM,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAA;AACnD,CAAC;AAZD,oEAYC"} \ No newline at end of file diff --git a/dist/main/atom/tooltipManager.js b/dist/main/atom/tooltipManager.js deleted file mode 100644 index 0f6fd21bb..000000000 --- a/dist/main/atom/tooltipManager.js +++ /dev/null @@ -1,171 +0,0 @@ -"use strict"; -// Inspiration : https://atom.io/packages/ide-haskell -// and https://atom.io/packages/ide-flow -Object.defineProperty(exports, "__esModule", { value: true }); -const atomUtils = require("./utils"); -const Atom = require("atom"); -const fs = require("fs"); -const element_listener_1 = require("./utils/element-listener"); -const tooltipView_1 = require("./views/tooltipView"); -const escape = require("escape-html"); -const tooltipMap = new WeakMap(); -// screen position from mouse event -- with <3 from Atom-Haskell -function bufferPositionFromMouseEvent(editor, event) { - const sp = atom.views - .getView(editor) - .getComponent() - .screenPositionForMouseEvent(event); - if (isNaN(sp.row) || isNaN(sp.column)) { - return; - } - return editor.bufferPositionForScreenPosition(sp); -} -async function showExpressionAt(editor, pt) { - const ed = tooltipMap.get(editor); - if (ed) { - return ed.showExpressionTypeKbd(pt); - } -} -exports.showExpressionAt = showExpressionAt; -class TooltipManager { - constructor(editor, getClient) { - this.editor = editor; - this.getClient = getClient; - this.subscriptions = new Atom.CompositeDisposable(); - this.reinitialize = () => { - this.clientPromise = undefined; - // Only on ".ts" files - const filePath = this.editor.getPath(); - if (filePath === undefined) - return; - if (!atomUtils.isTypescriptEditorWithPath(this.editor)) - return; - // We only create a "program" once the file is persisted to disk - if (!fs.existsSync(filePath)) - return; - this.clientPromise = this.getClient(filePath); - }; - /** clears the timeout && the tooltip */ - this.clearExprTypeTimeout = () => { - if (this.exprTypeTimeout !== undefined) { - clearTimeout(this.exprTypeTimeout); - this.exprTypeTimeout = undefined; - } - if (this.cancelShowTooltip) - this.cancelShowTooltip(); - this.hideExpressionType(); - }; - this.trackMouseMovement = (e) => { - const bufferPt = bufferPositionFromMouseEvent(this.editor, e); - if (!bufferPt) - return; - if (this.lastExprTypeBufferPt && - this.lastExprTypeBufferPt.isEqual(bufferPt) && - TooltipManager.exprTypeTooltip) { - return; - } - this.lastExprTypeBufferPt = bufferPt; - this.clearExprTypeTimeout(); - this.exprTypeTimeout = window.setTimeout(() => this.showExpressionType(e), atom.config.get("atom-typescript.tooltipDelay")); - }; - this.rawView = atom.views.getView(editor); - this.lines = this.rawView.querySelector(".lines"); - tooltipMap.set(editor, this); - this.subscriptions.add(element_listener_1.listen(this.rawView, "mousemove", ".scroll-view", this.trackMouseMovement), element_listener_1.listen(this.rawView, "mouseout", ".scroll-view", this.clearExprTypeTimeout), element_listener_1.listen(this.rawView, "keydown", ".scroll-view", this.clearExprTypeTimeout), this.rawView.onDidChangeScrollTop(this.clearExprTypeTimeout), this.rawView.onDidChangeScrollLeft(this.clearExprTypeTimeout)); - this.subscriptions.add(this.editor.onDidChangePath(this.reinitialize)); - this.reinitialize(); - } - dispose() { - this.subscriptions.dispose(); - this.clearExprTypeTimeout(); - } - async showExpressionTypeKbd(pt) { - const view = atom.views.getView(this.editor); - const px = view.pixelPositionForBufferPosition(pt); - return this.showExpressionType(this.mousePositionForPixelPosition(px)); - } - mousePositionForPixelPosition(p) { - const linesRect = this.lines.getBoundingClientRect(); - return { - clientY: p.top + linesRect.top + this.editor.getLineHeightInPixels() / 2, - clientX: p.left + linesRect.left, - }; - } - async showExpressionType(e) { - if (!this.clientPromise) - return; - // If we are already showing we should wait for that to clear - if (TooltipManager.exprTypeTooltip) - return; - if (this.cancelShowTooltip) - this.cancelShowTooltip(); - let cancelled = false; - this.cancelShowTooltip = () => { - cancelled = true; - this.cancelShowTooltip = undefined; - }; - const bufferPt = bufferPositionFromMouseEvent(this.editor, e); - if (!bufferPt) - return; - const curCharPixelPt = this.rawView.pixelPositionForBufferPosition(bufferPt); - const nextCharPixelPt = this.rawView.pixelPositionForBufferPosition(bufferPt.traverse([0, 1])); - if (curCharPixelPt.left >= nextCharPixelPt.left) { - return; - } - // find out show position - const offset = this.editor.getLineHeightInPixels() * 0.7; - const tooltipRect = { - left: e.clientX, - right: e.clientX, - top: e.clientY - offset, - bottom: e.clientY + offset, - }; - const msg = await this.getMessage(bufferPt); - if (cancelled) - return; - if (msg !== undefined) - this.showTooltip(tooltipRect, msg); - } - async getMessage(bufferPt) { - let result; - if (!this.clientPromise) - return; - const client = await this.clientPromise; - const filePath = this.editor.getPath(); - try { - if (filePath === undefined) { - return; - } - result = await client.execute("quickinfo", { - file: filePath, - line: bufferPt.row + 1, - offset: bufferPt.column + 1, - }); - } - catch (e) { - return; - } - const { displayString, documentation } = result.body; - let message = `${escape(displayString)}`; - if (documentation) { - message = - message + `
${escape(documentation).replace(/(?:\r\n|\r|\n)/g, "
")}
`; - } - return message; - } - showTooltip(tooltipRect, message) { - if (TooltipManager.exprTypeTooltip) - return; - TooltipManager.exprTypeTooltip = new tooltipView_1.TooltipView(); - document.body.appendChild(TooltipManager.exprTypeTooltip.element); - TooltipManager.exprTypeTooltip.update(Object.assign({}, tooltipRect, { text: message })); - } - hideExpressionType() { - if (!TooltipManager.exprTypeTooltip) - return; - TooltipManager.exprTypeTooltip.destroy(); - TooltipManager.exprTypeTooltip = undefined; - } -} -exports.TooltipManager = TooltipManager; -//# sourceMappingURL=tooltipManager.js.map \ No newline at end of file diff --git a/dist/main/atom/tooltipManager.js.map b/dist/main/atom/tooltipManager.js.map deleted file mode 100644 index 05ed81888..000000000 --- a/dist/main/atom/tooltipManager.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tooltipManager.js","sourceRoot":"","sources":["../../../lib/main/atom/tooltipManager.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,wCAAwC;;AAExC,qCAAqC;AACrC,6BAA4B;AAC5B,yBAAyB;AACzB,+DAA+C;AAC/C,qDAA+C;AAC/C,sCAAsC;AAGtC,MAAM,UAAU,GAAG,IAAI,OAAO,EAAmC,CAAA;AASjE,gEAAgE;AAChE,SAAS,4BAA4B,CACnC,MAAuB,EACvB,KAAyC;IAEzC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK;SAClB,OAAO,CAAC,MAAM,CAAC;SACf,YAAY,EAAE;SACd,2BAA2B,CAAC,KAAK,CAAC,CAAA;IACrC,IAAI,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE;QACrC,OAAM;KACP;IACD,OAAO,MAAM,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAA;AACnD,CAAC;AAEM,KAAK,UAAU,gBAAgB,CAAC,MAAuB,EAAE,EAAc;IAC5E,MAAM,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,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W,EAAE;gBACzC,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC;gBACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC;aAC5B,CAAC,CAAA;SACH;QAAC,OAAO,CAAC,EAAE;YACV,OAAM;SACP;QAED,MAAM,EAAC,aAAa,EAAE,aAAa,EAAC,GAAG,MAAM,CAAC,IAAK,CAAA;QAEnD,IAAI,OAAO,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAA;QAC/C,IAAI,aAAa,EAAE;YACjB,OAAO;gBACL,OAAO,GAAG,WAAW,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAA;SACxF;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IAEO,WAAW,CAAC,WAAiB,EAAE,OAAe;QACpD,IAAI,cAAc,CAAC,eAAe;YAAE,OAAM;QAC1C,cAAc,CAAC,eAAe,GAAG,IAAI,yBAAW,EAAE,CAAA;QAClD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;QACjE,cAAc,CAAC,eAAe,CAAC,MAAM,mBAAK,WAAW,IAAE,IAAI,EAAE,OAAO,IAAE,CAAA;IACxE,CAAC;IAYO,kBAAkB;QACxB,IAAI,CAAC,cAAc,CAAC,eAAe;YAAE,OAAM;QAC3C,cAAc,CAAC,eAAe,CAAC,OAAO,EAAE,CAAA;QACxC,cAAc,CAAC,eAAe,GAAG,SAAS,CAAA;IAC5C,CAAC;CAqBF;AAxKD,wCAwKC"} \ No newline at end of file diff --git a/dist/main/atom/tooltips/controller.js b/dist/main/atom/tooltips/controller.js new file mode 100644 index 000000000..2a71630ea --- /dev/null +++ b/dist/main/atom/tooltips/controller.js @@ -0,0 +1,70 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("../../../utils"); +const tooltipView_1 = require("./tooltipView"); +const util_1 = require("./util"); +class TooltipController { + constructor(getClient, editor, e) { + this.getClient = getClient; + this.cancelled = false; + utils_1.handlePromise(this.initialize(editor, e)); + } + dispose() { + this.cancelled = true; + if (this.view) { + utils_1.handlePromise(this.view.destroy()); + this.view = undefined; + } + } + async initialize(editor, e) { + const bufferPt = util_1.bufferPositionFromMouseEvent(editor, e); + if (!bufferPt) + return; + const rawView = atom.views.getView(editor); + const curCharPixelPt = rawView.pixelPositionForBufferPosition(bufferPt); + const nextCharPixelPt = rawView.pixelPositionForBufferPosition(bufferPt.traverse([0, 1])); + if (curCharPixelPt.left >= nextCharPixelPt.left) + return; + // find out show position + const offset = editor.getLineHeightInPixels() * 0.7; + const tooltipRect = { + left: e.clientX, + right: e.clientX, + top: e.clientY - offset, + bottom: e.clientY + offset, + }; + const msg = await this.getMessage(editor, bufferPt); + if (this.cancelled) + return; + if (msg !== undefined) + await this.showTooltip(tooltipRect, msg); + } + async getMessage(editor, bufferPt) { + let result; + const client = await this.getClient(editor); + if (!client) + return; + const filePath = editor.getPath(); + try { + if (filePath === undefined) { + return; + } + result = await client.execute("quickinfo", { + file: filePath, + line: bufferPt.row + 1, + offset: bufferPt.column + 1, + }); + } + catch (e) { + return; + } + return result.body; + } + async showTooltip(tooltipRect, info) { + this.view = new tooltipView_1.TooltipView(); + document.body.appendChild(this.view.element); + await this.view.update(Object.assign({}, tooltipRect, { info })); + } +} +exports.TooltipController = TooltipController; +//# sourceMappingURL=controller.js.map \ No newline at end of file diff --git a/dist/main/atom/tooltips/controller.js.map b/dist/main/atom/tooltips/controller.js.map new file mode 100644 index 000000000..af9919bc5 --- /dev/null +++ b/dist/main/atom/tooltips/controller.js.map @@ -0,0 +1 @@ +{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../lib/main/atom/tooltips/controller.ts"],"names":[],"mappings":";;AAEA,0CAA4C;AAC5C,+CAAyC;AACzC,iCAAmD;AASnD,MAAa,iBAAiB;IAG5B,YAC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AAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QACnD,IAAI,IAAI,CAAC,SAAS;YAAE,OAAM;QAC1B,IAAI,GAAG,KAAK,SAAS;YAAE,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,GAAG,CAAC,CAAA;IACjE,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,MAAuB,EAAE,QAAoB;QACpE,IAAI,MAAkC,CAAA;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAC3C,IAAI,CAAC,MAAM;YAAE,OAAM;QACnB,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;QACjC,IAAI;YACF,IAAI,QAAQ,KAAK,SAAS,EAAE;gBAC1B,OAAM;aACP;YACD,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE;gBACzC,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC;gBACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC;aAC5B,CAAC,CAAA;SACH;QAAC,OAAO,CAAC,EAAE;YACV,OAAM;SACP;QAED,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;IAEO,KAAK,CAAC,WAAW,CAAC,WAAiB,EAAE,IAAoC;QAC/E,IAAI,CAAC,IAAI,GAAG,IAAI,yBAAW,EAAE,CAAA;QAC7B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5C,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,mBAAK,WAAW,IAAE,IAAI,IAAE,CAAA;IAChD,CAAC;CACF;AApED,8CAoEC"} \ No newline at end of file diff --git a/dist/main/atom/tooltips/manager.js b/dist/main/atom/tooltips/manager.js new file mode 100644 index 000000000..a946eac2a --- /dev/null +++ b/dist/main/atom/tooltips/manager.js @@ -0,0 +1,97 @@ +"use strict"; +// Inspiration : https://atom.io/packages/ide-haskell +// and https://atom.io/packages/ide-flow +Object.defineProperty(exports, "__esModule", { value: true }); +const Atom = require("atom"); +const fs = require("fs"); +const atomUtils = require("../utils"); +const element_listener_1 = require("../utils/element-listener"); +const controller_1 = require("./controller"); +const util_1 = require("./util"); +class TooltipManager { + constructor(getClientInternal) { + this.getClientInternal = getClientInternal; + this.subscriptions = new Atom.CompositeDisposable(); + this.editorMap = new WeakMap(); + this.getClient = async (editor) => { + // Only on ".ts" files + const filePath = editor.getPath(); + if (filePath === undefined) + return; + if (!atomUtils.isTypescriptEditorWithPath(editor)) + return; + // We only create a "program" once the file is persisted to disk + if (!fs.existsSync(filePath)) + return; + return this.getClientInternal(filePath); + }; + /** clears the timeout && the tooltip */ + this.clearExprTypeTimeout = () => { + if (this.exprTypeTimeout !== undefined) { + clearTimeout(this.exprTypeTimeout); + this.exprTypeTimeout = undefined; + } + this.hideExpressionType(); + }; + this.trackMouseMovement = (editor) => { + let lastExprTypeBufferPt; + return (e) => { + const bufferPt = util_1.bufferPositionFromMouseEvent(editor, e); + if (!bufferPt) + return; + if (lastExprTypeBufferPt && lastExprTypeBufferPt.isEqual(bufferPt) && this.pendingTooltip) { + return; + } + lastExprTypeBufferPt = bufferPt; + this.clearExprTypeTimeout(); + this.exprTypeTimeout = window.setTimeout(() => this.showExpressionType(editor, e), atom.config.get("atom-typescript").tooltipDelay); + }; + }; + this.subscriptions.add(atom.workspace.observeTextEditors(editor => { + const rawView = atom.views.getView(editor); + const lines = rawView.querySelector(".lines"); + this.editorMap.set(editor, { + rawView, + lines, + }); + const disp = new Atom.CompositeDisposable(); + disp.add(element_listener_1.listen(rawView, "mousemove", ".scroll-view", this.trackMouseMovement(editor)), element_listener_1.listen(rawView, "mouseout", ".scroll-view", this.clearExprTypeTimeout), element_listener_1.listen(rawView, "keydown", ".scroll-view", this.clearExprTypeTimeout), rawView.onDidChangeScrollTop(this.clearExprTypeTimeout), rawView.onDidChangeScrollLeft(this.clearExprTypeTimeout), editor.onDidDestroy(() => { + disp.dispose(); + this.subscriptions.remove(disp); + })); + this.subscriptions.add(disp); + })); + } + dispose() { + this.subscriptions.dispose(); + this.clearExprTypeTimeout(); + } + async showExpressionAt(editor) { + const pt = editor.getLastCursor().getBufferPosition(); + const view = atom.views.getView(editor); + const px = view.pixelPositionForBufferPosition(pt); + return this.showExpressionType(editor, this.mousePositionForPixelPosition(editor, px)); + } + mousePositionForPixelPosition(editor, p) { + const rawView = atom.views.getView(editor); + const lines = rawView.querySelector(".lines"); + const linesRect = lines.getBoundingClientRect(); + return { + clientY: p.top + linesRect.top + editor.getLineHeightInPixels() / 2, + clientX: p.left + linesRect.left, + }; + } + async showExpressionType(editor, e) { + if (this.pendingTooltip) + this.pendingTooltip.dispose(); + this.pendingTooltip = new controller_1.TooltipController(this.getClient, editor, e); + } + hideExpressionType() { + if (!this.pendingTooltip) + return; + this.pendingTooltip.dispose(); + this.pendingTooltip = undefined; + } +} +exports.TooltipManager = TooltipManager; +//# sourceMappingURL=manager.js.map \ No newline at end of file diff --git a/dist/main/atom/tooltips/manager.js.map b/dist/main/atom/tooltips/manager.js.map new file mode 100644 index 000000000..48992119e --- /dev/null +++ b/dist/main/atom/tooltips/manager.js.map @@ -0,0 +1 @@ +{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../../../lib/main/atom/tooltips/manager.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,wCAAwC;;AAExC,6BAA4B;AAC5B,yBAAyB;AAEzB,sCAAsC;AACtC,gEAAgD;AAChD,6CAA8C;AAC9C,iCAAmD;AAOnD,MAAa,cAAc;IAMzB,YAAoB,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;QALhD,kBAAa,GAAG,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAE9C,cAAS,GAAG,IAAI,OAAO,EAA+B,CAAA;QAyCtD,cAAS,GAAG,KAAK,EAAE,MAAuB,EAAE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BF;AAvGD,wCAuGC"} \ No newline at end of file diff --git a/dist/main/atom/views/tooltipView.js b/dist/main/atom/tooltips/tooltipView.js similarity index 78% rename from dist/main/atom/views/tooltipView.js rename to dist/main/atom/tooltips/tooltipView.js index 8336e2b7b..5fe097e14 100644 --- a/dist/main/atom/views/tooltipView.js +++ b/dist/main/atom/tooltips/tooltipView.js @@ -8,7 +8,6 @@ class TooltipView { right: 0, top: 0, bottom: 0, - text: "", }; etch.initialize(this); } @@ -51,7 +50,14 @@ class TooltipView { } render() { return (etch.dom("div", { class: "atom-typescript-tooltip tooltip" }, - etch.dom("div", { class: "tooltip-inner", innerHTML: this.props.text }))); + etch.dom("div", { class: "tooltip-inner" }, this.tooltipContents()))); + } + tooltipContents() { + if (!this.props.info) + return "â€Ĥ"; + const code = (etch.dom("div", { class: "atom-typescript-tooltip-tooltip-code" }, this.props.info.displayString)); + const docs = this.props.info.documentation ? (etch.dom("div", { class: "atom-typescript-tooltip-tooltip-doc" }, this.props.info.documentation)) : null; + return [code, docs]; } } exports.TooltipView = TooltipView; diff --git a/dist/main/atom/tooltips/tooltipView.js.map b/dist/main/atom/tooltips/tooltipView.js.map new file mode 100644 index 000000000..f2efc1869 --- /dev/null +++ b/dist/main/atom/tooltips/tooltipView.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tooltipView.js","sourceRoot":"","sources":["../../../../lib/main/atom/tooltips/tooltipView.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAU5B,MAAa,WAAW;IAItB;QACE,IAAI,CAAC,KAAK,GAAG;YACX,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,CAAC;YACR,GAAG,EAAE,CAAC;YACN,MAAM,EAAE,CAAC;SACV,CAAA;QACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAEM,KAAK,CAAC,MAAM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I,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,KAAK,IAAI,CAAA;QAC5D,IAAI,UAAU;YAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,UAAU,CAAA;IAC5D,CAAC;IAEM,MAAM;QACX,OAAO,CACL,kBAAK,KAAK,EAAC,iCAAiC;YAC1C,kBAAK,KAAK,EAAC,eAAe,IAAE,IAAI,CAAC,eAAe,EAAE,CAAO,CACrD,CACP,CAAA;IACH,CAAC;IAEO,eAAe;QACrB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI;YAAE,OAAO,GAAG,CAAA;QAChC,MAAM,IAAI,GAAG,CACX,kBAAK,KAAK,EAAC,sCAAsC,IAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAO,CACxF,CAAA;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAC3C,kBAAK,KAAK,EAAC,qCAAqC,IAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAO,CACvF,CAAC,CAAC,CAAC,IAAI,CAAA;QACR,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACrB,CAAC;CACF;AA3ED,kCA2EC"} \ No newline at end of file diff --git a/dist/main/atom/tooltips/util.js b/dist/main/atom/tooltips/util.js new file mode 100644 index 000000000..cac843fa4 --- /dev/null +++ b/dist/main/atom/tooltips/util.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// screen position from mouse event -- with <3 from Atom-Haskell +function bufferPositionFromMouseEvent(editor, event) { + const sp = atom.views + .getView(editor) + .getComponent() + .screenPositionForMouseEvent(event); + if (isNaN(sp.row) || isNaN(sp.column)) { + return; + } + return editor.bufferPositionForScreenPosition(sp); +} +exports.bufferPositionFromMouseEvent = bufferPositionFromMouseEvent; +//# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/dist/main/atom/tooltips/util.js.map b/dist/main/atom/tooltips/util.js.map new file mode 100644 index 000000000..e3009330f --- /dev/null +++ b/dist/main/atom/tooltips/util.js.map @@ -0,0 +1 @@ +{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../../lib/main/atom/tooltips/util.ts"],"names":[],"mappings":";;AAEA,gEAAgE;AAChE,SAAgB,4BAA4B,CAC1C,MAAkB,EAClB,KAAyC;IAEzC,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK;SAClB,OAAO,CAAC,MAAM,CAAC;SACf,YAAY,EAAE;SACd,2BAA2B,CAAC,KAAK,CAAC,CAAA;IACrC,IAAI,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE;QACrC,OAAM;KACP;IACD,OAAO,MAAM,CAAC,+BAA+B,CAAC,EAAE,CAAC,CAAA;AACnD,CAAC;AAZD,oEAYC"} \ No newline at end of file diff --git a/dist/main/atom/utils/atom.js b/dist/main/atom/utils/atom.js index a4a25009d..77a7c5779 100644 --- a/dist/main/atom/utils/atom.js +++ b/dist/main/atom/utils/atom.js @@ -1,6 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const path = require("path"); +const ts_1 = require("./ts"); // Return line/offset position in the editor using 1-indexed coordinates function getEditorPosition(editor) { const pos = editor.getCursorBufferPosition(); @@ -16,7 +17,11 @@ function isTypescriptFile(filePath) { } exports.isTypescriptFile = isTypescriptFile; function typeScriptScopes() { - return ["source.ts", "source.tsx", "typescript"]; + const tsScopes = atom.config.get("atom-typescript").tsSyntaxScopes; + if (atom.config.get("atom-typescript").allowJS) { + tsScopes.push(...atom.config.get("atom-typescript").jsSyntaxScopes); + } + return tsScopes; } exports.typeScriptScopes = typeScriptScopes; function isTypescriptEditorWithPath(editor) { @@ -29,13 +34,25 @@ function isTypescriptGrammar(editor) { } exports.isTypescriptGrammar = isTypescriptGrammar; function isAllowedExtension(ext) { - return [".ts", ".tst", ".tsx"].includes(ext); + const tsExts = atom.config.get("atom-typescript").tsFileExtensions; + if (atom.config.get("atom-typescript").allowJS) { + tsExts.push(...atom.config.get("atom-typescript").jsFileExtensions); + } + return tsExts.includes(ext); } -function getFilePathPosition(editor) { +function getFilePathPosition(editor, position) { const file = editor.getPath(); if (file !== undefined) { - return Object.assign({ file }, getEditorPosition(editor)); + const location = position ? ts_1.pointToLocation(position) : getEditorPosition(editor); + return Object.assign({ file }, location); } } exports.getFilePathPosition = getFilePathPosition; +function* getOpenEditorsPaths() { + for (const ed of atom.workspace.getTextEditors()) { + if (isTypescriptEditorWithPath(ed)) + yield ed.getPath(); + } +} +exports.getOpenEditorsPaths = getOpenEditorsPaths; //# sourceMappingURL=atom.js.map \ No newline at end of file diff --git a/dist/main/atom/utils/atom.js.map b/dist/main/atom/utils/atom.js.map index 038206c4f..8f6519142 100644 --- a/dist/main/atom/utils/atom.js.map +++ b/dist/main/atom/utils/atom.js.map @@ -1 +1 @@ -{"version":3,"file":"atom.js","sourceRoot":"","sources":["../../../../lib/main/atom/utils/atom.ts"],"names":[],"mappings":";;AACA,6BAA4B;AAG5B,wEAAwE;AACxE,SAAS,iBAAiB,CAAC,MAAuB;IAChD,MAAM,GAAG,GAAG,MAAM,CAAC,uBAAuB,EAAE,CAAA;IAC5C,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;QACjB,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC;KACvB,CAAA;AACH,CAAC;AAED,SAAgB,gBAAgB,CAAC,QAA4B;IAC3D,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IACxC,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAA;AACnD,CAAC;AAHD,4CAGC;AAED,SAAgB,gBAAgB;IAC9B,OAAO,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;AAClD,CAAC;A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AG,MAAM,CAAC,OAAO,EAAE,CAAA;IAC7B,IAAI,IAAI,KAAK,SAAS,EAAE;QACtB,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,oBAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;QACjF,uBAAQ,IAAI,IAAK,QAAQ,EAAC;KAC3B;AACH,CAAC;AATD,kDASC;AAED,QAAe,CAAC,CAAC,mBAAmB;IAClC,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,EAAE;QAChD,IAAI,0BAA0B,CAAC,EAAE,CAAC;YAAE,MAAM,EAAE,CAAC,OAAO,EAAG,CAAA;KACxD;AACH,CAAC;AAJD,kDAIC"} \ No newline at end of file diff --git a/dist/main/atom/utils/ts.js b/dist/main/atom/utils/ts.js index 02d32b985..89f9e633a 100644 --- a/dist/main/atom/utils/ts.js +++ b/dist/main/atom/utils/ts.js @@ -27,35 +27,34 @@ function rangeToLocationRange(range) { }; } exports.rangeToLocationRange = rangeToLocationRange; -// Compare loc2 with loc1. The result is -1 if loc1 is smaller and 1 if it's larger. -function compareLocation(loc1, loc2) { - if (loc1.line < loc2.line) { - return -1; - } - else if (loc1.line > loc2.line) { - return 1; - } - else { - if (loc1.offset < loc2.offset) { - return -1; - } - else if (loc1.offset > loc2.offset) { - return 1; - } - else { - return 0; - } - } -} -exports.compareLocation = compareLocation; -function isLocationInRange(loc, range) { - return compareLocation(range.start, loc) !== 1 && compareLocation(range.end, loc) !== -1; -} -exports.isLocationInRange = isLocationInRange; -async function getProjectCodeSettings(configFile) { +async function getProjectConfig(configFile) { const { config } = await tsconfig.load(configFile); const options = config.formatCodeOptions; - return Object.assign({ indentSize: atom.config.get("editor.tabLength"), tabSize: atom.config.get("editor.tabLength") }, options); + return { + formatCodeOptions: Object.assign({ indentSize: atom.config.get("editor.tabLength"), tabSize: atom.config.get("editor.tabLength") }, options), + compileOnSave: !!config.compileOnSave, + }; +} +exports.getProjectConfig = getProjectConfig; +function signatureHelpItemToSignature(i) { + return { + label: partsToStr(i.prefixDisplayParts) + + i.parameters.map(x => partsToStr(x.displayParts)).join(partsToStr(i.separatorDisplayParts)) + + partsToStr(i.suffixDisplayParts), + documentation: partsToStr(i.documentation), + parameters: i.parameters.map(signatureHelpParameterToSignatureParameter), + }; +} +exports.signatureHelpItemToSignature = signatureHelpItemToSignature; +function signatureHelpParameterToSignatureParameter(p) { + return { + label: partsToStr(p.displayParts), + documentation: partsToStr(p.documentation), + }; +} +exports.signatureHelpParameterToSignatureParameter = signatureHelpParameterToSignatureParameter; +function partsToStr(x) { + return x.map(i => i.text).join(""); } -exports.getProjectCodeSettings = getProjectCodeSettings; +exports.partsToStr = partsToStr; //# sourceMappingURL=ts.js.map \ No newline at end of file diff --git a/dist/main/atom/utils/ts.js.map b/dist/main/atom/utils/ts.js.map index a3baa4d83..b7895a2a5 100644 --- a/dist/main/atom/utils/ts.js.map +++ b/dist/main/atom/utils/ts.js.map @@ -1 +1 @@ -{"version":3,"file":"ts.js","sourceRoot":"","sources":["../../../../lib/main/atom/utils/ts.ts"],"names":[],"mappings":";;AACA,6BAA4B;AAC5B,qCAAoC;AAapC,SAAgB,eAAe,CAAC,KAAqB;IACnD,OAAO,EAAC,IAAI,EAAE,KAAK,CAAC,GAAG,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,EAAC,CAAA;AACxD,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe,CAAC,GAAa;IAC3C,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AACrD,CAAC;AAFD,0CAEC;AAED,SAAgB,WAAW,CAAC,IAAc;IACxC,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC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AAU,CAAC,CAAC,CAAC,YAAY,CAAC;QACjC,aAAa,EAAE,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC;KAC3C,CAAA;AACH,CAAC;AAPD,gGAOC;AAED,SAAgB,UAAU,CAAC,CAAwB;IACjD,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACpC,CAAC;AAFD,gCAEC"} \ No newline at end of file diff --git a/dist/main/atom/views/highlightComponent.js.map b/dist/main/atom/views/highlightComponent.js.map index 5f49b063e..65e50a04d 100644 --- a/dist/main/atom/views/highlightComponent.js.map +++ b/dist/main/atom/views/highlightComponent.js.map @@ -1 +1 @@ -{"version":3,"file":"highlightComponent.js","sourceRoot":"","sources":["../../../../lib/main/atom/views/highlightComponent.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,2CAAgC;AAYhC,MAAa,kBAAkB;IAE7B,YAAmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB;QACvC,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAEM,MAAM;QACX,OAAO,CACL,uBACG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,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,SAAS,GAAG,UAAU,GAAG,CAAC,CAAA;KAC3B;IAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,YAAY,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAC,CAAC,CAAA;KAC1E;IAED,sCAAsC;IACtC,YAAY,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAC,CAAC,CAAA;IAEpD,OAAO,YAAY,CAAA;AACrB,CAAC;AA/BD,4CA+BC"} \ No newline at end of file +{"version":3,"file":"highlightComponent.js","sourceRoot":"","sources":["../../../../lib/main/atom/views/highlightComponent.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,2CAAgC;AAYhC,MAAa,kBAAkB;IAE7B,YAAmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB;QACvC,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAEM,MAAM;QACX,OAAO,CACL,uBACG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CACrB,mBAAM,KAAK,EAAE,CAAC,CAAC,IAAI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CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,YAAY,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAC,CAAC,CAAA;KAC1E;IAED,sCAAsC;IACtC,YAAY,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAC,CAAC,CAAA;IAEpD,OAAO,YAAY,CAAA;AACrB,CAAC;AA/BD,4CA+BC"} \ No newline at end of file diff --git a/dist/main/atom/views/outline/navTreeUtils.js b/dist/main/atom/views/outline/navTreeUtils.js index 65ab13508..66484935e 100644 --- a/dist/main/atom/views/outline/navTreeUtils.js +++ b/dist/main/atom/views/outline/navTreeUtils.js @@ -53,7 +53,6 @@ exports.findNodeAt = findNodeAt; * @return the start line for the NavTree node, or 0, if none could be determined */ function getNodeStartLine(node) { - // console.log('getNodeStartLine.node -> ', node) return node.spans.length > 0 ? node.spans[0].start.line - 1 : 0; } exports.getNodeStartLine = getNodeStartLine; @@ -63,7 +62,6 @@ exports.getNodeStartLine = getNodeStartLine; * @return the start column for the NavTree node, or 0, if none could be determined */ function getNodeStartOffset(node) { - // console.log('getNodeStartLine.node -> ', node) return node.spans.length > 0 ? node.spans[0].start.offset - 1 : 0; } exports.getNodeStartOffset = getNodeStartOffset; diff --git a/dist/main/atom/views/outline/navTreeUtils.js.map b/dist/main/atom/views/outline/navTreeUtils.js.map index 2b7369240..808de8a8f 100644 --- a/dist/main/atom/views/outline/navTreeUtils.js.map +++ b/dist/main/atom/views/outline/navTreeUtils.js.map @@ -1 +1 @@ -{"version":3,"file":"navTreeUtils.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/navTreeUtils.ts"],"names":[],"mappings":";;AAEA,mCAA8B;AAE9B;;;;;;;;;;;GAWG;AACH,SAAgB,UAAU,CACxB,SAAiB,EACjB,OAAe,EACf,IAA6B;IAE7B,IAAI,CAA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AC,CAAC,CAAA;QAE5E,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,UAAU,EAAE;YACtC,cAAc,CAAC,KAAK,CAAC,CAAA;SACtB;KACF;AACH,CAAC;AAlBD,wCAkBC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,IAA6B,EAAE,GAAW;IACnE,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE;QAChE,MAAM,KAAK,GAAW,gBAAgB,CAAC,IAAI,CAAC,CAAA;QAC5C,MAAM,GAAG,GAAW,cAAc,CAAC,IAAI,CAAC,CAAA;QACxC,IAAI,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;YAChC,6DAA6D;YAC7D,OAAO,KAAK,CAAA;SACb;QACD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAXD,gCAWC;AAED;;;GAGG;AACH,SAAgB,UAAU,CAAC,EAA2B,EAAE,EAA2B;IACjF,OAAO,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,IAAI,gBAAO,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAA;AAC3D,CAAC;AAFD,gCAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,aAAa,CAAC,IAA6B,EAAE,KAAiB;IAC5E,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,aAAa,CAAA;AAClE,CAAC;AAFD,sCAEC"} \ No newline at end of file +{"version":3,"file":"navTreeUtils.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/navTreeUtils.ts"],"names":[],"mappings":";;AAAA,mCAA8B;AAI9B;;;;;;;;;;;GAWG;AACH,SAAgB,UAAU,CACxB,SAAiB,EACjB,OAAe,EACf,IAA6B;IAE7B,IAAI,CAAC,IA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,KAAK,IAAI,OAAO,CAAC,UAAU,EAAE;YACtC,cAAc,CAAC,KAAK,CAAC,CAAA;SACtB;KACF;AACH,CAAC;AAlBD,wCAkBC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,IAA6B,EAAE,GAAW;IACnE,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE;QAChE,MAAM,KAAK,GAAW,gBAAgB,CAAC,IAAI,CAAC,CAAA;QAC5C,MAAM,GAAG,GAAW,cAAc,CAAC,IAAI,CAAC,CAAA;QACxC,IAAI,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE;YAChC,6DAA6D;YAC7D,OAAO,KAAK,CAAA;SACb;QACD,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAXD,gCAWC;AAED;;;GAGG;AACH,SAAgB,UAAU,CAAC,EAA2B,EAAE,EAA2B;IACjF,OAAO,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,IAAI,gBAAO,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAA;AAC3D,CAAC;AAFD,gCAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,aAAa,CAAC,IAA6B,EAAE,KAAiB;IAC5E,OAAO,CAAC,CAAC,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,aAAa,CAAA;AAClE,CAAC;AAFD,sCAEC"} \ No newline at end of file diff --git a/dist/main/atom/views/outline/navigationNodeComponent.js b/dist/main/atom/views/outline/navigationNodeComponent.js index 4c5e518ab..f7868194d 100644 --- a/dist/main/atom/views/outline/navigationNodeComponent.js +++ b/dist/main/atom/views/outline/navigationNodeComponent.js @@ -1,6 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const etch = require("etch"); +const utils_1 = require("../../../../utils"); const navTreeUtils_1 = require("./navTreeUtils"); class NavigationNodeComponent { constructor(props) { @@ -53,7 +54,7 @@ class NavigationNodeComponent { } else { node.collapsed = !node.collapsed; - etch.update(this); + utils_1.handlePromise(etch.update(this)); } } } diff --git a/dist/main/atom/views/outline/navigationNodeComponent.js.map b/dist/main/atom/views/outline/navigationNodeComponent.js.map index 8e385fa35..ec28ec981 100644 --- a/dist/main/atom/views/outline/navigationNodeComponent.js.map +++ b/dist/main/atom/views/outline/navigationNodeComponent.js.map @@ -1 +1 @@ -{"version":3,"file":"navigationNodeComponent.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/navigationNodeComponent.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAE5B,iDAAwD;AAOxD,MAAa,uBAAuB;IAClC,YAAmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB;QACvC,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAEM,MAAM;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAA;QAC/B,MAAM,EAAC,IAAI,EAAC,GAAG,IAAI,CAAC,KAAK,CAAA;QACzB,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAA;QAC3C,MAAM,QAAQ,GAAG,YAAY,IAAI,yBAAU,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;QAC/D,MAAM,OAAO,GACX,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC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C;IAEO,YAAY,CAAC,KAAiB,EAAE,IAA6B;QACnE,KAAK,CAAC,eAAe,EAAE,CAAA;QAEvB,MAAM,QAAQ,GAAY,4BAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACpD,IAAI,CAAC,QAAQ,EAAE;YACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;SAC/B;aAAM;YACL,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,SAAS,CAAA;YAChC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;SAClB;IACH,CAAC;CACF;AAlED,0DAkEC"} \ No newline at end of file +{"version":3,"file":"navigationNodeComponent.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/navigationNodeComponent.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,6CAA+C;AAC/C,iDAAwD;AAQxD,MAAa,uBAAuB;IAClC,YAAmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB;QACvC,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAEM,MAAM;QACX,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAA;QAC/B,MAAM,EAAC,IAAI,EAAC,GAAG,IAAI,CAAC,KAAK,CAAA;QACzB,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAA;QAC3C,MAAM,QAAQ,GAAG,YAAY,IAAI,yBAAU,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;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C,IAAI,EAAE,EAAE,CAAC;yBAC9C,IAAI,CAAC,GAAG,CAAC,CAAA;SACf;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,YAAY,CAAC,KAAiB,EAAE,IAA6B;QACnE,KAAK,CAAC,eAAe,EAAE,CAAA;QAEvB,MAAM,QAAQ,GAAY,4BAAa,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QACpD,IAAI,CAAC,QAAQ,EAAE;YACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;SAC/B;aAAM;YACL,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,CAAC,SAAS,CAAA;YAChC,qBAAa,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;SACjC;IACH,CAAC;CACF;AAlED,0DAkEC"} \ No newline at end of file diff --git a/dist/main/atom/views/outline/navigationTreeComponent.js b/dist/main/atom/views/outline/navigationTreeComponent.js index eb85b01a3..25b442d1a 100644 --- a/dist/main/atom/views/outline/navigationTreeComponent.js +++ b/dist/main/atom/views/outline/navigationTreeComponent.js @@ -1,29 +1,32 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const atomUtils = require("../../utils"); +const atom_1 = require("atom"); const etch = require("etch"); const lodash_1 = require("lodash"); +const utils_1 = require("../../../../utils"); +const atomUtils = require("../../utils"); const navigationNodeComponent_1 = require("./navigationNodeComponent"); const navTreeUtils_1 = require("./navTreeUtils"); class NavigationTreeComponent { constructor(props) { this.props = props; + this.subscriptions = new atom_1.CompositeDisposable(); this.loadNavTree = async () => { if (!this.editor) return; - if (!this.withTypescriptBuffer) + if (!this.getClient) return; const filePath = this.editor.getPath(); if (filePath === undefined) return; try { - return await this.withTypescriptBuffer(filePath, async (buffer) => { - const navTree = await buffer.getNavTree(); - if (navTree) { - this.setNavTree(navTree); - await etch.update(this); - } - }); + const client = await this.getClient(filePath); + const navtreeResult = await client.execute("navtree", { file: filePath }); + const navTree = navtreeResult.body; + if (navTree) { + this.setNavTree(navTree); + await etch.update(this); + } } catch (err) { console.error(err, filePath); @@ -41,38 +44,27 @@ class NavigationTreeComponent { const selectedChild = navTreeUtils_1.findNodeAt(cursorLine, cursorLine, this.props.navTree); if (selectedChild !== this.selectedNode) { this.selectedNode = selectedChild; - etch.update(this); + utils_1.handlePromise(etch.update(this)); } }; - this.subscribeToEditor = (editor) => { + this.subscribeToEditor = async (editor) => { + if (this.editorScrolling) + this.editorScrolling.dispose(); + if (this.editorChanging) + this.editorChanging.dispose(); if (!editor || !atomUtils.isTypescriptEditorWithPath(editor)) { - // unsubscribe from editor - // dispose subscriptions (except for editor-changing) - if (this.editorScrolling) { - this.editorScrolling.dispose(); - } - if (this.editorChanging) { - this.editorChanging.dispose(); - } - this.update({ navTree: null }); - return; + return this.update({ navTree: null }); } + // else this.editor = editor; // set navTree - this.loadNavTree(); - // Subscribe to stop scrolling - if (this.editorScrolling) { - this.editorScrolling.dispose(); - } + await this.loadNavTree(); this.editorScrolling = editor.onDidChangeCursorPosition(this.selectAtCursorLine); - if (this.editorChanging) { - this.editorChanging.dispose(); - } this.editorChanging = editor.onDidStopChanging(this.loadNavTree); }; navTreeUtils_1.prepareNavTree(props.navTree); etch.initialize(this); - atom.workspace.observeActiveTextEditor(this.subscribeToEditor); + this.subscriptions.add(atom.workspace.observeActiveTextEditor(this.subscribeToEditor)); } async update(props) { if (props.navTree !== undefined) { @@ -82,18 +74,19 @@ class NavigationTreeComponent { await etch.update(this); } async destroy() { - if (this.editorScrolling) { + if (this.editorScrolling) this.editorScrolling.dispose(); - } - if (this.editorChanging) { + if (this.editorChanging) this.editorChanging.dispose(); - } + this.editorScrolling = undefined; + this.editorChanging = undefined; this.selectedNode = undefined; + this.subscriptions.dispose(); await etch.destroy(this); } - setWithTypescriptBuffer(wtb) { - this.withTypescriptBuffer = wtb; - this.loadNavTree(); + async setGetClient(getClient) { + this.getClient = getClient; + await this.loadNavTree(); } getSelectedNode() { return this.selectedNode; @@ -129,7 +122,7 @@ class NavigationTreeComponent { else return undefined; } - async setNavTree(navTree) { + setNavTree(navTree) { navTreeUtils_1.prepareNavTree(navTree); if (lodash_1.isEqual(navTree, this.props.navTree)) { return; diff --git a/dist/main/atom/views/outline/navigationTreeComponent.js.map b/dist/main/atom/views/outline/navigationTreeComponent.js.map index ef8bd7434..f8cbb4037 100644 --- a/dist/main/atom/views/outline/navigationTreeComponent.js.map +++ b/dist/main/atom/views/outline/navigationTreeComponent.js.map @@ -1 +1 @@ -{"version":3,"file":"navigationTreeComponent.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/navigationTreeComponent.tsx"],"names":[],"mappings":";;AAAA,yCAAyC;AAEzC,6BAA4B;AAC5B,mCAA8B;AAG9B,uEAAiE;AACjE,iDAMuB;AAOvB,MAAa,uBAAuB;IASlC,YAAmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAwFvB,gBAAW,GAAG,KAAK,IAAI,EAAE;YAC/B,IAAI,CAAC,IAAI,CAAC,MAAM;gBAAE,OAAM;YACxB,IAAI,CAAC,IAAI,CAAC,oBAAoB;gBAAE,OAAM;YACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;YACtC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAM;YAClC,IAAI;gBACF,OAAO,MAAM,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,EAAC,EAAE;oBAC9D,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAA;oBACzC,IAAI,OAAO,EAAE;wBACX,IAAI,CAAC,UAAU,CAAC,OAAkC,CAAC,CAAA;wBACnD,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;qBACxB;gBACH,CAAC,CAAC,CAAA;aACH;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,CAAC,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,IAAI,YAAiD,CAAA;QACrD,IAAI,OAAO,EAAE;YACX,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;YACvC,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC5B,YAAY,GAAG,yBAAU,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;aAC3D;SACF;QACD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAqCD;;;;OAIG;IACK,QAAQ,CAAC,OAAgB;QAC/B,MAAM,IAAI,GAAe,OAAqB,CAAA;QAC9C,IAAI,OAAO,IAAI,CAAC,sBAAsB,KAAK,UAAU,EAAE;YACrD,IAAI,CAAC,sBAAsB,EAAE,CAAA;SAC9B;aAAM;YACL,IAAI,CAAC,cAAc,EAAE,CAAA;SACtB;IACH,CAAC;CAgCF;AAhLD,0DAgLC"} \ No newline at end of file +{"version":3,"file":"navigationTreeComponent.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/navigationTreeComponent.tsx"],"names":[],"mappings":";;AAAA,+BAA4F;AAC5F,6BAA4B;AAC5B,mCAA8B;AAG9B,6CAA+C;AAC/C,yCAAyC;AACzC,uEAAiE;AACjE,iDAMuB;AAOvB,MAAa,uBAAuB;IAUlC,YAAmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAFvB,kBAAa,GAAG,IAAI,0BAAmB,EAAE,CAAA;QAyFzC,gBAAW,GAAG,KAAK,IAAI,EAAE;YAC/B,IAAI,CAAC,IAAI,CAAC,MAAM;gBAAE,OAAM;YACxB,IAAI,CAAC,IAAI,CAAC,SAAS;gBAAE,OAAM;YAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;YACtC,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAM;YAClC,IAAI;gBACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;gBAC7C,MAAM,aAAa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AEO,UAAU,CAAC,OAAuC;QACxD,6BAAc,CAAC,OAAO,CAAC,CAAA;QACvB,IAAI,gBAAO,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;YACxC,OAAM;SACP;QACD,+BAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC7C,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAA;QAE5B,IAAI,YAAiD,CAAA;QACrD,IAAI,OAAO,EAAE;YACX,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;YACvC,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC5B,YAAY,GAAG,yBAAU,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;aAC3D;SACF;QACD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAqCD;;;;OAIG;IACK,QAAQ,CAAC,OAAgB;QAC/B,MAAM,IAAI,GAAe,OAAqB,CAAA;QAC9C,IAAI,OAAO,IAAI,CAAC,sBAAsB,KAAK,UAAU,EAAE;YACrD,IAAI,CAAC,sBAAsB,EAAE,CAAA;SAC9B;aAAM;YACL,IAAI,CAAC,cAAc,EAAE,CAAA;SACtB;IACH,CAAC;CAiBF;AAjKD,0DAiKC"} \ No newline at end of file diff --git a/dist/main/atom/views/outline/semanticView.js b/dist/main/atom/views/outline/semanticView.js index ef0888e78..c8fbe973c 100644 --- a/dist/main/atom/views/outline/semanticView.js +++ b/dist/main/atom/views/outline/semanticView.js @@ -2,10 +2,6 @@ Object.defineProperty(exports, "__esModule", { value: true }); const navigationTreeComponent_1 = require("./navigationTreeComponent"); exports.SEMANTIC_VIEW_URI = "atom-typescript://semantic-view"; -function deserializeSemanticView(serialized) { - return SemanticView.create(serialized.data); -} -exports.deserializeSemanticView = deserializeSemanticView; class SemanticView { constructor(config) { this.comp = new navigationTreeComponent_1.NavigationTreeComponent({ navTree: config.navTree }); @@ -18,9 +14,9 @@ class SemanticView { get element() { return this.comp.element; } - setWithTypescriptBuffer(wtb) { - this.comp.setWithTypescriptBuffer(wtb); - this.comp.update({}); + async setGetClient(gc) { + await this.comp.setGetClient(gc); + await this.comp.update({}); } getTitle() { return "TypeScript"; @@ -28,9 +24,9 @@ class SemanticView { getURI() { return exports.SEMANTIC_VIEW_URI; } - destroy() { + async destroy() { SemanticView.instance = null; - this.comp.destroy(); + await this.comp.destroy(); } getDefaultLocation() { return "right"; @@ -40,7 +36,6 @@ class SemanticView { return ["left", "right"]; } serialize() { - // console.log("SemanticView.serialize()") // DEBUG return { deserializer: "atomts-semantic-view/SemanticView", data: { navTree: this.comp.props.navTree }, diff --git a/dist/main/atom/views/outline/semanticView.js.map b/dist/main/atom/views/outline/semanticView.js.map index d2c9ff8e7..f020d2b8d 100644 --- a/dist/main/atom/views/outline/semanticView.js.map +++ b/dist/main/atom/views/outline/semanticView.js.map @@ -1 +1 @@ -{"version":3,"file":"semanticView.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/semanticView.ts"],"names":[],"mappings":";;AAAA,uEAAiE;AAIpD,QAAA,iBAAiB,GAAG,iCAAiC,CAAA;AAWlE,SAAgB,uBAAuB,CAAC,UAAyC;IAC/E,OAAO,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AAC7C,CAAC;AAFD,0DAEC;AAED,MAAa,YAAY;IAYvB,YAAoB,MAA2B;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,iDAAuB,CAAC,EAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IACpE,CAAC;IAbM,MAAM,CAAC,MAAM,CAAC,MAA2B;QAC9C,IAAI,CAAC,YAAY,CAAC,QAAQ;YAAE,YAAY,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;QAC5E,OAAO,YAAY,CAAC,QAAQ,CAAA;IAC9B,CAAC;IAID,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAA;IAC1B,CAAC;IAMM,uBAAuB,CAAC,GAAyB;QACtD,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAA;QACtC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACtB,CAAC;IAEM,QAAQ;QACb,OAAO,YAAY,CAAA;IACrB,CAAC;IAEM,MAAM;QACX,OAAO,yBAAiB,CAAA;IAC1B,CAAC;IAEM,OAAO;QACZ,YAAY,CAAC,QAAQ,GAAG,IAAI,CAAA;QAC5B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;IACrB,CAAC;IAEM,kBAAkB;QACvB,OAAO,OAAO,CAAA;IAChB,CAAC;IAEM,mBAAmB;QACxB,kDAAkD;QAClD,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC1B,CAAC;IAEM,SAAS;QACd,mDAAmD;QACnD,OAAO;YACL,YAAY,EAAE,mCAAmC;YACjD,IAAI,EAAE,EAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAC;SACzC,CAAA;IACH,CAAC;;AA5Cc,qBAAQ,GAAwB,IAAI,CAAA;AALrD,oCAkDC"} \ No newline at end of file +{"version":3,"file":"semanticView.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/semanticView.ts"],"names":[],"mappings":";;AACA,uEAAiE;AAGpD,QAAA,iBAAiB,GAAG,iCAAiC,CAAA;AAWlE,MAAa,YAAY;IAYvB,YAAoB,MAA2B;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,iDAAuB,CAAC,EAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAC,CAAC,CAAA;IACpE,CAAC;IAbM,MAAM,CAAC,MAAM,CAAC,MAA2B;QAC9C,IAAI,CAAC,YAAY,CAAC,QAAQ;YAAE,YAAY,CAAC,QAAQ,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAA;QAC5E,OAAO,YAAY,CAAC,QAAQ,CAAA;IAC9B,CAAC;IAID,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAA;IAC1B,CAAC;IAMM,KAAK,CAAC,YAAY,CAAC,EAAqB;QAC7C,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;QAChC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC5B,CAAC;IAEM,QAAQ;QACb,OAAO,YAAY,CAAA;IACrB,CAAC;IAEM,MAAM;QACX,OAAO,yBAAiB,CAAA;IAC1B,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,YAAY,CAAC,QAAQ,GAAG,IAAI,CAAA;QAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;IAC3B,CAAC;IAEM,kBAAkB;QACvB,OAAO,OAAO,CAAA;IAChB,CAAC;IAEM,mBAAmB;QACxB,kDAAkD;QAClD,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC1B,CAAC;IAEM,SAAS;QACd,OAAO;YACL,YAAY,EAAE,mCAAmC;YACjD,IAAI,EAAE,EAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAC;SACzC,CAAA;IACH,CAAC;;AA3Cc,qBAAQ,GAAwB,IAAI,CAAA;AALrD,oCAiDC"} \ No newline at end of file diff --git a/dist/main/atom/views/outline/semanticViewController.js b/dist/main/atom/views/outline/semanticViewController.js index 2a96fd4db..1fef2b3a0 100644 --- a/dist/main/atom/views/outline/semanticViewController.js +++ b/dist/main/atom/views/outline/semanticViewController.js @@ -1,25 +1,26 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const atom_1 = require("atom"); -const semanticView_1 = require("./semanticView"); const atom_2 = require("atom"); +const utils_1 = require("../../../../utils"); +const semanticView_1 = require("./semanticView"); class SemanticViewController { - constructor(withTypescriptBuffer) { - this.withTypescriptBuffer = withTypescriptBuffer; + constructor(getClient) { + this.getClient = getClient; this.subscriptions = new atom_1.CompositeDisposable(); const pane = atom.workspace.paneForURI(semanticView_1.SEMANTIC_VIEW_URI); if (pane) this.view = pane.itemForURI(semanticView_1.SEMANTIC_VIEW_URI); if (this.view) - this.view.setWithTypescriptBuffer(this.withTypescriptBuffer); + utils_1.handlePromise(this.view.setGetClient(this.getClient)); this.subscriptions.add(new atom_2.Disposable(() => { if (this.view) { atom.workspace.hide(this.view); - this.view.destroy(); + utils_1.handlePromise(this.view.destroy()); } }), atom.config.observe("atom-typescript.showSemanticView", val => { if (val) - this.show(); + utils_1.handlePromise(this.show()); else this.hide(); })); @@ -36,7 +37,7 @@ class SemanticViewController { async show() { if (!this.view) { this.view = semanticView_1.SemanticView.create({ navTree: null }); - this.view.setWithTypescriptBuffer(this.withTypescriptBuffer); + await this.view.setGetClient(this.getClient); } await atom.workspace.open(this.view, { searchAllPanes: true }); } diff --git a/dist/main/atom/views/outline/semanticViewController.js.map b/dist/main/atom/views/outline/semanticViewController.js.map index 2e5e5a0b8..d5b80f954 100644 --- a/dist/main/atom/views/outline/semanticViewController.js.map +++ b/dist/main/atom/views/outline/semanticViewController.js.map @@ -1 +1 @@ -{"version":3,"file":"semanticViewController.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/semanticViewController.ts"],"names":[],"mappings":";;AAAA,+BAAwC;AACxC,iDAA8D;AAC9D,+BAA+B;AAG/B,MAAa,sBAAsB;IAIjC,YAAoB,oBAA0C;QAA1C,yBAAoB,GAApB,oBAAoB,CAAsB;QAC5D,IAAI,CAAC,aAAa,GAAG,IAAI,0BAAmB,EAAE,CAAA;QAE9C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,gCAAiB,CAAC,CAAA;QACzD,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU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9D,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;;YACvB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC;CACF;AA/CD,wDA+CC"} \ No newline at end of file +{"version":3,"file":"semanticViewController.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/outline/semanticViewController.ts"],"names":[],"mappings":";;AAAA,+BAAwC;AACxC,+BAA+B;AAE/B,6CAA+C;AAC/C,iDAA8D;AAE9D,MAAa,sBAAsB;IAIjC,YAAoB,SAA4B;QAA5B,cAAS,GAAT,SAAS,CAAmB;QAC9C,IAAI,CAAC,aAAa,GAAG,IAAI,0BAAmB,EAAE,CAAA;QAE9C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,gCAAiB,CAAC,CAAA;QACzD,IAAI,IAAI;YAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,gCAAiB,CAA6B,CAAA;QACpF,IAAI,IAAI,CAAC,IAAI;YAAE,qBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;QAEpE,IAAI,CAAC,aAAa,CAAC,GAAG,CACpB,IAAI,iBAAU,CAAC,GAAG,EAAE;YAClB,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBAC9B,qBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;aACnC;QACH,CAAC,CAAC,EACF,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kCAAkC,EAAE,GAAG,CAAC,EAAE;YAC5D,IAAI,GAAG;gBAAE,qBAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;;gBAC9B,IAAI,CAAC,IAAI,EAAE,CAAA;QAClB,CAAC,CAAC,CACH,CAAA;IACH,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAA;IAC9B,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;;YAC5B,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC7C,CAAC;IAEO,KAAK,CAAC,IAAI;QAChB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,IAAI,CAAC,IAAI,GAAG,2BAAY,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAA;YAChD,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;SAC7C;QAED,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC,CAAA;IAC9D,CAAC;IAEO,IAAI;QACV,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;;YACvB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC;CACF;AA/CD,wDA+CC"} \ No newline at end of file diff --git a/dist/main/atom/views/renameView.js b/dist/main/atom/views/renameView.js index d4f0cbcb2..6b21cb245 100644 --- a/dist/main/atom/views/renameView.js +++ b/dist/main/atom/views/renameView.js @@ -1,7 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const etch = require("etch"); const atom_1 = require("atom"); +const etch = require("etch"); +const utils_1 = require("../../../utils"); const miniEditor_1 = require("../components/miniEditor"); class RenameView { constructor(props) { @@ -68,7 +69,7 @@ async function showRenameDialog(options) { const newText = item.getText(); const invalid = options.onValidate(newText); if (invalid) { - item.update({ validationMessage: invalid }); + utils_1.handlePromise(item.update({ validationMessage: invalid })); return; } resolve(newText); diff --git a/dist/main/atom/views/renameView.js.map b/dist/main/atom/views/renameView.js.map index 9a0e80ad8..427a74bbe 100644 --- a/dist/main/atom/views/renameView.js.map +++ b/dist/main/atom/views/renameView.js.map @@ -1 +1 @@ -{"version":3,"file":"renameView.js","sourceRoot":"","sources":["../../../../lib/main/atom/views/renameView.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,+BAAwC;AACxC,yDAAmD;AAgBnD,MAAM,UAAU;IAMd,YAAmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB;QACvC,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAEM,MAAM;QACX,OAAO,CACL,kBAAK,KAAK,EAAC,oBAAoB,EAAC,GAAG,EAAC,MAAM;YACxC,kBAAK,KAAK,EAAC,OAAO;gBAChB;oBACE,mBAAM,GAAG,EAAC,OAAO,IAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAQ;oBAC3C,mBAAM,KAAK,EAAC,qBAAqB;wBAC/B,gDAAmC;wBACnC,mBAAM,KAAK,EAAC,WAAW,UAAW;wBAClC,oDAAuC;wBACvC,mBAAM,KAAK,EAAC,WAAW,YAAa;wBACpC,+BAAkB,CACb,CACH;gBACN,kBAAK,KAAK,EAAC,sBAAsB;oBAC/B,kBAAK,KAAK,EAAC,kBAAkB;wBAC3B,SAAC,uBAAU,IACT,GAAG,EAAC,QAAQ,EACZ,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,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AE;gBAChC,aAAa,EAAE,GAAG,EAAE;oBAClB,OAAO,CAAC,SAAS,CAAC,CAAA;gBACpB,CAAC;gBACD,cAAc,EAAE,GAAG,EAAE;oBACnB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;oBAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;oBAC3C,IAAI,OAAO,EAAE;wBACX,IAAI,CAAC,MAAM,CAAC,EAAC,iBAAiB,EAAE,OAAO,EAAC,CAAC,CAAA;wBACzC,OAAM;qBACP;oBACD,OAAO,CAAC,OAAO,CAAC,CAAA;gBAClB,CAAC;aACF,CAAC,CACH,CAAA;QACH,CAAC,CAAC,CAAA;KACH;YAAS;QACR,KAAK,CAAC,OAAO,EAAE,CAAA;QACf,WAAW,CAAC,OAAO,EAAE,CAAA;QACrB,IAAI,YAAY;YAAE,YAAY,CAAC,KAAK,EAAE,CAAA;KACvC;AACH,CAAC;AAxCD,4CAwCC"} \ No newline at end of file +{"version":3,"file":"renameView.js","sourceRoot":"","sources":["../../../../lib/main/atom/views/renameView.tsx"],"names":[],"mappings":";;AAAA,+BAAwC;AACxC,6BAA4B;AAC5B,0CAA4C;AAC5C,yDAAmD;AAgBnD,MAAM,UAAU;IAMd,YAAmB,KAAY;QAAZ,UAAK,GAAL,KAAK,CAAO;QAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB;QACvC,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAEM,MAAM;QACX,OAAO,CACL,kBAAK,KAAK,EAAC,oBAAoB,EAAC,GAAG,EAAC,MAAM;YACxC,kBAAK,KAAK,EAAC,OAAO;gBAChB;oBACE,mBAAM,GAAG,EAAC,OAAO,IA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AAA;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;QACzC,IAAI;QACJ,QAAQ,EAAE,IAAI;KACf,CAAC,CAAA;IAEF,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAmC,CAAA;IAEjE,IAAI,CAAC,KAAK,EAAE,CAAA;IAEZ,MAAM,WAAW,GAAG,IAAI,0BAAmB,EAAE,CAAA;IAC7C,IAAI;QACF,OAAO,MAAM,IAAI,OAAO,CAAqB,OAAO,CAAC,EAAE;YACrD,WAAW,CAAC,GAAG,CACb,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;gBAChC,aAAa,EAAE,GAAG,EAAE;oBAClB,OAAO,CAAC,SAAS,CAAC,CAAA;gBACpB,CAAC;gBACD,cAAc,EAAE,GAAG,EAAE;oBACnB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;oBAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;oBAC3C,IAAI,OAAO,EAAE;wBACX,qBAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAC,iBAAiB,EAAE,OAAO,EAAC,CAAC,CAAC,CAAA;wBACxD,OAAM;qBACP;oBACD,OAAO,CAAC,OAAO,CAAC,CAAA;gBAClB,CAAC;aACF,CAAC,CACH,CAAA;QACH,CAAC,CAAC,CAAA;KACH;YAAS;QACR,KAAK,CAAC,OAAO,EAAE,CAAA;QACf,WAAW,CAAC,OAAO,EAAE,CAAA;QACrB,IAAI,YAAY;YAAE,YAAY,CAAC,KAAK,EAAE,CAAA;KACvC;AACH,CAAC;AAxCD,4CAwCC"} \ No newline at end of file diff --git a/dist/main/atom/views/simpleSelectionView.js b/dist/main/atom/views/simpleSelectionView.js index f1d0822cc..a2a58ae64 100644 --- a/dist/main/atom/views/simpleSelectionView.js +++ b/dist/main/atom/views/simpleSelectionView.js @@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const SelectListView = require("atom-select-list"); const etch = require("etch"); +const utils_1 = require("../../../utils"); async function selectListView({ items, itemTemplate, itemFilterKey, didChangeSelection, }) { let panel; const currentFocus = document.activeElement; @@ -14,7 +15,7 @@ async function selectListView({ items, itemTemplate, itemFilterKey, didChangeSel const update = (props) => { if (resolved) return; - select.update(props); + utils_1.handlePromise(select.update(props)); }; if (typeof items === "function") { didChangeQuery = async (query) => { @@ -49,9 +50,9 @@ async function selectListView({ items, itemTemplate, itemFilterKey, didChangeSel itemsClassList: ["atom-typescript"], }); if (typeof items !== "function") { - Promise.resolve(items).then(is => { + utils_1.handlePromise(Promise.resolve(items).then(is => { update({ items: is, loadingMessage: undefined }); - }); + })); } panel = atom.workspace.addModalPanel({ item: select, diff --git a/dist/main/atom/views/simpleSelectionView.js.map b/dist/main/atom/views/simpleSelectionView.js.map index ea06041dd..369d78d9d 100644 --- a/dist/main/atom/views/simpleSelectionView.js.map +++ b/dist/main/atom/views/simpleSelectionView.js.map @@ -1 +1 @@ -{"version":3,"file":"simpleSelectionView.js","sourceRoot":"","sources":["../../../../lib/main/atom/views/simpleSelectionView.tsx"],"names":[],"mappings":";;AAAA,mDAAmD;AAEnD,6BAA4B;AASrB,KAAK,UAAU,cAAc,CAAI,EACtC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,GACO;IACzB,IAAI,KAA2C,CAAA;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAmC,CAAA;IACjE,IAAI;QACF,OAAO,MAAM,IAAI,OAAO,CAAgB,OAAO,CAAC,EAAE;YAChD,IAAI,cAAc,CAAA;YAClB,IAAI,cAAc,GAAuB,YAAY,CAAA;YACrD,IAAI,YAAY,CAAA;YAChB,IAAI,QAAQ,GAAG,KAAK,CAAA;YACpB,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE;gBAC/B,IAAI,QAAQ;oBAAE,OAAM;gBACpB,MAAM,CAAC,MAAM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AO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;oBAC/B,MAAM,CAAC,EAAC,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,SAAS,EAAC,CAAC,CAAA;gBAChD,CAAC,CAAC,CAAA;aACH;YACD,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;gBACnC,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,IAAI;aACd,CAAC,CAAA;YACF,MAAM,CAAC,KAAK,EAAE,CAAA;QAChB,CAAC,CAAC,CAAA;KACH;YAAS;QACR,IAAI,KAAK;YAAE,KAAK,CAAC,OAAO,EAAE,CAAA;QAC1B,IAAI,YAAY;YAAE,YAAY,CAAC,KAAK,EAAE,CAAA;KACvC;AACH,CAAC;AAjED,wCAiEC"} \ No newline at end of file +{"version":3,"file":"simpleSelectionView.js","sourceRoot":"","sources":["../../../../lib/main/atom/views/simpleSelectionView.tsx"],"names":[],"mappings":";;AACA,mDAAmD;AACnD,6BAA4B;AAC5B,0CAA4C;AASrC,KAAK,UAAU,cAAc,CAAI,EACtC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,kBAAkB,GACO;IACzB,IAAI,KAA2C,CAAA;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAmC,CAAA;IACjE,IAAI;QACF,OAAO,MAAM,IAAI,OAAO,CAAgB,OAAO,CAAC,EAAE;YAChD,IAAI,cAAc,CAAA;YAClB,IAAI,cAAc,GAAuB,YAAY,CAAA;YACrD,IAAI,YAAY,CAAA;YAChB,IAAI,QAAQ,GAAG,KAAK,CAAA;YACpB,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE;gBAC/B,IAAI,QAAQ;oBAAE,OAAM;gBACpB,qBAAa,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;YACrC,CAAC,CAAA;YACD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;gBAC/B,cA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,CAAC,EAAC,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,SAAS,EAAC,CAAC,CAAA;gBAChD,CAAC,CAAC,CACH,CAAA;aACF;YACD,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC;gBACnC,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,IAAI;aACd,CAAC,CAAA;YACF,MAAM,CAAC,KAAK,EAAE,CAAA;QAChB,CAAC,CAAC,CAAA;KACH;YAAS;QACR,IAAI,KAAK;YAAE,KAAK,CAAC,OAAO,EAAE,CAAA;QAC1B,IAAI,YAAY;YAAE,YAAY,CAAC,KAAK,EAAE,CAAA;KACvC;AACH,CAAC;AAnED,wCAmEC"} \ No newline at end of file diff --git a/dist/main/atom/views/symbols/fileSymbolsView.js b/dist/main/atom/views/symbols/fileSymbolsView.js index 19051d579..84f497153 100644 --- a/dist/main/atom/views/symbols/fileSymbolsView.js +++ b/dist/main/atom/views/symbols/fileSymbolsView.js @@ -1,10 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const simpleSelectionView_1 = require("../simpleSelectionView"); const etch = require("etch"); +const highlightComponent_1 = require("../highlightComponent"); +const simpleSelectionView_1 = require("../simpleSelectionView"); const generator_1 = require("./generator"); const utils = require("./utils"); -const highlightComponent_1 = require("../highlightComponent"); async function toggle(editor, deps) { const filePath = editor.getPath(); if (filePath !== undefined) { @@ -28,7 +28,7 @@ async function toggle(editor, deps) { itemFilterKey: "name", }); if (tag) - utils.openTag(tag, editor, deps.getEditorPositionHistoryManager()); + await utils.openTag(tag, editor, deps.histGoForward); else if (initialState) utils.deserializeEditorState(editor, initialState); } diff --git a/dist/main/atom/views/symbols/fileSymbolsView.js.map b/dist/main/atom/views/symbols/fileSymbolsView.js.map index 1b7f173a1..9faec1892 100644 --- a/dist/main/atom/views/symbols/fileSymbolsView.js.map +++ b/dist/main/atom/views/symbols/fileSymbolsView.js.map @@ -1 +1 @@ -{"version":3,"file":"fileSymbolsView.js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AAE,IAAI,CAAC,+BAA+B,EAAE,CAAC,CAAA;aACtE,IAAI,YAAY;YAAE,KAAK,CAAC,sBAAsB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;KAC1E;AACH,CAAC;AA7BD,wBA6BC"} \ No newline at end of file +{"version":3,"file":"fileSymbolsView.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/symbols/fileSymbolsView.tsx"],"names":[],"mappings":";;AACA,6BAA4B;AAC5B,8DAAwD;AACxD,gEAAqD;AAErD,2CAAwC;AAExC,iCAAgC;AAEzB,KAAK,UAAU,MAAM,CAAC,MAAkB,EAAE,IAAU;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IACjC,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,qEAAqE;QACrE,IAAI,YAAY,CAAA;QAChB,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,EAAE;YACzD,YAAY,GAAG,KAAK,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAA;SAClD;QACD,MAAM,GAAG,GAAG,MAAM,oCAAc,CAAC;YAC/B,KAAK,EAAE,wBAAY,CAAC,QAAQ,EAAE,IAAI,CAAC;YACnC,YAAY,EAAE,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CACvC,iBAAI,KAAK,EAAC,WAAW;gBACnB,kBAAK,KAAK,EAAC,cAAc;oBACvB,SAAC,uCAAkB,IAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,cAAc,EAAE,GAAI,CAC5D;gBACN,kBAAK,KAAK,EAAC,gBAAgB,IAAE,QAAQ,QAAQ,CAAC,GAAG,GAAG,CAAC,EAAE,CAAO,CAC3D,CACN;YACD,kBAAkB,CAAC,IAAU;gBAC3B,qEAAqE;gBACrE,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,IAAI,IAAI,EAAE;oBACjE,MAAM,CAAC,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;iBAC9C;YACH,CAAC;YACD,aAAa,EAAE,MAAM;SACtB,CAAC,CAAA;QACF,IAAI,GAAG;YAAE,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;aACxD,IAAI,YAAY;YAAE,KAAK,CAAC,sBAAsB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;KAC1E;AACH,CAAC;AA7BD,wBA6BC"} \ No newline at end of file diff --git a/dist/main/atom/views/symbols/generator.js b/dist/main/atom/views/symbols/generator.js index 19c39b33a..4b53b394e 100644 --- a/dist/main/atom/views/symbols/generator.js +++ b/dist/main/atom/views/symbols/generator.js @@ -35,13 +35,28 @@ function* parseNavTo(navTree, parent) { } } async function getNavTree(filePath, deps) { - return deps.withTypescriptBuffer(filePath, buffer => { - return buffer.getNavTree(); - }); + try { + const client = await deps.getClient(filePath); + const navtreeResult = await client.execute("navtree", { file: filePath }); + return navtreeResult.body; + } + catch (e) { + console.error(filePath, e); + } } async function getNavTo(filePath, search, deps) { - return deps.withTypescriptBuffer(filePath, buffer => { - return buffer.getNavTo(search); - }); + try { + const client = await deps.getClient(filePath); + const navtoResult = await client.execute("navto", { + file: filePath, + currentFileOnly: false, + searchValue: search, + maxResultCount: 1000, + }); + return navtoResult.body; + } + catch (e) { + console.error(filePath, e); + } } //# sourceMappingURL=generator.js.map \ No newline at end of file diff --git a/dist/main/atom/views/symbols/generator.js.map b/dist/main/atom/views/symbols/generator.js.map index 92e98f471..a930539c3 100644 --- a/dist/main/atom/views/symbols/generator.js.map +++ b/dist/main/atom/views/symbols/generator.js.map @@ -1 +1 @@ -{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/symbols/generator.ts"],"names":[],"mappings":";;AAAA,6CAAgC;AAIzB,KAAK,UAAU,YAAY,CAAC,QAAgB,EAAE,IAAU;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CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;KAClC;AACH,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,QAAgB,EAAE,IAAU;IACpD,OAAO,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;QAClD,OAAO,MAAM,CAAC,UAAU,EAAE,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,QAAgB,EAAE,MAAc,EAAE,IAAU;IAClE,OAAO,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE;QAClD,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC,CAAC,CAAA;AACJ,CAAC"} \ No newline at end of file +{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/symbols/generator.ts"],"names":[],"mappings":";;AAEA,6CAAgC;AAEzB,KAAK,UAAU,YAAY,CAAC,QAAgB,EAAE,IAAU;IAC7D,MAAM,OAAO,GAAG,MAAM,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAChD,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE;QACjC,oFAAoF;QACpF,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;KACpD;;QAAM,OAAO,EAAE,CAAA;AAClB,CAAC;AAND,oCAMC;AAEM,KAAK,UAAU,eAAe,CAAC,QAAgB,EAAE,MAAc,EAAE,IAAU;IAChF,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IACtD,IAAI,OAAO,EAAE;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;KACvC;;QAAM,OAAO,EAAE,CAAA;AAClB,CAAC;AALD,0CAKC;AAED,QAAQ,CA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AC,CAAA;QAC7C,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE;YAChD,IAAI,EAAE,QAAQ;YACd,eAAe,EAAE,KAAK;YACtB,WAAW,EAAE,MAAM;YACnB,cAAc,EAAE,IAAI;SACrB,CAAC,CAAA;QACF,OAAO,WAAW,CAAC,IAAI,CAAA;KACxB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;KAC3B;AACH,CAAC"} \ No newline at end of file diff --git a/dist/main/atom/views/symbols/projectSymbolsView.js b/dist/main/atom/views/symbols/projectSymbolsView.js index 780d6dff1..775bacd12 100644 --- a/dist/main/atom/views/symbols/projectSymbolsView.js +++ b/dist/main/atom/views/symbols/projectSymbolsView.js @@ -1,10 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const simpleSelectionView_1 = require("../simpleSelectionView"); const etch = require("etch"); -const utils = require("./utils"); -const generator_1 = require("./generator"); const highlightComponent_1 = require("../highlightComponent"); +const simpleSelectionView_1 = require("../simpleSelectionView"); +const generator_1 = require("./generator"); +const utils = require("./utils"); async function toggle(editor, deps) { const filePath = editor.getPath(); if (filePath !== undefined) { @@ -20,7 +20,7 @@ async function toggle(editor, deps) { itemFilterKey: "name", }); if (tag) - utils.openTag(tag, editor, deps.getEditorPositionHistoryManager()); + await utils.openTag(tag, editor, deps.histGoForward); } } exports.toggle = toggle; diff --git a/dist/main/atom/views/symbols/projectSymbolsView.js.map b/dist/main/atom/views/symbols/projectSymbolsView.js.map index 17a6833c8..94c392ed1 100644 --- a/dist/main/atom/views/symbols/projectSymbolsView.js.map +++ b/dist/main/atom/views/symbols/projectSymbolsView.js.map @@ -1 +1 @@ -{"version":3,"file":"projectSymbolsView.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/symbols/projectSymbolsView.tsx"],"names":[],"mappings":";;AACA,gEAAqD;AACrD,6BAA4B;AAC5B,iCAAgC;AAChC,2CAA2C;AAE3C,8DAAwD;AAEjD,KAAK,UAAU,MAAM,CAAC,MAAkB,EAAE,IAAU;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IACjC,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,MAAM,GAAG,GAAG,MAAM,oCAAc,CAAC;YAC/B,KAAK,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,2BAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;YAClE,YAAY,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,EAAE,GAAG;gBACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAK,CAAC,CAAA;gBAC9C,OAAO,CACL,iBAAI,KAAK,EAAC,WAAW;oBACnB,kBAAK,KAAK,EAAC,cAAc;wBACvB,SAAC,uCAAkB,IAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,cAAc,EAAE,GAAI,CAC5D;oBACN,kBAAK,KAAK,EAAC,gBAAgB,IAAE,QAAQ,OAAO,SAAS,QAAQ,CAAC,GAAG,GAAG,CAAC,EAAE,CAAO,CAC3E,CACN,CAAA;YACH,CAAC;YACD,aAAa,EAAE,MAAM;SACtB,CAAC,CAAA;QACF,IAAI,GAAG;YAAE,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,+BAA+B,EAAE,CAAC,CAAA;KAC5E;AACH,CAAC;AApBD,wBAoBC"} \ No newline at end of file +{"version":3,"file":"projectSymbolsView.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/symbols/projectSymbolsView.tsx"],"names":[],"mappings":";;AACA,6BAA4B;AAC5B,8DAAwD;AACxD,gEAAqD;AAErD,2CAA2C;AAC3C,iCAAgC;AAEzB,KAAK,UAAU,MAAM,CAAC,MAAkB,EAAE,IAAU;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,CAAA;IACjC,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,MAAM,GAAG,GAAG,MAAM,oCAAc,CAAC;YAC/B,KAAK,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,2BAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC;YAClE,YAAY,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,EAAE,GAAG;gBACtC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAK,CAAC,CAAA;gBAC9C,OAAO,CACL,iBAAI,KAAK,EAAC,WAAW;oBACnB,kBAAK,KAAK,EAAC,cAAc;wBACvB,SAAC,uCAAkB,IAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,cAAc,EAAE,GAAI,CAC5D;oBACN,kBAAK,KAAK,EAAC,gBAAgB,IAAE,QAAQ,OAAO,SAAS,QAAQ,CAAC,GAAG,GAAG,CAAC,EAAE,CAAO,CAC3E,CACN,CAAA;YACH,CAAC;YACD,aAAa,EAAE,MAAM;SACtB,CAAC,CAAA;QACF,IAAI,GAAG;YAAE,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;KAC9D;AACH,CAAC;AApBD,wBAoBC"} \ No newline at end of file diff --git a/dist/main/atom/views/symbols/symbolsViewController.js b/dist/main/atom/views/symbols/symbolsViewController.js index dd91a6461..b23edbd56 100644 --- a/dist/main/atom/views/symbols/symbolsViewController.js +++ b/dist/main/atom/views/symbols/symbolsViewController.js @@ -1,5 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const utils_1 = require("../../../../utils"); const fileSymbolsView_1 = require("./fileSymbolsView"); const projectSymbolsView_1 = require("./projectSymbolsView"); class SymbolsViewController { @@ -7,10 +8,10 @@ class SymbolsViewController { this.deps = deps; } toggleFileView(editor) { - fileSymbolsView_1.toggle(editor, this.deps); + utils_1.handlePromise(fileSymbolsView_1.toggle(editor, this.deps)); } toggleProjectView(editor) { - projectSymbolsView_1.toggle(editor, this.deps); + utils_1.handlePromise(projectSymbolsView_1.toggle(editor, this.deps)); } dispose() { // TODO: proper disposal diff --git a/dist/main/atom/views/symbols/symbolsViewController.js.map b/dist/main/atom/views/symbols/symbolsViewController.js.map index ef4ee4667..b782df8cb 100644 --- a/dist/main/atom/views/symbols/symbolsViewController.js.map +++ b/dist/main/atom/views/symbols/symbolsViewController.js.map @@ -1 +1 @@ -{"version":3,"file":"symbolsViewController.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/symbols/symbolsViewController.ts"],"names":[],"mappings":";;AAAA,uDAA0D;AAC1D,6DAAgE;AAIhE,MAAa,qBAAqB;IAChC,YAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAAG,CAAC;IAE3B,cAAc,CAAC,MAAkB;QACtC,wBAAc,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;IAEM,iBAAiB,CAAC,MAAkB;QACzC,2BAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC;IAEM,OAAO;QACZ,wBAAwB;IAC1B,CAAC;CACF;AAdD,sDAcC"} \ No newline at end of file +{"version":3,"file":"symbolsViewController.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/symbols/symbolsViewController.ts"],"names":[],"mappings":";;AACA,6CAA+C;AAE/C,uDAA0D;AAC1D,6DAAgE;AAEhE,MAAa,qBAAqB;IAChC,YAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAAG,CAAC;IAE3B,cAAc,CAAC,MAAkB;QACtC,qBAAa,CAAC,wBAAc,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAClD,CAAC;IAEM,iBAAiB,CAAC,MAAkB;QACzC,qBAAa,CAAC,2BAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACrD,CAAC;IAEM,OAAO;QACZ,wBAAwB;IAC1B,CAAC;CACF;AAdD,sDAcC"} \ No newline at end of file diff --git a/dist/main/atom/views/symbols/utils.js b/dist/main/atom/views/symbols/utils.js index 403a7c641..b7e63fcb8 100644 --- a/dist/main/atom/views/symbols/utils.js +++ b/dist/main/atom/views/symbols/utils.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -async function openTag(tag, editor, ephm) { +async function openTag(tag, editor, histGoForward) { if (tag.file !== undefined) { - return ephm.goForward(editor, { + return histGoForward(editor, { file: tag.file, start: { line: tag.position.row + 1, diff --git a/dist/main/atom/views/symbols/utils.js.map b/dist/main/atom/views/symbols/utils.js.map index d2c074ac2..c12c8e553 100644 --- a/dist/main/atom/views/symbols/utils.js.map +++ b/dist/main/atom/views/symbols/utils.js.map @@ -1 +1 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/symbols/utils.ts"],"names":[],"mappings":";;AAIO,KAAK,UAAU,OAAO,CAAC,GAAQ,EAAE,MAAkB,EAAE,IAAkC;IAC5F,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YAC5B,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;gBAC1B,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;aAChC;SACF,CAAC,CAAA;KACH;AACH,CAAC;AAVD,0BAUC;AAED,SAAgB,oBAAoB,CAAC,MAAkB;IACrD,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,EAAE,CAAA;IAE9C,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,uBAAuB,EAAE;QAC9C,SAAS;KACV,CAAA;AACH,CAAC;AARD,oDAQC;AAED,SAAgB,sBAAsB,CACpC,MAAkB,EAClB,EAAC,YAAY,EAAE,SAAS,EAA0C;IAElE,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAA;IAC5C,aAAa,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;AACvC,CAAC;AAPD,wDAOC"} \ No newline at end of file +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../lib/main/atom/views/symbols/utils.ts"],"names":[],"mappings":";;AAIO,KAAK,UAAU,OAAO,CAC3B,GAAQ,EACR,MAAkB,EAClB,aAAwD;IAExD,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE;QAC1B,OAAO,aAAa,CAAC,MAAM,EAAE;YAC3B,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;gBAC1B,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;aAChC;SACF,CAAC,CAAA;KACH;AACH,CAAC;AAdD,0BAcC;AAED,SAAgB,oBAAoB,CAAC,MAAkB;IACrD,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,EAAE,CAAA;IAE9C,OAAO;QACL,YAAY,EAAE,MAAM,CAAC,uBAAuB,EAAE;QAC9C,SAAS;KACV,CAAA;AACH,CAAC;AARD,oDAQC;AAED,SAAgB,sBAAsB,CACpC,MAAkB,EAClB,EAAC,YAAY,EAAE,SAAS,EAA0C;IAElE,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAA;IAC5C,aAAa,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;AACvC,CAAC;AAPD,wDAOC"} \ No newline at end of file diff --git a/dist/main/atom/views/tooltipView.js.map b/dist/main/atom/views/tooltipView.js.map deleted file mode 100644 index 2df3aec03..000000000 --- a/dist/main/atom/views/tooltipView.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"tooltipView.js","sourceRoot":"","sources":["../../../../lib/main/atom/views/tooltipView.tsx"],"names":[],"mappings":";;AAAA,6BAA4B;AAU5B,MAAa,WAAW;IAItB;QACE,IAAI,CAAC,KAAK,GAAG;YACX,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,CAAC;YACR,GAAG,EAAE,CAAC;YACN,MAAM,EAAE,CAAC;YACT,IAAI,EAAE,EAAE;SACT,CAAA;QACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;IACvB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,KAAqB;QACvC,IAAI,CAAC,KAAK,qBAAO,IAAI,CAAC,KAAK,EAAK,KAAK,CAAC,CAAA;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC;IAEM,gBAAgB;QACrB,MAAM,MAAM,GAAG,EAAE,CAAA;QACjB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;QAC3B,IAAI,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAA;QAC3B,IAAI,KAAK,GAAmB,KAAK,CAAA;QAEjC,IAAI,UAAU,GAAG,EAAE,CAAA;QAEnB,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAA;QAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAA;QAC5C,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAA;QAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAA;QAE9C,gBAAgB;QAChB,IAAI,IAAI,GAAG,WAAW,IAAI,WAAW,EAAE;YACrC,IAAI,GAAG,WAAW,GAAG,WAAW,GAAG,MAAM,CAAA;SAC1C;QACD,IAAI,IAAI,GAAG,CAAC,EAAE;YACZ,UAAU,GAAG,UAAU,CAAA;YACvB,IAAI,GAAG,MAAM,CAAA;YACb,KAAK,GAAG,MAAM,CAAA;SACf;QAED,gBAAgB;QAChB,IAAI,GAAG,GAAG,YAAY,IAAI,YAAY,EAAE;YACtC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,YAAY,CAAA;SACpC;QAED,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAA;QACrC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAA;QACnC,IAAI,KAAK,KAAK,KAAK;YAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,KAAK,IAAI,CAAA;QAC5D,IAAI,UAAU;YAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,UAAU,CAAA;IAC5D,CAAC;IAEM,MAAM;QACX,OAAO,CACL,kBAAK,KAAK,EAAC,iCAAiC;YAC1C,kBAAK,KAAK,EAAC,eAAe,EAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAI,CACrD,CACP,CAAA;IACH,CAAC;CACF;AAjED,kCAiEC"} \ No newline at end of file diff --git a/dist/main/atomts.js b/dist/main/atomts.js index 931ec2b50..d39c9124a 100644 --- a/dist/main/atomts.js +++ b/dist/main/atomts.js @@ -1,19 +1,18 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var semanticView_1 = require("./atom/views/outline/semanticView"); -exports.deserializeSemanticView = semanticView_1.deserializeSemanticView; let pluginManager; async function activate(state) { - // tslint:disable:no-unsafe-any const pns = atom.packages.getAvailablePackageNames(); - if (!(pns.includes("atom-ide-ui") || pns.includes("linter"))) { + const packagesProvidingUIServices = ["atom-ide-ui", "linter", "nuclide"]; + if (!packagesProvidingUIServices.some(p => pns.includes(p))) { + // tslint:disable-next-line:no-unsafe-any await require("atom-package-deps").install("atom-typescript", true); } + // tslint:disable-next-line:no-unsafe-any require("etch").setScheduler(atom.views); // tslint:disable-next-line:no-shadowed-variable const { PluginManager } = require("./pluginManager"); pluginManager = new PluginManager(state); - // tslint:enable:no-unsafe-any } exports.activate = activate; function deactivate() { @@ -29,6 +28,13 @@ function serialize() { return undefined; } exports.serialize = serialize; +function deserializeSemanticView(serialized) { + const { + // tslint:disable-next-line:no-unsafe-any no-shadowed-variable + SemanticView, } = require("./atom/views/outline/semanticView"); + return SemanticView.create(serialized.data); +} +exports.deserializeSemanticView = deserializeSemanticView; ////////////////////////////////// Consumers /////////////////////////////////// function consumeLinter(register) { if (pluginManager) @@ -40,6 +46,21 @@ function consumeStatusBar(statusBar) { return pluginManager.consumeStatusBar(statusBar); } exports.consumeStatusBar = consumeStatusBar; +function consumeDatatipService(datatipService) { + if (pluginManager) + return pluginManager.consumeDatatipService(datatipService); +} +exports.consumeDatatipService = consumeDatatipService; +function consumeSignatureHelp(registry) { + if (pluginManager) + return pluginManager.consumeSigHelpService(registry); +} +exports.consumeSignatureHelp = consumeSignatureHelp; +function consumeBusySignal(busySignalService) { + if (pluginManager) + return pluginManager.consumeBusySignal(busySignalService); +} +exports.consumeBusySignal = consumeBusySignal; ////////////////////////////////// Providers /////////////////////////////////// function provideAutocomplete() { if (pluginManager) @@ -51,6 +72,11 @@ function provideIntentions() { return pluginManager.provideIntentions(); } exports.provideIntentions = provideIntentions; +function provideIntentionsHighlight() { + if (pluginManager) + return pluginManager.provideIntentionsHighlight(); +} +exports.provideIntentionsHighlight = provideIntentionsHighlight; function provideCodeActions() { if (pluginManager) return pluginManager.provideCodeActions(); @@ -61,4 +87,24 @@ function provideHyperclick() { return pluginManager.provideHyperclick(); } exports.provideHyperclick = provideHyperclick; +function provideReferences() { + if (pluginManager) + return pluginManager.provideReferences(); +} +exports.provideReferences = provideReferences; +function provideOutlines() { + if (pluginManager) + return pluginManager.provideOutlines(); +} +exports.provideOutlines = provideOutlines; +function provideDefinitions() { + if (pluginManager) + return pluginManager.provideDefinitions(); +} +exports.provideDefinitions = provideDefinitions; +function provideCodeHighlight() { + if (pluginManager) + return pluginManager.provideCodeHighlight(); +} +exports.provideCodeHighlight = provideCodeHighlight; //# sourceMappingURL=atomts.js.map \ No newline at end of file diff --git a/dist/main/atomts.js.map b/dist/main/atomts.js.map index f78f1b549..e62221cb1 100644 --- a/dist/main/atomts.js.map +++ b/dist/main/atomts.js.map @@ -1 +1 @@ -{"version":3,"file":"atomts.js","sourceRoot":"","sources":["../../lib/main/atomts.ts"],"names":[],"mappings":";;AAIA,kEAAyE;AAAjE,iDAAA,uBAAuB,CAAA;AAE/B,IAAI,aAAwC,CAAA;AAErC,KAAK,UAAU,QAAQ,CAAC,KAAY;IACzC,+BAA+B;IAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,wBAAwB,EAAE,CAAA;IACpD,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE;QAC5D,MAAM,OAAO,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAA;KACpE;IAED,OAAO,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAExC,gDAAgD;IAChD,MAAM,EAAC,aAAa,EAAC,GAAG,OAAO,CAAC,iBAAiB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AFD,8CAEC;AAED,SAAgB,eAAe;IAC7B,IAAI,aAAa;QAAE,OAAO,aAAa,CAAC,eAAe,EAAE,CAAA;AAC3D,CAAC;AAFD,0CAEC;AAED,SAAgB,kBAAkB;IAChC,IAAI,aAAa;QAAE,OAAO,aAAa,CAAC,kBAAkB,EAAE,CAAA;AAC9D,CAAC;AAFD,gDAEC;AAED,SAAgB,oBAAoB;IAClC,IAAI,aAAa;QAAE,OAAO,aAAa,CAAC,oBAAoB,EAAE,CAAA;AAChE,CAAC;AAFD,oDAEC"} \ No newline at end of file diff --git a/dist/main/errorPusher.js b/dist/main/errorPusher.js index 40e148191..7289133ce 100644 --- a/dist/main/errorPusher.js +++ b/dist/main/errorPusher.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const lodash_1 = require("lodash"); -const utils_1 = require("./atom/utils"); const atom_1 = require("atom"); +const lodash_1 = require("lodash"); const path = require("path"); +const utils_1 = require("./atom/utils"); /** Class that collects errors from all of the clients and pushes them to the Linter service */ class ErrorPusher { constructor() { @@ -15,16 +15,20 @@ class ErrorPusher { })); this.pushErrors = lodash_1.debounce(this.pushErrors.bind(this), 100); } + *getErrorsInRange(filePath, range) { + for (const prefixed of this.errors.values()) { + const errors = prefixed.get(path.normalize(filePath)); + if (errors) + yield* errors.filter(err => utils_1.spanToRange(err).intersectsWith(range)); + } + } /** Return any errors that cover the given location */ - getErrorsAt(filePath, loc) { - const result = []; + *getErrorsAt(filePath, loc) { for (const prefixed of this.errors.values()) { const errors = prefixed.get(path.normalize(filePath)); - if (errors) { - result.push(...errors.filter(err => utils_1.isLocationInRange(loc, err))); - } + if (errors) + yield* errors.filter(err => utils_1.spanToRange(err).containsPoint(loc)); } - return result; } /** Set errors. Previous errors with the same prefix and filePath are going to be replaced */ setErrors(prefix, filePath, errors) { @@ -36,11 +40,16 @@ class ErrorPusher { prefixed.set(path.normalize(filePath), errors); this.pushErrors(); } - /** Clear all errors */ - clear() { - if (this.linter) { - this.linter.clearMessages(); + clearFileErrors(filePath) { + for (const map of this.errors.values()) { + map.delete(filePath); } + this.pushErrors(); + } + clear() { + if (!this.linter) + return; + this.linter.clearMessages(); } setLinter(linter) { this.linter = linter; diff --git a/dist/main/errorPusher.js.map b/dist/main/errorPusher.js.map index 7295cf24d..00b36337b 100644 --- a/dist/main/errorPusher.js.map +++ b/dist/main/errorPusher.js.map @@ -1 +1 @@ -{"version":3,"file":"errorPusher.js","sourceRoot":"","sources":["../../lib/main/errorPusher.ts"],"names":[],"mappings":";;AAAA,mCAA+B;AAG/B,wCAAgE;AAChE,+BAAwC;AACxC,6BAA4B;AAE5B,+FAA+F;AAC/F,MAAa,WAAW;IAMtB;QAJQ,WAAM,GAA2C,IAAI,GAAG,EAAE,CAAA;QAC1D,iBAAY,GAAG,IAAI,CAAA;QACnB,kBAAa,GAAG,IAAI,0BAAmB,EAAE,CAAA;QAG/C,IAAI,CAAC,aAAa,CAAC,GAAG,CACpB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,8BAA8B,EAAE,CAAC,YAAqB,EAAE,EAAE;YAC5E,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAClC,CAAC,CAAC,CACH,CAAA;QACD,IAAI,CAAC,UAAU,GAAG,iBAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;IAC7D,CAAC;IAED,sDAAsD;IAC/C,WAAW,CAAC,QAAgB,EAAE,GAAa;QAChD,MAAM,MAAM,GAAiB,EAAE,CAAA;QAC/B,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;YACrD,IAAI,MAAM,EAAE;gBACV,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,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AK,MAAM,UAAU,IAAI,WAAW,EAAE;wBACpC,IAAI,MAAM,CAAC,sBAAsB,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;4BAAE,SAAQ;wBAC1E,IAAI,MAAM,CAAC,iCAAiC,IAAI,UAAU,CAAC,kBAAkB;4BAAE,SAAQ;wBACvF,qFAAqF;wBACrF,uFAAuF;wBACvF,IAAI,EAAC,KAAK,EAAE,GAAG,EAAC,GAAG,UAAiC,CAAA;wBACpD,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE;4BAClB,KAAK,GAAG,GAAG,GAAG,EAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAC,CAAA;yBACnC;wBAED,MAAM,CAAC,IAAI,CAAC;4BACV,QAAQ,EAAE,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;4BACtC,OAAO,EAAE,UAAU,CAAC,IAAI;4BACxB,QAAQ,EAAE;gCACR,IAAI,EAAE,QAAQ;gCACd,QAAQ,EAAE,wBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC;6BACvC;yBACF,CAAC,CAAA;qBACH;iBACF;aACF;SACF;QAED,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;SACnC;IACH,CAAC;IAEO,WAAW,CAAC,UAAsB;QACxC,IAAI,IAAI,CAAC,YAAY,IAAI,UAAU,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,MAAM,CAAA;QAChE,QAAQ,UAAU,CAAC,QAAQ,EAAE;YAC3B,KAAK,OAAO;gBACV,OAAO,OAAO,CAAA;YAChB,KAAK,SAAS;gBACZ,OAAO,SAAS,CAAA;YAClB;gBACE,OAAO,MAAM,CAAA;SAChB;IACH,CAAC;CACF;AAvGD,kCAuGC"} \ No newline at end of file +{"version":3,"file":"errorPusher.js","sourceRoot":"","sources":["../../lib/main/errorPusher.ts"],"names":[],"mappings":";;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YAChB,KAAK,SAAS;gBACZ,OAAO,SAAS,CAAA;YAClB;gBACE,OAAO,MAAM,CAAA;SAChB;IACH,CAAC;CACF;AA/GD,kCA+GC"} \ No newline at end of file diff --git a/dist/main/pluginManager.js b/dist/main/pluginManager.js index d81caa166..228f7ac02 100644 --- a/dist/main/pluginManager.js +++ b/dist/main/pluginManager.js @@ -1,46 +1,73 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Atom = require("atom"); -const autoCompleteProvider_1 = require("./atom/autoCompleteProvider"); -const clientResolver_1 = require("../client/clientResolver"); -const hyperclickProvider_1 = require("./atom/hyperclickProvider"); -const codefix_1 = require("./atom/codefix"); const atom_1 = require("atom"); const lodash_1 = require("lodash"); -const errorPusher_1 = require("./errorPusher"); -const statusPanel_1 = require("./atom/components/statusPanel"); -const typescriptEditorPane_1 = require("./typescriptEditorPane"); -const typescriptBuffer_1 = require("./typescriptBuffer"); +const path = require("path"); +const client_1 = require("../client"); +const utils_1 = require("../utils"); +const codeActionsProvider_1 = require("./atom-ide/codeActionsProvider"); +const codeHighlightProvider_1 = require("./atom-ide/codeHighlightProvider"); +const datatipProvider_1 = require("./atom-ide/datatipProvider"); +const definitionsProvider_1 = require("./atom-ide/definitionsProvider"); +const findReferencesProvider_1 = require("./atom-ide/findReferencesProvider"); +const hyperclickProvider_1 = require("./atom-ide/hyperclickProvider"); +const outlineProvider_1 = require("./atom-ide/outlineProvider"); +const sigHelpProvider_1 = require("./atom-ide/sigHelpProvider"); +const autoCompleteProvider_1 = require("./atom/autoCompleteProvider"); +const codefix_1 = require("./atom/codefix"); +const intentionsProvider_1 = require("./atom/codefix/intentionsProvider"); const commands_1 = require("./atom/commands"); +const statusPanel_1 = require("./atom/components/statusPanel"); +const editorPositionHistoryManager_1 = require("./atom/editorPositionHistoryManager"); +const manager_1 = require("./atom/occurrence/manager"); +const manager_2 = require("./atom/sigHelp/manager"); +const manager_3 = require("./atom/tooltips/manager"); +const utils_2 = require("./atom/utils"); const semanticViewController_1 = require("./atom/views/outline/semanticViewController"); const symbolsViewController_1 = require("./atom/views/symbols/symbolsViewController"); -const editorPositionHistoryManager_1 = require("./atom/editorPositionHistoryManager"); -const utils_1 = require("./atom/utils"); -const path = require("path"); +const errorPusher_1 = require("./errorPusher"); +const typescriptBuffer_1 = require("./typescriptBuffer"); +const typescriptEditorPane_1 = require("./typescriptEditorPane"); class PluginManager { constructor(state) { - this.panes = []; // TODO: do we need it? + this.usingBuiltinTooltipManager = true; + this.usingBuiltinSigHelpManager = true; + this.pending = new Set(); this.clearErrors = () => { this.errorPusher.clear(); }; + this.clearFileErrors = (filePath) => { + this.errorPusher.clearFileErrors(filePath); + }; this.getClient = async (filePath) => { - const pane = this.panes.find(p => p.buffer.getPath() === filePath); - if (pane && pane.client) { - return pane.client; - } return this.clientResolver.get(filePath); }; - this.getStatusPanel = () => this.statusPanel; - this.withTypescriptBuffer = async (filePath, action) => { + this.killAllServers = () => { + utils_1.handlePromise(this.clientResolver.restartAllServers()); + }; + this.flushTypescriptBuffer = async (filePath) => { const normalizedFilePath = path.normalize(filePath); - const pane = this.panes.find(p => p.buffer.getPath() === normalizedFilePath); - if (pane) - return action(pane.buffer); + const ed = atom.workspace.getTextEditors().find(p => p.getPath() === normalizedFilePath); + if (ed) { + const buffer = typescriptBuffer_1.TypescriptBuffer.create(ed.getBuffer(), { + getClient: this.getClient, + clearFileErrors: this.clearFileErrors, + reportBuildStatus: this.reportBuildStatus, + }); + await buffer.flush(); + } + }; + this.withBuffer = async (filePath, action) => { + const normalizedFilePath = path.normalize(filePath); + const ed = atom.workspace.getTextEditors().find(p => p.getPath() === normalizedFilePath); + // found open buffer + if (ed) + return action(ed.getBuffer()); // no open buffer const buffer = await Atom.TextBuffer.load(normalizedFilePath); try { - const tsbuffer = typescriptBuffer_1.TypescriptBuffer.create(buffer, fp => this.clientResolver.get(fp)); - return await action(tsbuffer); + return await action(buffer); } finally { if (buffer.isModified()) @@ -48,42 +75,135 @@ class PluginManager { buffer.destroy(); } }; - this.applyEdits = async (edits) => void Promise.all(edits.map(edit => this.withTypescriptBuffer(edit.fileName, async (buffer) => { - buffer.buffer.transact(() => { + this.reportBusyWhile = async (title, generator) => { + if (this.busySignalService) { + return this.busySignalService.reportBusyWhile(title, generator); + } + else { + const event = { title }; + try { + this.pending.add(event); + this.drawPending(Array.from(this.pending)); + return await generator(); + } + finally { + this.pending.delete(event); + this.drawPending(Array.from(this.pending)); + } + } + }; + this.reportProgress = (progress) => { + utils_1.handlePromise(this.statusPanel.update({ progress })); + }; + this.reportBuildStatus = (buildStatus) => { + utils_1.handlePromise(this.statusPanel.update({ buildStatus })); + }; + this.reportClientInfo = (info) => { + utils_1.handlePromise(this.statusPanel.update(info)); + }; + this.applyEdits = async (edits) => void Promise.all(edits.map(edit => this.withBuffer(edit.fileName, async (buffer) => { + buffer.transact(() => { const changes = edit.textChanges - .map(e => ({ range: utils_1.spanToRange(e), newText: e.newText })) + .map(e => ({ range: utils_2.spanToRange(e), newText: e.newText })) + .reverse() // NOTE: needs reverse for cases where ranges are same for two changes .sort((a, b) => b.range.compare(a.range)); for (const change of changes) { - buffer.buffer.setTextInRange(change.range, change.newText); + buffer.setTextInRange(change.range, change.newText); } }); - return buffer.flush(); + const filePath = buffer.getPath(); + if (filePath !== undefined) + await this.flushTypescriptBuffer(filePath); }))); - this.getSemanticViewController = () => this.semanticViewController; - this.getSymbolsViewController = () => this.symbolsViewController; - this.getEditorPositionHistoryManager = () => this.editorPosHist; + this.showTooltipAt = async (ed) => { + if (this.usingBuiltinTooltipManager) + await this.tooltipManager.showExpressionAt(ed); + else + await atom.commands.dispatch(atom.views.getView(ed), "datatip:toggle"); + }; + this.showSigHelpAt = async (ed) => { + if (this.usingBuiltinSigHelpManager) + await this.sigHelpManager.showTooltipAt(ed); + else + await atom.commands.dispatch(atom.views.getView(ed), "signature-help:show"); + }; + this.hideSigHelpAt = (ed) => { + if (this.usingBuiltinSigHelpManager) + return this.sigHelpManager.hideTooltipAt(ed); + else + return false; + }; + this.histGoForward = (ed, opts) => { + return this.editorPosHist.goForward(ed, opts); + }; + // tslint:disable-next-line:member-ordering + this.drawPending = lodash_1.throttle((pending) => utils_1.handlePromise(this.statusPanel.update({ pending })), 100, { leading: false }); this.subscriptions = new atom_1.CompositeDisposable(); - this.clientResolver = new clientResolver_1.ClientResolver(); + this.clientResolver = new client_1.ClientResolver(this.reportBusyWhile); this.subscriptions.add(this.clientResolver); - this.statusPanel = new statusPanel_1.StatusPanel({ clientResolver: this.clientResolver }); + this.statusPanel = new statusPanel_1.StatusPanel(); this.subscriptions.add(this.statusPanel); this.errorPusher = new errorPusher_1.ErrorPusher(); this.subscriptions.add(this.errorPusher); - // NOTE: This has to run before withTypescriptBuffer is used to populate this.panes - this.subscribeEditors(); this.codefixProvider = new codefix_1.CodefixProvider(this.clientResolver, this.errorPusher, this.applyEdits); this.subscriptions.add(this.codefixProvider); - this.semanticViewController = new semanticViewController_1.SemanticViewController(this.withTypescriptBuffer); + this.semanticViewController = new semanticViewController_1.SemanticViewController(this.getClient); this.subscriptions.add(this.semanticViewController); - this.symbolsViewController = new symbolsViewController_1.SymbolsViewController(this); - this.subscriptions.add(this.symbolsViewController); this.editorPosHist = new editorPositionHistoryManager_1.EditorPositionHistoryManager(state && state.editorPosHistState); this.subscriptions.add(this.editorPosHist); + this.symbolsViewController = new symbolsViewController_1.SymbolsViewController({ + histGoForward: this.histGoForward, + getClient: this.getClient, + }); + this.subscriptions.add(this.symbolsViewController); + this.tooltipManager = new manager_3.TooltipManager(this.getClient); + this.subscriptions.add(this.tooltipManager); + this.sigHelpManager = new manager_2.SigHelpManager({ + getClient: this.getClient, + flushTypescriptBuffer: this.flushTypescriptBuffer, + }); + this.subscriptions.add(this.sigHelpManager); + this.occurrenceManager = new manager_1.OccurrenceManager(this.getClient); + this.subscriptions.add(this.occurrenceManager); + this.typescriptPaneFactory = typescriptEditorPane_1.TypescriptEditorPane.createFactory({ + clearFileErrors: this.clearFileErrors, + getClient: this.getClient, + reportBuildStatus: this.reportBuildStatus, + reportClientInfo: this.reportClientInfo, + }); + this.subscribeEditors(); // Register the commands - this.subscriptions.add(commands_1.registerCommands(this)); + this.subscriptions.add(commands_1.registerCommands({ + getClient: this.getClient, + applyEdits: this.applyEdits, + clearErrors: this.clearErrors, + killAllServers: this.killAllServers, + reportProgress: this.reportProgress, + reportBuildStatus: this.reportBuildStatus, + toggleSemanticViewController: () => { + utils_1.handlePromise(this.semanticViewController.toggle()); + }, + toggleFileSymbolsView: ed => { + this.symbolsViewController.toggleFileView(ed); + }, + toggleProjectSymbolsView: ed => { + this.symbolsViewController.toggleProjectView(ed); + }, + histGoForward: this.histGoForward, + histGoBack: () => this.editorPosHist.goBack(), + histShowHistory: () => this.editorPosHist.showHistory(), + showTooltipAt: this.showTooltipAt, + showSigHelpAt: this.showSigHelpAt, + hideSigHelpAt: this.hideSigHelpAt, + })); } destroy() { this.subscriptions.dispose(); + for (const ed of atom.workspace.getTextEditors()) { + const pane = typescriptEditorPane_1.TypescriptEditorPane.lookupPane(ed); + if (pane) + pane.destroy(); + } } serialize() { return { @@ -96,9 +216,9 @@ class PluginManager { name: "TypeScript", }); this.errorPusher.setLinter(linter); - this.clientResolver.on("diagnostics", ({ type, filePath, diagnostics }) => { + this.subscriptions.add(this.clientResolver.on("diagnostics", ({ type, filePath, diagnostics }) => { this.errorPusher.setErrors(type, filePath, diagnostics); - }); + })); } consumeStatusBar(statusBar) { let statusPriority = 100; @@ -117,65 +237,83 @@ class PluginManager { this.subscriptions.add(disp); return disp; } + consumeDatatipService(datatip) { + if (atom.config.get("atom-typescript").preferBuiltinTooltips) + return; + const disp = datatip.addProvider(new datatipProvider_1.TSDatatipProvider(this.getClient)); + this.subscriptions.add(disp); + this.tooltipManager.dispose(); + this.usingBuiltinTooltipManager = false; + return disp; + } + consumeSigHelpService(registry) { + if (atom.config.get("atom-typescript").preferBuiltinSigHelp) + return; + const disp = registry(new sigHelpProvider_1.TSSigHelpProvider(this.getClient, this.flushTypescriptBuffer)); + this.subscriptions.add(disp); + this.sigHelpManager.dispose(); + this.usingBuiltinSigHelpManager = false; + return disp; + } + consumeBusySignal(busySignalService) { + if (atom.config.get("atom-typescript").preferBuiltinBusySignal) + return; + this.busySignalService = busySignalService; + const disp = { + dispose: () => { + if (this.busySignalService) + this.busySignalService.dispose(); + this.busySignalService = undefined; + }, + }; + this.subscriptions.add(disp); + return disp; + } // Registering an autocomplete provider provideAutocomplete() { - return [ - new autoCompleteProvider_1.AutocompleteProvider(this.clientResolver, { - withTypescriptBuffer: this.withTypescriptBuffer, - }), - ]; + return [new autoCompleteProvider_1.AutocompleteProvider(this.getClient, this.flushTypescriptBuffer)]; } provideIntentions() { - return new codefix_1.IntentionsProvider(this.codefixProvider); + return intentionsProvider_1.getIntentionsProvider(this.codefixProvider); + } + provideIntentionsHighlight() { + return intentionsProvider_1.getIntentionsHighlightsProvider(this.codefixProvider); } provideCodeActions() { - return new codefix_1.CodeActionsProvider(this.codefixProvider); + return codeActionsProvider_1.getCodeActionsProvider(this.codefixProvider); } provideHyperclick() { - return hyperclickProvider_1.getHyperclickProvider(this.clientResolver, this.editorPosHist); + return hyperclickProvider_1.getHyperclickProvider(this.getClient, this.histGoForward); + } + provideReferences() { + return findReferencesProvider_1.getFindReferencesProvider(this.getClient); + } + provideOutlines() { + return outlineProvider_1.getOutlineProvider(this.getClient); + } + provideDefinitions() { + if (atom.config.get("atom-typescript").disableAtomIdeDefinitions) + return; + return definitionsProvider_1.getDefinitionProvider(this.getClient); + } + provideCodeHighlight() { + if (atom.config.get("atom-typescript").preferBuiltinOccurrenceHighlight) + return; + this.occurrenceManager.dispose(); + return codeHighlightProvider_1.getCodeHighlightProvider(this.getClient); } subscribeEditors() { - let activePane; this.subscriptions.add(atom.workspace.observeTextEditors((editor) => { - this.panes.push(new typescriptEditorPane_1.TypescriptEditorPane(editor, { - getClient: (filePath) => this.clientResolver.get(filePath), - onClose: filePath => { - // Clear errors if any from this file - this.errorPusher.setErrors("syntaxDiag", filePath, []); - this.errorPusher.setErrors("semanticDiag", filePath, []); - }, - onDispose: pane => { - if (activePane === pane) { - activePane = undefined; - } - this.panes.splice(this.panes.indexOf(pane), 1); - }, - onSave: lodash_1.debounce((pane) => { - if (!pane.client) { - return; - } - const files = []; - for (const p of this.panes.sort((a, b) => a.activeAt - b.activeAt)) { - const filePath = p.buffer.getPath(); - if (filePath !== undefined && p.isTypescript && p.client === pane.client) { - files.push(filePath); - } - } - pane.client.execute("geterr", { files, delay: 100 }); - }, 50), - statusPanel: this.statusPanel, - })); - })); - this.subscriptions.add(atom.workspace.observeActiveTextEditor((editor) => { - if (activePane) { - activePane.onDeactivated(); - activePane = undefined; - } - const pane = this.panes.find(p => p.editor === editor); - if (pane) { - activePane = pane; - pane.onActivated(); + this.typescriptPaneFactory(editor); + }), atom.workspace.onDidChangeActiveTextEditor(ed => { + if (ed && utils_2.isTypescriptEditorWithPath(ed)) { + utils_1.handlePromise(this.statusPanel.show()); + const tep = typescriptEditorPane_1.TypescriptEditorPane.lookupPane(ed); + if (tep) + tep.didActivate(); } + else + utils_1.handlePromise(this.statusPanel.hide()); })); } } diff --git a/dist/main/pluginManager.js.map b/dist/main/pluginManager.js.map index c04ce163a..ca106b4b0 100644 --- a/dist/main/pluginManager.js.map +++ b/dist/main/pluginManager.js.map @@ -1 +1 @@ -{"version":3,"file":"pluginManager.js","sourceRoot":"","sources":["../../lib/main/pluginManager.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,sEAAgE;AAChE,6DAAuD;AACvD,kEAA+D;AAC/D,4CAAuF;AACvF,+BAAwC;AACxC,mCAA+B;AAC/B,+CAAyC;AAGzC,+DAAyD;AACzD,iEAA2D;AAC3D,yDAAmD;AACnD,8CAAgD;AAChD,wFAAkF;AAClF,sFAAgF;AAChF,sFAAgF;AAEhF,wCAAkD;AAClD,6BAA4B;AAiB5B,MAAa,aAAa;IAYxB,YAAmB,KAAsB;QAFxB,UAAK,GAA2B,EAAE,CAAA,C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I,IAAI,EAAE;gBACR,UAAU,GAAG,IAAI,CAAA;gBACjB,IAAI,CAAC,WAAW,EAAE,CAAA;aACnB;QACH,CAAC,CAAC,CACH,CAAA;IACH,CAAC;CACF;AA3ND,sCA2NC"} \ No newline at end of file +{"version":3,"file":"pluginManager.js","sourceRoot":"","sources":["../../lib/main/pluginManager.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,+BAAwC;AAIxC,mCAA+B;AAC/B,6BAA4B;AAC5B,sCAAwC;AACxC,oCAAsC;AACtC,wEAAqE;AACrE,4EAAyE;AACzE,gEAA4D;AAC5D,wEAAoE;AACpE,8EAA2E;AAC3E,sEAAmE;AACnE,gEAA6D;AAC7D,gEAA4D;AAC5D,sEAAgE;AAChE,4CAA8C;AAC9C,0EAG0C;AAC1C,8CAAgD;AAChD,+DAAkF;AAClF,sFAAgF;AAChF,uDAA2D;AAC3D,oDAAqD;AACrD,qDAAsD;AACtD,wCAA8E;AAC9E,wFAAkF;AAClF,sFAAgF;AAChF,+CAAyC;AAEzC,yDAAmD;AACnD,iEAA2D;AAe3D,MAAa,aAAa;IAmBxB,YAAmB,KAAsB;QARjC,+BAA0B,GAAG,IAAI,CAAA;QAEjC,+BAA0B,GAAG,IAAI,CAAA;QAEjC,YAAO,GAAG,IAAI,GAAG,EAAmB,CAAA;QAyMpC,gBAAW,GAAG,GAAG,EAAE;YACzB,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA;QAC1B,CAAC,CAAA;QAEO,oBAAe,GAAG,CAAC,QAAgB,EAAE,EAAE;YAC7C,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAC5C,CAAC,CAAA;QAEO,cAAS,GAAG,KAAK,EAAE,QAAgB,EAAE,EAAE;YAC7C,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAC1C,CAAC,CAAA;QAEO,mBAAc,GAAG,GAAG,EAAE;YAC5B,qBAAa,CA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AiB,CAAC,CAAC,yBAAyB;YAAE,OAAM;QACxE,OAAO,2CAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC9C,CAAC;IAEM,oBAAoB;QACzB,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,gCAAgC;YAAE,OAAM;QAC/E,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAA;QAChC,OAAO,gDAAwB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACjD,CAAC;IAqHO,gBAAgB;QACtB,IAAI,CAAC,aAAa,CAAC,GAAG,CACpB,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC,MAAuB,EAAE,EAAE;YAC5D,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;QACpC,CAAC,CAAC,EACF,IAAI,CAAC,SAAS,CAAC,2BAA2B,CAAC,EAAE,CAAC,EAAE;YAC9C,IAAI,EAAE,IAAI,kCAA0B,CAAC,EAAE,CAAC,EAAE;gBACxC,qBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAA;gBACtC,MAAM,GAAG,GAAG,2CAAoB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;gBAC/C,IAAI,GAAG;oBAAE,GAAG,CAAC,WAAW,EAAE,CAAA;aAC3B;;gBAAM,qBAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAA;QAC/C,CAAC,CAAC,CACH,CAAA;IACH,CAAC;CAQF;AAhWD,sCAgWC"} \ No newline at end of file diff --git a/dist/main/typescriptBuffer.js b/dist/main/typescriptBuffer.js index a912ddf03..a1b27e0c2 100644 --- a/dist/main/typescriptBuffer.js +++ b/dist/main/typescriptBuffer.js @@ -3,69 +3,93 @@ Object.defineProperty(exports, "__esModule", { value: true }); // A class to keep all changes to the buffer in sync with tsserver. This is mainly used with // the editor panes, but is also useful for editor-less buffer changes (renameRefactor). const Atom = require("atom"); -const utils_1 = require("./atom/utils"); +const lodash_1 = require("lodash"); +const utils_1 = require("../utils"); +const utils_2 = require("./atom/utils"); class TypescriptBuffer { - constructor(buffer, getClient) { + constructor(buffer, deps) { this.buffer = buffer; - this.getClient = getClient; + this.deps = deps; this.events = new Atom.Emitter(); - // Timestamps for buffer events - this.changedAt = 0; - this.changedAtBatch = 0; + this.lastChangedAt = Date.now(); + this.lastUpdatedAt = Date.now(); + this.compileOnSave = false; this.subscriptions = new Atom.CompositeDisposable(); - this.dispose = async () => { + // tslint:disable-next-line:member-ordering + this.on = this.events.on.bind(this.events); + this.dispose = () => { this.subscriptions.dispose(); - await this.close(); + utils_1.handlePromise(this.close()); + }; + this.init = async () => { + if (!this.state) + return; + await this.state.client.execute("open", { + file: this.state.filePath, + fileContent: this.buffer.getText(), + }); + await this.getErr({ allFiles: false }); }; this.close = async () => { + await this.openPromise; if (this.state) { - const client = await this.state.client; + const client = this.state.client; const file = this.state.filePath; await client.execute("close", { file }); - this.events.emit("closed", file); + this.deps.clearFileErrors(file); + this.state.subscriptions.dispose(); this.state = undefined; } }; this.onDidChange = () => { - this.changedAt = Date.now(); + this.lastChangedAt = Date.now(); }; - this.onDidChangePath = async () => { - await this.close(); - await this.open(); + this.onDidChangePath = (newPath) => { + utils_1.handlePromise(this.close().then(() => { + this.openPromise = this.open(newPath); + })); }; this.onDidSave = async () => { - // Check if there isn't a onDidStopChanging event pending. - const { changedAt, changedAtBatch } = this; - if (changedAtBatch > 0 && changedAt > changedAtBatch) { - await new Promise(resolve => this.events.once("changed", resolve)); - } - this.events.emit("saved"); + await this.flush(); + await this.getErr({ allFiles: true }); + await this.doCompileOnSave(); }; this.onDidStopChanging = async ({ changes }) => { - // Don't update changedAt or emit any events if there are no actual changes or file isn't open + // If there are no actual changes, or the file isn't open, we have nothing to do if (changes.length === 0 || !this.state) return; - this.changedAtBatch = Date.now(); - const client = await this.state.client; - for (const change of changes) { - const { start, oldExtent, newText } = change; - const end = { - endLine: start.row + oldExtent.row + 1, - endOffset: (oldExtent.row === 0 ? start.column + oldExtent.column : oldExtent.column) + 1, - }; - await client.execute("change", Object.assign({}, end, { file: this.state.filePath, line: start.row + 1, offset: start.column + 1, insertString: newText })); - } - this.events.emit("changed"); + this.deps.reportBuildStatus(undefined); + const { client, filePath } = this.state; + // NOTE: this might look somewhat weird until we realize that + // awaiting on each "change" command may lead to arbitrary + // interleaving, while pushing them all at once guarantees + // that all subsequent "change" commands will be sequenced after + // the ones we pushed + await Promise.all(changes.map(({ oldRange, newText }) => client.execute("change", { + file: filePath, + line: oldRange.start.row + 1, + offset: oldRange.start.column + 1, + endLine: oldRange.end.row + 1, + endOffset: oldRange.end.column + 1, + insertString: newText, + }))); + this.lastUpdatedAt = Date.now(); + this.events.emit("updated"); + return this.getErr({ allFiles: false }); }; - this.subscriptions.add(buffer.onDidChange(this.onDidChange), buffer.onDidChangePath(this.onDidChangePath), buffer.onDidDestroy(this.dispose), buffer.onDidSave(this.onDidSave), buffer.onDidStopChanging(this.onDidStopChanging)); - this.open(); + this.subscriptions.add(buffer.onDidChange(this.onDidChange), buffer.onDidChangePath(this.onDidChangePath), buffer.onDidDestroy(this.dispose), buffer.onDidSave(() => { + utils_1.handlePromise(this.onDidSave()); + }), buffer.onDidStopChanging(arg => { + utils_1.handlePromise(this.onDidStopChanging(arg)); + })); + this.openPromise = this.open(this.buffer.getPath()); } - static create(buffer, getClient) { + static create(buffer, deps) { const b = TypescriptBuffer.bufferMap.get(buffer); if (b) return b; else { - const nb = new TypescriptBuffer(buffer, getClient); + const nb = new TypescriptBuffer(buffer, deps); TypescriptBuffer.bufferMap.set(buffer, nb); return nb; } @@ -75,65 +99,101 @@ class TypescriptBuffer { } // If there are any pending changes, flush them out to the Typescript server async flush() { - if (this.changedAt > this.changedAtBatch) { + if (this.lastChangedAt > this.lastUpdatedAt) { await new Promise(resolve => { - const sub = this.buffer.onDidStopChanging(() => { - sub.dispose(); + const disp = this.events.once("updated", () => { + disp.dispose(); resolve(); }); this.buffer.emitDidStopChangingEvent(); }); } } - async getNavTree() { + getInfo() { if (!this.state) return; - const client = await this.state.client; - try { - const navtreeResult = await client.execute("navtree", { file: this.state.filePath }); - return navtreeResult.body; - } - catch (err) { - console.error(err, this.state.filePath); - } - return; + return { + clientVersion: this.state.client.version, + tsConfigPath: this.state.configFile && this.state.configFile.getPath(), + }; } - async getNavTo(search) { + async getErr({ allFiles }) { if (!this.state) return; - const client = await this.state.client; + const files = allFiles ? Array.from(utils_2.getOpenEditorsPaths()) : [this.state.filePath]; + await this.state.client.execute("geterr", { + files, + delay: 100, + }); + } + /** Throws! */ + async compile() { + if (!this.state) + return; + const { client, filePath } = this.state; + const result = await client.execute("compileOnSaveAffectedFileList", { + file: filePath, + }); + const fileNames = lodash_1.flatten(result.body.map(project => project.fileNames)); + if (fileNames.length === 0) + return; + const promises = fileNames.map(file => client.execute("compileOnSaveEmitFile", { file })); + const saved = await Promise.all(promises); + if (!saved.every(res => !!res.body)) { + throw new Error("Some files failed to emit"); + } + } + async doCompileOnSave() { + if (!this.compileOnSave) + return; + this.deps.reportBuildStatus(undefined); try { - const navtoResult = await client.execute("navto", { - file: this.state.filePath, - currentFileOnly: false, - searchValue: search, - maxResultCount: 1000, - }); - return navtoResult.body; + await this.compile(); + this.deps.reportBuildStatus({ success: true }); } - catch (err) { - console.error(err, this.state.filePath); + catch (error) { + const e = error; + console.error("Save failed with error", e); + this.deps.reportBuildStatus({ success: false, message: e.message }); } - return; } - async open() { - const filePath = this.buffer.getPath(); - if (filePath !== undefined && utils_1.isTypescriptFile(filePath)) { + async open(filePath) { + if (filePath !== undefined && utils_2.isTypescriptFile(filePath)) { + const client = await this.deps.getClient(filePath); this.state = { - client: this.getClient(filePath), + client, filePath, + configFile: undefined, + subscriptions: new Atom.CompositeDisposable(), }; - const client = await this.state.client; - await client.execute("open", { - file: this.state.filePath, - fileContent: this.buffer.getText(), + this.state.subscriptions.add(client.on("restarted", () => utils_1.handlePromise(this.init()))); + await this.init(); + const result = await client.execute("projectInfo", { + needFileNameList: false, + file: filePath, }); + // TODO: wrong type here, complain on TS repo + if (result.body.configFileName !== undefined) { + this.state.configFile = new Atom.File(result.body.configFileName); + await this.readConfigFile(); + this.state.subscriptions.add(this.state.configFile.onDidChange(() => utils_1.handlePromise(this.readConfigFile()))); + } this.events.emit("opened"); } else { - this.state = undefined; + return this.close(); } } + async readConfigFile() { + if (!this.state || !this.state.configFile) + return; + const options = await utils_2.getProjectConfig(this.state.configFile.getPath()); + this.compileOnSave = options.compileOnSave; + await this.state.client.execute("configure", { + file: this.state.filePath, + formatOptions: options.formatCodeOptions, + }); + } } TypescriptBuffer.bufferMap = new WeakMap(); exports.TypescriptBuffer = TypescriptBuffer; diff --git a/dist/main/typescriptBuffer.js.map b/dist/main/typescriptBuffer.js.map index 1ed21bf74..1f12a1cf5 100644 --- a/dist/main/typescriptBuffer.js.map +++ b/dist/main/typescriptBuffer.js.map @@ -1 +1 @@ -{"version":3,"file":"typescriptBuffer.js","sourceRoot":"","sources":["../../lib/main/typescriptBuffer.ts"],"names":[],"mappings":";;AAAA,4FAA4F;AAC5F,wFAAwF;AACxF,6BAA4B;AAE5B,wCAA6C;AAE7C,MAAa,gBAAgB;IAmC3B,YACS,MAAuB,EACvB,SAAgD;QADhD,WAAM,GAAN,MAAM,CAAiB;QACvB,cAAS,GAAT,SAAS,CAAuC;QAzBzC,WAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAStC,CAAA;QAEH,+BAA+B;QACvB,cAAS,GAAW,CAAC,CAAA;QACrB,mBAAc,GAAW,CAAC,CAAA;QAQ1B,kBAAa,GAAG,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAoF9C,YAAO,GAAG,KAAK,IAAI,EAAE;YAC3B,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAA;YAC5B,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QACpB,CAAC,CAAA;QAEO,UAAK,GAAG,KAAK,IAAI,EAAE;Y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AA;IACJ,CAAC;;AA5Jc,0BAAS,GAAG,IAAI,OAAO,EAAqC,CAAA;AAV7E,4CA8OC"} \ No newline at end of file diff --git a/dist/main/typescriptEditorPane.js b/dist/main/typescriptEditorPane.js index 1532de3ae..c2e430ea6 100644 --- a/dist/main/typescriptEditorPane.js +++ b/dist/main/typescriptEditorPane.js @@ -1,190 +1,66 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const atom_1 = require("atom"); -const lodash_1 = require("lodash"); const utils_1 = require("./atom/utils"); const typescriptBuffer_1 = require("./typescriptBuffer"); -const tooltipManager_1 = require("./atom/tooltipManager"); class TypescriptEditorPane { constructor(editor, opts) { this.editor = editor; this.opts = opts; - // Timestamp for activated event - this.activeAt = 0; - this.isTypescript = false; - // Path to the project's tsconfig.json - this.configFile = ""; - this.isActive = false; - this.isOpen = false; - this.occurrenceMarkers = []; this.subscriptions = new atom_1.CompositeDisposable(); - this.onActivated = () => { - this.activeAt = Date.now(); - this.isActive = true; - const filePath = this.buffer.getPath(); - if (this.isTypescript && filePath !== undefined) { - this.opts.statusPanel.show(); - // The first activation might happen before we even have a client - if (this.client) { - this.client.execute("geterr", { - files: [filePath], - delay: 100, - }); - this.opts.statusPanel.update({ version: this.client.version }); - } - } - this.opts.statusPanel.update({ tsConfigPath: this.configFile }); - }; - this.onDeactivated = () => { - this.isActive = false; - this.opts.statusPanel.hide(); + this.isTypescript = false; + this.destroy = () => { + atom.views.getView(this.editor).classList.remove("typescript-editor"); + this.subscriptions.dispose(); }; - this.onChanged = () => { - if (!this.client) - return; - const filePath = this.buffer.getPath(); - if (filePath === undefined) - return; - this.opts.statusPanel.update({ buildStatus: undefined }); - this.client.execute("geterr", { - files: [filePath], - delay: 100, - }); + /** NOTE: + * it is implicitly assumed that `atom.workspace.getActiveTextEditor() === this.editor` + * which has to be ensured at call site + */ + this.didActivate = () => { + if (this.isTypescript) + this.reportInfo(); }; - this.onDidChangeCursorPosition = ({ textChanged }) => { - if (!this.isTypescript || !this.isOpen) - return; - if (textChanged) { - this.clearOccurrenceMarkers(); - return; - } - this.updateMarkers(); - }; - this.onDidDestroy = () => { - this.dispose(); - }; - this.onOpened = async () => { - const filePath = this.buffer.getPath(); - if (filePath === undefined) - return; - this.client = await this.opts.getClient(filePath); - // onOpened might trigger before onActivated so we can't rely on isActive flag - if (atom.workspace.getActiveTextEditor() === this.editor) { - this.isActive = true; - this.opts.statusPanel.update({ version: this.client.version }); - } - if (this.isTypescript) { - this.client.execute("geterr", { - files: [filePath], - delay: 100, - }); - this.isOpen = true; - try { - const result = await this.client.execute("projectInfo", { - needFileNameList: false, - file: filePath, - }); - this.configFile = result.body.configFileName; - if (this.isActive) { - this.opts.statusPanel.update({ tsConfigPath: this.configFile }); - } - utils_1.getProjectCodeSettings(this.configFile).then(options => { - this.client.execute("configure", { - file: filePath, - formatOptions: options, - }); - }); - } - catch (e) { - if (window.atom_typescript_debug) - console.error(e); - } - } - }; - this.onSaved = () => { - this.opts.onSave(this); - this.compileOnSave(); + this.onOpened = () => { + const isActive = atom.workspace.getActiveTextEditor() === this.editor; + if (isActive) + this.reportInfo(); }; this.checkIfTypescript = () => { this.isTypescript = utils_1.isTypescriptEditorWithPath(this.editor); - // Add 'typescript-editor' class to the where typescript is active. if (this.isTypescript) { atom.views.getView(this.editor).classList.add("typescript-editor"); } + else { + atom.views.getView(this.editor).classList.remove("typescript-editor"); + } }; - this.updateMarkers = lodash_1.debounce(this.updateMarkers.bind(this), 100); - this.buffer = typescriptBuffer_1.TypescriptBuffer.create(editor.getBuffer(), opts.getClient); - this.subscriptions.add(this.buffer.events.on("changed", this.onChanged), this.buffer.events.on("closed", this.opts.onClose), this.buffer.events.on("opened", this.onOpened), this.buffer.events.on("saved", this.onSaved)); + this.buffer = typescriptBuffer_1.TypescriptBuffer.create(editor.getBuffer(), opts); + this.subscriptions.add(this.buffer.on("opened", this.onOpened)); this.checkIfTypescript(); - this.subscriptions.add(editor.onDidChangePath(this.checkIfTypescript), editor.onDidChangeGrammar(this.checkIfTypescript), this.editor.onDidChangeCursorPosition(this.onDidChangeCursorPosition), this.editor.onDidDestroy(this.onDidDestroy)); - this.subscriptions.add(new tooltipManager_1.TooltipManager(this.editor, opts.getClient)); - } - dispose() { - atom.views.getView(this.editor).classList.remove("typescript-editor"); - this.subscriptions.dispose(); - this.opts.onDispose(this); + this.subscriptions.add(editor.onDidChangePath(this.checkIfTypescript), editor.onDidChangeGrammar(this.checkIfTypescript), editor.onDidDestroy(this.destroy)); } - clearOccurrenceMarkers() { - for (const marker of this.occurrenceMarkers) { - marker.destroy(); - } - } - async updateMarkers() { - if (!this.client) - return; - const filePath = this.buffer.getPath(); - if (filePath === undefined) - return; - const pos = this.editor.getLastCursor().getBufferPosition(); - this.clearOccurrenceMarkers(); - try { - const result = await this.client.execute("occurrences", { - file: filePath, - line: pos.row + 1, - offset: pos.column + 1, - }); - for (const ref of result.body) { - const marker = this.editor.markBufferRange(utils_1.spanToRange(ref)); - this.editor.decorateMarker(marker, { - type: "highlight", - class: "atom-typescript-occurrence", - }); - this.occurrenceMarkers.push(marker); + // tslint:disable-next-line:member-ordering + static createFactory(opts) { + return (editor) => { + let tep = TypescriptEditorPane.editorMap.get(editor); + if (!tep) { + tep = new TypescriptEditorPane(editor, opts); + TypescriptEditorPane.editorMap.set(editor, tep); } - } - catch (e) { - if (window.atom_typescript_debug) - console.error(e); - } + return tep; + }; } - async compileOnSave() { - const { client } = this; - if (!client) - return; - const filePath = this.buffer.getPath(); - if (filePath === undefined) - return; - const result = await client.execute("compileOnSaveAffectedFileList", { - file: filePath, - }); - this.opts.statusPanel.update({ buildStatus: undefined }); - const fileNames = lodash_1.flatten(result.body.map(project => project.fileNames)); - if (fileNames.length === 0) - return; - try { - const promises = fileNames.map(file => client.execute("compileOnSaveEmitFile", { file })); - const saved = await Promise.all(promises); - if (!saved.every(res => !!res.body)) { - throw new Error("Some files failed to emit"); - } - this.opts.statusPanel.update({ buildStatus: { success: true } }); - } - catch (error) { - const e = error; - console.error("Save failed with error", e); - this.opts.statusPanel.update({ buildStatus: { success: false, message: e.message } }); - } + // tslint:disable-next-line:member-ordering + static lookupPane(editor) { + return TypescriptEditorPane.editorMap.get(editor); + } + reportInfo() { + const info = this.buffer.getInfo(); + if (info) + this.opts.reportClientInfo(info); } } +TypescriptEditorPane.editorMap = new WeakMap(); exports.TypescriptEditorPane = TypescriptEditorPane; //# sourceMappingURL=typescriptEditorPane.js.map \ No newline at end of file diff --git a/dist/main/typescriptEditorPane.js.map b/dist/main/typescriptEditorPane.js.map index 5b0f77b0f..8e4a7a0ae 100644 --- a/dist/main/typescriptEditorPane.js.map +++ b/dist/main/typescriptEditorPane.js.map @@ -1 +1 @@ -{"version":3,"file":"typescriptEditorPane.js","sourceRoot":"","sources":["../../lib/main/typescriptEditorPane.ts"],"names":[],"mappings":";;AACA,+BAAwC;AACxC,mCAAwC;AACxC,wCAA4F;AAE5F,yDAAmD;AAEnD,0DAAoD;AAgBpD,MAAa,oBAAoB;IAe/B,YAA4B,MAAuB,EAAU,IAAiB;QAAlD,WAAM,GAAN,MAAM,CAAiB;QAAU,SAAI,GAAJ,IAAI,CAAa;QAd9E,gCAAgC;QACzB,aAAQ,GAAW,CAAC,CAAA;QAEpB,iBAAY,GAAG,KAAK,CAAA;QAG3B,sCAAsC;QAC9B,eAAU,GAAW,EAAE,CAAA;QACvB,aAAQ,GAAG,KAAK,CAAA;QAChB,WAAM,GAAG,KAAK,CAAA;QAEL,sBAAiB,GAAyB,EAAE,CAAA;QAC5C,kBAAa,GAAG,IAAI,0BAAmB,EAAE,CAAA;QA8BnD,gBAAW,GAAG,GAAG,EAAE;YACxB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;YAEpB,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;YACtC,IAAI,IAAI,CAAC,YAAY,IAAI,QAAQ,KAA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H,CAAC;CAUF;AA3ND,oDA2NC"} \ No newline at end of file +{"version":3,"file":"typescriptEditorPane.js","sourceRoot":"","sources":["../../lib/main/typescriptEditorPane.ts"],"names":[],"mappings":";;AACA,+BAAwC;AAGxC,wCAAuD;AACvD,yDAAmD;AASnD,MAAa,oBAAoB;IAyB/B,YAAqC,MAAuB,EAAU,IAAiB;QAAlD,WAAM,GAAN,MAAM,CAAiB;QAAU,SAAI,GAAJ,IAAI,CAAa;QAHtE,kBAAa,GAAG,IAAI,0BAAmB,EAAE,CAAA;QAClD,iBAAY,GAAG,KAAK,CAAA;QAerB,YAAO,GAAG,GAAG,EAAE;YACpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAA;YACrE,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAA;QAC9B,CAAC,CAAA;QAED;;;WAGG;QACI,gBAAW,GAAG,GAAG,EAAE;YACxB,IAAI,IAAI,CAAC,YAAY;gBAAE,IAAI,CAAC,UAAU,EAAE,CAAA;QAC1C,CAAC,CAAA;QAEO,aAAQ,GAAG,GAAG,EAAE;YACtB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,KAAK,IAAI,CAAC,MAAM,CAAA;YACrE,IAAI,QAAQ;gBAAE,IAAI,CAAC,UAAU,EAAE,CAAA;QACjC,CAAC,CAAA;QAOO,sBAAiB,GAAG,GAAG,EAAE;YAC/B,IAAI,CAAC,YAAY,GAAG,kCAA0B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAE3D,IAAI,IAAI,CAAC,YAAY,EAAE;gBACrB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;aACnE;iBAAM;gBACL,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IA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AI;YAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;IAC5C,CAAC;;AA1Dc,8BAAS,GAAG,IAAI,OAAO,EAAyC,CAAA;AADjF,oDAsEC"} \ No newline at end of file diff --git a/dist/utils.js b/dist/utils.js new file mode 100644 index 000000000..7c81d69b7 --- /dev/null +++ b/dist/utils.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function handlePromise(promise) { + // tslint:disable-next-line:strict-type-predicates no-unbound-method + if (typeof promise.catch !== "function") { + atom.notifications.addFatalError("Atom-Typescript: non-promise passed to handlePromise. Please report this.", { + stack: new Error().stack, + dismissable: true, + }); + return; + } + promise.catch((err) => { + atom.notifications.addFatalError(`Atom-Typescript error: ${err.message}`, { + detail: err.toString(), + stack: err.stack, + dismissable: true, + }); + }); +} +exports.handlePromise = handlePromise; +//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/dist/utils.js.map b/dist/utils.js.map new file mode 100644 index 000000000..147ecd3a2 --- /dev/null +++ b/dist/utils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"utils.js","sourceRoot":"","sources":["../lib/utils.ts"],"names":[],"mappings":";;AAAA,SAAgB,aAAa,CAAC,OAAqB;IACjD,oEAAoE;IACpE,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,UAAU,EAAE;QACvC,IAAI,CAAC,aAAa,CAAC,aAAa,CAC9B,2EAA2E,EAC3E;YACE,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC,KAAK;YACxB,WAAW,EAAE,IAAI;SAClB,CACF,CAAA;QACD,OAAM;KACP;IACD,OAAO,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE;QAC3B,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,0BAA0B,GAAG,CAAC,OAAO,EAAE,EAAE;YACxE,MAAM,EAAE,GAAG,CAAC,QAAQ,EAAE;YACtB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,WAAW,EAAE,IAAI;SAClB,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAnBD,sCAmBC"} \ No newline at end of file diff --git a/keymaps/atom-typescript.cson b/keymaps/atom-typescript.cson index 1b8c009c4..90a5aa2fd 100644 --- a/keymaps/atom-typescript.cson +++ b/keymaps/atom-typescript.cson @@ -3,6 +3,7 @@ 'shift-f12': 'typescript:find-references' 'f6': 'typescript:build' 'f12': 'typescript:go-to-declaration' + 'escape': 'typescript:hide-signature-help' 'atom-workspace': 'f10': 'typescript:return-from-declaration' diff --git a/lib/client/callbacks.ts b/lib/client/callbacks.ts index 5a55375bb..57d50a86c 100644 --- a/lib/client/callbacks.ts +++ b/lib/client/callbacks.ts @@ -1,29 +1,34 @@ -import * as protocol from "typescript/lib/protocol" +import {ReportBusyWhile} from "../main/pluginManager" +import {CommandRes, CommandsWithResponse} from "./commandArgsResponseMap" interface Request { - name: string started: number reject(err: Error): void - resolve(res: protocol.Response): void + resolve(res: any): void } // Callbacks keeps track of all the outstanding requests export class Callbacks { private callbacks: Map = new Map() - constructor(private onPendingChange: (pending: string[]) => void) {} + constructor(private reportBusyWhile: ReportBusyWhile) {} - public add(seq: number, command: string) { - return new Promise((resolve, reject) => { - this.callbacks.set(seq, { - name: command, - resolve, - reject, - started: Date.now(), + public async add( + seq: number, + command: T, + ): Promise> { + try { + const promise = new Promise>((resolve, reject) => { + this.callbacks.set(seq, { + resolve, + reject, + started: Date.now(), + }) }) - - this.onPendingChange(this.pending()) - }) + return await this.reportBusyWhile(command, () => promise) + } finally { + this.callbacks.delete(seq) + } } public rejectAll(error: Error) { @@ -32,27 +37,30 @@ export class Callbacks { } this.callbacks.clear() - this.onPendingChange(this.pending()) } - // Remove and return a Request object, if one exists - public remove(seq: number): Request | undefined { + public resolve(seq: number, res: CommandRes): void { const req = this.callbacks.get(seq) - this.callbacks.delete(seq) if (req) { - this.onPendingChange(this.pending()) - } - return req + if (window.atom_typescript_debug) { + console.log( + "received response for", + res.command, + "in", + Date.now() - req.started, + "ms", + "with data", + res.body, + ) + } + if (res.success) req.resolve(res) + else req.reject(new Error(res.message)) + } else console.warn("unexpected response:", res) } - // pending returns names of requests waiting for a response - private pending(): string[] { - const pending: string[] = [] - - for (const {name} of this.callbacks.values()) { - pending.push(name) - } - - return pending + public error(seq: number, err: Error): void { + const req = this.callbacks.get(seq) + if (req) req.reject(err) + else console.error(err) } } diff --git a/lib/client/client.ts b/lib/client/client.ts index 0b34e5785..8574a599b 100644 --- a/lib/client/client.ts +++ b/lib/client/client.ts @@ -1,21 +1,23 @@ // tslint:disable:max-classes-per-file -import * as protocol from "typescript/lib/protocol" -import {CommandArgResponseMap, CommandArg, CommandRes} from "./commandArgsResponseMap" import {BufferedNodeProcess, BufferedProcess, Emitter} from "atom" -import {Callbacks} from "./callbacks" -import {ChildProcess} from "child_process" -import {Transform, Readable} from "stream" import byline = require("byline") +import {ChildProcess} from "child_process" +import {Readable, Transform} from "stream" +import * as protocol from "typescript/lib/protocol" +import {ReportBusyWhile} from "../main/pluginManager" +import {Callbacks} from "./callbacks" +import { + AllTSClientCommands, + CommandArg, + CommandRes, + CommandsWithResponse, +} from "./commandArgsResponseMap" import {EventTypes} from "./events" // Set this to true to start tsserver with node --inspect const INSPECT_TSSERVER = false -type CommandArgResponseKeysWithArgs = { - [K in keyof CommandArgResponseMap]: CommandRes extends void ? never : K -}[keyof CommandArgResponseMap] - -const commandWithResponseMap: {readonly [K in CommandArgResponseKeysWithArgs]: true} = { +const commandWithResponseMap: {readonly [K in CommandsWithResponse]: true} = { compileOnSaveAffectedFileList: true, compileOnSaveEmitFile: true, completionEntryDetails: true, @@ -35,126 +37,148 @@ const commandWithResponseMap: {readonly [K in CommandArgResponseKeysWithArgs]: t navto: true, getApplicableRefactors: true, getEditsForRefactor: true, - ping: true, organizeImports: true, + signatureHelp: true, } const commandWithResponse = new Set(Object.keys(commandWithResponseMap)) +function isCommandWithResponse(command: AllTSClientCommands): command is CommandsWithResponse { + return commandWithResponse.has(command) +} + export class TypescriptServiceClient { /** Callbacks that are waiting for responses */ private readonly callbacks: Callbacks - private readonly emitter = new Emitter<{}, EventTypes>() + private readonly emitter = new Emitter< + { + restarted: void + }, + EventTypes + >() private seq = 0 - private readonly serverPromise: Promise - private running = false + private server?: ChildProcess private lastStderrOutput = "" - - constructor(public tsServerPath: string, public version: string) { - this.callbacks = new Callbacks(this.emitPendingRequests) - this.serverPromise = this.startServer() + private lastStartAttempt?: number + + // tslint:disable-next-line:member-ordering + public on = this.emitter.on.bind(this.emitter) + + constructor( + public tsServerPath: string, + public version: string, + private reportBusyWhile: ReportBusyWhile, + ) { + this.callbacks = new Callbacks(this.reportBusyWhile) + this.server = this.startServer() } - public async execute( + public async execute( command: T, - args: CommandArg, + ...args: CommandArg ): Promise> { - if (!this.running) { + if (!this.server) { throw new Error("Server is not running") } - return this.sendRequest(await this.serverPromise, command, args) + const req = { + seq: this.seq++, + command, + arguments: args[0], + } + + if (window.atom_typescript_debug) { + console.log("sending request", command, "with args", args) + } + + const result = isCommandWithResponse(command) + ? this.callbacks.add(req.seq, command) + : (undefined as CommandRes) + + try { + this.server.stdin.write(JSON.stringify(req) + "\n") + } catch (error) { + this.callbacks.error(req.seq, error as Error) + } + return result } - public on(name: T, listener: (result: EventTypes[T]) => void) { - return this.emitter.on(name, listener) + public async restartServer() { + if (this.server) { + this.lastStartAttempt = undefined // reset auto-restart loop guard + const server = this.server + const graceTimer = setTimeout(() => server.kill(), 10000) + await this.execute("exit") + clearTimeout(graceTimer) + } else { + this.server = this.startServer() + this.emitter.emit("restarted", undefined) + } } private startServer() { - return new Promise((resolve, reject) => { - this.running = true - if (window.atom_typescript_debug) { - console.log("starting", this.tsServerPath) - } - - const cp = startServer(this.tsServerPath) + if (window.atom_typescript_debug) { + console.log("starting", this.tsServerPath) + } - const h = this.exitHandler(reject) - if (!cp) { - h(new Error("ChildProcess failed to start")) - return - } + this.lastStartAttempt = Date.now() + const cp = startServer(this.tsServerPath) - cp.once("error", h) - cp.once("exit", (code: number | null, signal: string | null) => { - if (code !== null) h(new Error(`exited with code: ${code}`)) - else if (signal !== null) h(new Error(`terminated on signal: ${signal}`)) - }) + if (!cp) throw new Error("ChildProcess failed to start") - // Pipe both stdout and stderr appropriately - messageStream(cp.stdout).on("data", this.onMessage) - cp.stderr.on("data", data => { - console.warn("tsserver stderr:", (this.lastStderrOutput = data.toString())) - }) + const h = this.exitHandler + cp.once("error", h) + cp.once("exit", (code: number | null, signal: string | null) => { + if (code === 0) h(new Error("Server stopped normally"), false) + else if (code !== null) h(new Error(`exited with code: ${code}`)) + else if (signal !== null) h(new Error(`terminated on signal: ${signal}`)) + }) - this.sendRequest(cp, "ping", undefined).then(() => resolve(cp), () => resolve(cp)) + // Pipe both stdout and stderr appropriately + messageStream(cp.stdout).on("data", this.onMessage) + cp.stderr.on("data", data => { + console.warn("tsserver stderr:", (this.lastStderrOutput = data.toString())) }) + return cp } - private exitHandler = (reject: (err: Error) => void) => (err: Error) => { - console.error("tsserver: ", err) + private exitHandler = (err: Error, report = true) => { this.callbacks.rejectAll(err) - this.emitter.dispose() - reject(err) - this.running = false + if (report) console.error("tsserver: ", err) + this.server = undefined setImmediate(() => { - let detail = err.message - if (this.lastStderrOutput) { - detail = `Last output from tsserver:\n${this.lastStderrOutput}\n\n${detail}` + if (report) { + let detail = err.message + if (this.lastStderrOutput) { + detail = `Last output from tsserver:\n${this.lastStderrOutput}\n\n${detail}` + } + atom.notifications.addError("TypeScript quit unexpectedly", { + detail, + stack: err.stack, + dismissable: true, + }) + } + if (this.lastStartAttempt === undefined || Date.now() - this.lastStartAttempt > 5000) { + this.server = this.startServer() + this.emitter.emit("restarted", undefined) + } else { + atom.notifications.addWarning("Not restarting tsserver", { + detail: "Restarting too fast", + }) } - atom.notifications.addError("TypeScript quit unexpectedly", { - detail, - stack: err.stack, - dismissable: true, - }) }) } - private emitPendingRequests = (pending: string[]) => { - this.emitter.emit("pendingRequestsChange", pending) - } - private onMessage = (res: protocol.Response | protocol.Event) => { if (res.type === "response") this.onResponse(res) else this.onEvent(res) } private onResponse(res: protocol.Response) { - const req = this.callbacks.remove(res.request_seq) - if (req) { - if (window.atom_typescript_debug) { - console.log( - "received response for", - res.command, - "in", - Date.now() - req.started, - "ms", - "with data", - res.body, - ) - } - - if (res.success) { - req.resolve(res) - } else { - req.reject(new Error(res.message)) - } - } else { - console.warn("unexpected response:", res) - } + this.callbacks.resolve(res.request_seq, res) } private onEvent(res: protocol.Event) { @@ -165,46 +189,10 @@ export class TypescriptServiceClient { // tslint:disable-next-line:no-unsafe-any if (res.body) this.emitter.emit(res.event as keyof EventTypes, res.body) } - - private async sendRequest( - cp: ChildProcess, - command: T, - args: CommandArg, - ): Promise> { - const expectResponse = commandWithResponse.has(command) - const req = { - seq: this.seq++, - command, - arguments: args, - } - - if (window.atom_typescript_debug) { - console.log("sending request", command, "with args", args) - } - - setImmediate(() => { - try { - cp.stdin.write(JSON.stringify(req) + "\n") - } catch (error) { - const callback = this.callbacks.remove(req.seq) - if (callback) { - callback.reject(error as Error) - } else { - console.error(error) - } - } - }) - - if (expectResponse) { - return this.callbacks.add(req.seq, command) as CommandRes - } else { - return undefined as CommandRes - } - } } function startServer(tsServerPath: string): ChildProcess | undefined { - const locale = atom.config.get("atom-typescript.locale") + const locale = atom.config.get("atom-typescript").locale const tsServerArgs: string[] = locale ? ["--locale", locale] : [] if (INSPECT_TSSERVER) { return new BufferedProcess({ diff --git a/lib/client/clientResolver.ts b/lib/client/clientResolver.ts index 84a29a0f8..49c6067f9 100644 --- a/lib/client/clientResolver.ts +++ b/lib/client/clientResolver.ts @@ -1,14 +1,16 @@ -import {TypescriptServiceClient as Client} from "./client" +import {CompositeDisposable, Emitter} from "atom" +import * as fs from "fs" import * as path from "path" import * as Resolve from "resolve" import { + ConfigFileDiagnosticEventBody, Diagnostic, DiagnosticEventBody, - ConfigFileDiagnosticEventBody, } from "typescript/lib/protocol" -import {Emitter} from "atom" +import {ReportBusyWhile} from "../main/pluginManager" +import {TypescriptServiceClient as Client} from "./client" -type DiagnosticTypes = protocol.DiagnosticEventKind | "configFileDiag" +export type DiagnosticTypes = protocol.DiagnosticEventKind | "configFileDiag" interface DiagnosticsPayload { diagnostics: Diagnostic[] @@ -22,14 +24,8 @@ interface Binary { pathToBin: string } -interface ClientRec { - client: Client - pending: string[] -} - export interface EventTypes { diagnostics: DiagnosticsPayload - pendingRequestsChange: string[] } /** @@ -37,56 +33,68 @@ export interface EventTypes { * require("typescript") from the same source file would resolve. */ export class ClientResolver { - public clients = new Map() + private clients = new Map>() private emitter = new Emitter<{}, EventTypes>() - + private subscriptions = new CompositeDisposable() // This is just here so TypeScript can infer the types of the callbacks when using "on" method - public on(event: T, callback: (result: EventTypes[T]) => void) { - return this.emitter.on(event, callback) + // tslint:disable-next-line:member-ordering + public on = this.emitter.on.bind(this.emitter) + + constructor(private reportBusyWhile: ReportBusyWhile) {} + + public async restartAllServers() { + await Promise.all(Array.from(this.getAllClients()).map(client => client.restartServer())) } public async get(pFilePath: string): Promise { const {pathToBin, version} = await resolveBinary(pFilePath, "tsserver") + const tsconfigPath = await resolveTsConfig(pFilePath) - const clientRec = this.clients.get(pathToBin) - if (clientRec) return clientRec.client - - const newClientRec: ClientRec = { - client: new Client(pathToBin, version), - pending: [], - } - this.clients.set(pathToBin, newClientRec) - - newClientRec.client.on("pendingRequestsChange", pending => { - newClientRec.pending = pending - this.emitter.emit("pendingRequestsChange", pending) - }) - - const diagnosticHandler = (type: DiagnosticTypes) => ( - result: DiagnosticEventBody | ConfigFileDiagnosticEventBody, - ) => { - const filePath = isConfDiagBody(result) ? result.configFile : result.file - - if (filePath) { - this.emitter.emit("diagnostics", { - type, - serverPath: pathToBin, - filePath, - diagnostics: result.diagnostics, - }) - } + let tsconfigMap = this.clients.get(pathToBin) + if (!tsconfigMap) { + tsconfigMap = new Map() + this.clients.set(pathToBin, tsconfigMap) } + const client = tsconfigMap.get(tsconfigPath) + if (client) return client - newClientRec.client.on("configFileDiag", diagnosticHandler("configFileDiag")) - newClientRec.client.on("semanticDiag", diagnosticHandler("semanticDiag")) - newClientRec.client.on("syntaxDiag", diagnosticHandler("syntaxDiag")) - newClientRec.client.on("suggestionDiag", diagnosticHandler("suggestionDiag")) + const newClient = new Client(pathToBin, version, this.reportBusyWhile) + tsconfigMap.set(tsconfigPath, newClient) - return newClientRec.client + this.subscriptions.add( + newClient.on("configFileDiag", this.diagnosticHandler(pathToBin, "configFileDiag")), + newClient.on("semanticDiag", this.diagnosticHandler(pathToBin, "semanticDiag")), + newClient.on("syntaxDiag", this.diagnosticHandler(pathToBin, "syntaxDiag")), + newClient.on("suggestionDiag", this.diagnosticHandler(pathToBin, "suggestionDiag")), + ) + + return newClient } public dispose() { this.emitter.dispose() + this.subscriptions.dispose() + } + + private *getAllClients() { + for (const tsconfigMap of this.clients.values()) { + yield* tsconfigMap.values() + } + } + + private diagnosticHandler = (serverPath: string, type: DiagnosticTypes) => ( + result: DiagnosticEventBody | ConfigFileDiagnosticEventBody, + ) => { + const filePath = isConfDiagBody(result) ? result.configFile : result.file + + if (filePath) { + this.emitter.emit("diagnostics", { + type, + serverPath, + filePath, + diagnostics: result.diagnostics, + }) + } } } @@ -122,6 +130,24 @@ export async function resolveBinary(sourcePath: string, binName: string): Promis } } +async function fsexists(filePath: string): Promise { + return new Promise(resolve => { + fs.exists(filePath, resolve) + }) +} + +async function resolveTsConfig(sourcePath: string): Promise { + let parentDir = path.dirname(sourcePath) + let tsconfigPath = path.join(parentDir, "tsconfig.json") + while (!(await fsexists(tsconfigPath))) { + const oldParentDir = parentDir + parentDir = path.dirname(parentDir) + if (oldParentDir === parentDir) return undefined + tsconfigPath = path.join(parentDir, "tsconfig.json") + } + return tsconfigPath +} + function isConfDiagBody(body: any): body is ConfigFileDiagnosticEventBody { // tslint:disable-next-line:no-unsafe-any return body && body.triggerFile && body.configFile diff --git a/lib/client/commandArgsResponseMap.d.ts b/lib/client/commandArgsResponseMap.d.ts index 587681d98..27c240b1e 100644 --- a/lib/client/commandArgsResponseMap.d.ts +++ b/lib/client/commandArgsResponseMap.d.ts @@ -11,7 +11,7 @@ export interface CommandArgResponseMap { definition: (x: p.FileLocationRequestArgs) => p.DefinitionResponse format: (x: p.FormatRequestArgs) => p.FormatResponse getCodeFixes: (x: p.CodeFixRequestArgs) => p.GetCodeFixesResponse - getSupportedCodeFixes: (x: undefined) => p.GetSupportedCodeFixesResponse + getSupportedCodeFixes: () => p.GetSupportedCodeFixesResponse geterr: (x: p.GeterrRequestArgs) => void geterrForProject: (x: p.GeterrForProjectRequestArgs) => void occurrences: (x: p.FileLocationRequestArgs) => p.OccurrencesResponse @@ -24,16 +24,23 @@ export interface CommandArgResponseMap { saveto: (x: p.SavetoRequestArgs) => void navtree: (x: p.FileRequestArgs) => p.NavTreeResponse navto: (x: p.NavtoRequestArgs) => p.NavtoResponse - reloadProjects: (x: undefined) => void + reloadProjects: () => void getApplicableRefactors: ( x: p.GetApplicableRefactorsRequestArgs, ) => p.GetApplicableRefactorsResponse getEditsForRefactor: (x: p.GetEditsForRefactorRequestArgs) => p.GetEditsForRefactorResponse - ping: (x: undefined) => null organizeImports: (x: p.OrganizeImportsRequestArgs) => p.OrganizeImportsResponse + exit: () => void + signatureHelp: (x: p.SignatureHelpRequestArgs) => p.SignatureHelpResponse } -export type ArgType any> = T extends (x: infer U) => any ? U : never +export type AllTSClientCommands = keyof CommandArgResponseMap -export type CommandArg = ArgType -export type CommandRes = ReturnType +export type CommandsWithResponse = { + [K in AllTSClientCommands]: CommandRes extends void ? never : K +}[AllTSClientCommands] + +export type ArgType any> = T extends (...x: infer U) => any ? U : never + +export type CommandArg = ArgType +export type CommandRes = ReturnType diff --git a/lib/client/events.d.ts b/lib/client/events.d.ts index d89512465..efc9eb7be 100644 --- a/lib/client/events.d.ts +++ b/lib/client/events.d.ts @@ -1,6 +1,4 @@ import * as p from "typescript/lib/protocol" export type EventTypes = {[T in p.DiagnosticEventKind]: p.DiagnosticEventBody} & { - pendingRequestsChange: string[] -} & { configFileDiag: p.ConfigFileDiagnosticEventBody } diff --git a/lib/client/index.ts b/lib/client/index.ts new file mode 100644 index 000000000..2ca686685 --- /dev/null +++ b/lib/client/index.ts @@ -0,0 +1,7 @@ +export {ClientResolver, resolveBinary} from "./clientResolver" + +import {TypescriptServiceClient} from "./client" + +export {TypescriptServiceClient as TSClient} + +export type GetClientFunction = (filePath: string) => Promise diff --git a/lib/main/atom-ide/codeActionsProvider.ts b/lib/main/atom-ide/codeActionsProvider.ts new file mode 100644 index 000000000..c1c3b4ffe --- /dev/null +++ b/lib/main/atom-ide/codeActionsProvider.ts @@ -0,0 +1,25 @@ +import * as Atom from "atom" +import {CodeAction, CodeActionProvider} from "atom/ide" +import {Message} from "atom/linter" +import {CodefixProvider} from "../atom/codefix/codefixProvider" +import {typeScriptScopes} from "../atom/utils" + +export function getCodeActionsProvider(codefixProvider: CodefixProvider): CodeActionProvider { + return { + grammarScopes: typeScriptScopes(), + priority: 0, + async getCodeActions( + textEditor: Atom.TextEditor, + range: Atom.Range, + _diagnostics: Message[], + ): Promise { + return (await codefixProvider.runCodeFix(textEditor, range.start)).map(fix => ({ + getTitle: async () => fix.description, + dispose: () => {}, + apply: async () => { + await codefixProvider.applyFix(fix) + }, + })) + }, + } +} diff --git a/lib/main/atom-ide/codeHighlightProvider.ts b/lib/main/atom-ide/codeHighlightProvider.ts new file mode 100644 index 000000000..627336a09 --- /dev/null +++ b/lib/main/atom-ide/codeHighlightProvider.ts @@ -0,0 +1,24 @@ +import {CodeHighlightProvider} from "atom/ide" +import {GetClientFunction} from "../../client" +import { + getFilePathPosition, + isTypescriptEditorWithPath, + spanToRange, + typeScriptScopes, +} from "../atom/utils" + +export function getCodeHighlightProvider(getClient: GetClientFunction): CodeHighlightProvider { + return { + grammarScopes: typeScriptScopes(), + priority: 100, + async highlight(editor, position) { + if (!isTypescriptEditorWithPath(editor)) return + const location = getFilePathPosition(editor, position) + if (!location) return + const client = await getClient(location.file) + const result = await client.execute("occurrences", location) + if (!result.body) return + return result.body.map(spanToRange) + }, + } +} diff --git a/lib/main/atom-ide/datatipProvider.tsx b/lib/main/atom-ide/datatipProvider.tsx new file mode 100644 index 000000000..b338bfd14 --- /dev/null +++ b/lib/main/atom-ide/datatipProvider.tsx @@ -0,0 +1,118 @@ +import * as Atom from "atom" +import {Datatip, DatatipProvider} from "atom/ide" +import {GetClientFunction} from "../../client" +import {locationToPoint, typeScriptScopes} from "../atom/utils" + +// Note: a horrible hack to avoid dependency on React +const REACT_ELEMENT_SYMBOL = Symbol.for("react.element") +const etch = { + dom(type: string, props: any, ...children: any[]): any { + if (children.length > 0) { + return { + $$typeof: REACT_ELEMENT_SYMBOL, + type, + ref: null, + props: {...props, children}, + } + } else { + return { + $$typeof: REACT_ELEMENT_SYMBOL, + type, + ref: null, + props: {...props}, + } + } + }, +} + +export class TSDatatipProvider implements DatatipProvider { + public readonly providerName = "TypeScript type tooltips" + public readonly priority = 100 + public readonly grammarScopes = typeScriptScopes() + + constructor(private getClient: GetClientFunction) {} + + public async datatip( + editor: Atom.TextEditor, + bufferPt: Atom.Point, + ): Promise { + try { + const filePath = editor.getPath() + if (filePath === undefined) return + const client = await this.getClient(filePath) + const result = await client.execute("quickinfo", { + file: filePath, + line: bufferPt.row + 1, + offset: bufferPt.column + 1, + }) + const data = result.body! + const code = await highlightCode(data.displayString.replace(/^\(.+?\)\s+/, "")) + const kind = ( +
+ {data.kind} + {data.kindModifiers ? ({data.kindModifiers}) : null} +
+ ) + const docs =
{data.documentation}
+ return { + component: () => ( +
+ {code} + {kind} + {docs} +
+ ), + range: Atom.Range.fromObject([locationToPoint(data.start), locationToPoint(data.end)]), + } + } catch (e) { + return + } + } +} + +async function highlightCode(code: string) { + const fontFamily = atom.config.get("editor.fontFamily") + + const ed = new Atom.TextEditor({ + readonly: true, + keyboardInputEnabled: false, + showInvisibles: false, + tabLength: atom.config.get("editor.tabLength"), + }) + const el = atom.views.getView(ed) + try { + el.setUpdatedSynchronously(true) + el.style.pointerEvents = "none" + el.style.position = "absolute" + el.style.width = "0px" + el.style.height = "1px" + atom.views.getView(atom.workspace).appendChild(el) + atom.grammars.assignLanguageMode(ed.getBuffer(), "source.ts") + ed.setText(code.replace(/\r?\n$/, "")) + await editorTokenized(ed) + const html = Array.from(el.querySelectorAll(".line:not(.dummy)")) + return ( +
x.innerHTML).join("\n")}} + /> + ) + } finally { + el.remove() + } +} + +async function editorTokenized(editor: Atom.TextEditor) { + return new Promise(resolve => { + if (editor.getBuffer().getLanguageMode().fullyTokenized) { + resolve() + } else { + const disp = editor.onDidTokenize(() => { + disp.dispose() + resolve() + }) + } + }) +} diff --git a/lib/main/atom-ide/definitionsProvider.ts b/lib/main/atom-ide/definitionsProvider.ts new file mode 100644 index 000000000..36740d714 --- /dev/null +++ b/lib/main/atom-ide/definitionsProvider.ts @@ -0,0 +1,41 @@ +import {Definition, DefinitionProvider} from "atom/ide" +import {FileSpan} from "typescript/lib/protocol" +import {GetClientFunction} from "../../client" +import { + getFilePathPosition, + isTypescriptEditorWithPath, + spanToRange, + typeScriptScopes, +} from "../atom/utils" + +export function getDefinitionProvider(getClient: GetClientFunction): DefinitionProvider { + return { + priority: 0, + grammarScopes: typeScriptScopes(), + wordRegExp: /([A-Za-z0-9_])+|['"`](\\.|[^'"`\\\\])*['"`]/g, + async getDefinition(editor, position) { + if (!isTypescriptEditorWithPath(editor)) return + const location = getFilePathPosition(editor, position) + if (!location) return + const client = await getClient(location.file) + const result = await client.execute("definition", location) + if (!result.body) return + if (result.body.length === 0) return + + return { + queryRange: undefined, + definitions: result.body.map(fileSpanToDefinition), + } + }, + } +} + +function fileSpanToDefinition(span: FileSpan): Definition { + const range = spanToRange(span) + return { + path: span.file, + position: range.start, + range, + language: "TypeScript", + } +} diff --git a/lib/main/atom-ide/findReferencesProvider.ts b/lib/main/atom-ide/findReferencesProvider.ts new file mode 100644 index 000000000..64278bb40 --- /dev/null +++ b/lib/main/atom-ide/findReferencesProvider.ts @@ -0,0 +1,33 @@ +import {FindReferencesProvider, Reference} from "atom/ide" +import {GetClientFunction} from "../../client" +import {getFilePathPosition, isTypescriptEditorWithPath, locationsToRange} from "../atom/utils" + +export function getFindReferencesProvider(getClient: GetClientFunction): FindReferencesProvider { + return { + async isEditorSupported(editor) { + return isTypescriptEditorWithPath(editor) + }, + async findReferences(editor, position) { + const location = getFilePathPosition(editor, position) + if (!location) return + + const client = await getClient(location.file) + const result = await client.execute("references", location) + if (!result.body) return + return { + type: "data", + baseUri: location.file, + referencedSymbolName: result.body.symbolDisplayString, + references: result.body.refs.map(refTsToIde), + } + }, + } +} + +function refTsToIde(ref: protocol.ReferencesResponseItem): Reference { + return { + uri: ref.file, + range: locationsToRange(ref.start, ref.end), + name: undefined, + } +} diff --git a/lib/main/atom-ide/hyperclickProvider.ts b/lib/main/atom-ide/hyperclickProvider.ts new file mode 100644 index 000000000..717a71f72 --- /dev/null +++ b/lib/main/atom-ide/hyperclickProvider.ts @@ -0,0 +1,36 @@ +import * as Atom from "atom" +import {HyperclickProvider} from "atom/ide" +import {GetClientFunction} from "../../client" +import {handleDefinitionResult} from "../atom/commands/goToDeclaration" +import {Dependencies} from "../atom/commands/registry" +import {isTypescriptEditorWithPath} from "../atom/utils" + +export function getHyperclickProvider( + getClient: GetClientFunction, + histGoForward: Dependencies["histGoForward"], +): HyperclickProvider { + return { + priority: 0, + providerName: "typescript-hyperclick-provider", + wordRegExp: /([A-Za-z0-9_])+|['"`](\\.|[^'"`\\\\])*['"`]/g, + async getSuggestionForWord(editor: Atom.TextEditor, _text: string, range: Atom.Range) { + if (!isTypescriptEditorWithPath(editor)) return + const filePath = editor.getPath() + if (filePath === undefined) return + + return { + range, + callback: async () => { + const location = { + file: filePath, + line: range.start.row + 1, + offset: range.start.column + 1, + } + const client = await getClient(location.file) + const result = await client.execute("definition", location) + await handleDefinitionResult(result, editor, histGoForward) + }, + } + }, + } +} diff --git a/lib/main/atom-ide/outlineProvider.ts b/lib/main/atom-ide/outlineProvider.ts new file mode 100644 index 000000000..032a231f2 --- /dev/null +++ b/lib/main/atom-ide/outlineProvider.ts @@ -0,0 +1,91 @@ +import {OutlineProvider, OutlineTree, OutlineTreeKind} from "atom/ide" +import {NavigationTree, ScriptElementKind} from "typescript/lib/protocol" +import {GetClientFunction} from "../../client" +import {spanToRange, typeScriptScopes} from "../atom/utils" + +export function getOutlineProvider(getClient: GetClientFunction): OutlineProvider { + return { + name: "Atom-TypeScript", + grammarScopes: typeScriptScopes(), + priority: 100, + updateOnEdit: true, + async getOutline(editor) { + const filePath = editor.getPath() + if (filePath === undefined) return + const client = await getClient(filePath) + const navTreeResult = await client.execute("navtree", {file: filePath}) + const navTree = navTreeResult.body + if (!navTree) return + return {outlineTrees: [navTreeToOutline(navTree)]} + }, + } +} + +function navTreeToOutline(navTree: NavigationTree): OutlineTree { + const ranges = navTree.spans.map(spanToRange) + const range = ranges.reduce((prev, cur) => cur.union(prev)) + return { + kind: kindMap[navTree.kind], + plainText: navTree.text, + startPosition: range.start, + endPosition: range.end, + landingPosition: navTree.nameSpan ? spanToRange(navTree.nameSpan).start : undefined, + children: navTree.childItems ? navTree.childItems.map(navTreeToOutline) : [], + } +} + +const kindMap: {[key in ScriptElementKind]: OutlineTreeKind | undefined} = { + // | "file" + directory: "file", + // | "module" + module: "module", + "external module name": "module", + // | "namespace" + // | "package" + // | "class" + class: "class", + "local class": "class", + // | "method" + method: "method", + // | "property" + property: "property", + getter: "property", + setter: "property", + // | "field" + "JSX attribute": "field", + // | "constructor" + constructor: "constructor", + // | "enum" + enum: "enum", + // | "interface" + interface: "interface", + type: "interface", + // | "function" + function: "function", + "local function": "function", + // | "variable" + label: "variable", + alias: "variable", + var: "variable", + let: "variable", + "local var": "variable", + parameter: "variable", + // | "constant" + "enum member": "constant", + const: "constant", + // | "string" + string: "string", + // | "number" + // | "boolean" + // | "array" + // ??? + "": undefined, + warning: undefined, + keyword: undefined, + script: undefined, + call: undefined, + index: undefined, + construct: undefined, + "type parameter": undefined, + "primitive type": undefined, +} diff --git a/lib/main/atom-ide/sigHelpProvider.ts b/lib/main/atom-ide/sigHelpProvider.ts new file mode 100644 index 000000000..5d8449714 --- /dev/null +++ b/lib/main/atom-ide/sigHelpProvider.ts @@ -0,0 +1,42 @@ +import {Point, TextEditor} from "atom" +import {SignatureHelp, SignatureHelpProvider} from "atom/ide" +import {GetClientFunction} from "../../client" +import {signatureHelpItemToSignature, typeScriptScopes} from "../atom/utils" +import {FlushTypescriptBuffer} from "../pluginManager" + +export class TSSigHelpProvider implements SignatureHelpProvider { + public triggerCharacters = new Set(["(", ","]) + public grammarScopes = typeScriptScopes() + public priority = 100 + + constructor( + private getClient: GetClientFunction, + private flushTypescriptBuffer: FlushTypescriptBuffer, + ) {} + + public async getSignatureHelp( + editor: TextEditor, + pos: Point, + ): Promise { + try { + const filePath = editor.getPath() + if (filePath === undefined) return + const client = await this.getClient(filePath) + await this.flushTypescriptBuffer(filePath) + const result = await client.execute("signatureHelp", { + file: filePath, + line: pos.row + 1, + offset: pos.column + 1, + }) + const data = result.body! + const signatures = data.items.map(signatureHelpItemToSignature) + return { + signatures, + activeParameter: data.argumentIndex, + activeSignature: data.selectedItemIndex, + } + } catch (e) { + return + } + } +} diff --git a/lib/main/atom/autoCompleteProvider.ts b/lib/main/atom/autoCompleteProvider.ts index bd36f8e32..90a524bc2 100644 --- a/lib/main/atom/autoCompleteProvider.ts +++ b/lib/main/atom/autoCompleteProvider.ts @@ -1,11 +1,10 @@ // more: https://github.com/atom-community/autocomplete-plus/wiki/Provider-API -import {ClientResolver} from "../../client/clientResolver" -import {FileLocationQuery, typeScriptScopes, spanToRange} from "./utils" -import * as ACP from "atom/autocomplete-plus" -import {TypescriptServiceClient} from "../../client/client" import * as Atom from "atom" +import * as ACP from "atom/autocomplete-plus" import * as fuzzaldrin from "fuzzaldrin" -import {WithTypescriptBuffer} from "../pluginManager" +import {GetClientFunction, TSClient} from "../../client" +import {FlushTypescriptBuffer} from "../pluginManager" +import {FileLocationQuery, spanToRange, typeScriptScopes} from "./utils" const importPathScopes = ["meta.import", "meta.import-equals", "triple-slash-directive"] @@ -14,10 +13,6 @@ type SuggestionWithDetails = ACP.TextSuggestion & { replacementRange?: Atom.Range } -interface Options { - withTypescriptBuffer: WithTypescriptBuffer -} - export class AutocompleteProvider implements ACP.AutocompleteProvider { public selector = typeScriptScopes() .map(x => (x.includes(".") ? `.${x}` : x)) @@ -26,13 +21,12 @@ export class AutocompleteProvider implements ACP.AutocompleteProvider { public disableForSelector = ".comment" public inclusionPriority = 3 - public suggestionPriority = atom.config.get("atom-typescript.autocompletionSuggestionPriority") + public suggestionPriority = atom.config.get("atom-typescript").autocompletionSuggestionPriority public excludeLowerPriority = false - private clientResolver: ClientResolver private lastSuggestions?: { // Client used to get the suggestions - client: TypescriptServiceClient + client: TSClient // File and position for the suggestions location: FileLocationQuery @@ -44,12 +38,10 @@ export class AutocompleteProvider implements ACP.AutocompleteProvider { suggestions: SuggestionWithDetails[] } - private opts: Options - - constructor(clientResolver: ClientResolver, opts: Options) { - this.clientResolver = clientResolver - this.opts = opts - } + constructor( + private getClient: GetClientFunction, + private flushTypescriptBuffer: FlushTypescriptBuffer, + ) {} public async getSuggestions(opts: ACP.SuggestionsRequestedEvent): Promise { const location = getLocationQuery(opts) @@ -85,9 +77,7 @@ export class AutocompleteProvider implements ACP.AutocompleteProvider { } // Flush any pending changes for this buffer to get up to date completions - await this.opts.withTypescriptBuffer(location.file, async buffer => { - await buffer.flush() - }) + await this.flushTypescriptBuffer(location.file) try { let suggestions = await this.getSuggestionsWithCache(prefix, location, opts.activatedManually) @@ -164,7 +154,7 @@ export class AutocompleteProvider implements ACP.AutocompleteProvider { } } - const client = await this.clientResolver.get(location.file) + const client = await this.getClient(location.file) const completions = await client.execute("completions", { prefix, includeExternalModuleExports: false, @@ -245,35 +235,61 @@ function completionEntryToSuggestion(entry: protocol.CompletionEntry): Suggestio text: entry.insertText !== undefined ? entry.insertText : entry.name, leftLabel: entry.kind, replacementRange: entry.replacementSpan ? spanToRange(entry.replacementSpan) : undefined, - type: kindToType(entry.kind), + type: kindMap[entry.kind], } } -/** See types : +/** From : * https://github.com/atom-community/autocomplete-plus/pull/334#issuecomment-85697409 */ -export function kindToType(kind: string) { - // variable, constant, property, value, method, function, class, type, keyword, tag, snippet, import, require - switch (kind) { - case "const": - return "constant" - case "interface": - return "type" - case "identifier": - return "variable" - case "local function": - return "function" - case "local var": - return "variable" - case "let": - case "var": - case "parameter": - return "variable" - case "alias": - return "import" - case "type parameter": - return "type" - default: - return kind.split(" ")[0] - } +type ACPCompletionType = + | "variable" + | "constant" + | "property" + | "value" + | "method" + | "function" + | "class" + | "type" + | "keyword" + | "tag" + | "import" + | "require" + | "snippet" + +const kindMap: {[key in protocol.ScriptElementKind]: ACPCompletionType | undefined} = { + directory: "require", + module: "import", + "external module name": "import", + class: "class", + "local class": "class", + method: "method", + property: "property", + getter: "property", + setter: "property", + "JSX attribute": "property", + constructor: "method", + enum: "type", + interface: "type", + type: "type", + "type parameter": "type", + "primitive type": "type", + function: "function", + "local function": "function", + label: "variable", + alias: "import", + var: "variable", + let: "variable", + "local var": "variable", + parameter: "variable", + "enum member": "constant", + const: "constant", + string: "value", + keyword: "keyword", + "": undefined, + warning: undefined, + script: undefined, + call: undefined, + index: undefined, + construct: undefined, } diff --git a/lib/main/atom/codefix/codeActionsProvider.ts b/lib/main/atom/codefix/codeActionsProvider.ts deleted file mode 100644 index 5d4b0429b..000000000 --- a/lib/main/atom/codefix/codeActionsProvider.ts +++ /dev/null @@ -1,46 +0,0 @@ -import * as Atom from "atom" -import {CodefixProvider} from "./codefixProvider" -import {typeScriptScopes} from "../utils" - -export interface Message { - filePath: string - range?: Atom.Range - // this interface is rater obviously incomplete -} - -export interface CodeAction { - apply(): Promise - getTitle(): Promise - dispose(): void -} - -export interface CodeActionProvider { - grammarScopes: ReadonlyArray - priority: number - getCodeActions( - editor: Atom.TextEditor, - range: Atom.Range, - diagnostics: Message[], - ): Promise -} - -export class CodeActionsProvider implements CodeActionProvider { - public grammarScopes = typeScriptScopes() - public priority = 0 - - constructor(private codefixProvider: CodefixProvider) {} - - public async getCodeActions( - textEditor: Atom.TextEditor, - range: Atom.Range, - _diagnostics: Message[], - ): Promise { - return (await this.codefixProvider.runCodeFix(textEditor, range.start)).map(fix => ({ - getTitle: async () => fix.description, - dispose: () => {}, - apply: async () => { - await this.codefixProvider.applyFix(fix) - }, - })) - } -} diff --git a/lib/main/atom/codefix/codefixProvider.ts b/lib/main/atom/codefix/codefixProvider.ts index c09078edd..b8b4b918b 100644 --- a/lib/main/atom/codefix/codefixProvider.ts +++ b/lib/main/atom/codefix/codefixProvider.ts @@ -1,12 +1,11 @@ import * as Atom from "atom" -import {ClientResolver} from "../../../client/clientResolver" +import {ClientResolver, TSClient} from "../../../client" import {ErrorPusher} from "../../errorPusher" -import {pointToLocation} from "../utils" -import {TypescriptServiceClient} from "../../../client/client" import {ApplyEdits} from "../../pluginManager" +import {spanToRange} from "../utils" export class CodefixProvider { - private supportedFixes: WeakMap> = new WeakMap() + private supportedFixes: WeakMap> = new WeakMap() constructor( private clientResolver: ClientResolver, @@ -14,9 +13,23 @@ export class CodefixProvider { private applyEdits: ApplyEdits, ) {} + public async getFixableRanges(textEditor: Atom.TextEditor, range: Atom.Range) { + const filePath = textEditor.getPath() + if (filePath === undefined) return [] + const errors = this.errorPusher.getErrorsInRange(filePath, range) + const client = await this.clientResolver.get(filePath) + const supportedCodes = await this.getSupportedFixes(client) + + const ranges = Array.from(errors) + .filter(error => error.code !== undefined && supportedCodes.has(error.code)) + .map(error => spanToRange(error)) + + return ranges + } + public async runCodeFix( textEditor: Atom.TextEditor, - bufferPosition: Atom.PointLike, + bufferPosition: Atom.Point, ): Promise { const filePath = textEditor.getPath() @@ -25,8 +38,7 @@ export class CodefixProvider { const client = await this.clientResolver.get(filePath) const supportedCodes = await this.getSupportedFixes(client) - const requests = this.errorPusher - .getErrorsAt(filePath, pointToLocation(bufferPosition)) + const requests = Array.from(this.errorPusher.getErrorsAt(filePath, bufferPosition)) .filter(error => error.code !== undefined && supportedCodes.has(error.code)) .map(error => client.execute("getCodeFixes", { @@ -61,13 +73,13 @@ export class CodefixProvider { // NOOP } - private async getSupportedFixes(client: TypescriptServiceClient) { + private async getSupportedFixes(client: TSClient) { let codes = this.supportedFixes.get(client) if (codes) { return codes } - const result = await client.execute("getSupportedCodeFixes", undefined) + const result = await client.execute("getSupportedCodeFixes") if (!result.body) { throw new Error("No code fixes are supported") diff --git a/lib/main/atom/codefix/index.ts b/lib/main/atom/codefix/index.ts index e0ffa8b5d..e61327805 100644 --- a/lib/main/atom/codefix/index.ts +++ b/lib/main/atom/codefix/index.ts @@ -1,3 +1 @@ -export {CodeActionsProvider} from "./codeActionsProvider" -export {IntentionsProvider} from "./intentionsProvider" export {CodefixProvider} from "./codefixProvider" diff --git a/lib/main/atom/codefix/intentionsProvider.ts b/lib/main/atom/codefix/intentionsProvider.ts index 6f26e765e..d483bbdf8 100644 --- a/lib/main/atom/codefix/intentionsProvider.ts +++ b/lib/main/atom/codefix/intentionsProvider.ts @@ -1,4 +1,5 @@ import * as Atom from "atom" +import {handlePromise} from "../../../utils" import {CodefixProvider} from "./codefixProvider" interface Intention { @@ -9,31 +10,69 @@ interface Intention { selected: () => void } +interface IntentionHighlight { + range: Atom.Range + created: (args: CreatedCallbackArgs) => void +} + +interface CreatedCallbackArgs { + textEditor: Atom.TextEditor + element: HTMLElement + marker: Atom.DisplayMarker + matchedText: string +} + interface IntentionsProviderInterface { grammarScopes: string[] getIntentions: (opts: GetIntentionsOptions) => Intention[] | Promise } +interface IntentionsHighlightsProviderInterface { + grammarScopes: string[] + getIntentions: ( + opts: GetIntentionsHighlightsOptions, + ) => IntentionHighlight[] | Promise +} + interface GetIntentionsOptions { bufferPosition: Atom.Point textEditor: Atom.TextEditor } -export class IntentionsProvider implements IntentionsProviderInterface { - public grammarScopes = ["*"] +interface GetIntentionsHighlightsOptions { + visibleRange: Atom.Range + textEditor: Atom.TextEditor +} - constructor(private codefixProvider: CodefixProvider) {} +export function getIntentionsProvider( + codefixProvider: CodefixProvider, +): IntentionsProviderInterface { + return { + grammarScopes: ["*"], + async getIntentions({bufferPosition, textEditor}) { + return (await codefixProvider.runCodeFix(textEditor, bufferPosition)).map(fix => ({ + priority: 100, + title: fix.description, + selected: () => { + handlePromise(codefixProvider.applyFix(fix)) + }, + })) + }, + } +} - public async getIntentions({ - bufferPosition, - textEditor, - }: GetIntentionsOptions): Promise { - return (await this.codefixProvider.runCodeFix(textEditor, bufferPosition)).map(fix => ({ - priority: 100, - title: fix.description, - selected: () => { - this.codefixProvider.applyFix(fix) - }, - })) +export function getIntentionsHighlightsProvider( + codefixProvider: CodefixProvider, +): IntentionsHighlightsProviderInterface { + return { + grammarScopes: ["*"], + async getIntentions({visibleRange, textEditor}) { + return (await codefixProvider.getFixableRanges(textEditor, visibleRange)).map(range => ({ + range, + created: (_opts: CreatedCallbackArgs) => { + // NOOP + }, + })) + }, } } diff --git a/lib/main/atom/commands/build.ts b/lib/main/atom/commands/build.ts index 0af4b8197..5d0fb36be 100644 --- a/lib/main/atom/commands/build.ts +++ b/lib/main/atom/commands/build.ts @@ -7,6 +7,8 @@ addCommand("atom-text-editor", "typescript:build", deps => ({ if (file === undefined) return const client = await deps.getClient(file) + deps.reportBuildStatus(undefined) + const projectInfo = await client.execute("projectInfo", { file, needFileNameList: true, @@ -15,11 +17,10 @@ addCommand("atom-text-editor", "typescript:build", deps => ({ const files = new Set(projectInfo.body!.fileNames) files.delete(projectInfo.body!.configFileName) let filesSoFar = 0 - const stp = deps.getStatusPanel() const promises = [...files.values()].map(f => _finally(client.execute("compileOnSaveEmitFile", {file: f, forced: true}), () => { - stp.update({progress: {max: files.size, value: (filesSoFar += 1)}}) - if (files.size <= filesSoFar) stp.update({progress: undefined}) + filesSoFar += 1 + deps.reportProgress({max: files.size, value: filesSoFar}) }), ) @@ -28,11 +29,11 @@ addCommand("atom-text-editor", "typescript:build", deps => ({ if (results.some(result => result.body === false)) { throw new Error("Emit failed") } - stp.update({buildStatus: {success: true}}) + deps.reportBuildStatus({success: true}) } catch (error) { const err = error as Error console.error(err) - stp.update({buildStatus: {success: false, message: err.message}}) + deps.reportBuildStatus({success: false, message: err.message}) } }, })) diff --git a/lib/main/atom/commands/checkAllFiles.ts b/lib/main/atom/commands/checkAllFiles.ts index fc65066c0..0d5e88941 100644 --- a/lib/main/atom/commands/checkAllFiles.ts +++ b/lib/main/atom/commands/checkAllFiles.ts @@ -23,16 +23,14 @@ addCommand("atom-text-editor", "typescript:check-all-files", deps => ({ const disp = client.on("syntaxDiag", evt => { if (cancelTimeout !== undefined) window.clearTimeout(cancelTimeout) - cancelTimeout = window.setTimeout(cancel, 500) + cancelTimeout = window.setTimeout(cancel, 2000) files.delete(evt.file) updateStatus() }) - const stp = deps.getStatusPanel() - - stp.update({progress: {max, value: 0}}) - client.execute("geterrForProject", {file, delay: 0}) + deps.reportProgress({max, value: 0}) + await client.execute("geterrForProject", {file, delay: 0}) function cancel() { files.clear() @@ -40,12 +38,8 @@ addCommand("atom-text-editor", "typescript:check-all-files", deps => ({ } function updateStatus() { - if (files.size === 0) { - disp.dispose() - stp.update({progress: undefined}) - } else { - stp.update({progress: {max, value: max - files.size}}) - } + if (files.size === 0) disp.dispose() + deps.reportProgress({max, value: max - files.size}) } }, })) diff --git a/lib/main/atom/commands/clearErrors.ts b/lib/main/atom/commands/clearErrors.ts index 243d21563..b0afce891 100644 --- a/lib/main/atom/commands/clearErrors.ts +++ b/lib/main/atom/commands/clearErrors.ts @@ -6,13 +6,3 @@ addCommand("atom-workspace", "typescript:clear-errors", deps => ({ deps.clearErrors() }, })) - -addCommand("atom-text-editor", "typescript:reload-projects", deps => ({ - description: "Reload projects", - async didDispatch(editor) { - const path = editor.getPath() - if (path === undefined) return - const client = await deps.getClient(path) - client.execute("reloadProjects", undefined) - }, -})) diff --git a/lib/main/atom/commands/findReferences.tsx b/lib/main/atom/commands/findReferences.tsx index af155ef08..843417dd4 100644 --- a/lib/main/atom/commands/findReferences.tsx +++ b/lib/main/atom/commands/findReferences.tsx @@ -1,9 +1,9 @@ -import {addCommand} from "./registry" -import {getFilePathPosition} from "../utils" -import {selectListView} from "../views/simpleSelectionView" import * as etch from "etch" import {TsView} from "../components/tsView" +import {getFilePathPosition} from "../utils" import {HighlightComponent} from "../views/highlightComponent" +import {selectListView} from "../views/simpleSelectionView" +import {addCommand} from "./registry" addCommand("atom-text-editor", "typescript:find-references", deps => ({ description: "Find where symbol under text cursor is referenced", @@ -30,6 +30,6 @@ addCommand("atom-text-editor", "typescript:find-references", deps => ({ }, itemFilterKey: "file", }) - if (res) deps.getEditorPositionHistoryManager().goForward(editor, res) + if (res) await deps.histGoForward(editor, res) }, })) diff --git a/lib/main/atom/commands/formatCode.ts b/lib/main/atom/commands/formatCode.ts index f83f4cab8..6ed224548 100644 --- a/lib/main/atom/commands/formatCode.ts +++ b/lib/main/atom/commands/formatCode.ts @@ -1,6 +1,6 @@ -import {addCommand} from "./registry" -import {CodeEdit, LocationRangeQuery, rangeToLocationRange, spanToRange} from "../utils" import {TextEditor} from "atom" +import {CodeEdit, LocationRangeQuery, rangeToLocationRange, spanToRange} from "../utils" +import {addCommand} from "./registry" addCommand("atom-text-editor", "typescript:format-code", deps => ({ description: "Format code in currently active text editor", diff --git a/lib/main/atom/commands/goToDeclaration.tsx b/lib/main/atom/commands/goToDeclaration.tsx index 54edd05e6..416285d20 100644 --- a/lib/main/atom/commands/goToDeclaration.tsx +++ b/lib/main/atom/commands/goToDeclaration.tsx @@ -1,10 +1,9 @@ -import {addCommand} from "./registry" -import {getFilePathPosition} from "../utils" -import {selectListView} from "../views/simpleSelectionView" +import {TextEditor} from "atom" import * as etch from "etch" +import {getFilePathPosition} from "../utils" import {HighlightComponent} from "../views/highlightComponent" -import {TextEditor} from "atom" -import {EditorPositionHistoryManager} from "../editorPositionHistoryManager" +import {selectListView} from "../views/simpleSelectionView" +import {addCommand, Dependencies} from "./registry" addCommand("atom-text-editor", "typescript:go-to-declaration", deps => ({ description: "Go to declaration of symbol under text cursor", @@ -14,14 +13,14 @@ addCommand("atom-text-editor", "typescript:go-to-declaration", deps => ({ const client = await deps.getClient(location.file) const result = await client.execute("definition", location) - handleDefinitionResult(result, editor, deps.getEditorPositionHistoryManager()) + await handleDefinitionResult(result, editor, deps.histGoForward) }, })) export async function handleDefinitionResult( result: protocol.DefinitionResponse, editor: TextEditor, - hist: EditorPositionHistoryManager, + histGoForward: Dependencies["histGoForward"], ): Promise { if (!result.body) { return @@ -38,8 +37,8 @@ export async function handleDefinitionResult( }, itemFilterKey: "file", }) - if (res) hist.goForward(editor, res) + if (res) await histGoForward(editor, res) } else if (result.body.length > 0) { - hist.goForward(editor, result.body[0]) + await histGoForward(editor, result.body[0]) } } diff --git a/lib/main/atom/commands/hideSigHelp.ts b/lib/main/atom/commands/hideSigHelp.ts new file mode 100644 index 000000000..8532072b1 --- /dev/null +++ b/lib/main/atom/commands/hideSigHelp.ts @@ -0,0 +1,8 @@ +import {addCommand} from "./registry" + +addCommand("atom-text-editor", "typescript:hide-signature-help", deps => ({ + description: "Hide the currently visible signature help", + async didDispatch(ed, ignore) { + if (!deps.hideSigHelpAt(ed)) ignore() + }, +})) diff --git a/lib/main/atom/commands/index.ts b/lib/main/atom/commands/index.ts index ebf5394bd..e36674831 100644 --- a/lib/main/atom/commands/index.ts +++ b/lib/main/atom/commands/index.ts @@ -1,24 +1,28 @@ -import {getCommands, Dependencies} from "./registry" -import {CompositeDisposable} from "atom" +import {CompositeDisposable, DisposableLike} from "atom" import {isTypescriptEditorWithPath, isTypescriptGrammar} from "../utils" +import {Dependencies, getCommands} from "./registry" // Import all of the command files for their side effects import "./build" import "./checkAllFiles" import "./clearErrors" -import "./formatCode" import "./findReferences" +import "./formatCode" import "./goToDeclaration" -import "./returnFromDeclaration" -import "./renameRefactor" -import "./showTooltip" +import "./hideSigHelp" import "./initializeConfig" +import "./organizeImports" +import "./refactorCode" +import "./reloadProjects" +import "./renameRefactor" +import "./restartAllServers" +import "./returnFromDeclaration" import "./semanticView" +import "./showSigHelp" +import "./showTooltip" import "./symbolsView" -import "./refactorCode" -import "./organizeImports" -export function registerCommands(deps: Dependencies) { +export function registerCommands(deps: Dependencies): DisposableLike { const disp = new CompositeDisposable() for (const cmd of getCommands()) { if (cmd.selector === "atom-text-editor") { @@ -54,16 +58,18 @@ export function registerCommands(deps: Dependencies) { ) } else { const d = cmd.desc(deps) - atom.commands.add(cmd.selector, cmd.command, { - ...d, - async didDispatch() { - try { - await d.didDispatch() - } catch (error) { - handle(error as Error) - } - }, - }) + disp.add( + atom.commands.add(cmd.selector, cmd.command, { + ...d, + async didDispatch() { + try { + await d.didDispatch() + } catch (error) { + handle(error as Error) + } + }, + }), + ) } } return disp diff --git a/lib/main/atom/commands/initializeConfig.ts b/lib/main/atom/commands/initializeConfig.ts index ca7256f0b..adb7a4e89 100644 --- a/lib/main/atom/commands/initializeConfig.ts +++ b/lib/main/atom/commands/initializeConfig.ts @@ -1,6 +1,6 @@ -import {addCommand} from "./registry" -import {resolveBinary} from "../../../client/clientResolver" import {BufferedNodeProcess} from "atom" +import {resolveBinary} from "../../../client" +import {addCommand} from "./registry" addCommand("atom-text-editor", "typescript:initialize-config", () => ({ description: "Create tsconfig.json in the project related to currently-active text edtior", @@ -24,21 +24,26 @@ addCommand("atom-text-editor", "typescript:initialize-config", () => ({ }, })) -function initConfig(tsc: string, projectRoot: string): Promise { - return new Promise((resolve, reject) => { - try { - const bnp = new BufferedNodeProcess({ - command: tsc, - args: ["--init"], - options: {cwd: projectRoot}, - exit: code => { - if (code === 0) resolve() - else reject(new Error(`Tsc ended with nonzero exit code ${code}`)) - }, - }) - bnp.onWillThrowError(reject) - } catch (e) { - reject(e) - } - }) +async function initConfig(tsc: string, projectRoot: string): Promise { + let disp: {dispose: () => void} | undefined + try { + return await new Promise((resolve, reject) => { + try { + const bnp = new BufferedNodeProcess({ + command: tsc, + args: ["--init"], + options: {cwd: projectRoot}, + exit: code => { + if (code === 0) resolve() + else reject(new Error(`Tsc ended with nonzero exit code ${code}`)) + }, + }) + disp = bnp.onWillThrowError(reject) + } catch (e) { + reject(e) + } + }) + } finally { + if (disp) disp.dispose() + } } diff --git a/lib/main/atom/commands/refactorCode.tsx b/lib/main/atom/commands/refactorCode.tsx index efaf4e834..e848d7056 100644 --- a/lib/main/atom/commands/refactorCode.tsx +++ b/lib/main/atom/commands/refactorCode.tsx @@ -1,10 +1,10 @@ -import {addCommand, Dependencies} from "./registry" -import {getFilePathPosition} from "../utils" -import {selectListView} from "../views/simpleSelectionView" import * as etch from "etch" -import {HighlightComponent} from "../views/highlightComponent" import * as protocol from "typescript/lib/protocol" -import {TypescriptServiceClient} from "../../../client/client" +import {TSClient} from "../../../client" +import {getFilePathPosition} from "../utils" +import {HighlightComponent} from "../views/highlightComponent" +import {selectListView} from "../views/simpleSelectionView" +import {addCommand, Dependencies} from "./registry" interface RefactorAction { refactorName: string @@ -61,7 +61,7 @@ addCommand("atom-text-editor", "typescript:refactor-selection", deps => ({ })) async function getApplicableRefactorsActions( - client: TypescriptServiceClient, + client: TSClient, pointOrRange: protocol.FileLocationOrRangeRequestArgs, ) { const responseApplicable = await getApplicabeRefactors(client, pointOrRange) @@ -87,7 +87,7 @@ async function getApplicableRefactorsActions( } async function getApplicabeRefactors( - client: TypescriptServiceClient, + client: TSClient, pointOrRange: protocol.FileLocationOrRangeRequestArgs, ) { try { @@ -100,7 +100,7 @@ async function getApplicabeRefactors( async function applyRefactors( selectedAction: RefactorAction, range: protocol.FileLocationOrRangeRequestArgs, - client: TypescriptServiceClient, + client: TSClient, deps: Dependencies, ) { const responseEdits = await client.execute("getEditsForRefactor", { diff --git a/lib/main/atom/commands/registry.ts b/lib/main/atom/commands/registry.ts index 3000c2408..fba6f9cb2 100644 --- a/lib/main/atom/commands/registry.ts +++ b/lib/main/atom/commands/registry.ts @@ -1,19 +1,25 @@ import * as Atom from "atom" -import {TypescriptServiceClient} from "../../../client/client" -import {StatusPanel} from "../../atom/components/statusPanel" -import {SemanticViewController} from "../views/outline/semanticViewController" -import {SymbolsViewController} from "../views/symbols/symbolsViewController" +import {GetClientFunction} from "../../../client" import {ApplyEdits} from "../../pluginManager" -import {EditorPositionHistoryManager} from "../editorPositionHistoryManager" +import {TBuildStatus, TProgress} from "../components/statusPanel" +import {OpenParams} from "../editorPositionHistoryManager" export interface Dependencies { + getClient: GetClientFunction applyEdits: ApplyEdits - clearErrors(): void - getClient(filePath: string): Promise - getStatusPanel(): StatusPanel - getSemanticViewController(): SemanticViewController - getSymbolsViewController(): SymbolsViewController - getEditorPositionHistoryManager(): EditorPositionHistoryManager + clearErrors: () => void + killAllServers: () => void + reportProgress: (progress: TProgress) => void + reportBuildStatus: (status: TBuildStatus | undefined) => void + toggleSemanticViewController: () => void + toggleFileSymbolsView: (ed: Atom.TextEditor) => void + toggleProjectSymbolsView: (ed: Atom.TextEditor) => void + histGoForward: (ed: Atom.TextEditor, openParams: OpenParams) => Promise + histGoBack: () => Promise + histShowHistory: () => Promise + showTooltipAt: (ed: Atom.TextEditor) => void + showSigHelpAt: (ed: Atom.TextEditor) => void + hideSigHelpAt: (ed: Atom.TextEditor) => boolean } export type AllowedSelectors = keyof Dispatch diff --git a/lib/main/atom/commands/reloadProjects.ts b/lib/main/atom/commands/reloadProjects.ts new file mode 100644 index 000000000..05fc988ae --- /dev/null +++ b/lib/main/atom/commands/reloadProjects.ts @@ -0,0 +1,11 @@ +import {addCommand} from "./registry" + +addCommand("atom-text-editor", "typescript:reload-projects", deps => ({ + description: "Reload projects", + async didDispatch(editor) { + const path = editor.getPath() + if (path === undefined) return + const client = await deps.getClient(path) + await client.execute("reloadProjects") + }, +})) diff --git a/lib/main/atom/commands/renameRefactor.ts b/lib/main/atom/commands/renameRefactor.ts index e4e623f14..ecf0c32dd 100644 --- a/lib/main/atom/commands/renameRefactor.ts +++ b/lib/main/atom/commands/renameRefactor.ts @@ -1,6 +1,6 @@ -import {addCommand} from "./registry" import {getFilePathPosition} from "../utils" import {showRenameDialog} from "../views/renameView" +import {addCommand} from "./registry" addCommand("atom-text-editor", "typescript:rename-refactor", deps => ({ description: "Rename symbol under text cursor everywhere it is used", diff --git a/lib/main/atom/commands/restartAllServers.ts b/lib/main/atom/commands/restartAllServers.ts new file mode 100644 index 000000000..55248faa8 --- /dev/null +++ b/lib/main/atom/commands/restartAllServers.ts @@ -0,0 +1,8 @@ +import {addCommand} from "./registry" + +addCommand("atom-workspace", "typescript:restart-all-servers", deps => ({ + description: "Kill all tsserver instances. They will be auto-restarted", + async didDispatch() { + deps.killAllServers() + }, +})) diff --git a/lib/main/atom/commands/returnFromDeclaration.tsx b/lib/main/atom/commands/returnFromDeclaration.tsx index 9821d61c3..1aff0e13d 100644 --- a/lib/main/atom/commands/returnFromDeclaration.tsx +++ b/lib/main/atom/commands/returnFromDeclaration.tsx @@ -1,37 +1,15 @@ import {addCommand} from "./registry" -import {selectListView} from "../views/simpleSelectionView" -import * as etch from "etch" -import {HighlightComponent} from "../views/highlightComponent" addCommand("atom-workspace", "typescript:return-from-declaration", deps => ({ description: "If used `go-to-declaration`, return to previous text cursor position", async didDispatch() { - deps.getEditorPositionHistoryManager().goBack() + await deps.histGoBack() }, })) addCommand("atom-workspace", "typescript:show-editor-position-history", deps => ({ description: "If used `go-to-declaration`, return to previous text cursor position", async didDispatch() { - const ehm = deps.getEditorPositionHistoryManager() - const res = await selectListView({ - items: ehm - .getHistory() - .slice() - .reverse() - .map((item, idx) => ({...item, idx})), - itemTemplate: (item, ctx) => ( -
  • -
    - -
    -
    - Line: {item.line}, column: {item.offset} -
    -
  • - ), - itemFilterKey: "file", - }) - if (res) ehm.goHistory(res.idx + 1) + await deps.histShowHistory() }, })) diff --git a/lib/main/atom/commands/semanticView.ts b/lib/main/atom/commands/semanticView.ts index 5aca755cf..dc1acd3ca 100644 --- a/lib/main/atom/commands/semanticView.ts +++ b/lib/main/atom/commands/semanticView.ts @@ -3,6 +3,6 @@ import {addCommand} from "./registry" addCommand("atom-text-editor", "typescript:toggle-semantic-view", deps => ({ description: "Toggle semantic view outline", didDispatch() { - deps.getSemanticViewController().toggle() + deps.toggleSemanticViewController() }, })) diff --git a/lib/main/atom/commands/showSigHelp.ts b/lib/main/atom/commands/showSigHelp.ts new file mode 100644 index 000000000..3531fe4c5 --- /dev/null +++ b/lib/main/atom/commands/showSigHelp.ts @@ -0,0 +1,8 @@ +import {addCommand} from "./registry" + +addCommand("atom-text-editor", "typescript:show-signature-help", deps => ({ + description: "Show signature help tooltip at current text cursor position", + async didDispatch(ed) { + return deps.showSigHelpAt(ed) + }, +})) diff --git a/lib/main/atom/commands/showTooltip.ts b/lib/main/atom/commands/showTooltip.ts index ac17f878d..2a7a4805b 100644 --- a/lib/main/atom/commands/showTooltip.ts +++ b/lib/main/atom/commands/showTooltip.ts @@ -1,9 +1,8 @@ import {addCommand} from "./registry" -import {showExpressionAt} from "../tooltipManager" -addCommand("atom-text-editor", "typescript:show-tooltip", () => ({ +addCommand("atom-text-editor", "typescript:show-tooltip", deps => ({ description: "Show type tooltip at current text cursor position", async didDispatch(ed) { - return showExpressionAt(ed, ed.getLastCursor().getBufferPosition()) + return deps.showTooltipAt(ed) }, })) diff --git a/lib/main/atom/commands/symbolsView.ts b/lib/main/atom/commands/symbolsView.ts index fe6afe28d..7acf43102 100644 --- a/lib/main/atom/commands/symbolsView.ts +++ b/lib/main/atom/commands/symbolsView.ts @@ -3,13 +3,13 @@ import {addCommand} from "./registry" addCommand("atom-text-editor", "typescript:toggle-file-symbols", deps => ({ description: "Toggle view for finding file symbols", async didDispatch(editor) { - deps.getSymbolsViewController().toggleFileView(editor) + deps.toggleFileSymbolsView(editor) }, })) addCommand("atom-text-editor", "typescript:toggle-project-symbols", deps => ({ description: "Toggle view for finding file symbols", async didDispatch(editor) { - deps.getSymbolsViewController().toggleProjectView(editor) + deps.toggleProjectSymbolsView(editor) }, })) diff --git a/lib/main/atom/components/statusPanel.tsx b/lib/main/atom/components/statusPanel.tsx deleted file mode 100644 index e8141c4c1..000000000 --- a/lib/main/atom/components/statusPanel.tsx +++ /dev/null @@ -1,217 +0,0 @@ -import * as etch from "etch" -import {dirname} from "path" -import {ClientResolver} from "../../../client/clientResolver" -import {CompositeDisposable} from "atom" - -export interface Props extends JSX.Props { - version?: string - pending?: string[] - tsConfigPath?: string - buildStatus?: {success: true} | {success: false; message: string} - progress?: {max: number; value: number} - visible?: boolean - clientResolver: ClientResolver -} - -export class StatusPanel implements JSX.ElementClass { - public props: Props - private buildStatusTimeout?: number - private disposables = new CompositeDisposable() - - constructor(props: Props) { - this.props = { - visible: true, - ...props, - } - etch.initialize(this) - this.resetBuildStatusTimeout() - this.disposables.add( - this.props.clientResolver.on("pendingRequestsChange", this.handlePendingRequests), - ) - } - - public async update(props: Partial) { - this.props = {...this.props, ...props} - this.resetBuildStatusTimeout() - await etch.update(this) - } - - public render() { - return ( - - {this.renderVersion()} - {this.renderPending()} - {this.renderConfigPath()} - {this.renderStatus()} - {this.renderProgress()} - - ) - } - - public async destroy() { - await etch.destroy(this) - this.disposables.dispose() - } - - public dispose() { - this.destroy() - } - - public show() { - this.update({visible: true}) - } - - public hide() { - this.update({visible: false}) - } - - private resetBuildStatusTimeout() { - if (this.buildStatusTimeout !== undefined) { - window.clearTimeout(this.buildStatusTimeout) - this.buildStatusTimeout = undefined - } - if (this.props.buildStatus && this.props.buildStatus.success) { - const timeout = atom.config.get("atom-typescript.buildStatusTimeout") - if (timeout > 0) { - this.buildStatusTimeout = window.setTimeout(() => { - this.update({buildStatus: undefined}) - }, timeout * 1000) - } else if (timeout === 0) { - this.update({buildStatus: undefined}) - } - } - } - - private openConfigPath() { - if (this.props.tsConfigPath !== undefined && !this.props.tsConfigPath.startsWith("/dev/null")) { - atom.workspace.open(this.props.tsConfigPath) - } else { - atom.notifications.addInfo("No tsconfig for current file") - } - } - - private showPendingRequests() { - if (this.props.pending) { - atom.notifications.addInfo("Pending Requests:
    - " + this.props.pending.join("
    - ")) - } - } - - private renderVersion(): JSX.Element | null { - if (this.props.version !== undefined) { - return ( -
    - {this.props.version} -
    - ) - } - return null - } - - private renderPending(): JSX.Element | null { - if (this.props.pending && this.props.pending.length > 0) { - return ( - { - evt.preventDefault() - this.showPendingRequests() - }, - }}> - {this.props.pending.length.toString()} - - - ) - } - return null - } - - private renderConfigPath(): JSX.Element | null { - if (this.props.tsConfigPath !== undefined) { - return ( - { - evt.preventDefault() - this.openConfigPath() - }, - }}> - {this.props.tsConfigPath.startsWith("/dev/null") - ? "No project" - : dirname(getFilePathRelativeToAtomProject(this.props.tsConfigPath))} - - ) - } - return null - } - - private renderStatus(): JSX.Element | null { - if (this.props.buildStatus) { - let cls: string - let text: string - if (this.props.buildStatus.success) { - cls = "highlight-success" - text = "Emit Success" - } else { - cls = "highlight-error" - text = "Emit Failed" - } - return ( -
    - - {text} - -
    - ) - } - return null - } - - private buildStatusClicked = () => { - if (this.props.buildStatus && !this.props.buildStatus.success) { - atom.notifications.addError("Build failed", { - detail: this.props.buildStatus.message, - dismissable: true, - }) - } - } - - private renderProgress(): JSX.Element | null { - if (this.props.progress) { - return ( - - ) - } - return null - } - - private handlePendingRequests = () => { - this.update({ - pending: ([] as string[]).concat( - ...Array.from(this.props.clientResolver.clients.values()).map(el => el.pending), - ), - }) - } -} - -/** - * converts "c:\dev\somethin\bar.ts" to "~something\bar". - */ -function getFilePathRelativeToAtomProject(filePath: string) { - return "~" + atom.project.relativize(filePath) -} diff --git a/lib/main/atom/components/statusPanel/buildStatus.tsx b/lib/main/atom/components/statusPanel/buildStatus.tsx new file mode 100644 index 000000000..fc4739895 --- /dev/null +++ b/lib/main/atom/components/statusPanel/buildStatus.tsx @@ -0,0 +1,101 @@ +import {CompositeDisposable} from "atom" +import * as etch from "etch" +import {debounce} from "lodash" +import {handlePromise} from "../../../../utils" +import {Tooltip} from "./tooltip" + +export type TBuildStatus = {success: true} | {success: false; message: string} + +export interface Props extends JSX.Props { + buildStatus: TBuildStatus +} + +export class BuildStatus implements JSX.ElementClass { + public props: Props + private hiddenBuildStatus = false + private disposables = new CompositeDisposable() + private hideBuildStatus!: () => void + + constructor(props: Props) { + this.props = { + ...props, + } + this.setHideBuildStatus(atom.config.get("atom-typescript").buildStatusTimeout) + this.resetBuildStatusTimeout() + etch.initialize(this) + this.disposables.add( + atom.config.onDidChange("atom-typescript.buildStatusTimeout", ({newValue}) => { + this.setHideBuildStatus(newValue) + handlePromise(this.update({})) + }), + ) + } + + public async update(props: Partial) { + const successStateChanged = + props.buildStatus !== undefined && + props.buildStatus.success !== this.props.buildStatus.success + this.props = {...this.props, ...props} + if (successStateChanged) this.resetBuildStatusTimeout() + await etch.update(this) + } + + public render() { + if (this.hiddenBuildStatus) return + + let cls: string + let text: string + if (this.props.buildStatus.success) { + cls = "highlight-success" + text = "Emit Success" + } else { + cls = "highlight-error" + text = "Emit Failed" + } + return ( + + + {text} + + + ) + } + + public async destroy() { + await etch.destroy(this) + } + + private buildStatusClicked = () => { + if (!this.props.buildStatus.success) { + atom.notifications.addError("Build failed", { + detail: this.props.buildStatus.message, + dismissable: true, + }) + } + } + + private resetBuildStatusTimeout() { + this.hiddenBuildStatus = false + if (this.props.buildStatus.success) { + this.hideBuildStatus() + } + } + + private setHideBuildStatus(value: number) { + if (value > 0) { + this.hideBuildStatus = debounce(() => { + this.hiddenBuildStatus = true + handlePromise(etch.update(this)) + }, value * 1000) + } else if (value === 0) { + this.hideBuildStatus = () => { + this.hiddenBuildStatus = true + } + } else this.hideBuildStatus = () => {} + } +} diff --git a/lib/main/atom/components/statusPanel/configPath.tsx b/lib/main/atom/components/statusPanel/configPath.tsx new file mode 100644 index 000000000..75bd7a057 --- /dev/null +++ b/lib/main/atom/components/statusPanel/configPath.tsx @@ -0,0 +1,69 @@ +import * as etch from "etch" +import {dirname} from "path" +import {handlePromise} from "../../../../utils" +import {Tooltip} from "./tooltip" + +export interface Props extends JSX.Props { + tsConfigPath: string +} + +export class ConfigPath implements JSX.ElementClass { + public props: Props + public element!: HTMLElement + + constructor(props: Props) { + this.props = { + ...props, + } + etch.initialize(this) + } + + public async update(props: Partial) { + this.props = {...this.props, ...props} + await etch.update(this) + } + + public render() { + return ( + + this.props.tsConfigPath.startsWith("/dev/null") + ? "No tsconfig.json" + : `Click to open ${atom.project.relativize(this.props.tsConfigPath)}` + }> + { + evt.preventDefault() + this.openConfigPath() + }, + }}> + {this.props.tsConfigPath.startsWith("/dev/null") + ? "No project" + : dirname(getFilePathRelativeToAtomProject(this.props.tsConfigPath))} + + + ) + } + + public async destroy() { + await etch.destroy(this) + } + + private openConfigPath() { + if (!this.props.tsConfigPath.startsWith("/dev/null")) { + handlePromise(atom.workspace.open(this.props.tsConfigPath)) + } else { + atom.notifications.addInfo("No tsconfig for current file") + } + } +} + +/** + * converts "c:\dev\somethin\bar.ts" to "~something\bar". + */ +function getFilePathRelativeToAtomProject(filePath: string) { + return "~" + atom.project.relativize(filePath) +} diff --git a/lib/main/atom/components/statusPanel/index.tsx b/lib/main/atom/components/statusPanel/index.tsx new file mode 100644 index 000000000..499ecc661 --- /dev/null +++ b/lib/main/atom/components/statusPanel/index.tsx @@ -0,0 +1,121 @@ +import * as etch from "etch" +import {handlePromise} from "../../../../utils" +import {BuildStatus, TBuildStatus} from "./buildStatus" +import {ConfigPath} from "./configPath" +import {Tooltip} from "./tooltip" +export {TBuildStatus} + +export interface TProgress { + max: number + value: number +} + +export interface Props extends JSX.Props { + clientVersion?: string + pending: Array<{title: string}> + tsConfigPath?: string + buildStatus?: TBuildStatus + progress: TProgress + visible: boolean +} + +export class StatusPanel implements JSX.ElementClass { + public props: Props + + constructor(props: Partial = {}) { + this.props = { + visible: true, + pending: [], + progress: {max: 0, value: 0}, + ...props, + } + etch.initialize(this) + } + + public async update(props: Partial) { + this.props = {...this.props, ...props} + await etch.update(this) + } + + public render() { + return ( + + {this.renderVersion()} + {this.renderPending()} + {this.renderConfigPath()} + {this.renderStatus()} + {this.renderProgress()} + + ) + } + + public async destroy() { + await etch.destroy(this) + } + + public dispose() { + handlePromise(this.destroy()) + } + + public async show() { + await this.update({visible: true}) + } + + public async hide() { + await this.update({visible: false}) + } + + private renderVersion(): JSX.Element | null { + if (this.props.clientVersion !== undefined) { + return {this.props.clientVersion} + } + return null + } + + private renderPending(): JSX.Element | null { + if (this.props.pending.length > 0) { + return ( + ${this.props.pending + .map(({title}) => `
  • ${title}
  • `) + .join("")}`} + html={true}> + {this.props.pending.length.toString()} + +
    + ) + } else return null + } + + private renderConfigPath(): JSX.Element | null { + if (this.props.tsConfigPath !== undefined) { + return + } + return null + } + + private renderStatus(): JSX.Element | null { + if (this.props.buildStatus) { + return + } + return null + } + + private renderProgress(): JSX.Element | null { + if (this.props.progress.value < this.props.progress.max) { + return ( + + ) + } + return null + } +} diff --git a/lib/main/atom/components/statusPanel/tooltip.tsx b/lib/main/atom/components/statusPanel/tooltip.tsx new file mode 100644 index 000000000..1c2a47213 --- /dev/null +++ b/lib/main/atom/components/statusPanel/tooltip.tsx @@ -0,0 +1,46 @@ +import {DisposableLike, TooltipPlacement} from "atom" +import * as etch from "etch" + +export interface Props extends JSX.Props { + title?: string | (() => string) + html?: boolean + keyBindingCommand?: string + keyBindingTarget?: HTMLElement + class?: string + placement?: TooltipPlacement | (() => TooltipPlacement) + trigger?: "click" | "hover" | "focus" | "manual" + delay?: {show: number; hide: number} +} + +export class Tooltip implements JSX.ElementClass { + public props: Props + public element!: HTMLElement + private tooltipDisposable: DisposableLike + + constructor(props: Props, private children?: JSX.Element[]) { + this.props = { + ...props, + delay: {show: 0, hide: 0}, + } + etch.initialize(this) + + this.tooltipDisposable = atom.tooltips.add(this.element, this.props) + } + + public async update(props: Partial, children: JSX.Element[]) { + this.props = {...this.props, ...props} + this.children = children + await etch.update(this) + this.tooltipDisposable.dispose() + this.tooltipDisposable = atom.tooltips.add(this.element, this.props) + } + + public render() { + return
    {this.children ? this.children : null}
    + } + + public async destroy() { + await etch.destroy(this) + this.tooltipDisposable.dispose() + } +} diff --git a/lib/main/atom/editorPositionHistoryManager.ts b/lib/main/atom/editorPositionHistoryManager.tsx similarity index 68% rename from lib/main/atom/editorPositionHistoryManager.ts rename to lib/main/atom/editorPositionHistoryManager.tsx index 506eb64d9..417bc3863 100644 --- a/lib/main/atom/editorPositionHistoryManager.ts +++ b/lib/main/atom/editorPositionHistoryManager.tsx @@ -1,7 +1,10 @@ -import {FileLocationQuery, getFilePathPosition} from "./utils" import {TextEditor} from "atom" +import * as etch from "etch" +import {FileLocationQuery, getFilePathPosition} from "./utils" +import {HighlightComponent} from "./views/highlightComponent" +import {selectListView} from "./views/simpleSelectionView" -interface OpenParams { +export interface OpenParams { file: string start: {line: number; offset: number} } @@ -38,6 +41,27 @@ export class EditorPositionHistoryManager { return this.open(item) } + public async showHistory() { + const res = await selectListView({ + items: this.getHistory() + .slice() + .reverse() + .map((item, idx) => ({...item, idx})), + itemTemplate: (item, ctx) => ( +
  • +
    + +
    +
    + Line: {item.line}, column: {item.offset} +
    +
  • + ), + itemFilterKey: "file", + }) + if (res) await this.goHistory(res.idx + 1) + } + public getHistory() { return this.prevCursorPositions } diff --git a/lib/main/atom/hyperclickProvider.ts b/lib/main/atom/hyperclickProvider.ts deleted file mode 100644 index 7bf7f0fe4..000000000 --- a/lib/main/atom/hyperclickProvider.ts +++ /dev/null @@ -1,38 +0,0 @@ -import * as Atom from "atom" -import {ClientResolver} from "../../client/clientResolver" -import {handleDefinitionResult} from "./commands/goToDeclaration" -import {isTypescriptEditorWithPath} from "./utils" -import {EditorPositionHistoryManager} from "./editorPositionHistoryManager" - -export function getHyperclickProvider( - clientResolver: ClientResolver, - editorPosHist: EditorPositionHistoryManager, -) { - return { - providerName: "typescript-hyperclick-provider", - wordRegExp: /([A-Za-z0-9_])+|['"`](\\.|[^'"`\\\\])*['"`]/g, - getSuggestionForWord(editor: Atom.TextEditor, _text: string, range: Atom.Range) { - if (!isTypescriptEditorWithPath(editor)) { - return null - } - const filePath = editor.getPath() - if (filePath === undefined) { - return null - } - - return { - range, - callback: async () => { - const location = { - file: filePath, - line: range.start.row + 1, - offset: range.start.column + 1, - } - const client = await clientResolver.get(location.file) - const result = await client.execute("definition", location) - handleDefinitionResult(result, editor, editorPosHist) - }, - } - }, - } -} diff --git a/lib/main/atom/occurrence/controller.ts b/lib/main/atom/occurrence/controller.ts new file mode 100644 index 000000000..09053a526 --- /dev/null +++ b/lib/main/atom/occurrence/controller.ts @@ -0,0 +1,80 @@ +import {CompositeDisposable, DisplayMarker, TextEditor} from "atom" +import {debounce} from "lodash" +import {GetClientFunction} from "../../../client" +import {handlePromise} from "../../../utils" +import {isTypescriptEditorWithPath, spanToRange} from "../utils" + +export class OccurenceController { + private readonly disposables = new CompositeDisposable() + private occurrenceMarkers: DisplayMarker[] = [] + private disposed = false + + constructor(private getClient: GetClientFunction, private editor: TextEditor) { + const debouncedUpdate = debounce(() => { + handlePromise(this.update()) + }, 100) + this.disposables.add( + editor.onDidChangeCursorPosition(debouncedUpdate), + editor.onDidChangePath(debouncedUpdate), + editor.onDidChangeGrammar(debouncedUpdate), + ) + } + + public dispose() { + if (this.disposed) return + this.disposed = true + this.disposables.dispose() + this.clearMarkers() + } + + private clearMarkers() { + for (const marker of this.occurrenceMarkers) { + marker.destroy() + } + this.occurrenceMarkers = [] + } + + private async update() { + if (this.disposed) return + if (!isTypescriptEditorWithPath(this.editor)) { + this.clearMarkers() + return + } + const filePath = this.editor.getPath() + if (filePath === undefined) return + const client = await this.getClient(filePath) + if (this.disposed) return + + const pos = this.editor.getLastCursor().getBufferPosition() + + try { + const result = await client.execute("occurrences", { + file: filePath, + line: pos.row + 1, + offset: pos.column + 1, + }) + if (this.disposed) return + + const ranges = result.body!.map(spanToRange) + + const newOccurrenceMarkers = ranges.map(range => { + const oldMarker = this.occurrenceMarkers.find(m => m.getBufferRange().isEqual(range)) + if (oldMarker) return oldMarker + else { + const marker = this.editor.markBufferRange(range) + this.editor.decorateMarker(marker, { + type: "highlight", + class: "atom-typescript-occurrence", + }) + return marker + } + }) + for (const m of this.occurrenceMarkers) { + if (!newOccurrenceMarkers.includes(m)) m.destroy() + } + this.occurrenceMarkers = newOccurrenceMarkers + } catch (e) { + if (window.atom_typescript_debug) console.error(e) + } + } +} diff --git a/lib/main/atom/occurrence/manager.ts b/lib/main/atom/occurrence/manager.ts new file mode 100644 index 000000000..8f9147780 --- /dev/null +++ b/lib/main/atom/occurrence/manager.ts @@ -0,0 +1,26 @@ +import {CompositeDisposable} from "atom" +import {GetClientFunction} from "../../../client" +import {OccurenceController} from "./controller" + +export class OccurrenceManager { + private readonly disposables = new CompositeDisposable() + + constructor(getClient: GetClientFunction) { + this.disposables.add( + atom.workspace.observeTextEditors(editor => { + const controller = new OccurenceController(getClient, editor) + this.disposables.add( + controller, + editor.onDidDestroy(() => { + this.disposables.remove(controller) + controller.dispose() + }), + ) + }), + ) + } + + public dispose() { + this.disposables.dispose() + } +} diff --git a/lib/main/atom/sigHelp/controller.ts b/lib/main/atom/sigHelp/controller.ts new file mode 100644 index 000000000..8f4c6b071 --- /dev/null +++ b/lib/main/atom/sigHelp/controller.ts @@ -0,0 +1,105 @@ +import * as Atom from "atom" +import {debounce} from "lodash" +import {GetClientFunction} from "../../../client" +import {handlePromise} from "../../../utils" +import {FlushTypescriptBuffer} from "../../pluginManager" +import {isTypescriptEditorWithPath} from "../utils" +import {TooltipView} from "./tooltipView" + +export class TooltipController { + private cancelled = false + private view: TooltipView + private disposables = new Atom.CompositeDisposable() + constructor( + private deps: { + getClient: GetClientFunction + flushTypescriptBuffer: FlushTypescriptBuffer + }, + private editor: Atom.TextEditor, + bufferPt: Atom.Point, + ) { + const rawView = atom.views.getView(this.editor) + this.view = new TooltipView(rawView) + rawView.appendChild(this.view.element) + const debouncedUpdate = debounce(this.updateTooltip.bind(this), 100, {leading: true}) + this.disposables.add( + this.editor.onDidChangeCursorPosition(evt => { + bufferPt = evt.newBufferPosition + handlePromise(debouncedUpdate(bufferPt)) + }), + rawView.onDidChangeScrollTop(() => { + setImmediate(() => this.updateTooltipPosition(bufferPt)) + }), + rawView.onDidChangeScrollLeft(() => { + setImmediate(() => this.updateTooltipPosition(bufferPt)) + }), + ) + handlePromise(this.updateTooltip(bufferPt)) + } + + public isDisposed() { + return this.cancelled + } + + public dispose() { + if (this.cancelled) return + this.cancelled = true + this.disposables.dispose() + handlePromise(this.view.destroy()) + } + + private async updateTooltip(bufferPt: Atom.Point) { + if (this.cancelled) return + const tooltipRect = this.computeTooltipPosition(bufferPt) + + const msg = await this.getMessage(bufferPt) + if (this.cancelled) return + if (!msg) { + this.dispose() + return + } + await this.view.update({...tooltipRect, sigHelp: msg}) + } + + private updateTooltipPosition(bufferPt: Atom.Point) { + if (this.cancelled) return + const tooltipRect = this.computeTooltipPosition(bufferPt) + handlePromise(this.view.update({...tooltipRect})) + } + + private computeTooltipPosition(bufferPt: Atom.Point) { + const rawView = atom.views.getView(this.editor) + const pixelPos = rawView.pixelPositionForBufferPosition(bufferPt) + const lines = rawView.querySelector(".lines")! + const linesRect = lines.getBoundingClientRect() + const lineH = this.editor.getLineHeightInPixels() + const parentRect = rawView.getBoundingClientRect() + const Y = pixelPos.top + linesRect.top - parentRect.top + lineH / 2 + const X = pixelPos.left + linesRect.left - parentRect.left + const offset = lineH * 0.7 + return { + left: X, + right: X, + top: Y - offset, + bottom: Y + offset, + } + } + + private async getMessage(bufferPt: Atom.Point) { + if (!isTypescriptEditorWithPath(this.editor)) return + const filePath = this.editor.getPath() + if (filePath === undefined) return + const client = await this.deps.getClient(filePath) + try { + await this.deps.flushTypescriptBuffer(filePath) + const result = await client.execute("signatureHelp", { + file: filePath, + line: bufferPt.row + 1, + offset: bufferPt.column + 1, + }) + return result.body + } catch (e) { + return + } + } +} diff --git a/lib/main/atom/sigHelp/manager.ts b/lib/main/atom/sigHelp/manager.ts new file mode 100644 index 000000000..8eb9dddb8 --- /dev/null +++ b/lib/main/atom/sigHelp/manager.ts @@ -0,0 +1,80 @@ +// Inspiration : https://atom.io/packages/ide-haskell +// and https://atom.io/packages/ide-flow + +import * as Atom from "atom" +import {GetClientFunction} from "../../../client" +import {handlePromise} from "../../../utils" +import {FlushTypescriptBuffer} from "../../pluginManager" +import {TooltipController} from "./controller" + +export class SigHelpManager { + private subscriptions = new Atom.CompositeDisposable() + private editorMap = new WeakMap() + + constructor( + private deps: { + getClient: GetClientFunction + flushTypescriptBuffer: FlushTypescriptBuffer + }, + ) { + this.subscriptions.add( + atom.workspace.observeTextEditors(editor => { + const disp = new Atom.CompositeDisposable() + disp.add( + editor.onDidDestroy(() => { + disp.dispose() + this.subscriptions.remove(disp) + const controller = this.editorMap.get(editor) + if (controller) controller.dispose() + }), + editor.onDidStopChanging(this.stoppedChanging(editor)), + ) + this.subscriptions.add(disp) + }), + ) + } + + public dispose() { + this.subscriptions.dispose() + for (const editor of atom.workspace.getTextEditors()) { + const controller = this.editorMap.get(editor) + if (controller) controller.dispose() + } + } + + public async showTooltipAt(editor: Atom.TextEditor) { + const pt = editor.getLastCursor().getBufferPosition() + return this.showTooltip(editor, pt) + } + + public hideTooltipAt(editor: Atom.TextEditor): boolean { + const controller = this.editorMap.get(editor) + if (controller && !controller.isDisposed()) { + controller.dispose() + return true + } else { + return false + } + } + + private async showTooltip(editor: Atom.TextEditor, pos: Atom.Point) { + const controller = this.editorMap.get(editor) + if (!controller || controller.isDisposed()) { + this.editorMap.set(editor, new TooltipController(this.deps, editor, pos)) + } + } + + private stoppedChanging = (editor: Atom.TextEditor) => ( + event: Atom.BufferStoppedChangingEvent, + ) => { + const filePath = editor.getPath() + if (filePath === undefined) return + const pos = editor.getLastCursor().getBufferPosition() + const [ch] = event.changes.filter(x => x.newRange.containsPoint(pos)) as Array< + Atom.TextChange | undefined + > + if (ch && ch.newText.match(/[(,]/) !== null) { + handlePromise(this.showTooltip(editor, pos)) + } + } +} diff --git a/lib/main/atom/sigHelp/tooltipView.tsx b/lib/main/atom/sigHelp/tooltipView.tsx new file mode 100644 index 000000000..1bfe97b92 --- /dev/null +++ b/lib/main/atom/sigHelp/tooltipView.tsx @@ -0,0 +1,114 @@ +import {TextEditorElement} from "atom" +import * as etch from "etch" +import {partsToStr} from "../utils" + +interface Props extends JSX.Props { + left: number + right: number + top: number + bottom: number + sigHelp?: protocol.SignatureHelpItems +} + +export class TooltipView implements JSX.ElementClass { + public readonly element!: HTMLDivElement + public props: Props + + constructor(private parent: TextEditorElement) { + this.props = { + left: 0, + right: 0, + top: 0, + bottom: 0, + } + etch.initialize(this) + } + + public async destroy() { + return etch.destroy(this) + } + + public async update(props: Partial) { + this.props = {...this.props, ...props} + await etch.update(this) + } + + public writeAfterUpdate() { + const offset = 10 + let left = this.props.right + let right: number | false = false + + let whiteSpace = "" + + const clientWidth = this.parent.clientWidth + const offsetWidth = this.element.offsetWidth + const offsetHeight = this.element.offsetHeight + + let top = this.props.top - offsetHeight + + // X axis adjust + if (left + offsetWidth >= clientWidth) { + left = clientWidth - offsetWidth - offset + } + if (left < 0) { + whiteSpace = "pre-wrap" + left = offset + right = offset + } + + // Y axis adjust + if (top < 0) { + top = this.props.bottom + } + + this.element.style.left = `${left}px` + this.element.style.top = `${top}px` + if (right !== false) this.element.style.right = `${right}px` + if (whiteSpace) this.element.style.whiteSpace = whiteSpace + } + + public render() { + return ( +
    +
    {this.tooltipContents()}
    +
    + ) + } + + private sigHelpHash() { + if (!this.props.sigHelp) return undefined + const {start, end} = this.props.sigHelp.applicableSpan + return `${start.line}:${start.offset}-${end.line}:${end.offset}` + } + + private tooltipContents() { + if (!this.props.sigHelp) return "â€Ĥ" + const {sigHelp} = this.props + return sigHelp.items.map((sig, idx) => ( +
    + {partsToStr(sig.prefixDisplayParts)} + {this.renderSigHelpParams(sig.parameters, sigHelp.argumentIndex)} + {partsToStr(sig.suffixDisplayParts)} +
    + {partsToStr(sig.documentation)} +
    +
    + )) + } + + private renderSigHelpParams(params: protocol.SignatureHelpParameter[], selIdx: number) { + return params.map((p, i) => ( + + {i > 0 ? ", " : null} + + {partsToStr(p.displayParts)} + + + )) + } +} diff --git a/lib/main/atom/sigHelp/util.ts b/lib/main/atom/sigHelp/util.ts new file mode 100644 index 000000000..a7720c0a2 --- /dev/null +++ b/lib/main/atom/sigHelp/util.ts @@ -0,0 +1,16 @@ +import {TextEditor} from "atom" + +// screen position from mouse event -- with <3 from Atom-Haskell +export function bufferPositionFromMouseEvent( + editor: TextEditor, + event: {clientX: number; clientY: number}, +) { + const sp = atom.views + .getView(editor) + .getComponent() + .screenPositionForMouseEvent(event) + if (isNaN(sp.row) || isNaN(sp.column)) { + return + } + return editor.bufferPositionForScreenPosition(sp) +} diff --git a/lib/main/atom/tooltipManager.ts b/lib/main/atom/tooltipManager.ts deleted file mode 100644 index 9fea09ba4..000000000 --- a/lib/main/atom/tooltipManager.ts +++ /dev/null @@ -1,211 +0,0 @@ -// Inspiration : https://atom.io/packages/ide-haskell -// and https://atom.io/packages/ide-flow - -import atomUtils = require("./utils") -import * as Atom from "atom" -import fs = require("fs") -import {listen} from "./utils/element-listener" -import {TooltipView} from "./views/tooltipView" -import escape = require("escape-html") -import {TypescriptServiceClient} from "../../client/client" - -const tooltipMap = new WeakMap() - -interface Rect { - left: number - right: number - top: number - bottom: number -} - -// screen position from mouse event -- with <3 from Atom-Haskell -function bufferPositionFromMouseEvent( - editor: Atom.TextEditor, - event: {clientX: number; clientY: number}, -) { - const sp = atom.views - .getView(editor) - .getComponent() - .screenPositionForMouseEvent(event) - if (isNaN(sp.row) || isNaN(sp.column)) { - return - } - return editor.bufferPositionForScreenPosition(sp) -} - -export async function showExpressionAt(editor: Atom.TextEditor, pt: Atom.Point) { - const ed = tooltipMap.get(editor) - if (ed) { - return ed.showExpressionTypeKbd(pt) - } -} - -export class TooltipManager { - private static exprTypeTooltip: TooltipView | undefined - private clientPromise?: Promise - private rawView: Atom.TextEditorElement - private lines: Element - private subscriptions = new Atom.CompositeDisposable() - private exprTypeTimeout: number | undefined - private lastExprTypeBufferPt?: Atom.Point - private cancelShowTooltip?: () => void - - constructor( - private editor: Atom.TextEditor, - private getClient: (fp: string) => Promise, - ) { - this.rawView = atom.views.getView(editor) - this.lines = this.rawView.querySelector(".lines")! - tooltipMap.set(editor, this) - - this.subscriptions.add( - listen(this.rawView, "mousemove", ".scroll-view", this.trackMouseMovement), - listen(this.rawView, "mouseout", ".scroll-view", this.clearExprTypeTimeout), - listen(this.rawView, "keydown", ".scroll-view", this.clearExprTypeTimeout), - this.rawView.onDidChangeScrollTop(this.clearExprTypeTimeout), - this.rawView.onDidChangeScrollLeft(this.clearExprTypeTimeout), - ) - - this.subscriptions.add(this.editor.onDidChangePath(this.reinitialize)) - - this.reinitialize() - } - - public dispose() { - this.subscriptions.dispose() - this.clearExprTypeTimeout() - } - - public async showExpressionTypeKbd(pt: Atom.Point) { - const view = atom.views.getView(this.editor) - const px = view.pixelPositionForBufferPosition(pt) - return this.showExpressionType(this.mousePositionForPixelPosition(px)) - } - - private reinitialize = () => { - this.clientPromise = undefined - // Only on ".ts" files - const filePath = this.editor.getPath() - if (filePath === undefined) return - if (!atomUtils.isTypescriptEditorWithPath(this.editor)) return - // We only create a "program" once the file is persisted to disk - if (!fs.existsSync(filePath)) return - - this.clientPromise = this.getClient(filePath) - } - - private mousePositionForPixelPosition(p: Atom.PixelPosition) { - const linesRect = this.lines.getBoundingClientRect() - return { - clientY: p.top + linesRect.top + this.editor.getLineHeightInPixels() / 2, - clientX: p.left + linesRect.left, - } - } - - private async showExpressionType(e: {clientX: number; clientY: number}) { - if (!this.clientPromise) return - // If we are already showing we should wait for that to clear - if (TooltipManager.exprTypeTooltip) return - - if (this.cancelShowTooltip) this.cancelShowTooltip() - - let cancelled = false - this.cancelShowTooltip = () => { - cancelled = true - this.cancelShowTooltip = undefined - } - - const bufferPt = bufferPositionFromMouseEvent(this.editor, e) - if (!bufferPt) return - const curCharPixelPt = this.rawView.pixelPositionForBufferPosition(bufferPt) - const nextCharPixelPt = this.rawView.pixelPositionForBufferPosition(bufferPt.traverse([0, 1])) - - if (curCharPixelPt.left >= nextCharPixelPt.left) { - return - } - - // find out show position - const offset = this.editor.getLineHeightInPixels() * 0.7 - const tooltipRect = { - left: e.clientX, - right: e.clientX, - top: e.clientY - offset, - bottom: e.clientY + offset, - } - - const msg = await this.getMessage(bufferPt) - if (cancelled) return - if (msg !== undefined) this.showTooltip(tooltipRect, msg) - } - - private async getMessage(bufferPt: Atom.Point) { - let result: protocol.QuickInfoResponse - if (!this.clientPromise) return - const client = await this.clientPromise - const filePath = this.editor.getPath() - try { - if (filePath === undefined) { - return - } - result = await client.execute("quickinfo", { - file: filePath, - line: bufferPt.row + 1, - offset: bufferPt.column + 1, - }) - } catch (e) { - return - } - - const {displayString, documentation} = result.body! - - let message = `${escape(displayString)}` - if (documentation) { - message = - message + `
    ${escape(documentation).replace(/(?:\r\n|\r|\n)/g, "
    ")}
    ` - } - return message - } - - private showTooltip(tooltipRect: Rect, message: string) { - if (TooltipManager.exprTypeTooltip) return - TooltipManager.exprTypeTooltip = new TooltipView() - document.body.appendChild(TooltipManager.exprTypeTooltip.element) - TooltipManager.exprTypeTooltip.update({...tooltipRect, text: message}) - } - - /** clears the timeout && the tooltip */ - private clearExprTypeTimeout = () => { - if (this.exprTypeTimeout !== undefined) { - clearTimeout(this.exprTypeTimeout) - this.exprTypeTimeout = undefined - } - if (this.cancelShowTooltip) this.cancelShowTooltip() - this.hideExpressionType() - } - - private hideExpressionType() { - if (!TooltipManager.exprTypeTooltip) return - TooltipManager.exprTypeTooltip.destroy() - TooltipManager.exprTypeTooltip = undefined - } - - private trackMouseMovement = (e: MouseEvent) => { - const bufferPt = bufferPositionFromMouseEvent(this.editor, e) - if (!bufferPt) return - if ( - this.lastExprTypeBufferPt && - this.lastExprTypeBufferPt.isEqual(bufferPt) && - TooltipManager.exprTypeTooltip - ) { - return - } - - this.lastExprTypeBufferPt = bufferPt - - this.clearExprTypeTimeout() - this.exprTypeTimeout = window.setTimeout( - () => this.showExpressionType(e), - atom.config.get("atom-typescript.tooltipDelay"), - ) - } -} diff --git a/lib/main/atom/tooltips/controller.ts b/lib/main/atom/tooltips/controller.ts new file mode 100644 index 000000000..e59346215 --- /dev/null +++ b/lib/main/atom/tooltips/controller.ts @@ -0,0 +1,82 @@ +import * as Atom from "atom" +import {TSClient} from "../../../client" +import {handlePromise} from "../../../utils" +import {TooltipView} from "./tooltipView" +import {bufferPositionFromMouseEvent} from "./util" + +interface Rect { + left: number + right: number + top: number + bottom: number +} + +export class TooltipController { + private cancelled = false + private view?: TooltipView + constructor( + private getClient: (ed: Atom.TextEditor) => Promise, + editor: Atom.TextEditor, + e: {clientX: number; clientY: number}, + ) { + handlePromise(this.initialize(editor, e)) + } + + public dispose() { + this.cancelled = true + if (this.view) { + handlePromise(this.view.destroy()) + this.view = undefined + } + } + + private async initialize(editor: Atom.TextEditor, e: {clientX: number; clientY: number}) { + const bufferPt = bufferPositionFromMouseEvent(editor, e) + if (!bufferPt) return + + const rawView = atom.views.getView(editor) + const curCharPixelPt = rawView.pixelPositionForBufferPosition(bufferPt) + const nextCharPixelPt = rawView.pixelPositionForBufferPosition(bufferPt.traverse([0, 1])) + + if (curCharPixelPt.left >= nextCharPixelPt.left) return + // find out show position + const offset = editor.getLineHeightInPixels() * 0.7 + const tooltipRect = { + left: e.clientX, + right: e.clientX, + top: e.clientY - offset, + bottom: e.clientY + offset, + } + + const msg = await this.getMessage(editor, bufferPt) + if (this.cancelled) return + if (msg !== undefined) await this.showTooltip(tooltipRect, msg) + } + + private async getMessage(editor: Atom.TextEditor, bufferPt: Atom.Point) { + let result: protocol.QuickInfoResponse + const client = await this.getClient(editor) + if (!client) return + const filePath = editor.getPath() + try { + if (filePath === undefined) { + return + } + result = await client.execute("quickinfo", { + file: filePath, + line: bufferPt.row + 1, + offset: bufferPt.column + 1, + }) + } catch (e) { + return + } + + return result.body + } + + private async showTooltip(tooltipRect: Rect, info: protocol.QuickInfoResponseBody) { + this.view = new TooltipView() + document.body.appendChild(this.view.element) + await this.view.update({...tooltipRect, info}) + } +} diff --git a/lib/main/atom/tooltips/manager.ts b/lib/main/atom/tooltips/manager.ts new file mode 100644 index 000000000..16456712f --- /dev/null +++ b/lib/main/atom/tooltips/manager.ts @@ -0,0 +1,120 @@ +// Inspiration : https://atom.io/packages/ide-haskell +// and https://atom.io/packages/ide-flow + +import * as Atom from "atom" +import fs = require("fs") +import {GetClientFunction} from "../../../client" +import atomUtils = require("../utils") +import {listen} from "../utils/element-listener" +import {TooltipController} from "./controller" +import {bufferPositionFromMouseEvent} from "./util" + +interface EditorInfo { + rawView: Atom.TextEditorElement + lines: Element +} + +export class TooltipManager { + private subscriptions = new Atom.CompositeDisposable() + private pendingTooltip?: TooltipController + private editorMap = new WeakMap() + private exprTypeTimeout: number | undefined + + constructor(private getClientInternal: GetClientFunction) { + this.subscriptions.add( + atom.workspace.observeTextEditors(editor => { + const rawView = atom.views.getView(editor) + const lines = rawView.querySelector(".lines")! + this.editorMap.set(editor, { + rawView, + lines, + }) + const disp = new Atom.CompositeDisposable() + disp.add( + listen(rawView, "mousemove", ".scroll-view", this.trackMouseMovement(editor)), + listen(rawView, "mouseout", ".scroll-view", this.clearExprTypeTimeout), + listen(rawView, "keydown", ".scroll-view", this.clearExprTypeTimeout), + rawView.onDidChangeScrollTop(this.clearExprTypeTimeout), + rawView.onDidChangeScrollLeft(this.clearExprTypeTimeout), + editor.onDidDestroy(() => { + disp.dispose() + this.subscriptions.remove(disp) + }), + ) + this.subscriptions.add(disp) + }), + ) + } + + public dispose() { + this.subscriptions.dispose() + this.clearExprTypeTimeout() + } + + public async showExpressionAt(editor: Atom.TextEditor) { + const pt = editor.getLastCursor().getBufferPosition() + const view = atom.views.getView(editor) + const px = view.pixelPositionForBufferPosition(pt) + return this.showExpressionType(editor, this.mousePositionForPixelPosition(editor, px)) + } + + private getClient = async (editor: Atom.TextEditor) => { + // Only on ".ts" files + const filePath = editor.getPath() + if (filePath === undefined) return + if (!atomUtils.isTypescriptEditorWithPath(editor)) return + // We only create a "program" once the file is persisted to disk + if (!fs.existsSync(filePath)) return + + return this.getClientInternal(filePath) + } + + private mousePositionForPixelPosition(editor: Atom.TextEditor, p: Atom.PixelPosition) { + const rawView = atom.views.getView(editor) + const lines = rawView.querySelector(".lines")! + const linesRect = lines.getBoundingClientRect() + return { + clientY: p.top + linesRect.top + editor.getLineHeightInPixels() / 2, + clientX: p.left + linesRect.left, + } + } + + private async showExpressionType(editor: Atom.TextEditor, e: {clientX: number; clientY: number}) { + if (this.pendingTooltip) this.pendingTooltip.dispose() + this.pendingTooltip = new TooltipController(this.getClient, editor, e) + } + + /** clears the timeout && the tooltip */ + private clearExprTypeTimeout = () => { + if (this.exprTypeTimeout !== undefined) { + clearTimeout(this.exprTypeTimeout) + this.exprTypeTimeout = undefined + } + this.hideExpressionType() + } + + private hideExpressionType() { + if (!this.pendingTooltip) return + this.pendingTooltip.dispose() + this.pendingTooltip = undefined + } + + private trackMouseMovement = (editor: Atom.TextEditor) => { + let lastExprTypeBufferPt: Atom.Point | undefined + return (e: MouseEvent) => { + const bufferPt = bufferPositionFromMouseEvent(editor, e) + if (!bufferPt) return + if (lastExprTypeBufferPt && lastExprTypeBufferPt.isEqual(bufferPt) && this.pendingTooltip) { + return + } + + lastExprTypeBufferPt = bufferPt + + this.clearExprTypeTimeout() + this.exprTypeTimeout = window.setTimeout( + () => this.showExpressionType(editor, e), + atom.config.get("atom-typescript").tooltipDelay, + ) + } + } +} diff --git a/lib/main/atom/views/tooltipView.tsx b/lib/main/atom/tooltips/tooltipView.tsx similarity index 77% rename from lib/main/atom/views/tooltipView.tsx rename to lib/main/atom/tooltips/tooltipView.tsx index 906317267..92ec3c88c 100644 --- a/lib/main/atom/views/tooltipView.tsx +++ b/lib/main/atom/tooltips/tooltipView.tsx @@ -5,7 +5,7 @@ interface Props extends JSX.Props { right: number top: number bottom: number - text: string + info?: protocol.QuickInfoResponseBody } export class TooltipView implements JSX.ElementClass { @@ -18,7 +18,6 @@ export class TooltipView implements JSX.ElementClass { right: 0, top: 0, bottom: 0, - text: "", } etch.initialize(this) } @@ -69,8 +68,19 @@ export class TooltipView implements JSX.ElementClass { public render() { return (
    -
    +
    {this.tooltipContents()}
    ) } + + private tooltipContents() { + if (!this.props.info) return "â€Ĥ" + const code = ( +
    {this.props.info.displayString}
    + ) + const docs = this.props.info.documentation ? ( +
    {this.props.info.documentation}
    + ) : null + return [code, docs] + } } diff --git a/lib/main/atom/tooltips/util.ts b/lib/main/atom/tooltips/util.ts new file mode 100644 index 000000000..a7720c0a2 --- /dev/null +++ b/lib/main/atom/tooltips/util.ts @@ -0,0 +1,16 @@ +import {TextEditor} from "atom" + +// screen position from mouse event -- with <3 from Atom-Haskell +export function bufferPositionFromMouseEvent( + editor: TextEditor, + event: {clientX: number; clientY: number}, +) { + const sp = atom.views + .getView(editor) + .getComponent() + .screenPositionForMouseEvent(event) + if (isNaN(sp.row) || isNaN(sp.column)) { + return + } + return editor.bufferPositionForScreenPosition(sp) +} diff --git a/lib/main/atom/utils/atom.ts b/lib/main/atom/utils/atom.ts index 6714687dc..cefd79b58 100644 --- a/lib/main/atom/utils/atom.ts +++ b/lib/main/atom/utils/atom.ts @@ -1,6 +1,6 @@ import * as Atom from "atom" import * as path from "path" -import {FileLocationQuery, Location} from "./ts" +import {FileLocationQuery, Location, pointToLocation} from "./ts" // Return line/offset position in the editor using 1-indexed coordinates function getEditorPosition(editor: Atom.TextEditor): Location { @@ -17,7 +17,11 @@ export function isTypescriptFile(filePath: string | undefined): boolean { } export function typeScriptScopes(): ReadonlyArray { - return ["source.ts", "source.tsx", "typescript"] + const tsScopes = atom.config.get("atom-typescript").tsSyntaxScopes + if (atom.config.get("atom-typescript").allowJS) { + tsScopes.push(...atom.config.get("atom-typescript").jsSyntaxScopes) + } + return tsScopes } export function isTypescriptEditorWithPath(editor: Atom.TextEditor) { @@ -30,12 +34,26 @@ export function isTypescriptGrammar(editor: Atom.TextEditor): boolean { } function isAllowedExtension(ext: string) { - return [".ts", ".tst", ".tsx"].includes(ext) + const tsExts = atom.config.get("atom-typescript").tsFileExtensions + if (atom.config.get("atom-typescript").allowJS) { + tsExts.push(...atom.config.get("atom-typescript").jsFileExtensions) + } + return tsExts.includes(ext) } -export function getFilePathPosition(editor: Atom.TextEditor): FileLocationQuery | undefined { +export function getFilePathPosition( + editor: Atom.TextEditor, + position?: Atom.Point, +): FileLocationQuery | undefined { const file = editor.getPath() if (file !== undefined) { - return {file, ...getEditorPosition(editor)} + const location = position ? pointToLocation(position) : getEditorPosition(editor) + return {file, ...location} + } +} + +export function* getOpenEditorsPaths() { + for (const ed of atom.workspace.getTextEditors()) { + if (isTypescriptEditorWithPath(ed)) yield ed.getPath()! } } diff --git a/lib/main/atom/utils/ts.ts b/lib/main/atom/utils/ts.ts index 1171bcd6a..40b3ae0c2 100644 --- a/lib/main/atom/utils/ts.ts +++ b/lib/main/atom/utils/ts.ts @@ -1,6 +1,14 @@ -import {TextSpan, CodeEdit, FormatCodeSettings, Location} from "typescript/lib/protocol" import * as Atom from "atom" +import {Signature, SignatureParameter} from "atom/ide" import * as tsconfig from "tsconfig" +import { + CodeEdit, + FormatCodeSettings, + Location, + SignatureHelpItem, + SignatureHelpParameter, + TextSpan, +} from "typescript/lib/protocol" export {TextSpan, CodeEdit, FormatCodeSettings, Location} @@ -38,34 +46,45 @@ export function rangeToLocationRange(range: Atom.Range): LocationRangeQuery { } } -// Compare loc2 with loc1. The result is -1 if loc1 is smaller and 1 if it's larger. -export function compareLocation(loc1: Location, loc2: Location) { - if (loc1.line < loc2.line) { - return -1 - } else if (loc1.line > loc2.line) { - return 1 - } else { - if (loc1.offset < loc2.offset) { - return -1 - } else if (loc1.offset > loc2.offset) { - return 1 - } else { - return 0 - } +export async function getProjectConfig( + configFile: string, +): Promise<{ + formatCodeOptions: FormatCodeSettings + compileOnSave: boolean +}> { + const {config} = await tsconfig.load(configFile) + const options = (config as {formatCodeOptions?: FormatCodeSettings}).formatCodeOptions + + return { + formatCodeOptions: { + indentSize: atom.config.get("editor.tabLength"), + tabSize: atom.config.get("editor.tabLength"), + ...options, + }, + compileOnSave: !!(config as {compileOnSave?: boolean}).compileOnSave, } } -export function isLocationInRange(loc: Location, range: {start: Location; end: Location}) { - return compareLocation(range.start, loc) !== 1 && compareLocation(range.end, loc) !== -1 +export function signatureHelpItemToSignature(i: SignatureHelpItem): Signature { + return { + label: + partsToStr(i.prefixDisplayParts) + + i.parameters.map(x => partsToStr(x.displayParts)).join(partsToStr(i.separatorDisplayParts)) + + partsToStr(i.suffixDisplayParts), + documentation: partsToStr(i.documentation), + parameters: i.parameters.map(signatureHelpParameterToSignatureParameter), + } } -export async function getProjectCodeSettings(configFile: string): Promise { - const {config} = await tsconfig.load(configFile) - const options = config.formatCodeOptions - +export function signatureHelpParameterToSignatureParameter( + p: SignatureHelpParameter, +): SignatureParameter { return { - indentSize: atom.config.get("editor.tabLength"), - tabSize: atom.config.get("editor.tabLength"), - ...options, + label: partsToStr(p.displayParts), + documentation: partsToStr(p.documentation), } } + +export function partsToStr(x: Array<{text: string}>): string { + return x.map(i => i.text).join("") +} diff --git a/lib/main/atom/views/highlightComponent.tsx b/lib/main/atom/views/highlightComponent.tsx index 30e856e38..d74c2cff6 100644 --- a/lib/main/atom/views/highlightComponent.tsx +++ b/lib/main/atom/views/highlightComponent.tsx @@ -52,7 +52,7 @@ export function highlightMatches(name: string, query: string): QueryMatch[] { let matchedChars: string[] = [] // Build up a set of matched chars to be more semantic const queryMatches: QueryMatch[] = [] - const matches: number[] = match(name, query) + const matches: number[] = match(name, query) as number[] let matchIndex: number for (matchIndex of matches) { if (matchIndex < 0) { diff --git a/lib/main/atom/views/outline/navTreeUtils.ts b/lib/main/atom/views/outline/navTreeUtils.ts index 446632588..99de410ce 100644 --- a/lib/main/atom/views/outline/navTreeUtils.ts +++ b/lib/main/atom/views/outline/navTreeUtils.ts @@ -1,6 +1,6 @@ -import {NavigationTreeViewModel} from "./semanticViewModel" -import {NavigationTree} from "typescript/lib/protocol" import {isEqual} from "lodash" +import {NavigationTree} from "typescript/lib/protocol" +import {NavigationTreeViewModel} from "./semanticViewModel" /** * HELPER find the node that is "furthest down" the @@ -60,7 +60,6 @@ export function findNodeAt( * @return the start line for the NavTree node, or 0, if none could be determined */ export function getNodeStartLine(node: NavigationTree): number { - // console.log('getNodeStartLine.node -> ', node) return node.spans.length > 0 ? node.spans[0].start.line - 1 : 0 } @@ -70,7 +69,6 @@ export function getNodeStartLine(node: NavigationTree): number { * @return the start column for the NavTree node, or 0, if none could be determined */ export function getNodeStartOffset(node: NavigationTree): number { - // console.log('getNodeStartLine.node -> ', node) return node.spans.length > 0 ? node.spans[0].start.offset - 1 : 0 } diff --git a/lib/main/atom/views/outline/navigationNodeComponent.tsx b/lib/main/atom/views/outline/navigationNodeComponent.tsx index b9df13aec..3080fa0e4 100644 --- a/lib/main/atom/views/outline/navigationNodeComponent.tsx +++ b/lib/main/atom/views/outline/navigationNodeComponent.tsx @@ -1,6 +1,7 @@ import * as etch from "etch" -import {NavigationTreeViewModel, ToNodeScrollableEditor, SelectableNode} from "./semanticViewModel" +import {handlePromise} from "../../../../utils" import {isSameNode, isToggleEntry} from "./navTreeUtils" +import {NavigationTreeViewModel, SelectableNode, ToNodeScrollableEditor} from "./semanticViewModel" export interface Props extends JSX.Props { navTree: NavigationTreeViewModel @@ -70,7 +71,7 @@ export class NavigationNodeComponent implements JSX.ElementClass { this.props.ctrl.gotoNode(node) } else { node.collapsed = !node.collapsed - etch.update(this) + handlePromise(etch.update(this)) } } } diff --git a/lib/main/atom/views/outline/navigationTreeComponent.tsx b/lib/main/atom/views/outline/navigationTreeComponent.tsx index da9971306..1c6c5a9ac 100644 --- a/lib/main/atom/views/outline/navigationTreeComponent.tsx +++ b/lib/main/atom/views/outline/navigationTreeComponent.tsx @@ -1,18 +1,19 @@ -import atomUtils = require("../../utils") -import {Disposable, TextEditor, CursorPositionChangedEvent} from "atom" +import {CompositeDisposable, CursorPositionChangedEvent, Disposable, TextEditor} from "atom" import * as etch from "etch" import {isEqual} from "lodash" import {NavigationTree} from "typescript/lib/protocol" -import {NavigationTreeViewModel, ToNodeScrollableEditor, SelectableNode} from "./semanticViewModel" +import {GetClientFunction} from "../../../../client" +import {handlePromise} from "../../../../utils" +import atomUtils = require("../../utils") import {NavigationNodeComponent} from "./navigationNodeComponent" import { findNodeAt, getNodeStartLine, getNodeStartOffset, - restoreCollapsed, prepareNavTree, + restoreCollapsed, } from "./navTreeUtils" -import {WithTypescriptBuffer} from "../../../pluginManager" +import {NavigationTreeViewModel, SelectableNode, ToNodeScrollableEditor} from "./semanticViewModel" export interface Props extends JSX.Props { navTree: NavigationTreeViewModel | null @@ -25,12 +26,13 @@ export class NavigationTreeComponent private editorScrolling?: Disposable private editorChanging?: Disposable private selectedNode?: NavigationTreeViewModel - private withTypescriptBuffer?: WithTypescriptBuffer + private getClient?: GetClientFunction + private subscriptions = new CompositeDisposable() constructor(public props: Props) { prepareNavTree(props.navTree) etch.initialize(this) - atom.workspace.observeActiveTextEditor(this.subscribeToEditor) + this.subscriptions.add(atom.workspace.observeActiveTextEditor(this.subscribeToEditor)) } public async update(props: Partial) { @@ -42,19 +44,18 @@ export class NavigationTreeComponent } public async destroy() { - if (this.editorScrolling) { - this.editorScrolling.dispose() - } - if (this.editorChanging) { - this.editorChanging.dispose() - } + if (this.editorScrolling) this.editorScrolling.dispose() + if (this.editorChanging) this.editorChanging.dispose() + this.editorScrolling = undefined + this.editorChanging = undefined this.selectedNode = undefined + this.subscriptions.dispose() await etch.destroy(this) } - public setWithTypescriptBuffer(wtb: WithTypescriptBuffer) { - this.withTypescriptBuffer = wtb - this.loadNavTree() + public async setGetClient(getClient: GetClientFunction) { + this.getClient = getClient + await this.loadNavTree() } public getSelectedNode() { @@ -97,7 +98,7 @@ export class NavigationTreeComponent else return undefined } - private async setNavTree(navTree: NavigationTreeViewModel | null) { + private setNavTree(navTree: NavigationTreeViewModel | null) { prepareNavTree(navTree) if (isEqual(navTree, this.props.navTree)) { return @@ -117,17 +118,17 @@ export class NavigationTreeComponent private loadNavTree = async () => { if (!this.editor) return - if (!this.withTypescriptBuffer) return + if (!this.getClient) return const filePath = this.editor.getPath() if (filePath === undefined) return try { - return await this.withTypescriptBuffer(filePath, async buffer => { - const navTree = await buffer.getNavTree() - if (navTree) { - this.setNavTree(navTree as NavigationTreeViewModel) - await etch.update(this) - } - }) + const client = await this.getClient(filePath) + const navtreeResult = await client.execute("navtree", {file: filePath}) + const navTree = navtreeResult.body + if (navTree) { + this.setNavTree(navTree as NavigationTreeViewModel) + await etch.update(this) + } } catch (err) { console.error(err, filePath) } @@ -146,7 +147,7 @@ export class NavigationTreeComponent const selectedChild = findNodeAt(cursorLine, cursorLine, this.props.navTree) if (selectedChild !== this.selectedNode) { this.selectedNode = selectedChild - etch.update(this) + handlePromise(etch.update(this)) } } @@ -164,34 +165,19 @@ export class NavigationTreeComponent } } - private subscribeToEditor = (editor?: TextEditor) => { - if (!editor || !atomUtils.isTypescriptEditorWithPath(editor)) { - // unsubscribe from editor - // dispose subscriptions (except for editor-changing) - if (this.editorScrolling) { - this.editorScrolling.dispose() - } - if (this.editorChanging) { - this.editorChanging.dispose() - } + private subscribeToEditor = async (editor?: TextEditor) => { + if (this.editorScrolling) this.editorScrolling.dispose() + if (this.editorChanging) this.editorChanging.dispose() - this.update({navTree: null}) - return + if (!editor || !atomUtils.isTypescriptEditorWithPath(editor)) { + return this.update({navTree: null}) } + // else this.editor = editor - // set navTree - this.loadNavTree() + await this.loadNavTree() - // Subscribe to stop scrolling - if (this.editorScrolling) { - this.editorScrolling.dispose() - } this.editorScrolling = editor.onDidChangeCursorPosition(this.selectAtCursorLine) - - if (this.editorChanging) { - this.editorChanging.dispose() - } this.editorChanging = editor.onDidStopChanging(this.loadNavTree) } } diff --git a/lib/main/atom/views/outline/semanticView.ts b/lib/main/atom/views/outline/semanticView.ts index 9793e4674..82ece2b78 100644 --- a/lib/main/atom/views/outline/semanticView.ts +++ b/lib/main/atom/views/outline/semanticView.ts @@ -1,6 +1,6 @@ +import {GetClientFunction} from "../../../../client" import {NavigationTreeComponent} from "./navigationTreeComponent" import {NavigationTreeViewModel} from "./semanticViewModel" -import {WithTypescriptBuffer} from "../../../pluginManager" export const SEMANTIC_VIEW_URI = "atom-typescript://semantic-view" @@ -13,10 +13,6 @@ export interface SemanticViewSerializationData { deserializer: "atomts-semantic-view/SemanticView" } -export function deserializeSemanticView(serialized: SemanticViewSerializationData) { - return SemanticView.create(serialized.data) -} - export class SemanticView { public static create(config: SemanticViewOptions) { if (!SemanticView.instance) SemanticView.instance = new SemanticView(config) @@ -33,9 +29,9 @@ export class SemanticView { this.comp = new NavigationTreeComponent({navTree: config.navTree}) } - public setWithTypescriptBuffer(wtb: WithTypescriptBuffer) { - this.comp.setWithTypescriptBuffer(wtb) - this.comp.update({}) + public async setGetClient(gc: GetClientFunction) { + await this.comp.setGetClient(gc) + await this.comp.update({}) } public getTitle() { @@ -46,9 +42,9 @@ export class SemanticView { return SEMANTIC_VIEW_URI } - public destroy() { + public async destroy() { SemanticView.instance = null - this.comp.destroy() + await this.comp.destroy() } public getDefaultLocation() { @@ -61,7 +57,6 @@ export class SemanticView { } public serialize(): SemanticViewSerializationData { - // console.log("SemanticView.serialize()") // DEBUG return { deserializer: "atomts-semantic-view/SemanticView", data: {navTree: this.comp.props.navTree}, diff --git a/lib/main/atom/views/outline/semanticViewController.ts b/lib/main/atom/views/outline/semanticViewController.ts index 49f269f30..5dd63713b 100644 --- a/lib/main/atom/views/outline/semanticViewController.ts +++ b/lib/main/atom/views/outline/semanticViewController.ts @@ -1,28 +1,29 @@ import {CompositeDisposable} from "atom" -import {SemanticView, SEMANTIC_VIEW_URI} from "./semanticView" import {Disposable} from "atom" -import {WithTypescriptBuffer} from "../../../pluginManager" +import {GetClientFunction} from "../../../../client" +import {handlePromise} from "../../../../utils" +import {SEMANTIC_VIEW_URI, SemanticView} from "./semanticView" export class SemanticViewController { private view?: SemanticView private subscriptions: CompositeDisposable - constructor(private withTypescriptBuffer: WithTypescriptBuffer) { + constructor(private getClient: GetClientFunction) { this.subscriptions = new CompositeDisposable() const pane = atom.workspace.paneForURI(SEMANTIC_VIEW_URI) if (pane) this.view = pane.itemForURI(SEMANTIC_VIEW_URI) as SemanticView | undefined - if (this.view) this.view.setWithTypescriptBuffer(this.withTypescriptBuffer) + if (this.view) handlePromise(this.view.setGetClient(this.getClient)) this.subscriptions.add( new Disposable(() => { if (this.view) { atom.workspace.hide(this.view) - this.view.destroy() + handlePromise(this.view.destroy()) } }), atom.config.observe("atom-typescript.showSemanticView", val => { - if (val) this.show() + if (val) handlePromise(this.show()) else this.hide() }), ) @@ -40,7 +41,7 @@ export class SemanticViewController { private async show(): Promise { if (!this.view) { this.view = SemanticView.create({navTree: null}) - this.view.setWithTypescriptBuffer(this.withTypescriptBuffer) + await this.view.setGetClient(this.getClient) } await atom.workspace.open(this.view, {searchAllPanes: true}) diff --git a/lib/main/atom/views/renameView.tsx b/lib/main/atom/views/renameView.tsx index b9ff6a540..97255a096 100644 --- a/lib/main/atom/views/renameView.tsx +++ b/lib/main/atom/views/renameView.tsx @@ -1,5 +1,6 @@ -import * as etch from "etch" import {CompositeDisposable} from "atom" +import * as etch from "etch" +import {handlePromise} from "../../../utils" import {MiniEditor} from "../components/miniEditor" interface Props extends JSX.Props { @@ -108,7 +109,7 @@ export async function showRenameDialog(options: Options): Promise { items: T[] | Promise | ((filterText: string) => T[]) | ((filterText: string) => Promise) @@ -25,7 +26,7 @@ export async function selectListView({ let resolved = false const update = (props: object) => { if (resolved) return - select.update(props) + handlePromise(select.update(props)) } if (typeof items === "function") { didChangeQuery = async (query: string) => { @@ -60,9 +61,11 @@ export async function selectListView({ itemsClassList: ["atom-typescript"], }) if (typeof items !== "function") { - Promise.resolve(items).then(is => { - update({items: is, loadingMessage: undefined}) - }) + handlePromise( + Promise.resolve(items).then(is => { + update({items: is, loadingMessage: undefined}) + }), + ) } panel = atom.workspace.addModalPanel({ item: select, diff --git a/lib/main/atom/views/symbols/deps.d.ts b/lib/main/atom/views/symbols/deps.d.ts index 78280fff3..d3da96622 100644 --- a/lib/main/atom/views/symbols/deps.d.ts +++ b/lib/main/atom/views/symbols/deps.d.ts @@ -1,6 +1,6 @@ -import {WithTypescriptBuffer} from "../../../pluginManager" +import {GetClientFunction} from "../../../../client" import {EditorPositionHistoryManager} from "../../editorPositionHistoryManager" export interface Deps { - withTypescriptBuffer: WithTypescriptBuffer - getEditorPositionHistoryManager: () => EditorPositionHistoryManager + getClient: GetClientFunction + histGoForward: EditorPositionHistoryManager["goForward"] } diff --git a/lib/main/atom/views/symbols/fileSymbolsView.tsx b/lib/main/atom/views/symbols/fileSymbolsView.tsx index 8c7fdb497..4d4c46ff0 100644 --- a/lib/main/atom/views/symbols/fileSymbolsView.tsx +++ b/lib/main/atom/views/symbols/fileSymbolsView.tsx @@ -1,11 +1,11 @@ import {TextEditor} from "atom" -import {selectListView} from "../simpleSelectionView" import * as etch from "etch" +import {HighlightComponent} from "../highlightComponent" +import {selectListView} from "../simpleSelectionView" +import {Deps} from "./deps" import {generateFile} from "./generator" -import * as utils from "./utils" import {Tag} from "./symbolsTag" -import {Deps} from "./deps" -import {HighlightComponent} from "../highlightComponent" +import * as utils from "./utils" export async function toggle(editor: TextEditor, deps: Deps) { const filePath = editor.getPath() @@ -33,7 +33,7 @@ export async function toggle(editor: TextEditor, deps: Deps) { }, itemFilterKey: "name", }) - if (tag) utils.openTag(tag, editor, deps.getEditorPositionHistoryManager()) + if (tag) await utils.openTag(tag, editor, deps.histGoForward) else if (initialState) utils.deserializeEditorState(editor, initialState) } } diff --git a/lib/main/atom/views/symbols/generator.ts b/lib/main/atom/views/symbols/generator.ts index 4ddfb5881..46d965817 100644 --- a/lib/main/atom/views/symbols/generator.ts +++ b/lib/main/atom/views/symbols/generator.ts @@ -1,6 +1,6 @@ -import {Tag} from "./symbolsTag" import {NavigationTree, NavtoItem} from "typescript/lib/protocol" import {Deps} from "./deps" +import {Tag} from "./symbolsTag" export async function generateFile(filePath: string, deps: Deps) { const navtree = await getNavTree(filePath, deps) @@ -33,13 +33,26 @@ function* parseNavTo(navTree: NavtoItem[], parent?: Tag) { } async function getNavTree(filePath: string, deps: Deps) { - return deps.withTypescriptBuffer(filePath, buffer => { - return buffer.getNavTree() - }) + try { + const client = await deps.getClient(filePath) + const navtreeResult = await client.execute("navtree", {file: filePath}) + return navtreeResult.body + } catch (e) { + console.error(filePath, e) + } } async function getNavTo(filePath: string, search: string, deps: Deps) { - return deps.withTypescriptBuffer(filePath, buffer => { - return buffer.getNavTo(search) - }) + try { + const client = await deps.getClient(filePath) + const navtoResult = await client.execute("navto", { + file: filePath, + currentFileOnly: false, + searchValue: search, + maxResultCount: 1000, + }) + return navtoResult.body + } catch (e) { + console.error(filePath, e) + } } diff --git a/lib/main/atom/views/symbols/projectSymbolsView.tsx b/lib/main/atom/views/symbols/projectSymbolsView.tsx index d6279f4ce..aa378ff0c 100644 --- a/lib/main/atom/views/symbols/projectSymbolsView.tsx +++ b/lib/main/atom/views/symbols/projectSymbolsView.tsx @@ -1,10 +1,10 @@ import {TextEditor} from "atom" -import {selectListView} from "../simpleSelectionView" import * as etch from "etch" -import * as utils from "./utils" -import {generateProject} from "./generator" -import {Deps} from "./deps" import {HighlightComponent} from "../highlightComponent" +import {selectListView} from "../simpleSelectionView" +import {Deps} from "./deps" +import {generateProject} from "./generator" +import * as utils from "./utils" export async function toggle(editor: TextEditor, deps: Deps) { const filePath = editor.getPath() @@ -24,6 +24,6 @@ export async function toggle(editor: TextEditor, deps: Deps) { }, itemFilterKey: "name", }) - if (tag) utils.openTag(tag, editor, deps.getEditorPositionHistoryManager()) + if (tag) await utils.openTag(tag, editor, deps.histGoForward) } } diff --git a/lib/main/atom/views/symbols/symbolsViewController.ts b/lib/main/atom/views/symbols/symbolsViewController.ts index 6fde2c8ab..727d5144e 100644 --- a/lib/main/atom/views/symbols/symbolsViewController.ts +++ b/lib/main/atom/views/symbols/symbolsViewController.ts @@ -1,17 +1,18 @@ -import {toggle as toggleFileView} from "./fileSymbolsView" -import {toggle as toggleProjectView} from "./projectSymbolsView" import {TextEditor} from "atom" +import {handlePromise} from "../../../../utils" import {Deps} from "./deps" +import {toggle as toggleFileView} from "./fileSymbolsView" +import {toggle as toggleProjectView} from "./projectSymbolsView" export class SymbolsViewController { constructor(private deps: Deps) {} public toggleFileView(editor: TextEditor) { - toggleFileView(editor, this.deps) + handlePromise(toggleFileView(editor, this.deps)) } public toggleProjectView(editor: TextEditor) { - toggleProjectView(editor, this.deps) + handlePromise(toggleProjectView(editor, this.deps)) } public dispose() { diff --git a/lib/main/atom/views/symbols/utils.ts b/lib/main/atom/views/symbols/utils.ts index c637dcc3b..be7655f29 100644 --- a/lib/main/atom/views/symbols/utils.ts +++ b/lib/main/atom/views/symbols/utils.ts @@ -1,10 +1,14 @@ -import {Tag} from "./symbolsTag" import {TextEditor} from "atom" import {EditorPositionHistoryManager} from "../../editorPositionHistoryManager" +import {Tag} from "./symbolsTag" -export async function openTag(tag: Tag, editor: TextEditor, ephm: EditorPositionHistoryManager) { +export async function openTag( + tag: Tag, + editor: TextEditor, + histGoForward: EditorPositionHistoryManager["goForward"], +) { if (tag.file !== undefined) { - return ephm.goForward(editor, { + return histGoForward(editor, { file: tag.file, start: { line: tag.position.row + 1, diff --git a/lib/main/atomts.ts b/lib/main/atomts.ts index 92110c46f..df8e117a4 100644 --- a/lib/main/atomts.ts +++ b/lib/main/atomts.ts @@ -1,24 +1,38 @@ -import {PluginManager} from "./pluginManager" +import {DisposableLike} from "atom" +import {AutocompleteProvider} from "atom/autocomplete-plus" +import { + BusySignalService, + CodeActionProvider, + CodeHighlightProvider, + DatatipService, + DefinitionProvider, + FindReferencesProvider, + HyperclickProvider, + OutlineProvider, + SignatureHelpRegistry, +} from "atom/ide" import {IndieDelegate} from "atom/linter" import {StatusBar} from "atom/status-bar" +import {SemanticView, SemanticViewSerializationData} from "./atom/views/outline/semanticView" import {State} from "./packageState" -export {deserializeSemanticView} from "./atom/views/outline/semanticView" +import {PluginManager} from "./pluginManager" let pluginManager: PluginManager | undefined export async function activate(state: State) { - // tslint:disable:no-unsafe-any const pns = atom.packages.getAvailablePackageNames() - if (!(pns.includes("atom-ide-ui") || pns.includes("linter"))) { + const packagesProvidingUIServices = ["atom-ide-ui", "linter", "nuclide"] + if (!packagesProvidingUIServices.some(p => pns.includes(p))) { + // tslint:disable-next-line:no-unsafe-any await require("atom-package-deps").install("atom-typescript", true) } + // tslint:disable-next-line:no-unsafe-any require("etch").setScheduler(atom.views) // tslint:disable-next-line:no-shadowed-variable - const {PluginManager} = require("./pluginManager") + const {PluginManager} = require("./pluginManager") as typeof import("./pluginManager") pluginManager = new PluginManager(state) - // tslint:enable:no-unsafe-any } export function deactivate() { @@ -31,17 +45,39 @@ export function serialize() { else return undefined } +export function deserializeSemanticView(serialized: SemanticViewSerializationData): SemanticView { + const { + // tslint:disable-next-line:no-unsafe-any no-shadowed-variable + SemanticView, + } = require("./atom/views/outline/semanticView") as typeof import("./atom/views/outline/semanticView") + return SemanticView.create(serialized.data) +} + ////////////////////////////////// Consumers /////////////////////////////////// -export function consumeLinter(register: (opts: {name: string}) => IndieDelegate) { +export function consumeLinter( + register: (opts: {name: string}) => IndieDelegate, +): DisposableLike | void { if (pluginManager) return pluginManager.consumeLinter(register) } -export function consumeStatusBar(statusBar: StatusBar) { +export function consumeStatusBar(statusBar: StatusBar): DisposableLike | void { if (pluginManager) return pluginManager.consumeStatusBar(statusBar) } +export function consumeDatatipService(datatipService: DatatipService): DisposableLike | void { + if (pluginManager) return pluginManager.consumeDatatipService(datatipService) +} + +export function consumeSignatureHelp(registry: SignatureHelpRegistry): DisposableLike | void { + if (pluginManager) return pluginManager.consumeSigHelpService(registry) +} + +export function consumeBusySignal(busySignalService: BusySignalService): DisposableLike | void { + if (pluginManager) return pluginManager.consumeBusySignal(busySignalService) +} + ////////////////////////////////// Providers /////////////////////////////////// -export function provideAutocomplete() { +export function provideAutocomplete(): AutocompleteProvider[] | undefined { if (pluginManager) return pluginManager.provideAutocomplete() } @@ -49,10 +85,30 @@ export function provideIntentions() { if (pluginManager) return pluginManager.provideIntentions() } -export function provideCodeActions() { +export function provideIntentionsHighlight() { + if (pluginManager) return pluginManager.provideIntentionsHighlight() +} + +export function provideCodeActions(): CodeActionProvider | undefined { if (pluginManager) return pluginManager.provideCodeActions() } -export function provideHyperclick() { +export function provideHyperclick(): HyperclickProvider | undefined { if (pluginManager) return pluginManager.provideHyperclick() } + +export function provideReferences(): FindReferencesProvider | undefined { + if (pluginManager) return pluginManager.provideReferences() +} + +export function provideOutlines(): OutlineProvider | undefined { + if (pluginManager) return pluginManager.provideOutlines() +} + +export function provideDefinitions(): DefinitionProvider | undefined { + if (pluginManager) return pluginManager.provideDefinitions() +} + +export function provideCodeHighlight(): CodeHighlightProvider | undefined { + if (pluginManager) return pluginManager.provideCodeHighlight() +} diff --git a/lib/main/errorPusher.ts b/lib/main/errorPusher.ts index 3bc7ad77d..693c9d747 100644 --- a/lib/main/errorPusher.ts +++ b/lib/main/errorPusher.ts @@ -1,9 +1,10 @@ -import {debounce} from "lodash" -import {Diagnostic, Location} from "typescript/lib/protocol" +import {CompositeDisposable, Point, Range} from "atom" import {IndieDelegate, Message} from "atom/linter" -import {locationsToRange, isLocationInRange} from "./atom/utils" -import {CompositeDisposable} from "atom" +import {debounce} from "lodash" import * as path from "path" +import {Diagnostic} from "typescript/lib/protocol" +import {DiagnosticTypes} from "../client/clientResolver" +import {locationsToRange, spanToRange} from "./atom/utils" /** Class that collects errors from all of the clients and pushes them to the Linter service */ export class ErrorPusher { @@ -21,20 +22,23 @@ export class ErrorPusher { this.pushErrors = debounce(this.pushErrors.bind(this), 100) } + public *getErrorsInRange(filePath: string, range: Range): IterableIterator { + for (const prefixed of this.errors.values()) { + const errors = prefixed.get(path.normalize(filePath)) + if (errors) yield* errors.filter(err => spanToRange(err).intersectsWith(range)) + } + } + /** Return any errors that cover the given location */ - public getErrorsAt(filePath: string, loc: Location): Diagnostic[] { - const result: Diagnostic[] = [] + public *getErrorsAt(filePath: string, loc: Point): IterableIterator { for (const prefixed of this.errors.values()) { const errors = prefixed.get(path.normalize(filePath)) - if (errors) { - result.push(...errors.filter(err => isLocationInRange(loc, err))) - } + if (errors) yield* errors.filter(err => spanToRange(err).containsPoint(loc)) } - return result } /** Set errors. Previous errors with the same prefix and filePath are going to be replaced */ - public setErrors(prefix: string, filePath: string, errors: Diagnostic[]) { + public setErrors(prefix: DiagnosticTypes, filePath: string, errors: Diagnostic[]) { let prefixed = this.errors.get(prefix) if (!prefixed) { prefixed = new Map() @@ -46,11 +50,16 @@ export class ErrorPusher { this.pushErrors() } - /** Clear all errors */ - public clear() { - if (this.linter) { - this.linter.clearMessages() + public clearFileErrors(filePath: string) { + for (const map of this.errors.values()) { + map.delete(filePath) } + this.pushErrors() + } + + public clear() { + if (!this.linter) return + this.linter.clearMessages() } public setLinter(linter: IndieDelegate) { diff --git a/lib/main/pluginManager.ts b/lib/main/pluginManager.ts index 0842e71cd..71109eafe 100644 --- a/lib/main/pluginManager.ts +++ b/lib/main/pluginManager.ts @@ -1,28 +1,41 @@ import * as Atom from "atom" -import {AutocompleteProvider} from "./atom/autoCompleteProvider" -import {ClientResolver} from "../client/clientResolver" -import {getHyperclickProvider} from "./atom/hyperclickProvider" -import {CodefixProvider, IntentionsProvider, CodeActionsProvider} from "./atom/codefix" import {CompositeDisposable} from "atom" -import {debounce} from "lodash" -import {ErrorPusher} from "./errorPusher" +import {BusySignalService, DatatipService, SignatureHelpRegistry} from "atom/ide" import {IndieDelegate} from "atom/linter" import {StatusBar} from "atom/status-bar" -import {StatusPanel} from "./atom/components/statusPanel" -import {TypescriptEditorPane} from "./typescriptEditorPane" -import {TypescriptBuffer} from "./typescriptBuffer" +import {throttle} from "lodash" +import * as path from "path" +import {ClientResolver} from "../client" +import {handlePromise} from "../utils" +import {getCodeActionsProvider} from "./atom-ide/codeActionsProvider" +import {getCodeHighlightProvider} from "./atom-ide/codeHighlightProvider" +import {TSDatatipProvider} from "./atom-ide/datatipProvider" +import {getDefinitionProvider} from "./atom-ide/definitionsProvider" +import {getFindReferencesProvider} from "./atom-ide/findReferencesProvider" +import {getHyperclickProvider} from "./atom-ide/hyperclickProvider" +import {getOutlineProvider} from "./atom-ide/outlineProvider" +import {TSSigHelpProvider} from "./atom-ide/sigHelpProvider" +import {AutocompleteProvider} from "./atom/autoCompleteProvider" +import {CodefixProvider} from "./atom/codefix" +import { + getIntentionsHighlightsProvider, + getIntentionsProvider, +} from "./atom/codefix/intentionsProvider" import {registerCommands} from "./atom/commands" +import {StatusPanel, TBuildStatus, TProgress} from "./atom/components/statusPanel" +import {EditorPositionHistoryManager} from "./atom/editorPositionHistoryManager" +import {OccurrenceManager} from "./atom/occurrence/manager" +import {SigHelpManager} from "./atom/sigHelp/manager" +import {TooltipManager} from "./atom/tooltips/manager" +import {isTypescriptEditorWithPath, spanToRange, TextSpan} from "./atom/utils" import {SemanticViewController} from "./atom/views/outline/semanticViewController" import {SymbolsViewController} from "./atom/views/symbols/symbolsViewController" -import {EditorPositionHistoryManager} from "./atom/editorPositionHistoryManager" +import {ErrorPusher} from "./errorPusher" import {State} from "./packageState" -import {TextSpan, spanToRange} from "./atom/utils" -import * as path from "path" +import {TypescriptBuffer} from "./typescriptBuffer" +import {TypescriptEditorPane} from "./typescriptEditorPane" -export type WithTypescriptBuffer = ( - filePath: string, - action: (buffer: TypescriptBuffer) => Promise, -) => Promise +export type FlushTypescriptBuffer = (filePath: string) => Promise export interface Change extends TextSpan { newText: string @@ -33,6 +46,7 @@ export interface Edit { } export type Edits = ReadonlyArray> export type ApplyEdits = (edits: Edits) => Promise +export type ReportBusyWhile = (title: string, generator: () => Promise) => Promise export class PluginManager { // components @@ -44,23 +58,27 @@ export class PluginManager { private semanticViewController: SemanticViewController private symbolsViewController: SymbolsViewController private editorPosHist: EditorPositionHistoryManager - private readonly panes: TypescriptEditorPane[] = [] // TODO: do we need it? + private tooltipManager: TooltipManager + private usingBuiltinTooltipManager = true + private sigHelpManager: SigHelpManager + private usingBuiltinSigHelpManager = true + private occurrenceManager: OccurrenceManager + private pending = new Set<{title: string}>() + private busySignalService?: BusySignalService + private typescriptPaneFactory: (editor: Atom.TextEditor) => TypescriptEditorPane public constructor(state?: Partial) { this.subscriptions = new CompositeDisposable() - this.clientResolver = new ClientResolver() + this.clientResolver = new ClientResolver(this.reportBusyWhile) this.subscriptions.add(this.clientResolver) - this.statusPanel = new StatusPanel({clientResolver: this.clientResolver}) + this.statusPanel = new StatusPanel() this.subscriptions.add(this.statusPanel) this.errorPusher = new ErrorPusher() this.subscriptions.add(this.errorPusher) - // NOTE: This has to run before withTypescriptBuffer is used to populate this.panes - this.subscribeEditors() - this.codefixProvider = new CodefixProvider( this.clientResolver, this.errorPusher, @@ -68,21 +86,72 @@ export class PluginManager { ) this.subscriptions.add(this.codefixProvider) - this.semanticViewController = new SemanticViewController(this.withTypescriptBuffer) + this.semanticViewController = new SemanticViewController(this.getClient) this.subscriptions.add(this.semanticViewController) - this.symbolsViewController = new SymbolsViewController(this) - this.subscriptions.add(this.symbolsViewController) - this.editorPosHist = new EditorPositionHistoryManager(state && state.editorPosHistState) this.subscriptions.add(this.editorPosHist) + this.symbolsViewController = new SymbolsViewController({ + histGoForward: this.histGoForward, + getClient: this.getClient, + }) + this.subscriptions.add(this.symbolsViewController) + + this.tooltipManager = new TooltipManager(this.getClient) + this.subscriptions.add(this.tooltipManager) + + this.sigHelpManager = new SigHelpManager({ + getClient: this.getClient, + flushTypescriptBuffer: this.flushTypescriptBuffer, + }) + this.subscriptions.add(this.sigHelpManager) + + this.occurrenceManager = new OccurrenceManager(this.getClient) + this.subscriptions.add(this.occurrenceManager) + + this.typescriptPaneFactory = TypescriptEditorPane.createFactory({ + clearFileErrors: this.clearFileErrors, + getClient: this.getClient, + reportBuildStatus: this.reportBuildStatus, + reportClientInfo: this.reportClientInfo, + }) + this.subscribeEditors() + // Register the commands - this.subscriptions.add(registerCommands(this)) + this.subscriptions.add( + registerCommands({ + getClient: this.getClient, + applyEdits: this.applyEdits, + clearErrors: this.clearErrors, + killAllServers: this.killAllServers, + reportProgress: this.reportProgress, + reportBuildStatus: this.reportBuildStatus, + toggleSemanticViewController: () => { + handlePromise(this.semanticViewController.toggle()) + }, + toggleFileSymbolsView: ed => { + this.symbolsViewController.toggleFileView(ed) + }, + toggleProjectSymbolsView: ed => { + this.symbolsViewController.toggleProjectView(ed) + }, + histGoForward: this.histGoForward, + histGoBack: () => this.editorPosHist.goBack(), + histShowHistory: () => this.editorPosHist.showHistory(), + showTooltipAt: this.showTooltipAt, + showSigHelpAt: this.showSigHelpAt, + hideSigHelpAt: this.hideSigHelpAt, + }), + ) } public destroy() { this.subscriptions.dispose() + for (const ed of atom.workspace.getTextEditors()) { + const pane = TypescriptEditorPane.lookupPane(ed) + if (pane) pane.destroy() + } } public serialize(): State { @@ -99,9 +168,11 @@ export class PluginManager { this.errorPusher.setLinter(linter) - this.clientResolver.on("diagnostics", ({type, filePath, diagnostics}) => { - this.errorPusher.setErrors(type, filePath, diagnostics) - }) + this.subscriptions.add( + this.clientResolver.on("diagnostics", ({type, filePath, diagnostics}) => { + this.errorPusher.setErrors(type, filePath, diagnostics) + }), + ) } public consumeStatusBar(statusBar: StatusBar) { @@ -122,135 +193,211 @@ export class PluginManager { return disp } + public consumeDatatipService(datatip: DatatipService) { + if (atom.config.get("atom-typescript").preferBuiltinTooltips) return + const disp = datatip.addProvider(new TSDatatipProvider(this.getClient)) + this.subscriptions.add(disp) + this.tooltipManager.dispose() + this.usingBuiltinTooltipManager = false + return disp + } + + public consumeSigHelpService(registry: SignatureHelpRegistry): void | Atom.DisposableLike { + if (atom.config.get("atom-typescript").preferBuiltinSigHelp) return + const disp = registry(new TSSigHelpProvider(this.getClient, this.flushTypescriptBuffer)) + this.subscriptions.add(disp) + this.sigHelpManager.dispose() + this.usingBuiltinSigHelpManager = false + return disp + } + + public consumeBusySignal(busySignalService: BusySignalService): void | Atom.DisposableLike { + if (atom.config.get("atom-typescript").preferBuiltinBusySignal) return + this.busySignalService = busySignalService + const disp = { + dispose: () => { + if (this.busySignalService) this.busySignalService.dispose() + this.busySignalService = undefined + }, + } + this.subscriptions.add(disp) + return disp + } + // Registering an autocomplete provider public provideAutocomplete() { - return [ - new AutocompleteProvider(this.clientResolver, { - withTypescriptBuffer: this.withTypescriptBuffer, - }), - ] + return [new AutocompleteProvider(this.getClient, this.flushTypescriptBuffer)] } public provideIntentions() { - return new IntentionsProvider(this.codefixProvider) + return getIntentionsProvider(this.codefixProvider) } - public provideCodeActions(): CodeActionsProvider { - return new CodeActionsProvider(this.codefixProvider) + public provideIntentionsHighlight() { + return getIntentionsHighlightsProvider(this.codefixProvider) + } + + public provideCodeActions() { + return getCodeActionsProvider(this.codefixProvider) } public provideHyperclick() { - return getHyperclickProvider(this.clientResolver, this.editorPosHist) + return getHyperclickProvider(this.getClient, this.histGoForward) + } + + public provideReferences() { + return getFindReferencesProvider(this.getClient) + } + + public provideOutlines() { + return getOutlineProvider(this.getClient) } - public clearErrors = () => { + public provideDefinitions() { + if (atom.config.get("atom-typescript").disableAtomIdeDefinitions) return + return getDefinitionProvider(this.getClient) + } + + public provideCodeHighlight() { + if (atom.config.get("atom-typescript").preferBuiltinOccurrenceHighlight) return + this.occurrenceManager.dispose() + return getCodeHighlightProvider(this.getClient) + } + + private clearErrors = () => { this.errorPusher.clear() } - public getClient = async (filePath: string) => { - const pane = this.panes.find(p => p.buffer.getPath() === filePath) - if (pane && pane.client) { - return pane.client - } + private clearFileErrors = (filePath: string) => { + this.errorPusher.clearFileErrors(filePath) + } + private getClient = async (filePath: string) => { return this.clientResolver.get(filePath) } - public getStatusPanel = () => this.statusPanel + private killAllServers = () => { + handlePromise(this.clientResolver.restartAllServers()) + } + + private flushTypescriptBuffer: FlushTypescriptBuffer = async filePath => { + const normalizedFilePath = path.normalize(filePath) + const ed = atom.workspace.getTextEditors().find(p => p.getPath() === normalizedFilePath) + if (ed) { + const buffer = TypescriptBuffer.create(ed.getBuffer(), { + getClient: this.getClient, + clearFileErrors: this.clearFileErrors, + reportBuildStatus: this.reportBuildStatus, + }) + await buffer.flush() + } + } - public withTypescriptBuffer: WithTypescriptBuffer = async (filePath, action) => { + private withBuffer = async ( + filePath: string, + action: (buffer: Atom.TextBuffer) => Promise, + ) => { const normalizedFilePath = path.normalize(filePath) - const pane = this.panes.find(p => p.buffer.getPath() === normalizedFilePath) - if (pane) return action(pane.buffer) + const ed = atom.workspace.getTextEditors().find(p => p.getPath() === normalizedFilePath) + + // found open buffer + if (ed) return action(ed.getBuffer()) // no open buffer const buffer = await Atom.TextBuffer.load(normalizedFilePath) try { - const tsbuffer = TypescriptBuffer.create(buffer, fp => this.clientResolver.get(fp)) - return await action(tsbuffer) + return await action(buffer) } finally { if (buffer.isModified()) await buffer.save() buffer.destroy() } } - public applyEdits: ApplyEdits = async edits => + private reportBusyWhile: ReportBusyWhile = async (title, generator) => { + if (this.busySignalService) { + return this.busySignalService.reportBusyWhile(title, generator) + } else { + const event = {title} + try { + this.pending.add(event) + this.drawPending(Array.from(this.pending)) + return await generator() + } finally { + this.pending.delete(event) + this.drawPending(Array.from(this.pending)) + } + } + } + + private reportProgress = (progress: TProgress) => { + handlePromise(this.statusPanel.update({progress})) + } + + private reportBuildStatus = (buildStatus: TBuildStatus | undefined) => { + handlePromise(this.statusPanel.update({buildStatus})) + } + + private reportClientInfo = (info: {clientVersion: string; tsConfigPath: string | undefined}) => { + handlePromise(this.statusPanel.update(info)) + } + + private applyEdits: ApplyEdits = async edits => void Promise.all( edits.map(edit => - this.withTypescriptBuffer(edit.fileName, async buffer => { - buffer.buffer.transact(() => { + this.withBuffer(edit.fileName, async buffer => { + buffer.transact(() => { const changes = edit.textChanges .map(e => ({range: spanToRange(e), newText: e.newText})) + .reverse() // NOTE: needs reverse for cases where ranges are same for two changes .sort((a, b) => b.range.compare(a.range)) for (const change of changes) { - buffer.buffer.setTextInRange(change.range, change.newText) + buffer.setTextInRange(change.range, change.newText) } }) - return buffer.flush() + const filePath = buffer.getPath() + if (filePath !== undefined) await this.flushTypescriptBuffer(filePath) }), ), ) - public getSemanticViewController = () => this.semanticViewController + private showTooltipAt = async (ed: Atom.TextEditor): Promise => { + if (this.usingBuiltinTooltipManager) await this.tooltipManager.showExpressionAt(ed) + else await atom.commands.dispatch(atom.views.getView(ed), "datatip:toggle") + } - public getSymbolsViewController = () => this.symbolsViewController + private showSigHelpAt = async (ed: Atom.TextEditor): Promise => { + if (this.usingBuiltinSigHelpManager) await this.sigHelpManager.showTooltipAt(ed) + else await atom.commands.dispatch(atom.views.getView(ed), "signature-help:show") + } - public getEditorPositionHistoryManager = () => this.editorPosHist + private hideSigHelpAt = (ed: Atom.TextEditor): boolean => { + if (this.usingBuiltinSigHelpManager) return this.sigHelpManager.hideTooltipAt(ed) + else return false + } - private subscribeEditors() { - let activePane: TypescriptEditorPane | undefined + private histGoForward: EditorPositionHistoryManager["goForward"] = (ed, opts) => { + return this.editorPosHist.goForward(ed, opts) + } + private subscribeEditors() { this.subscriptions.add( atom.workspace.observeTextEditors((editor: Atom.TextEditor) => { - this.panes.push( - new TypescriptEditorPane(editor, { - getClient: (filePath: string) => this.clientResolver.get(filePath), - onClose: filePath => { - // Clear errors if any from this file - this.errorPusher.setErrors("syntaxDiag", filePath, []) - this.errorPusher.setErrors("semanticDiag", filePath, []) - }, - onDispose: pane => { - if (activePane === pane) { - activePane = undefined - } - - this.panes.splice(this.panes.indexOf(pane), 1) - }, - onSave: debounce((pane: TypescriptEditorPane) => { - if (!pane.client) { - return - } - - const files: string[] = [] - for (const p of this.panes.sort((a, b) => a.activeAt - b.activeAt)) { - const filePath = p.buffer.getPath() - if (filePath !== undefined && p.isTypescript && p.client === pane.client) { - files.push(filePath) - } - } - - pane.client.execute("geterr", {files, delay: 100}) - }, 50), - statusPanel: this.statusPanel, - }), - ) + this.typescriptPaneFactory(editor) }), - ) - - this.subscriptions.add( - atom.workspace.observeActiveTextEditor((editor?: Atom.TextEditor) => { - if (activePane) { - activePane.onDeactivated() - activePane = undefined - } - - const pane = this.panes.find(p => p.editor === editor) - if (pane) { - activePane = pane - pane.onActivated() - } + atom.workspace.onDidChangeActiveTextEditor(ed => { + if (ed && isTypescriptEditorWithPath(ed)) { + handlePromise(this.statusPanel.show()) + const tep = TypescriptEditorPane.lookupPane(ed) + if (tep) tep.didActivate() + } else handlePromise(this.statusPanel.hide()) }), ) } + + // tslint:disable-next-line:member-ordering + private drawPending = throttle( + (pending: Array<{title: string}>) => handlePromise(this.statusPanel.update({pending})), + 100, + {leading: false}, + ) } diff --git a/lib/main/typescriptBuffer.ts b/lib/main/typescriptBuffer.ts index 8874acb8b..a3b6e740f 100644 --- a/lib/main/typescriptBuffer.ts +++ b/lib/main/typescriptBuffer.ts @@ -1,57 +1,68 @@ // A class to keep all changes to the buffer in sync with tsserver. This is mainly used with // the editor panes, but is also useful for editor-less buffer changes (renameRefactor). import * as Atom from "atom" -import {TypescriptServiceClient as Client} from "../client/client" -import {isTypescriptFile} from "./atom/utils" +import {flatten} from "lodash" +import {GetClientFunction, TSClient} from "../client" +import {handlePromise} from "../utils" +import {TBuildStatus} from "./atom/components/statusPanel" +import {getOpenEditorsPaths, getProjectConfig, isTypescriptFile} from "./atom/utils" + +export interface Deps { + getClient: GetClientFunction + clearFileErrors: (filePath: string) => void + reportBuildStatus: (status: TBuildStatus | undefined) => void +} export class TypescriptBuffer { - public static create(buffer: Atom.TextBuffer, getClient: (filePath: string) => Promise) { + public static create(buffer: Atom.TextBuffer, deps: Deps) { const b = TypescriptBuffer.bufferMap.get(buffer) if (b) return b else { - const nb = new TypescriptBuffer(buffer, getClient) + const nb = new TypescriptBuffer(buffer, deps) TypescriptBuffer.bufferMap.set(buffer, nb) return nb } } private static bufferMap = new WeakMap() - public readonly events = new Atom.Emitter< - { - saved: void - opened: void - changed: void - }, - { - closed: string - } - >() + private events = new Atom.Emitter<{ + opened: void + updated: void + }>() - // Timestamps for buffer events - private changedAt: number = 0 - private changedAtBatch: number = 0 + private lastChangedAt = Date.now() + private lastUpdatedAt = Date.now() // Promise that resolves to the correct client for this filePath private state?: { - client: Promise + client: TSClient filePath: string + // Path to the project's tsconfig.json + configFile: Atom.File | undefined + subscriptions: Atom.CompositeDisposable } + private compileOnSave: boolean = false private subscriptions = new Atom.CompositeDisposable() + private openPromise: Promise + + // tslint:disable-next-line:member-ordering + public on = this.events.on.bind(this.events) - private constructor( - public buffer: Atom.TextBuffer, - public getClient: (filePath: string) => Promise, - ) { + private constructor(public buffer: Atom.TextBuffer, private deps: Deps) { this.subscriptions.add( buffer.onDidChange(this.onDidChange), buffer.onDidChangePath(this.onDidChangePath), buffer.onDidDestroy(this.dispose), - buffer.onDidSave(this.onDidSave), - buffer.onDidStopChanging(this.onDidStopChanging), + buffer.onDidSave(() => { + handlePromise(this.onDidSave()) + }), + buffer.onDidStopChanging(arg => { + handlePromise(this.onDidStopChanging(arg)) + }), ) - this.open() + this.openPromise = this.open(this.buffer.getPath()) } public getPath() { @@ -60,10 +71,10 @@ export class TypescriptBuffer { // If there are any pending changes, flush them out to the Typescript server public async flush() { - if (this.changedAt > this.changedAtBatch) { - await new Promise(resolve => { - const sub = this.buffer.onDidStopChanging(() => { - sub.dispose() + if (this.lastChangedAt > this.lastUpdatedAt) { + await new Promise(resolve => { + const disp = this.events.once("updated", () => { + disp.dispose() resolve() }) this.buffer.emitDidStopChangingEvent() @@ -71,115 +82,173 @@ export class TypescriptBuffer { } } - public async getNavTree() { + public getInfo() { if (!this.state) return - const client = await this.state.client - try { - const navtreeResult = await client.execute("navtree", {file: this.state.filePath}) - return navtreeResult.body! - } catch (err) { - console.error(err, this.state.filePath) + return { + clientVersion: this.state.client.version, + tsConfigPath: this.state.configFile && this.state.configFile.getPath(), } - return } - public async getNavTo(search: string) { + private async getErr({allFiles}: {allFiles: boolean}) { if (!this.state) return - const client = await this.state.client - try { - const navtoResult = await client.execute("navto", { - file: this.state.filePath, - currentFileOnly: false, - searchValue: search, - maxResultCount: 1000, - }) - return navtoResult.body! - } catch (err) { - console.error(err, this.state.filePath) + const files = allFiles ? Array.from(getOpenEditorsPaths()) : [this.state.filePath] + await this.state.client.execute("geterr", { + files, + delay: 100, + }) + } + + /** Throws! */ + private async compile() { + if (!this.state) return + const {client, filePath} = this.state + const result = await client.execute("compileOnSaveAffectedFileList", { + file: filePath, + }) + const fileNames = flatten(result.body.map(project => project.fileNames)) + + if (fileNames.length === 0) return + + const promises = fileNames.map(file => client.execute("compileOnSaveEmitFile", {file})) + const saved = await Promise.all(promises) + + if (!saved.every(res => !!res.body)) { + throw new Error("Some files failed to emit") } - return } - private async open() { - const filePath = this.buffer.getPath() + private async doCompileOnSave() { + if (!this.compileOnSave) return + this.deps.reportBuildStatus(undefined) + try { + await this.compile() + this.deps.reportBuildStatus({success: true}) + } catch (error) { + const e = error as Error + console.error("Save failed with error", e) + this.deps.reportBuildStatus({success: false, message: e.message}) + } + } + private async open(filePath: string | undefined) { if (filePath !== undefined && isTypescriptFile(filePath)) { + const client = await this.deps.getClient(filePath) + this.state = { - client: this.getClient(filePath), + client, filePath, + configFile: undefined, + subscriptions: new Atom.CompositeDisposable(), } - const client = await this.state.client - await client.execute("open", { - file: this.state.filePath, - fileContent: this.buffer.getText(), + this.state.subscriptions.add(client.on("restarted", () => handlePromise(this.init()))) + + await this.init() + + const result = await client.execute("projectInfo", { + needFileNameList: false, + file: filePath, }) + // TODO: wrong type here, complain on TS repo + if ((result.body!.configFileName as string | undefined) !== undefined) { + this.state.configFile = new Atom.File(result.body!.configFileName) + await this.readConfigFile() + this.state.subscriptions.add( + this.state.configFile.onDidChange(() => handlePromise(this.readConfigFile())), + ) + } + this.events.emit("opened") } else { - this.state = undefined + return this.close() } } - private dispose = async () => { + private dispose = () => { this.subscriptions.dispose() - await this.close() + handlePromise(this.close()) + } + + private async readConfigFile() { + if (!this.state || !this.state.configFile) return + const options = await getProjectConfig(this.state.configFile.getPath()) + this.compileOnSave = options.compileOnSave + await this.state.client.execute("configure", { + file: this.state.filePath, + formatOptions: options.formatCodeOptions, + }) + } + + private init = async () => { + if (!this.state) return + await this.state.client.execute("open", { + file: this.state.filePath, + fileContent: this.buffer.getText(), + }) + + await this.getErr({allFiles: false}) } private close = async () => { + await this.openPromise if (this.state) { - const client = await this.state.client + const client = this.state.client const file = this.state.filePath await client.execute("close", {file}) - this.events.emit("closed", file) + this.deps.clearFileErrors(file) + this.state.subscriptions.dispose() this.state = undefined } } private onDidChange = () => { - this.changedAt = Date.now() + this.lastChangedAt = Date.now() } - private onDidChangePath = async () => { - await this.close() - await this.open() + private onDidChangePath = (newPath: string) => { + handlePromise( + this.close().then(() => { + this.openPromise = this.open(newPath) + }), + ) } private onDidSave = async () => { - // Check if there isn't a onDidStopChanging event pending. - const {changedAt, changedAtBatch} = this - if (changedAtBatch > 0 && changedAt > changedAtBatch) { - await new Promise(resolve => this.events.once("changed", resolve)) - } - - this.events.emit("saved") + await this.flush() + await this.getErr({allFiles: true}) + await this.doCompileOnSave() } private onDidStopChanging = async ({changes}: {changes: Atom.TextChange[]}) => { - // Don't update changedAt or emit any events if there are no actual changes or file isn't open + // If there are no actual changes, or the file isn't open, we have nothing to do if (changes.length === 0 || !this.state) return - this.changedAtBatch = Date.now() - - const client = await this.state.client - - for (const change of changes) { - const {start, oldExtent, newText} = change - - const end = { - endLine: start.row + oldExtent.row + 1, - endOffset: (oldExtent.row === 0 ? start.column + oldExtent.column : oldExtent.column) + 1, - } - - await client.execute("change", { - ...end, - file: this.state.filePath, - line: start.row + 1, - offset: start.column + 1, - insertString: newText, - }) - } + this.deps.reportBuildStatus(undefined) + + const {client, filePath} = this.state + + // NOTE: this might look somewhat weird until we realize that + // awaiting on each "change" command may lead to arbitrary + // interleaving, while pushing them all at once guarantees + // that all subsequent "change" commands will be sequenced after + // the ones we pushed + await Promise.all( + changes.map(({oldRange, newText}) => + client.execute("change", { + file: filePath, + line: oldRange.start.row + 1, + offset: oldRange.start.column + 1, + endLine: oldRange.end.row + 1, + endOffset: oldRange.end.column + 1, + insertString: newText, + }), + ), + ) - this.events.emit("changed") + this.lastUpdatedAt = Date.now() + this.events.emit("updated") + return this.getErr({allFiles: false}) } } diff --git a/lib/main/typescriptEditorPane.ts b/lib/main/typescriptEditorPane.ts index 1ff7ed972..87048dadc 100644 --- a/lib/main/typescriptEditorPane.ts +++ b/lib/main/typescriptEditorPane.ts @@ -1,243 +1,85 @@ import * as Atom from "atom" import {CompositeDisposable} from "atom" -import {debounce, flatten} from "lodash" -import {spanToRange, getProjectCodeSettings, isTypescriptEditorWithPath} from "./atom/utils" -import {StatusPanel} from "./atom/components/statusPanel" +import {GetClientFunction} from "../client" +import {TBuildStatus} from "./atom/components/statusPanel" +import {isTypescriptEditorWithPath} from "./atom/utils" import {TypescriptBuffer} from "./typescriptBuffer" -import {TypescriptServiceClient} from "../client/client" -import {TooltipManager} from "./atom/tooltipManager" interface PaneOptions { - getClient: (filePath: string) => Promise - - // Called when the pane is being disposed. - onDispose: (pane: TypescriptEditorPane) => void - - // Called when the Typescript view of the file is closed. This happens when the pane is closed - // and also when the file is renamed. - onClose: (filePath: string) => void - - onSave: (pane: TypescriptEditorPane) => void - statusPanel: StatusPanel + getClient: GetClientFunction + reportClientInfo: (info: {clientVersion: string; tsConfigPath: string | undefined}) => void + reportBuildStatus: (status: TBuildStatus | undefined) => void + clearFileErrors: (filePath: string) => void } -export class TypescriptEditorPane implements Atom.Disposable { - // Timestamp for activated event - public activeAt: number = 0 - public client?: TypescriptServiceClient - public isTypescript = false - public readonly buffer: TypescriptBuffer +export class TypescriptEditorPane { + private static editorMap = new WeakMap() + // tslint:disable-next-line:member-ordering + public static createFactory( + opts: PaneOptions, + ): (editor: Atom.TextEditor) => TypescriptEditorPane { + return (editor: Atom.TextEditor) => { + let tep = TypescriptEditorPane.editorMap.get(editor) + if (!tep) { + tep = new TypescriptEditorPane(editor, opts) + TypescriptEditorPane.editorMap.set(editor, tep) + } + return tep + } + } + // tslint:disable-next-line:member-ordering + public static lookupPane(editor: Atom.TextEditor): TypescriptEditorPane | undefined { + return TypescriptEditorPane.editorMap.get(editor) + } - // Path to the project's tsconfig.json - private configFile: string = "" - private isActive = false - private isOpen = false + private readonly buffer: TypescriptBuffer - private readonly occurrenceMarkers: Atom.DisplayMarker[] = [] private readonly subscriptions = new CompositeDisposable() + private isTypescript = false - constructor(public readonly editor: Atom.TextEditor, private opts: PaneOptions) { - this.updateMarkers = debounce(this.updateMarkers.bind(this), 100) - this.buffer = TypescriptBuffer.create(editor.getBuffer(), opts.getClient) - this.subscriptions.add( - this.buffer.events.on("changed", this.onChanged), - this.buffer.events.on("closed", this.opts.onClose), - this.buffer.events.on("opened", this.onOpened), - this.buffer.events.on("saved", this.onSaved), - ) + private constructor(private readonly editor: Atom.TextEditor, private opts: PaneOptions) { + this.buffer = TypescriptBuffer.create(editor.getBuffer(), opts) + this.subscriptions.add(this.buffer.on("opened", this.onOpened)) this.checkIfTypescript() this.subscriptions.add( editor.onDidChangePath(this.checkIfTypescript), editor.onDidChangeGrammar(this.checkIfTypescript), - this.editor.onDidChangeCursorPosition(this.onDidChangeCursorPosition), - this.editor.onDidDestroy(this.onDidDestroy), + editor.onDidDestroy(this.destroy), ) - - this.subscriptions.add(new TooltipManager(this.editor, opts.getClient)) } - public dispose() { + public destroy = () => { atom.views.getView(this.editor).classList.remove("typescript-editor") this.subscriptions.dispose() - this.opts.onDispose(this) - } - - public onActivated = () => { - this.activeAt = Date.now() - this.isActive = true - - const filePath = this.buffer.getPath() - if (this.isTypescript && filePath !== undefined) { - this.opts.statusPanel.show() - - // The first activation might happen before we even have a client - if (this.client) { - this.client.execute("geterr", { - files: [filePath], - delay: 100, - }) - - this.opts.statusPanel.update({version: this.client.version}) - } - } - - this.opts.statusPanel.update({tsConfigPath: this.configFile}) - } - - public onDeactivated = () => { - this.isActive = false - this.opts.statusPanel.hide() - } - - private onChanged = () => { - if (!this.client) return - const filePath = this.buffer.getPath() - if (filePath === undefined) return - - this.opts.statusPanel.update({buildStatus: undefined}) - - this.client.execute("geterr", { - files: [filePath], - delay: 100, - }) - } - - private clearOccurrenceMarkers() { - for (const marker of this.occurrenceMarkers) { - marker.destroy() - } - } - - private async updateMarkers() { - if (!this.client) return - const filePath = this.buffer.getPath() - if (filePath === undefined) return - - const pos = this.editor.getLastCursor().getBufferPosition() - - this.clearOccurrenceMarkers() - try { - const result = await this.client.execute("occurrences", { - file: filePath, - line: pos.row + 1, - offset: pos.column + 1, - }) - - for (const ref of result.body!) { - const marker = this.editor.markBufferRange(spanToRange(ref)) - this.editor.decorateMarker(marker, { - type: "highlight", - class: "atom-typescript-occurrence", - }) - this.occurrenceMarkers.push(marker) - } - } catch (e) { - if (window.atom_typescript_debug) console.error(e) - } } - private onDidChangeCursorPosition = ({textChanged}: {textChanged: boolean}) => { - if (!this.isTypescript || !this.isOpen) return - - if (textChanged) { - this.clearOccurrenceMarkers() - return - } - - this.updateMarkers() - } - - private onDidDestroy = () => { - this.dispose() - } - - private onOpened = async () => { - const filePath = this.buffer.getPath() - if (filePath === undefined) return - this.client = await this.opts.getClient(filePath) - - // onOpened might trigger before onActivated so we can't rely on isActive flag - if (atom.workspace.getActiveTextEditor() === this.editor) { - this.isActive = true - this.opts.statusPanel.update({version: this.client.version}) - } - - if (this.isTypescript) { - this.client.execute("geterr", { - files: [filePath], - delay: 100, - }) - - this.isOpen = true - - try { - const result = await this.client.execute("projectInfo", { - needFileNameList: false, - file: filePath, - }) - this.configFile = result.body!.configFileName - - if (this.isActive) { - this.opts.statusPanel.update({tsConfigPath: this.configFile}) - } - - getProjectCodeSettings(this.configFile).then(options => { - this.client!.execute("configure", { - file: filePath, - formatOptions: options, - }) - }) - } catch (e) { - if (window.atom_typescript_debug) console.error(e) - } - } + /** NOTE: + * it is implicitly assumed that `atom.workspace.getActiveTextEditor() === this.editor` + * which has to be ensured at call site + */ + public didActivate = () => { + if (this.isTypescript) this.reportInfo() } - private onSaved = () => { - this.opts.onSave(this) - this.compileOnSave() + private onOpened = () => { + const isActive = atom.workspace.getActiveTextEditor() === this.editor + if (isActive) this.reportInfo() } - private async compileOnSave() { - const {client} = this - if (!client) return - const filePath = this.buffer.getPath() - if (filePath === undefined) return - - const result = await client.execute("compileOnSaveAffectedFileList", { - file: filePath, - }) - - this.opts.statusPanel.update({buildStatus: undefined}) - - const fileNames = flatten(result.body.map(project => project.fileNames)) - - if (fileNames.length === 0) return - - try { - const promises = fileNames.map(file => client.execute("compileOnSaveEmitFile", {file})) - const saved = await Promise.all(promises) - - if (!saved.every(res => !!res.body)) { - throw new Error("Some files failed to emit") - } - - this.opts.statusPanel.update({buildStatus: {success: true}}) - } catch (error) { - const e = error as Error - console.error("Save failed with error", e) - this.opts.statusPanel.update({buildStatus: {success: false, message: e.message}}) - } + private reportInfo() { + const info = this.buffer.getInfo() + if (info) this.opts.reportClientInfo(info) } private checkIfTypescript = () => { this.isTypescript = isTypescriptEditorWithPath(this.editor) - // Add 'typescript-editor' class to the where typescript is active. if (this.isTypescript) { atom.views.getView(this.editor).classList.add("typescript-editor") + } else { + atom.views.getView(this.editor).classList.remove("typescript-editor") } } } diff --git a/lib/tsconfig.json b/lib/tsconfig.json index cc675b88a..09b26bbbc 100644 --- a/lib/tsconfig.json +++ b/lib/tsconfig.json @@ -9,7 +9,7 @@ "noLib": false, "outDir": "../dist", "preserveConstEnums": true, - "skipLibCheck": true, + "skipLibCheck": false, "sourceMap": true, "strict": true, "target": "es2017", @@ -18,9 +18,7 @@ "noFallthroughCasesInSwitch": true, "noImplicitAny": true, "noImplicitThis": true, - "plugins": [ - { "name": "tslint-language-service"} - ] + "plugins": [{"name": "typescript-tslint-plugin"}] }, "compileOnSave": true } diff --git a/lib/tslint.json b/lib/tslint.json index 5496598d4..a02bf50d0 100644 --- a/lib/tslint.json +++ b/lib/tslint.json @@ -1,12 +1,13 @@ { "defaultSeverity": "warning", - "extends": ["tslint:recommended"], + "extends": ["tslint:recommended", "tslint-use-atom-disposables"], "jsRules": {}, + "defaultSeverity": "error", "rules": { "semicolon": false, "object-literal-sort-keys": false, "member-access": true, - "ordered-imports": false, + "ordered-imports": true, "interface-name": [true, "never-prefix"], "no-console": false, "arrow-parens": false, @@ -27,7 +28,10 @@ ], "strict-type-predicates": true, "no-unsafe-any": true, - "no-shadowed-variable": true + "no-unbound-method": true, + "no-shadowed-variable": true, + "no-floating-promises": true, + "await-promise": true }, "rulesDirectory": [] } diff --git a/lib/typings/atom-config.d.ts b/lib/typings/atom-config.d.ts index 2071d1e55..4371b9f1c 100644 --- a/lib/typings/atom-config.d.ts +++ b/lib/typings/atom-config.d.ts @@ -5,22 +5,42 @@ declare module "atom" { "atom-typescript.unusedAsInfo": boolean "atom-typescript.autocompletionSuggestionPriority": number "atom-typescript.locale": string + "atom-typescript.preferBuiltinTooltips": boolean + "atom-typescript.preferBuiltinSigHelp": boolean + "atom-typescript.preferBuiltinBusySignal": boolean + "atom-typescript.preferBuiltinOccurrenceHighlight": boolean + "atom-typescript.disableAtomIdeDefinitions": boolean "atom-typescript.buildStatusTimeout": number "atom-typescript.showSemanticView": boolean "atom-typescript.tooltipDelay": number "atom-typescript.ignoredDiagnosticCodes": string[] "atom-typescript.ignoreUnusedSuggestionDiagnostics": boolean "atom-typescript.suppressAllDiagnostics": boolean + "atom-typescript.tsFileExtensions": string[] + "atom-typescript.jsFileExtensions": string[] + "atom-typescript.tsSyntaxScopes": string[] + "atom-typescript.jsSyntaxScopes": string[] + "atom-typescript.allowJS": boolean "atom-typescript": { unusedAsInfo: boolean autocompletionSuggestionPriority: number locale: string + preferBuiltinTooltips: boolean + preferBuiltinSigHelp: boolean + preferBuiltinBusySignal: boolean + preferBuiltinOccurrenceHighlight: boolean + disableAtomIdeDefinitions: boolean buildStatusTimeout: number showSemanticView: boolean tooltipDelay: number ignoredDiagnosticCodes: string[] ignoreUnusedSuggestionDiagnostics: boolean suppressAllDiagnostics: boolean + tsFileExtensions: string[] + jsFileExtensions: string[] + tsSyntaxScopes: string[] + jsSyntaxScopes: string[] + allowJS: boolean } } } diff --git a/lib/typings/atom-ide-ui/LICENSE.Facebook b/lib/typings/atom-ide-ui/LICENSE.Facebook new file mode 100644 index 000000000..0db2dbf36 --- /dev/null +++ b/lib/typings/atom-ide-ui/LICENSE.Facebook @@ -0,0 +1,30 @@ +BSD License + +For atom-ide-ui software + +Copyright (c) 2017-present, Facebook, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/lib/typings/atom-ide-ui/PATENTS.Facebook b/lib/typings/atom-ide-ui/PATENTS.Facebook new file mode 100644 index 000000000..e19aca14c --- /dev/null +++ b/lib/typings/atom-ide-ui/PATENTS.Facebook @@ -0,0 +1,33 @@ +Additional Grant of Patent Rights Version 2 + +"Software" means the atom-ide-ui software contributed by Facebook, Inc. + +Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software +("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable +(subject to the termination provision below) license under any Necessary +Claims, to make, have made, use, sell, offer to sell, import, and otherwise +transfer the Software. For avoidance of doubt, no license is granted under +Facebook’s rights in any patent claims that are infringed by (i) modifications +to the Software made by you or any third party or (ii) the Software in +combination with any software or other technology. + +The license granted hereunder will terminate, automatically and without notice, +if you (or any of your subsidiaries, corporate affiliates or agents) initiate +directly or indirectly, or take a direct financial interest in, any Patent +Assertion: (i) against Facebook or any of its subsidiaries or corporate +affiliates, (ii) against any party if such Patent Assertion arises in whole or +in part from any software, technology, product or service of Facebook or any of +its subsidiaries or corporate affiliates, or (iii) against any party relating +to the Software. Notwithstanding the foregoing, if Facebook or any of its +subsidiaries or corporate affiliates files a lawsuit alleging patent +infringement against you in the first instance, and you respond by filing a +patent infringement counterclaim in that lawsuit against that party that is +unrelated to the Software, the license granted hereunder will not terminate +under section (i) of this paragraph due to such counterclaim. + +A "Necessary Claim" is a claim of a patent owned by Facebook that is +necessarily infringed by the Software standing alone. + +A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, +or contributory infringement or inducement to infringe any patent, including a +cross-claim or counterclaim. diff --git a/lib/typings/atom-ide-ui/busy-signal.d.ts b/lib/typings/atom-ide-ui/busy-signal.d.ts new file mode 100644 index 000000000..43b02561e --- /dev/null +++ b/lib/typings/atom-ide-ui/busy-signal.d.ts @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE.Facebook file in the directory containing this source file. + * An additional grant of patent rights can be found in the PATENTS.Facebook + * file in the same directory. + */ + +declare module "atom/ide" { + export interface BusySignalOptions { + // Can say that a busy signal will only appear when a given file is open. + // Default = null, meaning the busy signal applies to all files. + onlyForFile?: string + // Is user waiting for computer to finish a task? (traditional busy spinner) + // or is the computer waiting for user to finish a task? (action required) + // Default = spinner. + waitingFor?: "computer" | "user" + // Debounce it? default = true for busy-signal, and false for action-required. + debounce?: boolean + // If onClick is set, then the tooltip will be clickable. Default = null. + onDidClick?: () => void + // If set to true, the busy signal tooltip will be immediately revealed + // when it first becomes visible (without explicit mouse interaction). + revealTooltip?: boolean + } + + export interface BusySignalService { + // Activates the busy signal with the given title and returns the promise + // from the provided callback. + // The busy signal automatically deactivates when the returned promise + // either resolves or rejects. + reportBusyWhile(title: string, f: () => Promise, options?: BusySignalOptions): Promise + + // Activates the busy signal. Set the title in the returned BusySignal + // object (you can update the title multiple times) and dispose it when done. + reportBusy(title: string, options?: BusySignalOptions): BusyMessage + + // This is a no-op. When someone consumes the busy service, they get back a + // reference to the single shared instance, so disposing of it would be wrong. + dispose(): void + } + + export interface BusyMessage { + // You can set/update the title. + setTitle(title: string): void + // Dispose of the signal when done to make it go away. + dispose(): void + } +} diff --git a/lib/typings/atom-ide-ui/code-actions.d.ts b/lib/typings/atom-ide-ui/code-actions.d.ts new file mode 100644 index 000000000..0b6191bc2 --- /dev/null +++ b/lib/typings/atom-ide-ui/code-actions.d.ts @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE.Facebook file in the directory containing this source file. + * An additional grant of patent rights can be found in the PATENTS.Facebook + * file in the same directory. + */ + +declare module "atom/ide" { + import * as Atom from "atom" + import {Message} from "atom/linter" + + export interface CodeAction { + apply(): Promise + getTitle(): Promise + dispose(): void + } + + export interface CodeActionProvider { + grammarScopes?: ReadonlyArray + priority: number + getCodeActions( + editor: Atom.TextEditor, + range: Atom.Range, + diagnostics: Message[], + ): Promise + } + + /** + * atom-ide-code-actions provides a CodeActionFetcher which offers an API to + * request CodeActions from all CodeAction providers. For now, CodeActionFetcher + * can only fetch CodeActions for a Diagnostic. In the future, this API can be + * extended to provide a stream of CodeActions based on the cursor position. + */ + export interface CodeActionFetcher { + getCodeActionForDiagnostic: ( + diagnostic: Message, + editor: Atom.TextEditor, + ) => Promise + } +} diff --git a/lib/typings/atom-ide-ui/code-highlight.d.ts b/lib/typings/atom-ide-ui/code-highlight.d.ts new file mode 100644 index 000000000..159e99f9d --- /dev/null +++ b/lib/typings/atom-ide-ui/code-highlight.d.ts @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE.Facebook file in the directory containing this source file. + * An additional grant of patent rights can be found in the PATENTS.Facebook + * file in the same directory. + */ + +declare module "atom/ide" { + import * as Atom from "atom" + export interface CodeHighlightProvider { + priority: number + grammarScopes: ReadonlyArray + highlight( + editor: Atom.TextEditor, + bufferPosition: Atom.Point, + ): Promise + } +} diff --git a/lib/typings/atom-ide-ui/datatip.d.ts b/lib/typings/atom-ide-ui/datatip.d.ts new file mode 100644 index 000000000..f60bf3b39 --- /dev/null +++ b/lib/typings/atom-ide-ui/datatip.d.ts @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE.Facebook file in the directory containing this source file. + * An additional grant of patent rights can be found in the PATENTS.Facebook + * file in the same directory. + */ + +declare module "atom/ide" { + import * as Atom from "atom" + + export interface DatatipService { + addProvider(provider: DatatipProvider): Atom.DisposableLike + addModifierProvider(provider: ModifierDatatipProvider): Atom.DisposableLike + createPinnedDataTip( + datatip: Datatip, + editor: Atom.TextEditor, + options?: PinnedDatatipOptions, + ): Atom.DisposableLike + } + + export interface PinnedDatatipOptions { + // Defaults to 'end-of-line'. + position?: PinnedDatatipPosition + // Defaults to true. + showRangeHighlight?: boolean + } + + export type PinnedDatatipPosition = "end-of-line" | "above-range" + + export interface DatatipProvider { + priority: number + grammarScopes?: ReadonlyArray + // A unique name for the provider to be used for analytics. + // It is recommended that it be the name of the provider's package. + providerName: string + datatip( + editor: Atom.TextEditor, + bufferPosition: Atom.Point, + ): Promise + } + + export interface ModifierDatatipProvider { + priority: number + grammarScopes?: string[] + providerName: string + modifierDatatip( + editor: Atom.TextEditor, + bufferPosition: Atom.Point, + heldKeys: Set, + ): Promise + } + + export type AnyDatatipProvider = DatatipProvider | ModifierDatatipProvider + + export type Datatip = + | { + markedStrings: MarkedString[] + range: Atom.Range + pinnable?: boolean + } + | { + component: any // React component + range: Atom.Range + pinnable?: boolean + } + + // Borrowed from the LSP API. + export type MarkedString = + | { + type: "markdown" + value: string + } + | { + type: "snippet" + grammar: Atom.Grammar + value: string + } + + export type ModifierKey = "metaKey" | "shiftKey" | "altKey" | "ctrlKey" +} diff --git a/lib/typings/atom-ide-ui/definitions.d.ts b/lib/typings/atom-ide-ui/definitions.d.ts new file mode 100644 index 000000000..d5bc08036 --- /dev/null +++ b/lib/typings/atom-ide-ui/definitions.d.ts @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE.Facebook file in the directory containing this source file. + * An additional grant of patent rights can be found in the PATENTS.Facebook + * file in the same directory. + */ + +declare module "atom/ide" { + import * as Atom from "atom" + export interface Definition { + // Path of the file in which the definition is located. + path: string + // First character of the definition's identifier. + // e.g. "F" in `class Foo {}` + position: Atom.Point + // Optional: the range of the entire definition. + // e.g. "c" to "}" in `class Foo {}` + range?: Atom.Range + // Optional: `name` and `projectRoot` can be provided to display a more human-readable title + // inside of Hyperclick when there are multiple definitions. + name?: string + // If provided, `projectRoot` will be used to display a relativized version of `path`. + projectRoot?: string + // `language` may be used by consumers to identify the source of definitions. + language: string + } + + // Definition queries supply a point. + // The returned queryRange is the range within which the returned definition is valid. + // Typically queryRange spans the containing identifier around the query point. + // (If a null queryRange is returned, the range of the word containing the point is used.) + export interface DefinitionQueryResult { + queryRange: ReadonlyArray | null | undefined + definitions: ReadonlyArray // Must be non-empty. + } + + // Provides definitions for a set of language grammars. + export interface DefinitionProvider { + // If there are multiple providers for a given grammar, + // the one with the highest priority will be used. + priority: number + grammarScopes: ReadonlyArray + wordRegExp: RegExp | null | undefined + // Obtains the definition in an editor at the given point. + // This should return null if no definition is available. + getDefinition: ( + editor: Atom.TextEditor, + position: Atom.Point, + ) => Promise + } + + export interface DefinitionPreviewProvider { + getDefinitionPreview( + definition: Definition, + ): Promise< + | { + mime: string + contents: string + encoding: string + } + | null + | undefined + > + } +} diff --git a/lib/typings/atom-ide-ui/find-references.d.ts b/lib/typings/atom-ide-ui/find-references.d.ts new file mode 100644 index 000000000..644f55665 --- /dev/null +++ b/lib/typings/atom-ide-ui/find-references.d.ts @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE.Facebook file in the directory containing this source file. + * An additional grant of patent rights can be found in the PATENTS.Facebook + * file in the same directory. + */ + +declare module "atom/ide" { + import * as Atom from "atom" + + export interface FindReferencesProvider { + // Return true if your provider supports finding references for the provided Atom.TextEditor. + isEditorSupported(editor: Atom.TextEditor): Promise + + // `findReferences` will only be called if `isEditorSupported` previously returned true + // for the given Atom.TextEditor. + findReferences( + editor: Atom.TextEditor, + position: Atom.Point, + ): Promise + } + + export interface Reference { + uri: string // Nuclide URI of the file path + name: string | undefined | null // name of calling method/function/symbol + range: Atom.Range + } + + export interface FindReferencesData { + type: "data" + baseUri: string + referencedSymbolName: string + references: Reference[] + title?: string // defaults to 'Symbol References' + } + + export interface FindReferencesError { + type: "error" + message: string + } + + export type FindReferencesReturn = FindReferencesData | FindReferencesError +} diff --git a/lib/typings/atom-ide-ui/hyperclick.d.ts b/lib/typings/atom-ide-ui/hyperclick.d.ts new file mode 100644 index 000000000..206607611 --- /dev/null +++ b/lib/typings/atom-ide-ui/hyperclick.d.ts @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE.Facebook file in the directory containing this source file. + * An additional grant of patent rights can be found in the PATENTS.Facebook + * file in the same directory. + */ + +declare module "atom/ide" { + import * as Atom from "atom" + export interface HyperclickProvider { + // Use this to provide a suggestion for single-word matches. + // Optionally set `wordRegExp` to adjust word-matching. + getSuggestionForWord?: ( + textEditor: Atom.TextEditor, + text: string, + range: Atom.Range, + ) => Promise + + wordRegExp?: RegExp + + // Use this to provide a suggestion if it can have non-contiguous ranges. + // A primary use-case for this is Objective-C methods. + getSuggestion?: ( + textEditor: Atom.TextEditor, + position: Atom.Point, + ) => Promise + + // Must be unique. Used for analytics. + providerName?: string + + // The higher this is, the more precedence the provider gets. + priority: number + + // Optionally, limit the set of grammar scopes the provider should apply to. + grammarScopes?: string[] + } + + export interface HyperclickSuggestion { + // The range(s) to underline to provide as a visual cue for clicking. + range: Atom.Range | Atom.Range[] + + // The function to call when the underlined text is clicked. + callback: (() => void) | Array<{rightLabel?: string; title: string; callback: () => void}> + } +} diff --git a/lib/typings/atom-ide-ui/outline.d.ts b/lib/typings/atom-ide-ui/outline.d.ts new file mode 100644 index 000000000..c112c5786 --- /dev/null +++ b/lib/typings/atom-ide-ui/outline.d.ts @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE.Facebook file in the directory containing this source file. + * An additional grant of patent rights can be found in the PATENTS.Facebook + * file in the same directory. + */ + +declare module "atom/ide" { + import * as Atom from "atom" + + export interface OutlineProvider { + name: string + // If there are multiple providers for a given grammar, the one with the highest priority will be + // used. + priority: number + grammarScopes: ReadonlyArray + updateOnEdit?: boolean + getOutline(editor: Atom.TextEditor): Promise + } + + export interface OutlineTree { + icon?: string // from Atom.Octicon (that type's not allowed over rpc so we use string) + kind?: OutlineTreeKind // kind you can pass to the UI for theming + + // Must be one or the other. If both are present, tokenizedText is preferred. + plainText?: string + tokenizedText?: TokenizedText + + // If user has atom-ide-outline-view.nameOnly then representativeName is used instead. + representativeName?: string + + startPosition: Atom.Point + endPosition?: Atom.Point + landingPosition?: Atom.Point + children: OutlineTree[] + } + + export interface Outline { + outlineTrees: OutlineTree[] + } + + // Kind of outline tree - matches the names from the Language Server Protocol v2. + export type OutlineTreeKind = + | "file" + | "module" + | "namespace" + | "package" + | "class" + | "method" + | "property" + | "field" + | "constructor" + | "enum" + | "interface" + | "function" + | "variable" + | "constant" + | "string" + | "number" + | "boolean" + | "array" + + export type TokenKind = + | "keyword" + | "class-name" + | "constructor" + | "method" + | "param" + | "string" + | "whitespace" + | "plain" + | "type" + + export interface TextToken { + kind: TokenKind + value: string + } + + export type TokenizedText = TextToken[] +} diff --git a/lib/typings/atom-ide-ui/sig-help.d.ts b/lib/typings/atom-ide-ui/sig-help.d.ts new file mode 100644 index 000000000..9fad3a347 --- /dev/null +++ b/lib/typings/atom-ide-ui/sig-help.d.ts @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE.Facebook file in the directory containing this source file. + * An additional grant of patent rights can be found in the PATENTS.Facebook + * file in the same directory. + */ + +declare module "atom/ide" { + import {DisposableLike, Point, TextEditor} from "atom" + export type SignatureHelpRegistry = (provider: SignatureHelpProvider) => DisposableLike + + export interface SignatureHelpProvider { + priority: number + grammarScopes: ReadonlyArray + + triggerCharacters?: Set + + getSignatureHelp(editor: TextEditor, point: Point): Promise + } + + export interface SignatureHelp { + signatures: Signature[] + activeSignature?: number + activeParameter?: number + } + + export interface Signature { + label: string + documentation?: string + parameters?: SignatureParameter[] + } + + export interface SignatureParameter { + label: string + documentation?: string + } +} diff --git a/lib/typings/atom-select-list.d.ts b/lib/typings/atom-select-list.d.ts index 8a87c11fe..f49525157 100644 --- a/lib/typings/atom-select-list.d.ts +++ b/lib/typings/atom-select-list.d.ts @@ -1,59 +1,59 @@ declare module "atom-select-list" { export = SelectListView -} -declare class SelectListView { - public element: HTMLElement - constructor(props: Props) - public focus(): void - public update(props: Partial>): Promise - public getFilterQuery(): string -} -declare interface Props { - /** an array containing the objects you want to show in the select list. */ - items: T[] - /** a function that is called whenever an item needs to be displayed. */ - elementForItem: (item: T) => HTMLElement - /** the number of maximum items that are shown. */ - maxResults?: number - /** a function that allows to decide which items to show whenever the query changes. - * By default, it uses fuzzaldrin to filter results. - */ - filter?: (items: T[], query: string) => T[] - /** when filter is not provided, this function will be called to retrieve a string - * property on each item and that will be used to filter them. - */ - filterKeyForItem?: (item: T) => string - /** a function that allows to apply a transformation to the user query and whose - * return value will be used to filter items. - */ - filterQuery?: (query: string) => string - /** a string that will replace the contents of the query editor. */ - query?: string - /** a function that allows to change the order in which items are shown. */ - order?: (item1: T, item2: T) => number - /** a string shown when the list is empty. */ - emptyMessage?: string - /** a string that needs to be set when you want to notify the user that an error occurred. */ - errorMessage?: string - /** a string that needs to be set when you want to provide some information to the user. */ - infoMessage?: string - /** a string that needs to be set when you are loading items in the background. */ - loadingMessage?: string - /** - * a string or number that needs to be set when the progress status changes (e.g. a percentage - * showing how many items have been loaded so far). - */ - loadingBadge?: string | number - /** an array of strings that will be added as class names to the items element. */ - itemsClassList?: string[] - /** a function that is called when the query changes. */ - didChangeQuery?: (query: string) => void - /** a function that is called when the selected item changes. */ - didChangeSelection?: (item?: T) => void - /** a function that is called when the user clicks or presses enter on an item. */ - didConfirmSelection?: (item: T) => void - /** a function that is called when the user presses Enter but the list is empty. */ - didConfirmEmptySelection?: () => void - /** a function that is called when the user presses Esc or the list loses focus. */ - didCancelSelection?: () => void + class SelectListView { + public element: HTMLElement + constructor(props: Props) + public focus(): void + public update(props: Partial>): Promise + public getFilterQuery(): string + } + interface Props { + /** an array containing the objects you want to show in the select list. */ + items: T[] + /** a function that is called whenever an item needs to be displayed. */ + elementForItem: (item: T) => HTMLElement + /** the number of maximum items that are shown. */ + maxResults?: number + /** a function that allows to decide which items to show whenever the query changes. + * By default, it uses fuzzaldrin to filter results. + */ + filter?: (items: T[], query: string) => T[] + /** when filter is not provided, this function will be called to retrieve a string + * property on each item and that will be used to filter them. + */ + filterKeyForItem?: (item: T) => string + /** a function that allows to apply a transformation to the user query and whose + * return value will be used to filter items. + */ + filterQuery?: (query: string) => string + /** a string that will replace the contents of the query editor. */ + query?: string + /** a function that allows to change the order in which items are shown. */ + order?: (item1: T, item2: T) => number + /** a string shown when the list is empty. */ + emptyMessage?: string + /** a string that needs to be set when you want to notify the user that an error occurred. */ + errorMessage?: string + /** a string that needs to be set when you want to provide some information to the user. */ + infoMessage?: string + /** a string that needs to be set when you are loading items in the background. */ + loadingMessage?: string + /** + * a string or number that needs to be set when the progress status changes (e.g. a percentage + * showing how many items have been loaded so far). + */ + loadingBadge?: string | number + /** an array of strings that will be added as class names to the items element. */ + itemsClassList?: string[] + /** a function that is called when the query changes. */ + didChangeQuery?: (query: string) => void + /** a function that is called when the selected item changes. */ + didChangeSelection?: (item?: T) => void + /** a function that is called when the user clicks or presses enter on an item. */ + didConfirmSelection?: (item: T) => void + /** a function that is called when the user presses Enter but the list is empty. */ + didConfirmEmptySelection?: () => void + /** a function that is called when the user presses Esc or the list loses focus. */ + didCancelSelection?: () => void + } } diff --git a/lib/typings/atom.d.ts b/lib/typings/atom.d.ts index e856bd24a..3bee836e1 100644 --- a/lib/typings/atom.d.ts +++ b/lib/typings/atom.d.ts @@ -2,10 +2,12 @@ export {} declare module "atom" { interface TextBuffer { emitDidStopChangingEvent(): void + getLanguageMode(): {readonly fullyTokenized: boolean} } - interface TextEditor { - isDestroyed(): boolean - getURI(): string + onDidTokenize(callback: () => void): Disposable + } + interface TextEditorElement { + setUpdatedSynchronously(val: boolean): void } } diff --git a/lib/typings/etch.d.ts b/lib/typings/etch.d.ts index 506237e09..8ff54f404 100644 --- a/lib/typings/etch.d.ts +++ b/lib/typings/etch.d.ts @@ -162,6 +162,14 @@ interface EtchAttributes extends HTMLAttributes { key?: any } +type SingleOrArray = T | T[] +type ChildSpec = SingleOrArray +type TagSpec = string | ElementClassConstructor +type ElementClassConstructor = new ( + props: T["props"], + children: JSX.Element[], +) => T + // tslint:disable-next-line:no-namespace declare namespace JSX { interface IntrinsicElements { @@ -189,18 +197,6 @@ declare namespace JSX { // Custom & HTML [elem: string]: EtchAttributes } -} - -type SingleOrArray = T | T[] -type ChildSpec = SingleOrArray -type TagSpec = string | ElementClassConstructor -type ElementClassConstructor = new ( - props: T["props"], - children: JSX.Element[], -) => T - -// tslint:disable-next-line:no-namespace -declare namespace JSX { type Element = | {tag: TagSpec; props?: EtchAttributes | Props; children: Element[]} | {text: string | number} diff --git a/lib/typings/typings.d.ts b/lib/typings/typings.d.ts index 3e87b7c8c..85de2682d 100644 --- a/lib/typings/typings.d.ts +++ b/lib/typings/typings.d.ts @@ -2,12 +2,6 @@ interface Window { atom_typescript_debug: boolean } -// escape-html -declare module "escape-html" { - function escape(html: string): string - export = escape -} - // experimental properties / methods on Element // (do not use without checking existence of property/method first) interface ElementExp extends Element { diff --git a/lib/utils.ts b/lib/utils.ts new file mode 100644 index 000000000..69f6c4205 --- /dev/null +++ b/lib/utils.ts @@ -0,0 +1,20 @@ +export function handlePromise(promise: Promise): void { + // tslint:disable-next-line:strict-type-predicates no-unbound-method + if (typeof promise.catch !== "function") { + atom.notifications.addFatalError( + "Atom-Typescript: non-promise passed to handlePromise. Please report this.", + { + stack: new Error().stack, + dismissable: true, + }, + ) + return + } + promise.catch((err: Error) => { + atom.notifications.addFatalError(`Atom-Typescript error: ${err.message}`, { + detail: err.toString(), + stack: err.stack, + dismissable: true, + }) + }) +} diff --git a/package-lock.json b/package-lock.json index e569332a4..6fcef9086 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,12 +5,12 @@ "requires": true, "dependencies": { "@types/atom": { - "version": "1.28.0", - "resolved": "https://registry.npmjs.org/@types/atom/-/atom-1.28.0.tgz", - "integrity": "sha512-XslfCY9sXZs9lWghuF6n8WOgFTDowUZMxfquaaoYnSXIuM5DlgahKk6Y/2Ll8LVb6Ge0EjiREvYUBotgzpCnlg==", + "version": "1.31.0", + "resolved": "https://registry.npmjs.org/@types/atom/-/atom-1.31.0.tgz", + "integrity": "sha512-U0ShGgn9c1jAHK7Q2yv4koof71qr167ODMmRVhsmshFtwEDy758awCLU1oK9hL+3NSYondaHEbgWo7oC/CtUMw==", "dev": true, "requires": { - "@types/node": "8.10.26" + "@types/node": "8.10.38" } }, "@types/byline": { @@ -19,13 +19,13 @@ "integrity": "sha1-DmH8ucA+BH0hxEllVMcRYperYM0=", "dev": true, "requires": { - "@types/node": "8.10.26" + "@types/node": "8.10.38" } }, "@types/chai": { - "version": "4.1.4", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.4.tgz", - "integrity": "sha512-h6+VEw2Vr3ORiFCyyJmcho2zALnUq9cvdB/IO8Xs9itrJVCenC7o26A6+m7D0ihTTr65eS259H5/Ghl/VjYs6g==", + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.7.tgz", + "integrity": "sha512-2Y8uPt0/jwjhQ6EiluT0XCri1Dbplr0ZxfFXUz+ye13gaqE8u5gL5ppao1JrUYr9cIip5S6MvQzBS7Kke7U9VA==", "dev": true }, "@types/fuzzaldrin": { @@ -35,9 +35,9 @@ "dev": true }, "@types/lodash": { - "version": "4.14.116", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.116.tgz", - "integrity": "sha512-lRnAtKnxMXcYYXqOiotTmJd74uawNWuPnsnPrrO7HiFuE3npE2iQhfABatbYDyxTNqZNuXzcKGhw37R7RjBFLg==", + "version": "4.14.118", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.118.tgz", + "integrity": "sha512-iiJbKLZbhSa6FYRip/9ZDX6HXhayXLDGY2Fqws9cOkEQ6XeKfaxB0sC541mowZJueYyMnVUmmG+al5/4fCDrgw==", "dev": true }, "@types/mocha": { @@ -47,9 +47,9 @@ "dev": true }, "@types/node": { - "version": "8.10.26", - "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.26.tgz", - "integrity": "sha512-opk6bLLErLSwyVVJeSH5Ek7ZWOBSsN0JrvXTNVGLXLAXKB9xlTYajrplR44xVyMrmbut94H6uJ9jqzM/12jxkA==", + "version": "8.10.38", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.38.tgz", + "integrity": "sha512-EibsnbJerd0hBFaDjJStFrVbVBAtOy4dgL8zZFw0uOvPqzBAX59Ci8cgjg3+RgJIWhsB5A4c+pi+D4P9tQQh/A==", "dev": true }, "@types/resolve": { @@ -58,7 +58,7 @@ "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", "dev": true, "requires": { - "@types/node": "8.10.26" + "@types/node": "8.10.38" } }, "@types/strip-bom": { @@ -89,13 +89,10 @@ "dev": true }, "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "1.9.1" - } + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true }, "argparse": { "version": "1.0.10", @@ -198,9 +195,9 @@ } }, "atom-select-list": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/atom-select-list/-/atom-select-list-0.7.1.tgz", - "integrity": "sha1-wXk7fUZm3dongrTAu2oH99EZf+M=", + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/atom-select-list/-/atom-select-list-0.7.2.tgz", + "integrity": "sha512-a707OB1DhLGjzqtFrtMQKH7BBxFuCh8UBoUWxgFOrLrSwVh3g+/TlVPVDOz12+U0mDu3mIrnYLqQyhywQOTxhw==", "requires": { "etch": "0.12.8", "fuzzaldrin": "2.1.0" @@ -221,7 +218,7 @@ "requires": { "atom-mocha-test-runner": "1.2.0", "ts-node": "7.0.1", - "typescript": "3.0.1" + "typescript": "3.1.6" } }, "aws-sign2": { @@ -249,12 +246,6 @@ "js-tokens": "3.0.2" }, "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", @@ -340,15 +331,6 @@ "resolved": "https://registry.npmjs.org/byline/-/byline-5.0.0.tgz", "integrity": "sha1-dBxSFkaOrcRXsDQQEYrXfejB3bE=" }, - "caller-id": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-id/-/caller-id-0.1.0.tgz", - "integrity": "sha1-Wb2sCJPRLDhxQIJ5Ix+XRYNk8Hs=", - "dev": true, - "requires": { - "stack-trace": "0.0.10" - } - }, "camelize": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.0.tgz", @@ -363,9 +345,9 @@ "optional": true }, "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.2.0.tgz", + "integrity": "sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==", "dev": true, "requires": { "assertion-error": "1.1.0", @@ -377,16 +359,25 @@ } }, "chalk": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.1.tgz", - "integrity": "sha512-QUU4ofkDoMIVO7hcx1iPTISs88wsO8jA92RQIm4JAwZvFGGAV2hSAA1NX7oVj2Ej2Q6NDTcRDjPTFrMCRZoJ6g==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, "requires": { "ansi-styles": "3.2.1", "escape-string-regexp": "1.0.5", - "supports-color": "5.3.0" + "supports-color": "5.5.0" }, "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "1.9.3" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -394,9 +385,9 @@ "dev": true }, "supports-color": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", - "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, "requires": { "has-flag": "3.0.0" @@ -418,9 +409,9 @@ "optional": true }, "color-convert": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, "requires": { "color-name": "1.1.3" @@ -564,11 +555,6 @@ "xtend": "4.0.1" } }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -950,9 +936,9 @@ } }, "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" }, "lodash._baseassign": { "version": "3.2.0", @@ -1103,15 +1089,6 @@ "supports-color": "3.1.2" } }, - "mock-require": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/mock-require/-/mock-require-2.0.2.tgz", - "integrity": "sha1-HqpxqtIwE3c9En3H6Ro/u0g31g0=", - "dev": true, - "requires": { - "caller-id": "0.1.0" - } - }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -1171,9 +1148,9 @@ "optional": true }, "prettier": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.14.2.tgz", - "integrity": "sha512-McHPg0n1pIke+A/4VcaS2en+pTNjy4xF+Uuq86u/5dyDO59/TtFZtQ708QIRkEZ3qwKz3GVkVa6mpxK/CpB8Rg==", + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.2.tgz", + "integrity": "sha512-YgPLFFA0CdKL4Eg2IHtUSjzj/BWgszDHiNQAe0VAIBse34148whfdzLagRL+QiKS+YfK5ftB6X4v/MBw8yCoug==", "dev": true }, "process": { @@ -1349,12 +1326,6 @@ } } }, - "stack-trace": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=", - "dev": true - }, "string-template": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/string-template/-/string-template-0.2.1.tgz", @@ -1471,8 +1442,8 @@ "requires": { "babel-code-frame": "6.26.0", "builtin-modules": "1.1.1", - "chalk": "2.3.1", - "commander": "2.17.1", + "chalk": "2.4.1", + "commander": "2.19.0", "diff": "3.2.0", "glob": "7.1.1", "js-yaml": "3.12.0", @@ -1484,20 +1455,31 @@ }, "dependencies": { "commander": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", - "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", "dev": true } } }, - "tslint-language-service": { - "version": "0.9.9", - "resolved": "https://registry.npmjs.org/tslint-language-service/-/tslint-language-service-0.9.9.tgz", - "integrity": "sha1-9UbcOEg5eeb7PPpZWErYUls61No=", + "tslint-use-atom-disposables": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tslint-use-atom-disposables/-/tslint-use-atom-disposables-0.0.1.tgz", + "integrity": "sha512-o+7Jug7e2T3/z2y7tE0mS5XbnqCgOfplxPqhVMPzIMmReI5uOBVZwL6WuIQEzmJR89wXrRKjWee1l7oIot3Wog==", "dev": true, "requires": { - "mock-require": "2.0.2" + "tsutils": "3.4.0" + }, + "dependencies": { + "tsutils": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.4.0.tgz", + "integrity": "sha512-lJOYR+rsCnso8k7C/D1IVSgOmJS9Ds8U4P2H7CxBtTf1w227Zg2nk+Fod8AsUzu3msg8AjZVsNBJb5QgCZsBjQ==", + "dev": true, + "requires": { + "tslib": "1.9.3" + } + } } }, "tsutils": { @@ -1533,9 +1515,19 @@ "dev": true }, "typescript": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz", - "integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==" + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz", + "integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==" + }, + "typescript-tslint-plugin": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/typescript-tslint-plugin/-/typescript-tslint-plugin-0.0.4.tgz", + "integrity": "sha512-4ulIuRFrBfc52rmUvwOyPM8oRSqKmhyixpbk6v/1WaeoP9lc8o8lauCPpY7NFCK5FI3JZ/Znuak7OqBflwycTw==", + "dev": true, + "requires": { + "minimatch": "3.0.4", + "vscode-languageserver": "5.1.0" + } }, "underscore": { "version": "1.8.3", @@ -1586,6 +1578,44 @@ "x-is-string": "0.1.0" } }, + "vscode-jsonrpc": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-4.0.0.tgz", + "integrity": "sha512-perEnXQdQOJMTDFNv+UF3h1Y0z4iSiaN9jIlb0OqIYgosPCZGYh/MCUlkFtV2668PL69lRDO32hmvL2yiidUYg==", + "dev": true + }, + "vscode-languageserver": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver/-/vscode-languageserver-5.1.0.tgz", + "integrity": "sha512-CIsrgx2Y5VHS317g/HwkSTWYBIQmy0DwEyZPmB2pEpVOhYFwVsYpbiJwHIIyLQsQtmRaO4eA2xM8KPjNSdXpBw==", + "dev": true, + "requires": { + "vscode-languageserver-protocol": "3.13.0", + "vscode-uri": "1.0.6" + } + }, + "vscode-languageserver-protocol": { + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.13.0.tgz", + "integrity": "sha512-2ZGKwI+P2ovQll2PGAp+2UfJH+FK9eait86VBUdkPd9HRlm8e58aYT9pV/NYanHOcp3pL6x2yTLVCFMcTer0mg==", + "dev": true, + "requires": { + "vscode-jsonrpc": "4.0.0", + "vscode-languageserver-types": "3.13.0" + } + }, + "vscode-languageserver-types": { + "version": "3.13.0", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.13.0.tgz", + "integrity": "sha512-BnJIxS+5+8UWiNKCP7W3g9FlE7fErFw0ofP5BXJe7c2tl0VeWh+nNHFbwAS2vmVC4a5kYxHBjRy0UeOtziemVA==", + "dev": true + }, + "vscode-uri": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-1.0.6.tgz", + "integrity": "sha512-sLI2L0uGov3wKVb9EB+vIQBl9tVP90nqRvxSoJ35vI3NjxE8jfsE5DSOhWgSunHSZmKS4OCi2jrtfxK7uyp2ww==", + "dev": true + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index 0f93a8f34..8958a0e23 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test": "npm run typecheck && npm run lint && npm run prettier-check" }, "engines": { - "atom": ">=1.27.0 <2.0.0", + "atom": ">=1.31.0 <2.0.0", "node": "*" }, "configSchema": { @@ -46,6 +46,41 @@ "default": "en", "order": 50 }, + "preferBuiltinTooltips": { + "title": "Prefer built-in type tooltips", + "description": "Use built-in tooltips for displaying type information instead of Atom-IDE ones (if available); Change requires Atom restart", + "type": "boolean", + "default": false, + "order": 55 + }, + "preferBuiltinSigHelp": { + "title": "Prefer built-in signagure help tooltips", + "description": "Use built-in tooltips for displaying signature help instead of Atom-IDE ones (if available); Change requires Atom restart", + "type": "boolean", + "default": false, + "order": 56 + }, + "preferBuiltinBusySignal": { + "title": "Prefer built-in busy status indicator", + "description": "Use built-in busy status indicator instead of Atom-IDE one (if available); Change requires Atom restart", + "type": "boolean", + "default": false, + "order": 57 + }, + "preferBuiltinOccurrenceHighlight": { + "title": "Prefer built-in occurrence highligting", + "description": "Use built-in occurrence highlights instead of Atom-IDE one (if available); Change requires Atom restart", + "type": "boolean", + "default": false, + "order": 58 + }, + "disableAtomIdeDefinitions": { + "title": "Disable Atom-IDE Definitions interface", + "description": "Atom-IDE will revert to using Hyperclick for go-to-definition; Atom-Typescript will be able to track position history and return-from-declaration command will work; you will lose fancy previews on ctrl/cmd+mouseover though; Change requires Atom restart", + "type": "boolean", + "default": false, + "order": 59 + }, "buildStatusTimeout": { "title": "Build status visibility timeout", "description": "How long to show successful build status, in seconds. Failed status will be shown indefinitely. Negative means forever", @@ -90,6 +125,69 @@ "type": "boolean", "default": "false", "order": 120 + }, + "tsFileExtensions": { + "title": "TypeScript file extensions", + "description": "Comma-separated list of TypeScript file extensions; may require Atom restart to take effect; DO NOT EDIT unless you know what you are doing", + "type": "array", + "items": { + "type": "string" + }, + "default": [ + ".ts", + ".tst", + ".tsx" + ], + "order": 130 + }, + "jsFileExtensions": { + "title": "JavaScript file extensions", + "description": "Comma-separated list of JavaScript file extensions; may require Atom restart to take effect; DO NOT EDIT unless you know what you are doing", + "type": "array", + "items": { + "type": "string" + }, + "default": [ + ".js", + ".jst", + ".jsx" + ], + "order": 140 + }, + "tsSyntaxScopes": { + "title": "TypeScript syntax scopes", + "description": "Comma-separated list of TypeScript syntax scopes; may require Atom restart to take effect; DO NOT EDIT unless you know what you are doing", + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "source.ts", + "source.tsx", + "typescript" + ], + "order": 150 + }, + "jsSyntaxScopes": { + "title": "JavaScript syntax scopes", + "description": "Comma-separated list of JavaScript syntax scopes; may require Atom restart to take effect; DO NOT EDIT unless you know what you are doing", + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "source.js", + "source.jsx", + "javascript" + ], + "order": 160 + }, + "allowJS": { + "title": "Enable Atom-Typescript for JavaScript files (experimental)", + "description": "Passes JS files to TypeScript server; Most likely need allowJS: true and checkJS: true in tsconfig", + "type": "boolean", + "default": false, + "order": 170 } }, "deserializers": { @@ -105,6 +203,21 @@ "versions": { "^1.0.0": "consumeStatusBar" } + }, + "datatip": { + "versions": { + "0.1.0": "consumeDatatipService" + } + }, + "signature-help": { + "versions": { + "0.1.0": "consumeSignatureHelp" + } + }, + "atom-ide-busy-signal": { + "versions": { + "0.1.0": "consumeBusySignal" + } } }, "providedServices": { @@ -123,10 +236,35 @@ "1.0.0": "provideIntentions" } }, + "intentions:highlight": { + "versions": { + "1.0.0": "provideIntentionsHighlight" + } + }, "code-actions": { "versions": { "0.1.0": "provideCodeActions" } + }, + "find-references": { + "versions": { + "0.1.0": "provideReferences" + } + }, + "outline-view": { + "versions": { + "0.1.0": "provideOutlines" + } + }, + "definitions": { + "versions": { + "0.1.0": "provideDefinitions" + } + }, + "code-highlight": { + "versions": { + "0.1.0": "provideCodeHighlight" + } } }, "homepage": "https://github.com/TypeStrong/atom-typescript", @@ -141,32 +279,32 @@ "dependencies": { "atom-highlight": "^0.4.1", "atom-package-deps": "^4.6.2", - "atom-select-list": "^0.7.1", + "atom-select-list": "^0.7.2", "byline": "^5.0.0", - "escape-html": "^1.0.3", "etch": "^0.14.0", "fuzzaldrin": "^2.1.0", - "lodash": "^4.17.10", + "lodash": "^4.17.11", "resolve": "^1.8.1", "tsconfig": "^7.0.0", "tslib": "^1.9.3", - "typescript": "~3.0.1" + "typescript": "^3.1.6" }, "devDependencies": { - "@types/atom": "~1.28", + "@types/atom": "^1.31.0", "@types/byline": "^4.2.31", - "@types/chai": "^4.1.4", + "@types/chai": "^4.1.7", "@types/fuzzaldrin": "^2.1.1", - "@types/lodash": "^4.14.116", + "@types/lodash": "^4.14.118", "@types/mocha": "^2", - "@types/node": "^8", + "@types/node": "^8.10.38", "@types/resolve": "^0.0.8", "atom-ts-spec-runner": "^1.1.1", - "chai": "^4.1.2", - "prettier": "^1.14.2", + "chai": "^4.2.0", + "prettier": "^1.15.2", "ts-node": "^7.0.1", "tslint": "^5.11.0", - "tslint-language-service": "^0.9.9" + "tslint-use-atom-disposables": "0.0.1", + "typescript-tslint-plugin": "0.0.4" }, "package-deps": [ "atom-ide-ui:0.5.3" diff --git a/styles/atom-typescript-tooltip.less b/styles/atom-typescript-tooltip.less index 395a9ca2c..eaa07692e 100644 --- a/styles/atom-typescript-tooltip.less +++ b/styles/atom-typescript-tooltip.less @@ -22,16 +22,15 @@ // This class exists by default and this is what we are using .tooltip-inner { text-align: left; - white-space: pre !important; - - b { - word-break: break-word; + .atom-typescript-tooltip-tooltip-code { + font-weight: bold; + white-space: pre-wrap; word-wrap: break-word; - white-space: normal; } - i { - white-space: normal; + .atom-typescript-tooltip-tooltip-doc { + font-style: italic; + white-space: pre-line; } } } diff --git a/styles/atomts-datatip-style.less b/styles/atomts-datatip-style.less new file mode 100644 index 000000000..e465db1d7 --- /dev/null +++ b/styles/atomts-datatip-style.less @@ -0,0 +1,13 @@ +.atom-typescript-datatip-tooltip { + max-width: 500px; + white-space: normal; + .atom-typescript-datatip-tooltip-code { + white-space: pre-wrap; + } + .atom-typescript-datatip-tooltip-kind { + font-weight: bold; + } + .atom-typescript-datatip-tooltip-doc { + font-style: italic; + } +} diff --git a/styles/sig-help-tooltip.less b/styles/sig-help-tooltip.less new file mode 100644 index 000000000..9ae96fc7c --- /dev/null +++ b/styles/sig-help-tooltip.less @@ -0,0 +1,18 @@ +.atom-typescript-tooltip.tooltip .tooltip-inner { + font-size: initial; +} +.atom-typescript-tooltip-signature-help { + white-space: pre-line; + word-wrap: break-word; +} +.atom-typescript-tooltip-signature-help-parameter .atom-typescript-tooltip-signature-help-selected { + text-decoration: underline; +} +.atom-typescript-tooltip-signature-help.atom-typescript-tooltip-signature-help-selected { + font-weight: bold; +} +.atom-typescript-tooltip-signature-help-documentation { + font-style: italic; + word-wrap: normal; + font-weight: normal; +}