From 112fae6a6ccec932e1824a85e5086bbe866e1ec2 Mon Sep 17 00:00:00 2001 From: Brad Cornes Date: Fri, 5 Aug 2022 16:58:50 +0100 Subject: [PATCH] Replace `multi-regexp2` with `becke-ch--regex--s0-0-v1--base--pl--lib` (#590) --- package-lock.json | 142 +++++++++--------- .../package-lock.json | 22 +-- .../tailwindcss-language-service/package.json | 2 +- .../src/completionProvider.ts | 32 ++-- .../src/util/createMultiRegexp.ts | 57 ------- .../src/util/find.ts | 32 ++-- ...cke-ch--regex--s0-0-v1--base--pl--lib.d.ts | 6 + 7 files changed, 121 insertions(+), 172 deletions(-) delete mode 100644 packages/tailwindcss-language-service/src/util/createMultiRegexp.ts create mode 100644 types/becke-ch--regex--s0-0-v1--base--pl--lib.d.ts diff --git a/package-lock.json b/package-lock.json index d6403a4..0be4e92 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@types/node": "14.14.34", "@types/semver": "7.3.10", "@types/vscode": "1.60.0", + "becke-ch--regex--s0-0-v1--base--pl--lib": "1.4.0", "builtin-modules": "3.2.0", "chokidar": "3.5.1", "color-name": "1.1.4", @@ -35,7 +36,6 @@ "license-checker": "25.0.1", "line-column": "1.0.2", "moo": "0.5.1", - "multi-regexp2": "1.0.3", "normalize-path": "3.0.0", "pkg-up": "3.1.0", "postcss": "8.3.9", @@ -245,14 +245,12 @@ } }, "node_modules/@babel/helper-define-polyfill-provider": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.1.tgz", - "integrity": "sha512-J9hGMpJQmtWmj46B3kBHmL38UhJGhYX7eqkcq+2gsstyYt341HmPeWspihX43yVRA0mS+8GGk2Gckc7bY/HCmA==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.2.tgz", + "integrity": "sha512-r9QJJ+uDWrd+94BSPcP6/de67ygLtvVy6cK4luE6MOuDsZIdoaPBnfSpbO/+LTifjPckbKXRuI9BB/Z2/y3iTg==", "dependencies": { - "@babel/helper-compilation-targets": "^7.13.0", - "@babel/helper-module-imports": "^7.12.13", - "@babel/helper-plugin-utils": "^7.13.0", - "@babel/traverse": "^7.13.0", + "@babel/helper-compilation-targets": "^7.17.7", + "@babel/helper-plugin-utils": "^7.16.7", "debug": "^4.1.1", "lodash.debounce": "^4.0.8", "resolve": "^1.14.2", @@ -5657,12 +5655,12 @@ } }, "node_modules/babel-plugin-polyfill-corejs2": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz", - "integrity": "sha512-v7/T6EQcNfVLfcN2X8Lulb7DjprieyLWJK/zOWH5DUYcAgex9sP3h25Q+DLsX9TloXe3y1O8l2q2Jv9q8UVB9w==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.2.tgz", + "integrity": "sha512-LPnodUl3lS0/4wN3Rb+m+UK8s7lj2jcLRrjho4gLw+OJs+I4bvGXshINesY5xx/apM+biTnQ9reDI8yj+0M5+Q==", "dependencies": { - "@babel/compat-data": "^7.13.11", - "@babel/helper-define-polyfill-provider": "^0.3.1", + "@babel/compat-data": "^7.17.7", + "@babel/helper-define-polyfill-provider": "^0.3.2", "semver": "^6.1.1" }, "peerDependencies": { @@ -5678,11 +5676,11 @@ } }, "node_modules/babel-plugin-polyfill-corejs3": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.2.tgz", - "integrity": "sha512-G3uJih0XWiID451fpeFaYGVuxHEjzKTHtc9uGFEjR6hHrvNzeS/PX+LLLcetJcytsB5m4j+K3o/EpXJNb/5IEQ==", + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.3.tgz", + "integrity": "sha512-zKsXDh0XjnrUEW0mxIHLfjBfnXSMr5Q/goMe/fxpQnLm07mcOZiIZHBNWCMx60HmdvjxfXcalac0tfFg0wqxyw==", "dependencies": { - "@babel/helper-define-polyfill-provider": "^0.3.1", + "@babel/helper-define-polyfill-provider": "^0.3.2", "core-js-compat": "^3.21.0" }, "peerDependencies": { @@ -5816,6 +5814,11 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/becke-ch--regex--s0-0-v1--base--pl--lib": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", + "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==" + }, "node_modules/before-after-hook": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz", @@ -6134,9 +6137,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001368", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001368.tgz", - "integrity": "sha512-wgfRYa9DenEomLG/SdWgQxpIyvdtH3NW8Vq+tB6AwR9e56iOIcu1im5F/wNdDf04XlKHXqIx4N8Jo0PemeBenQ==", + "version": "1.0.30001370", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001370.tgz", + "integrity": "sha512-3PDmaP56wz/qz7G508xzjx8C+MC2qEm4SYhSEzC9IBROo+dGXFWRuaXkWti0A9tuI00g+toiriVqxtWMgl350g==", "funding": [ { "type": "opencollective", @@ -6383,9 +6386,9 @@ } }, "node_modules/cli-spinners": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.6.1.tgz", - "integrity": "sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.7.0.tgz", + "integrity": "sha512-qu3pN8Y3qHNgE2AFweciB1IfMnmZ/fsNTEE+NOFjmGB2F/7rLhnhzppvpCnN4FovtP26k8lHyy9ptEbNwWFLzw==", "engines": { "node": ">=6" }, @@ -7171,9 +7174,9 @@ } }, "node_modules/core-js-compat": { - "version": "3.23.5", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.23.5.tgz", - "integrity": "sha512-fHYozIFIxd+91IIbXJgWd/igXIc8Mf9is0fusswjnGIWVG96y2cwyUdlCkGOw6rMLHKAxg7xtCIVaHsyOUnJIg==", + "version": "3.24.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.24.0.tgz", + "integrity": "sha512-F+2E63X3ff/nj8uIrf8Rf24UDGIz7p838+xjEp+Bx3y8OWXj+VTPPZNCtdqovPaS9o7Tka5mCH01Zn5vOd6UQg==", "dependencies": { "browserslist": "^4.21.2", "semver": "7.0.0" @@ -7192,9 +7195,9 @@ } }, "node_modules/core-js-pure": { - "version": "3.23.5", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.23.5.tgz", - "integrity": "sha512-8t78LdpKSuCq4pJYCYk8hl7XEkAX+BP16yRIwL3AanTksxuEf7CM83vRyctmiEL8NDZ3jpUcv56fk9/zG3aIuw==", + "version": "3.24.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.24.0.tgz", + "integrity": "sha512-uzMmW8cRh7uYw4JQtzqvGWRyC2T5+4zipQLQdi2FmiRqP83k3d6F3stv2iAlNhOs6cXN401FCD5TL0vvleuHgA==", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -7751,9 +7754,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.198", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.198.tgz", - "integrity": "sha512-jwqQPdKGeAslcq8L+1SZZgL6uDiIDmTe9Gq4brsdWAH27y7MJ2g9Ue6MyST3ogmSM49EAQP7bype1V5hsuNrmQ==" + "version": "1.4.199", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.199.tgz", + "integrity": "sha512-WIGME0Cs7oob3mxsJwHbeWkH0tYkIE/sjkJ8ML2BYmuRcjhRl/q5kVDXG7W9LOOKwzPU5M0LBlXRq9rlSgnNlg==" }, "node_modules/emoji-regex": { "version": "9.2.2", @@ -14673,11 +14676,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "node_modules/multi-regexp2": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/multi-regexp2/-/multi-regexp2-1.0.3.tgz", - "integrity": "sha512-yYrsPk+8TW+r4HK8/7/BIqc7QzcMSIwUGwGouiwIC/anHpjCfKO/PNACGiPYn0WzEMiq+LuEAmZ80NRiCCykiw==" - }, "node_modules/multimatch": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/multimatch/-/multimatch-3.0.0.tgz", @@ -21100,14 +21098,12 @@ } }, "@babel/helper-define-polyfill-provider": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.1.tgz", - "integrity": "sha512-J9hGMpJQmtWmj46B3kBHmL38UhJGhYX7eqkcq+2gsstyYt341HmPeWspihX43yVRA0mS+8GGk2Gckc7bY/HCmA==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.3.2.tgz", + "integrity": "sha512-r9QJJ+uDWrd+94BSPcP6/de67ygLtvVy6cK4luE6MOuDsZIdoaPBnfSpbO/+LTifjPckbKXRuI9BB/Z2/y3iTg==", "requires": { - "@babel/helper-compilation-targets": "^7.13.0", - "@babel/helper-module-imports": "^7.12.13", - "@babel/helper-plugin-utils": "^7.13.0", - "@babel/traverse": "^7.13.0", + "@babel/helper-compilation-targets": "^7.17.7", + "@babel/helper-plugin-utils": "^7.16.7", "debug": "^4.1.1", "lodash.debounce": "^4.0.8", "resolve": "^1.14.2", @@ -25292,12 +25288,12 @@ } }, "babel-plugin-polyfill-corejs2": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.1.tgz", - "integrity": "sha512-v7/T6EQcNfVLfcN2X8Lulb7DjprieyLWJK/zOWH5DUYcAgex9sP3h25Q+DLsX9TloXe3y1O8l2q2Jv9q8UVB9w==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.2.tgz", + "integrity": "sha512-LPnodUl3lS0/4wN3Rb+m+UK8s7lj2jcLRrjho4gLw+OJs+I4bvGXshINesY5xx/apM+biTnQ9reDI8yj+0M5+Q==", "requires": { - "@babel/compat-data": "^7.13.11", - "@babel/helper-define-polyfill-provider": "^0.3.1", + "@babel/compat-data": "^7.17.7", + "@babel/helper-define-polyfill-provider": "^0.3.2", "semver": "^6.1.1" }, "dependencies": { @@ -25309,11 +25305,11 @@ } }, "babel-plugin-polyfill-corejs3": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.2.tgz", - "integrity": "sha512-G3uJih0XWiID451fpeFaYGVuxHEjzKTHtc9uGFEjR6hHrvNzeS/PX+LLLcetJcytsB5m4j+K3o/EpXJNb/5IEQ==", + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.3.tgz", + "integrity": "sha512-zKsXDh0XjnrUEW0mxIHLfjBfnXSMr5Q/goMe/fxpQnLm07mcOZiIZHBNWCMx60HmdvjxfXcalac0tfFg0wqxyw==", "requires": { - "@babel/helper-define-polyfill-provider": "^0.3.1", + "@babel/helper-define-polyfill-provider": "^0.3.2", "core-js-compat": "^3.21.0" } }, @@ -25421,6 +25417,11 @@ "tweetnacl": "^0.14.3" } }, + "becke-ch--regex--s0-0-v1--base--pl--lib": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", + "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==" + }, "before-after-hook": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.1.tgz", @@ -25671,9 +25672,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001368", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001368.tgz", - "integrity": "sha512-wgfRYa9DenEomLG/SdWgQxpIyvdtH3NW8Vq+tB6AwR9e56iOIcu1im5F/wNdDf04XlKHXqIx4N8Jo0PemeBenQ==" + "version": "1.0.30001370", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001370.tgz", + "integrity": "sha512-3PDmaP56wz/qz7G508xzjx8C+MC2qEm4SYhSEzC9IBROo+dGXFWRuaXkWti0A9tuI00g+toiriVqxtWMgl350g==" }, "capture-exit": { "version": "2.0.0", @@ -25861,9 +25862,9 @@ } }, "cli-spinners": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.6.1.tgz", - "integrity": "sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==" + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.7.0.tgz", + "integrity": "sha512-qu3pN8Y3qHNgE2AFweciB1IfMnmZ/fsNTEE+NOFjmGB2F/7rLhnhzppvpCnN4FovtP26k8lHyy9ptEbNwWFLzw==" }, "cli-width": { "version": "2.2.1", @@ -26489,9 +26490,9 @@ "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" }, "core-js-compat": { - "version": "3.23.5", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.23.5.tgz", - "integrity": "sha512-fHYozIFIxd+91IIbXJgWd/igXIc8Mf9is0fusswjnGIWVG96y2cwyUdlCkGOw6rMLHKAxg7xtCIVaHsyOUnJIg==", + "version": "3.24.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.24.0.tgz", + "integrity": "sha512-F+2E63X3ff/nj8uIrf8Rf24UDGIz7p838+xjEp+Bx3y8OWXj+VTPPZNCtdqovPaS9o7Tka5mCH01Zn5vOd6UQg==", "requires": { "browserslist": "^4.21.2", "semver": "7.0.0" @@ -26505,9 +26506,9 @@ } }, "core-js-pure": { - "version": "3.23.5", - "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.23.5.tgz", - "integrity": "sha512-8t78LdpKSuCq4pJYCYk8hl7XEkAX+BP16yRIwL3AanTksxuEf7CM83vRyctmiEL8NDZ3jpUcv56fk9/zG3aIuw==" + "version": "3.24.0", + "resolved": "https://registry.npmjs.org/core-js-pure/-/core-js-pure-3.24.0.tgz", + "integrity": "sha512-uzMmW8cRh7uYw4JQtzqvGWRyC2T5+4zipQLQdi2FmiRqP83k3d6F3stv2iAlNhOs6cXN401FCD5TL0vvleuHgA==" }, "core-util-is": { "version": "1.0.2", @@ -26938,9 +26939,9 @@ } }, "electron-to-chromium": { - "version": "1.4.198", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.198.tgz", - "integrity": "sha512-jwqQPdKGeAslcq8L+1SZZgL6uDiIDmTe9Gq4brsdWAH27y7MJ2g9Ue6MyST3ogmSM49EAQP7bype1V5hsuNrmQ==" + "version": "1.4.199", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.199.tgz", + "integrity": "sha512-WIGME0Cs7oob3mxsJwHbeWkH0tYkIE/sjkJ8ML2BYmuRcjhRl/q5kVDXG7W9LOOKwzPU5M0LBlXRq9rlSgnNlg==" }, "emoji-regex": { "version": "9.2.2", @@ -32302,11 +32303,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "multi-regexp2": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/multi-regexp2/-/multi-regexp2-1.0.3.tgz", - "integrity": "sha512-yYrsPk+8TW+r4HK8/7/BIqc7QzcMSIwUGwGouiwIC/anHpjCfKO/PNACGiPYn0WzEMiq+LuEAmZ80NRiCCykiw==" - }, "multimatch": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/multimatch/-/multimatch-3.0.0.tgz", diff --git a/packages/tailwindcss-language-service/package-lock.json b/packages/tailwindcss-language-service/package-lock.json index 64c4140..201680a 100644 --- a/packages/tailwindcss-language-service/package-lock.json +++ b/packages/tailwindcss-language-service/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@types/moo": "0.5.3", "@types/semver": "7.3.10", + "becke-ch--regex--s0-0-v1--base--pl--lib": "1.4.0", "color-name": "1.1.4", "css.escape": "1.5.1", "culori": "0.20.1", @@ -18,7 +19,6 @@ "dset": "3.1.2", "line-column": "1.0.2", "moo": "0.5.1", - "multi-regexp2": "1.0.3", "postcss": "8.3.9", "postcss-selector-parser": "6.0.2", "semver": "7.3.7", @@ -3026,6 +3026,11 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/becke-ch--regex--s0-0-v1--base--pl--lib": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", + "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -8502,11 +8507,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "node_modules/multi-regexp2": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/multi-regexp2/-/multi-regexp2-1.0.3.tgz", - "integrity": "sha512-yYrsPk+8TW+r4HK8/7/BIqc7QzcMSIwUGwGouiwIC/anHpjCfKO/PNACGiPYn0WzEMiq+LuEAmZ80NRiCCykiw==" - }, "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -14888,6 +14888,11 @@ "tweetnacl": "^0.14.3" } }, + "becke-ch--regex--s0-0-v1--base--pl--lib": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/becke-ch--regex--s0-0-v1--base--pl--lib/-/becke-ch--regex--s0-0-v1--base--pl--lib-1.4.0.tgz", + "integrity": "sha512-FnWonOyaw7Vivg5nIkrUll9HSS5TjFbyuURAiDssuL6VxrBe3ERzudRxOcWRhZYlP89UArMDikz7SapRPQpmZQ==" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -19137,11 +19142,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "multi-regexp2": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/multi-regexp2/-/multi-regexp2-1.0.3.tgz", - "integrity": "sha512-yYrsPk+8TW+r4HK8/7/BIqc7QzcMSIwUGwGouiwIC/anHpjCfKO/PNACGiPYn0WzEMiq+LuEAmZ80NRiCCykiw==" - }, "mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", diff --git a/packages/tailwindcss-language-service/package.json b/packages/tailwindcss-language-service/package.json index 6a075ba..f2d8f60 100644 --- a/packages/tailwindcss-language-service/package.json +++ b/packages/tailwindcss-language-service/package.json @@ -16,6 +16,7 @@ "dependencies": { "@types/moo": "0.5.3", "@types/semver": "7.3.10", + "becke-ch--regex--s0-0-v1--base--pl--lib": "1.4.0", "color-name": "1.1.4", "css.escape": "1.5.1", "culori": "0.20.1", @@ -24,7 +25,6 @@ "dset": "3.1.2", "line-column": "1.0.2", "moo": "0.5.1", - "multi-regexp2": "1.0.3", "postcss": "8.3.9", "postcss-selector-parser": "6.0.2", "semver": "7.3.7", diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts index f53ddd2..5be8c60 100644 --- a/packages/tailwindcss-language-service/src/completionProvider.ts +++ b/packages/tailwindcss-language-service/src/completionProvider.ts @@ -29,10 +29,10 @@ import { getClassAttributeLexer, getComputedClassAttributeLexer } from './util/l import { validateApply } from './util/validateApply' import { flagEnabled } from './util/flagEnabled' import { remToPx } from './util/remToPx' -import { createMultiRegexp } from './util/createMultiRegexp' import * as jit from './util/jit' import { getVariantsFromClassName } from './util/getVariantsFromClassName' import * as culori from 'culori' +import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib' let isUtil = (className) => Array.isArray(className.__info) @@ -414,28 +414,30 @@ async function provideCustomClassNameCompletions( for (let i = 0; i < regexes.length; i++) { try { - let [containerRegex, classRegex] = Array.isArray(regexes[i]) ? regexes[i] : [regexes[i]] + let [containerRegexString, classRegexString] = Array.isArray(regexes[i]) + ? regexes[i] + : [regexes[i]] - containerRegex = createMultiRegexp(containerRegex) - let containerMatch + let containerRegex = new Regex(containerRegexString, 'g') + let containerMatch: ReturnType while ((containerMatch = containerRegex.exec(str)) !== null) { const searchStart = document.offsetAt(searchRange.start) - const matchStart = searchStart + containerMatch.start - const matchEnd = searchStart + containerMatch.end + const matchStart = searchStart + containerMatch.index[1] + const matchEnd = matchStart + containerMatch[1].length const cursor = document.offsetAt(position) if (cursor >= matchStart && cursor <= matchEnd) { - let classList + let classList: string - if (classRegex) { - classRegex = createMultiRegexp(classRegex) - let classMatch + if (classRegexString) { + let classRegex = new Regex(classRegexString, 'g') + let classMatch: ReturnType - while ((classMatch = classRegex.exec(containerMatch.match)) !== null) { - const classMatchStart = matchStart + classMatch.start - const classMatchEnd = matchStart + classMatch.end + while ((classMatch = classRegex.exec(containerMatch[1])) !== null) { + const classMatchStart = matchStart + classMatch.index[1] + const classMatchEnd = classMatchStart + classMatch[1].length if (cursor >= classMatchStart && cursor <= classMatchEnd) { - classList = classMatch.match.substr(0, cursor - classMatchStart) + classList = classMatch[1].substr(0, cursor - classMatchStart) } } @@ -443,7 +445,7 @@ async function provideCustomClassNameCompletions( throw Error() } } else { - classList = containerMatch.match.substr(0, cursor - matchStart) + classList = containerMatch[1].substr(0, cursor - matchStart) } return completionsFromClassList(state, classList, { diff --git a/packages/tailwindcss-language-service/src/util/createMultiRegexp.ts b/packages/tailwindcss-language-service/src/util/createMultiRegexp.ts deleted file mode 100644 index e6e086f..0000000 --- a/packages/tailwindcss-language-service/src/util/createMultiRegexp.ts +++ /dev/null @@ -1,57 +0,0 @@ -import MultiRegexp from 'multi-regexp2' - -export function createMultiRegexp(regexString: string) { - let insideCharClass = false - let captureGroupIndex = -1 - - for (let i = 0; i < regexString.length; i++) { - if ( - !insideCharClass && - regexString[i] === '[' && - regexString[i - 1] !== '\\' - ) { - insideCharClass = true - } else if ( - insideCharClass && - regexString[i] === ']' && - regexString[i - 1] !== '\\' - ) { - insideCharClass = false - } else if ( - !insideCharClass && - regexString[i] === '(' && - regexString.substr(i + 1, 2) !== '?:' - ) { - captureGroupIndex = i - break - } - } - - const re = /(?:[^\\]|^)\(\?:/g - let match: RegExpExecArray - let nonCaptureGroupIndexes: number[] = [] - - while ((match = re.exec(regexString)) !== null) { - if (match[0].startsWith('(')) { - nonCaptureGroupIndexes.push(match.index) - } else { - nonCaptureGroupIndexes.push(match.index + 1) - } - } - - const regex = new MultiRegexp( - new RegExp( - regexString.replace(re, (m) => m.substr(0, m.length - 2)), - 'g' - ) - ) - - let groupIndex = - 1 + nonCaptureGroupIndexes.filter((i) => i < captureGroupIndex).length - - return { - exec: (str: string) => { - return regex.execForGroup(str, groupIndex) - }, - } -} diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts index b0a4196..d30ac49 100644 --- a/packages/tailwindcss-language-service/src/util/find.ts +++ b/packages/tailwindcss-language-service/src/util/find.ts @@ -10,8 +10,8 @@ import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers import { getLanguageBoundaries } from './getLanguageBoundaries' import { resolveRange } from './resolveRange' import dlv from 'dlv' -import { createMultiRegexp } from './createMultiRegexp' import { rangesEqual } from './rangesEqual' +import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib' export function findAll(re: RegExp, str: string): RegExpMatchArray[] { let match: RegExpMatchArray @@ -132,25 +132,27 @@ async function findCustomClassLists( for (let i = 0; i < regexes.length; i++) { try { - let [containerRegex, classRegex] = Array.isArray(regexes[i]) ? regexes[i] : [regexes[i]] + let [containerRegexString, classRegexString] = Array.isArray(regexes[i]) + ? regexes[i] + : [regexes[i]] - let containerRegex2 = createMultiRegexp(containerRegex) - let containerMatch + let containerRegex = new Regex(containerRegexString, 'g') + let containerMatch: ReturnType - while ((containerMatch = containerRegex2.exec(text)) !== null) { + while ((containerMatch = containerRegex.exec(text)) !== null) { const searchStart = doc.offsetAt(range?.start || { line: 0, character: 0 }) - const matchStart = searchStart + containerMatch.start - const matchEnd = searchStart + containerMatch.end + const matchStart = searchStart + containerMatch.index[1] + const matchEnd = matchStart + containerMatch[1].length - if (classRegex) { - let classRegex2 = createMultiRegexp(classRegex) - let classMatch + if (classRegexString) { + let classRegex = new Regex(classRegexString, 'g') + let classMatch: ReturnType - while ((classMatch = classRegex2.exec(containerMatch.match)) !== null) { - const classMatchStart = matchStart + classMatch.start - const classMatchEnd = matchStart + classMatch.end + while ((classMatch = classRegex.exec(containerMatch[1])) !== null) { + const classMatchStart = matchStart + classMatch.index[1] + const classMatchEnd = classMatchStart + classMatch[1].length result.push({ - classList: classMatch.match, + classList: classMatch[1], range: { start: doc.positionAt(classMatchStart), end: doc.positionAt(classMatchEnd), @@ -159,7 +161,7 @@ async function findCustomClassLists( } } else { result.push({ - classList: containerMatch.match, + classList: containerMatch[1], range: { start: doc.positionAt(matchStart), end: doc.positionAt(matchEnd), diff --git a/types/becke-ch--regex--s0-0-v1--base--pl--lib.d.ts b/types/becke-ch--regex--s0-0-v1--base--pl--lib.d.ts new file mode 100644 index 0000000..607dc97 --- /dev/null +++ b/types/becke-ch--regex--s0-0-v1--base--pl--lib.d.ts @@ -0,0 +1,6 @@ +declare module 'becke-ch--regex--s0-0-v1--base--pl--lib' { + export default class Regex { + constructor(regex: string, modifiers?: string) + exec(str: string): null | (string[] & { index: number[] }) + } +}