From 7a57e563d0421b1d4efb0de1473db60b3976ada0 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Sun, 26 Apr 2020 17:34:12 -0400 Subject: [PATCH] src/goLanguageServer.ts: respect configuration changes on server restart (#3186) --- package-lock.json | 254 +++++++++++++++++++++++++++++++++------- package.json | 6 +- src/goLanguageServer.ts | 171 ++++++++++++++------------- src/goMain.ts | 39 +++++- 4 files changed, 341 insertions(+), 129 deletions(-) diff --git a/package-lock.json b/package-lock.json index 525d7e756..cebc867b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -75,6 +75,12 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, + "@types/deep-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@types/deep-equal/-/deep-equal-1.0.1.tgz", + "integrity": "sha512-mMUu4nWHLBlHtxXY17Fg6+ucS/MnndyOWyOe7MmwkoMYxvfQU2ajtRaEvqSUv+aVkMqH/C0NCI8UoVfRNQ10yg==", + "dev": true + }, "@types/events": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz", @@ -114,9 +120,9 @@ "dev": true }, "@types/node": { - "version": "13.11.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.11.1.tgz", - "integrity": "sha512-eWQGP3qtxwL8FGneRrC5DwrJLGN4/dH1clNTuLfN81HCrxVtxRjygDTUoZJ5ASlDEeo0ppYFQjQIlXhtXpOn6g==", + "version": "13.13.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.0.tgz", + "integrity": "sha512-WE4IOAC6r/yBZss1oQGM5zs2D7RuKR6Q+w+X2SouPofnWn+LbCqClRyhO3ZE7Ix8nmFgo/oVuuE01cJT2XB13A==", "dev": true }, "@types/semver": { @@ -220,6 +226,11 @@ "sprintf-js": "~1.0.2" } }, + "array-filter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-1.0.0.tgz", + "integrity": "sha1-uveeYubvTCpMC4MSMtr/7CUfnYM=" + }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", @@ -268,6 +279,14 @@ "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", "dev": true }, + "available-typed-arrays": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz", + "integrity": "sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ==", + "requires": { + "array-filter": "^1.0.0" + } + }, "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", @@ -510,11 +529,37 @@ "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true }, + "deep-equal": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.0.2.tgz", + "integrity": "sha512-kX0bjV7tdMuhrhzKPEnVwqfQCuf+IEfN+4Xqv4eKd75xGRyn8yzdQ9ujPY6a221rgJKyQC4KBu1PibDTpa6m9w==", + "requires": { + "es-abstract": "^1.17.5", + "es-get-iterator": "^1.1.0", + "is-arguments": "^1.0.4", + "is-date-object": "^1.0.2", + "is-regex": "^1.0.5", + "isarray": "^2.0.5", + "object-is": "^1.0.2", + "object-keys": "^1.1.1", + "regexp.prototype.flags": "^1.3.0", + "side-channel": "^1.0.2", + "which-boxed-primitive": "^1.0.1", + "which-collection": "^1.0.1", + "which-typed-array": "^1.1.1" + }, + "dependencies": { + "isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==" + } + } + }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", - "dev": true, "requires": { "object-keys": "^1.0.12" } @@ -576,7 +621,6 @@ "version": "1.17.5", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz", "integrity": "sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg==", - "dev": true, "requires": { "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", @@ -591,11 +635,31 @@ "string.prototype.trimright": "^2.1.1" } }, + "es-get-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.0.tgz", + "integrity": "sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ==", + "requires": { + "es-abstract": "^1.17.4", + "has-symbols": "^1.0.1", + "is-arguments": "^1.0.4", + "is-map": "^2.0.1", + "is-set": "^2.0.1", + "is-string": "^1.0.5", + "isarray": "^2.0.5" + }, + "dependencies": { + "isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==" + } + } + }, "es-to-primitive": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, "requires": { "is-callable": "^1.1.4", "is-date-object": "^1.0.1", @@ -697,6 +761,11 @@ "is-buffer": "~2.0.3" } }, + "foreach": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", + "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=" + }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", @@ -740,8 +809,7 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "get-caller-file": { "version": "2.0.5", @@ -810,7 +878,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -824,8 +891,7 @@ "has-symbols": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==" }, "he": { "version": "1.2.0", @@ -912,6 +978,16 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, + "is-arguments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.0.4.tgz", + "integrity": "sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==" + }, + "is-bigint": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.0.tgz", + "integrity": "sha512-t5mGUXC/xRheCK431ylNiSkGGpBp8bHENBcENTkDT6ppwPzEVxNGZRvgvmOEfbWkFhA7D2GEuE2mmQTr78sl2g==" + }, "is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -921,6 +997,11 @@ "binary-extensions": "^2.0.0" } }, + "is-boolean-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.0.1.tgz", + "integrity": "sha512-TqZuVwa/sppcrhUCAYkGBk7w0yxfQQnxq28fjkO53tnK9FQXmdwz2JS5+GjsWQ6RByES1K40nI+yDic5c9/aAQ==" + }, "is-buffer": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", @@ -930,14 +1011,12 @@ "is-callable": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz", - "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==", - "dev": true + "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==" }, "is-date-object": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", - "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", - "dev": true + "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==" }, "is-extglob": { "version": "2.1.1", @@ -960,35 +1039,74 @@ "is-extglob": "^2.1.1" } }, + "is-map": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.1.tgz", + "integrity": "sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw==" + }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "is-number-object": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.4.tgz", + "integrity": "sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==" + }, "is-regex": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.5.tgz", "integrity": "sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ==", - "dev": true, "requires": { "has": "^1.0.3" } }, + "is-set": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.1.tgz", + "integrity": "sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA==" + }, + "is-string": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", + "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==" + }, "is-symbol": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", - "dev": true, "requires": { "has-symbols": "^1.0.1" } }, + "is-typed-array": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.3.tgz", + "integrity": "sha512-BSYUBOK/HJibQ30wWkWold5txYwMUXQct9YHAQJr8fSwvZoiglcqB0pd7vEN23+Tsi9IUEjztdOSzl4qLVYGTQ==", + "requires": { + "available-typed-arrays": "^1.0.0", + "es-abstract": "^1.17.4", + "foreach": "^2.0.5", + "has-symbols": "^1.0.1" + } + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, + "is-weakmap": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.1.tgz", + "integrity": "sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==" + }, + "is-weakset": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.1.tgz", + "integrity": "sha512-pi4vhbhVHGLxohUw7PhGsueT4vRGFoXhP7+RGN0jKIv9+8PWYCQTqtADngrxOm2g46hoH0+g8uZZBzMrvVGDmw==" + }, "isarray": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", @@ -1039,6 +1157,13 @@ "jsonparse": "1.x.x", "lodash": "3.x.x", "object-assign": "4.x" + }, + "dependencies": { + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=" + } } }, "json-schema": { @@ -1099,9 +1224,10 @@ } }, "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=" + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true }, "lodash.get": { "version": "4.4.2", @@ -1291,20 +1417,26 @@ "object-inspect": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.7.0.tgz", - "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==", - "dev": true + "integrity": "sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==" + }, + "object-is": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.2.tgz", + "integrity": "sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ==", + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + } }, "object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", - "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", - "dev": true + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" }, "object.assign": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz", "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==", - "dev": true, "requires": { "define-properties": "^1.1.2", "function-bind": "^1.1.1", @@ -1423,6 +1555,15 @@ "picomatch": "^2.0.4" } }, + "regexp.prototype.flags": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", + "integrity": "sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==", + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + } + }, "request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -1463,9 +1604,9 @@ "dev": true }, "resolve": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.16.0.tgz", - "integrity": "sha512-LarL/PIKJvc09k1jaeT4kQb/8/7P+qV4qSnN2K80AES+OHdfZELAKVOBjxsvtToT/uLOfFbvYvKfZmV8cee7nA==", + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.16.1.tgz", + "integrity": "sha512-rmAglCSqWWMrrBv/XM6sW0NuRFiKViw/W4d9EbC4pt+49H8JwHy+mcGmALTEg504AUDcLTvb1T2q3E9AnmY+ig==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -1506,6 +1647,15 @@ "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==" }, + "side-channel": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.2.tgz", + "integrity": "sha512-7rL9YlPHg7Ancea1S96Pa8/QWb4BtXL/TZvS6B8XFetGBeuhAsfmUspK6DokBeZ64+Kj9TCNRD/30pVz1BvQNA==", + "requires": { + "es-abstract": "^1.17.0-next.1", + "object-inspect": "^1.7.0" + } + }, "sinon": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/sinon/-/sinon-9.0.2.tgz", @@ -1579,7 +1729,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", - "dev": true, "requires": { "define-properties": "^1.1.3", "es-abstract": "^1.17.5" @@ -1589,7 +1738,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/string.prototype.trimleft/-/string.prototype.trimleft-2.1.2.tgz", "integrity": "sha512-gCA0tza1JBvqr3bfAIFJGqfdRTyPae82+KTnm3coDXkZN9wnuW3HjGgN386D7hfv5CHQYCI022/rJPVlqXyHSw==", - "dev": true, "requires": { "define-properties": "^1.1.3", "es-abstract": "^1.17.5", @@ -1600,7 +1748,6 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz", "integrity": "sha512-ZNRQ7sY3KroTaYjRS6EbNiiHrOkjihL9aQE/8gfQ4DtAC/aEBRHFJa44OmoWxGGqXuJlfKkZW4WcXErGr+9ZFg==", - "dev": true, "requires": { "define-properties": "^1.1.3", "es-abstract": "^1.17.5", @@ -1611,7 +1758,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", - "dev": true, "requires": { "define-properties": "^1.1.3", "es-abstract": "^1.17.5" @@ -1862,12 +2008,48 @@ "isexe": "^2.0.0" } }, + "which-boxed-primitive": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.1.tgz", + "integrity": "sha512-7BT4TwISdDGBgaemWU0N0OU7FeAEJ9Oo2P1PHRm/FCWoEi2VLWC9b6xvxAA3C/NMpxg3HXVgi0sMmGbNUbNepQ==", + "requires": { + "is-bigint": "^1.0.0", + "is-boolean-object": "^1.0.0", + "is-number-object": "^1.0.3", + "is-string": "^1.0.4", + "is-symbol": "^1.0.2" + } + }, + "which-collection": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.1.tgz", + "integrity": "sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==", + "requires": { + "is-map": "^2.0.1", + "is-set": "^2.0.1", + "is-weakmap": "^2.0.1", + "is-weakset": "^2.0.1" + } + }, "which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", "dev": true }, + "which-typed-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.2.tgz", + "integrity": "sha512-KT6okrd1tE6JdZAy3o2VhMoYPh3+J6EMZLyrxBQsZflI1QCZIxMrIYLkosd8Twf+YfknVIHmYQPgJt238p8dnQ==", + "requires": { + "available-typed-arrays": "^1.0.2", + "es-abstract": "^1.17.5", + "foreach": "^2.0.5", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.1", + "is-typed-array": "^1.1.3" + } + }, "wide-align": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", @@ -1993,14 +2175,6 @@ "flat": "^4.1.0", "lodash": "^4.17.15", "yargs": "^13.3.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", - "dev": true - } } } } diff --git a/package.json b/package.json index 59c1fed3c..a088c5155 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,8 @@ "vscode-debugprotocol": "^1.40.0", "vscode-extension-telemetry": "^0.1.2", "vscode-languageclient": "6.1.0", - "web-request": "^1.0.7" + "web-request": "^1.0.7", + "deep-equal": "^2.0.2" }, "devDependencies": { "@types/fs-extra": "^8.1.0", @@ -66,7 +67,8 @@ "sinon": "^9.0.2", "tslint": "^6.1.1", "typescript": "^3.8.3", - "vscode-test": "^1.3.0" + "vscode-test": "^1.3.0", + "@types/deep-equal": "^1.0.1" }, "engines": { "vscode": "^1.41.0" diff --git a/src/goLanguageServer.ts b/src/goLanguageServer.ts index 2c2384577..625fd9522 100644 --- a/src/goLanguageServer.ts +++ b/src/goLanguageServer.ts @@ -6,6 +6,7 @@ 'use strict'; import cp = require('child_process'); +import deepEqual = require('deep-equal'); import moment = require('moment'); import path = require('path'); import semver = require('semver'); @@ -13,36 +14,24 @@ import util = require('util'); import vscode = require('vscode'); import { Command, - FormattingOptions, HandleDiagnosticsSignature, LanguageClient, ProvideCompletionItemsSignature, - ProvideDocumentFormattingEditsSignature, ProvideDocumentLinksSignature, RevealOutputChannelOn } from 'vscode-languageclient'; import WebRequest = require('web-request'); -import { GoDefinitionProvider } from './goDeclaration'; -import { GoHoverProvider } from './goExtraInfo'; -import { GoDocumentFormattingEditProvider } from './goFormat'; -import { GoImplementationProvider } from './goImplementations'; import { promptForMissingTool, promptForUpdatingTool } from './goInstallTools'; -import { parseLiveFile } from './goLiveErrors'; -import { GO_MODE } from './goMode'; -import { GoDocumentSymbolProvider } from './goOutline'; import { getToolFromToolPath } from './goPath'; -import { GoReferenceProvider } from './goReferences'; -import { GoRenameProvider } from './goRename'; -import { GoSignatureHelpProvider } from './goSignature'; -import { GoCompletionItemProvider } from './goSuggest'; -import { GoWorkspaceSymbolProvider } from './goSymbol'; import { getTool, Tool } from './goTools'; -import { GoTypeDefinitionProvider } from './goTypeDefinition'; import { getBinPath, getCurrentGoPath, getGoConfig, getToolsEnvVars } from './util'; interface LanguageServerConfig { + serverName: string; + path: string; enabled: boolean; flags: string[]; + env: any; features: { diagnostics: boolean; documentLink: boolean; @@ -50,48 +39,91 @@ interface LanguageServerConfig { checkForUpdates: boolean; } -// registerLanguageFeatures registers providers for all the language features. -// It looks to either the language server or the standard providers for these features. -export async function registerLanguageFeatures(ctx: vscode.ExtensionContext) { +// Global variables used for management of the language client. +// They are global so that the server can be easily restarted with +// new configurations. +let languageClient: LanguageClient; +let languageServerDisposable: vscode.Disposable; +let latestConfig: LanguageServerConfig; +let serverOutputChannel: vscode.OutputChannel; + +// startLanguageServer starts the language server (if enabled), returning +// true on success. +export async function registerLanguageFeatures(ctx: vscode.ExtensionContext): Promise { // Subscribe to notifications for changes to the configuration of the language server. ctx.subscriptions.push(vscode.workspace.onDidChangeConfiguration((e) => watchLanguageServerConfiguration(e))); const config = parseLanguageServerConfig(); - - // If the user has not enabled the language server, - // register the default language features and return. if (!config.enabled) { - registerUsualProviders(ctx); - return; + return false; } - // The user has opted into the language server. - const languageServerToolPath = getLanguageServerToolPath(); - const toolName = getToolFromToolPath(languageServerToolPath); - if (!toolName) { - // language server binary is not installed yet. - // Return immediately. The information messages such as - // offering to install missing tools, and suggesting to - // reload the window after installing the language server - // should be presented by now. - return; + // Support a command to restart the language server, if it's enabled. + ctx.subscriptions.push(vscode.commands.registerCommand('go.languageserver.restart', () => { + return startLanguageServer(ctx, parseLanguageServerConfig()); + })); + + // If the language server is gopls, we can check if the user needs to + // update their gopls version. + if (config.serverName === 'gopls') { + const tool = getTool(config.serverName); + if (!tool) { + return false; + } + const versionToUpdate = await shouldUpdateLanguageServer(tool, config.path, config.checkForUpdates); + if (versionToUpdate) { + promptForUpdatingTool(tool.name); + } + } + + // This function handles the case when the server isn't started yet, + // so we can call it to start the language server. + return startLanguageServer(ctx, config); +} + +async function startLanguageServer(ctx: vscode.ExtensionContext, config: LanguageServerConfig): Promise { + // If the client has already been started, make sure to clear existing + // diagnostics and stop it. + if (languageClient) { + if (languageClient.diagnostics) { + languageClient.diagnostics.clear(); + } + await languageClient.stop(); + if (languageServerDisposable) { + languageServerDisposable.dispose(); + } } - const env = getToolsEnvVars(); - // If installed, check. The user may not have the most up-to-date version of the language server. - const tool = getTool(toolName); - const versionToUpdate = await shouldUpdateLanguageServer(tool, languageServerToolPath, config.checkForUpdates); + // Check if we should recreate the language client. This may be necessary + // if the user has changed settings in their config. + if (!deepEqual(latestConfig, config)) { + // Track the latest config used to start the language server. + latestConfig = config; - if (versionToUpdate) { - promptForUpdatingTool(toolName, versionToUpdate); + // If the user has not enabled or installed the language server, return. + if (!config.enabled || !config.path) { + return false; + } + buildLanguageClient(config); } - const c = new LanguageClient( - toolName, + languageServerDisposable = languageClient.start(); + ctx.subscriptions.push(languageServerDisposable); + + return true; +} + +function buildLanguageClient(config: LanguageServerConfig) { + // Reuse the same output channel for each instance of the server. + if (!serverOutputChannel) { + serverOutputChannel = vscode.window.createOutputChannel(config.serverName); + } + languageClient = new LanguageClient( + config.serverName, { - command: languageServerToolPath, + command: config.path, args: ['-mode=stdio', ...config.flags], - options: { env } + options: { env: config.env }, }, { initializationOptions: {}, @@ -102,6 +134,7 @@ export async function registerLanguageFeatures(ctx: vscode.ExtensionContext) { (uri.scheme ? uri : uri.with({ scheme: 'file' })).toString(), protocol2Code: (uri: string) => vscode.Uri.parse(uri) }, + outputChannel: serverOutputChannel, revealOutputChannelOn: RevealOutputChannelOn.Never, middleware: { handleDiagnostics: ( @@ -179,30 +212,14 @@ export async function registerLanguageFeatures(ctx: vscode.ExtensionContext) { } } ); - - c.onReady().then(() => { - const capabilities = c.initializeResult && c.initializeResult.capabilities; + languageClient.onReady().then(() => { + const capabilities = languageClient.initializeResult && languageClient.initializeResult.capabilities; if (!capabilities) { return vscode.window.showErrorMessage( 'The language server is not able to serve any features at the moment.' ); } }); - - let languageServerDisposable = c.start(); - ctx.subscriptions.push(languageServerDisposable); - - ctx.subscriptions.push( - vscode.commands.registerCommand('go.languageserver.restart', async () => { - if (c.diagnostics) { - c.diagnostics.clear(); - } - await c.stop(); - languageServerDisposable.dispose(); - languageServerDisposable = c.start(); - ctx.subscriptions.push(languageServerDisposable); - }) - ); } function watchLanguageServerConfiguration(e: vscode.ConfigurationChangeEvent) { @@ -242,8 +259,12 @@ function watchLanguageServerConfiguration(e: vscode.ConfigurationChangeEvent) { export function parseLanguageServerConfig(): LanguageServerConfig { const goConfig = getGoConfig(); - - const config = { + const toolsEnv = getToolsEnvVars(); + const languageServerPath = getLanguageServerToolPath(); + const languageServerName = getToolFromToolPath(languageServerPath); + return { + serverName: languageServerName, + path: languageServerPath, enabled: goConfig['useLanguageServer'], flags: goConfig['languageServerFlags'] || [], features: { @@ -252,9 +273,9 @@ export function parseLanguageServerConfig(): LanguageServerConfig { diagnostics: goConfig['languageServerExperimentalFeatures']['diagnostics'], documentLink: goConfig['languageServerExperimentalFeatures']['documentLink'] }, + env: toolsEnv, checkForUpdates: goConfig['useGoProxyToCheckForToolUpdates'] }; - return config; } /** @@ -314,28 +335,6 @@ function allFoldersHaveSameGopath(): boolean { return vscode.workspace.workspaceFolders.find((x) => tempGopath !== getCurrentGoPath(x.uri)) ? false : true; } -// registerUsualProviders registers the language feature providers if the language server is not enabled. -function registerUsualProviders(ctx: vscode.ExtensionContext) { - const provider = new GoCompletionItemProvider(ctx.globalState); - ctx.subscriptions.push(provider); - ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(GO_MODE, provider, '.', '"')); - ctx.subscriptions.push(vscode.languages.registerHoverProvider(GO_MODE, new GoHoverProvider())); - ctx.subscriptions.push(vscode.languages.registerDefinitionProvider(GO_MODE, new GoDefinitionProvider())); - ctx.subscriptions.push(vscode.languages.registerReferenceProvider(GO_MODE, new GoReferenceProvider())); - ctx.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(GO_MODE, new GoDocumentSymbolProvider())); - ctx.subscriptions.push(vscode.languages.registerWorkspaceSymbolProvider(new GoWorkspaceSymbolProvider())); - ctx.subscriptions.push( - vscode.languages.registerSignatureHelpProvider(GO_MODE, new GoSignatureHelpProvider(), '(', ',') - ); - ctx.subscriptions.push(vscode.languages.registerImplementationProvider(GO_MODE, new GoImplementationProvider())); - ctx.subscriptions.push( - vscode.languages.registerDocumentFormattingEditProvider(GO_MODE, new GoDocumentFormattingEditProvider()) - ); - ctx.subscriptions.push(vscode.languages.registerTypeDefinitionProvider(GO_MODE, new GoTypeDefinitionProvider())); - ctx.subscriptions.push(vscode.languages.registerRenameProvider(GO_MODE, new GoRenameProvider())); - vscode.workspace.onDidChangeTextDocument(parseLiveFile, null, ctx.subscriptions); -} - const acceptGoplsPrerelease = false; const defaultLatestVersion = semver.coerce('0.3.1'); const defaultLatestVersionTime = moment('2020-02-04', 'YYYY-MM-DD'); diff --git a/src/goMain.ts b/src/goMain.ts index 64145be8b..f9684d4cc 100644 --- a/src/goMain.ts +++ b/src/goMain.ts @@ -22,11 +22,15 @@ import { updateCodeCoverageDecorators } from './goCover'; import { GoDebugConfigurationProvider } from './goDebugConfiguration'; +import { GoDefinitionProvider } from './goDeclaration'; import { extractFunction, extractVariable } from './goDoctor'; +import { GoHoverProvider } from './goExtraInfo'; import { runFillStruct } from './goFillStruct'; +import { GoDocumentFormattingEditProvider } from './goFormat'; import * as goGenerateTests from './goGenerateTests'; import { goGetPackage } from './goGetPackage'; import { implCursor } from './goImpl'; +import { GoImplementationProvider } from './goImplementations'; import { addImport, addImportToWorkspace } from './goImport'; import { installCurrentPackage } from './goInstall'; import { @@ -38,16 +42,24 @@ import { } from './goInstallTools'; import { registerLanguageFeatures } from './goLanguageServer'; import { lintCode } from './goLint'; +import { parseLiveFile } from './goLiveErrors'; import { GO_MODE } from './goMode'; import { addTags, removeTags } from './goModifytags'; import { GO111MODULE, isModSupported } from './goModules'; +import { GoDocumentSymbolProvider } from './goOutline'; import { clearCacheForTools, fileExists } from './goPath'; import { playgroundCommand } from './goPlayground'; +import { GoReferenceProvider } from './goReferences'; import { GoReferencesCodeLensProvider } from './goReferencesCodelens'; +import { GoRenameProvider } from './goRename'; import { GoRunTestCodeLensProvider } from './goRunTestCodelens'; +import { GoSignatureHelpProvider } from './goSignature'; import { outputChannel, showHideStatus } from './goStatus'; +import { GoCompletionItemProvider } from './goSuggest'; +import { GoWorkspaceSymbolProvider } from './goSymbol'; import { testAtCursor, testCurrentFile, testCurrentPackage, testPrevious, testWorkspace } from './goTest'; import { getConfiguredTools } from './goTools'; +import { GoTypeDefinitionProvider } from './goTypeDefinition'; import { vetCode } from './goVet'; import { getFromGlobalState, @@ -135,7 +147,10 @@ export function activate(ctx: vscode.ExtensionContext): void { // This handles all of the configurations and registrations for the language server. // It also registers the necessary language feature providers that the language server may not support. - await registerLanguageFeatures(ctx); + const ok = await registerLanguageFeatures(ctx); + if (!ok) { + registerUsualProviders(ctx); + } if ( vscode.window.activeTextEditor && @@ -608,6 +623,28 @@ function addOnSaveTextDocumentListeners(ctx: vscode.ExtensionContext) { ); } +// registerUsualProviders registers the language feature providers if the language server is not enabled. +function registerUsualProviders(ctx: vscode.ExtensionContext) { + const provider = new GoCompletionItemProvider(ctx.globalState); + ctx.subscriptions.push(provider); + ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(GO_MODE, provider, '.', '"')); + ctx.subscriptions.push(vscode.languages.registerHoverProvider(GO_MODE, new GoHoverProvider())); + ctx.subscriptions.push(vscode.languages.registerDefinitionProvider(GO_MODE, new GoDefinitionProvider())); + ctx.subscriptions.push(vscode.languages.registerReferenceProvider(GO_MODE, new GoReferenceProvider())); + ctx.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(GO_MODE, new GoDocumentSymbolProvider())); + ctx.subscriptions.push(vscode.languages.registerWorkspaceSymbolProvider(new GoWorkspaceSymbolProvider())); + ctx.subscriptions.push( + vscode.languages.registerSignatureHelpProvider(GO_MODE, new GoSignatureHelpProvider(), '(', ',') + ); + ctx.subscriptions.push(vscode.languages.registerImplementationProvider(GO_MODE, new GoImplementationProvider())); + ctx.subscriptions.push( + vscode.languages.registerDocumentFormattingEditProvider(GO_MODE, new GoDocumentFormattingEditProvider()) + ); + ctx.subscriptions.push(vscode.languages.registerTypeDefinitionProvider(GO_MODE, new GoTypeDefinitionProvider())); + ctx.subscriptions.push(vscode.languages.registerRenameProvider(GO_MODE, new GoRenameProvider())); + vscode.workspace.onDidChangeTextDocument(parseLiveFile, null, ctx.subscriptions); +} + function addOnChangeTextDocumentListeners(ctx: vscode.ExtensionContext) { vscode.workspace.onDidChangeTextDocument(trackCodeCoverageRemovalOnFileChange, null, ctx.subscriptions); vscode.workspace.onDidChangeTextDocument(removeTestStatus, null, ctx.subscriptions);