From e945532956d5dab36273ddc9ad9412b86a116523 Mon Sep 17 00:00:00 2001 From: Andy Bunce Date: Sun, 6 Mar 2022 23:46:59 +0000 Subject: [PATCH 1/3] [mod] symbols --- package-lock.json | 290 +++++++++--------- package.json | 26 +- src/common/configuration.ts | 12 +- src/common/logger.ts | 6 +- .../xquery-completion-item-provider.ts | 2 + src/constants.ts | 1 + src/extension.ts | 37 +-- src/formatting/XQueryFormatter.ts | 18 -- src/formatting/index.ts | 1 + src/formatting/xml-formatter.ts | 4 +- src/formatting/xquery-formatting-provider.ts | 33 ++ src/symbols/symbols.ts | 45 +++ 12 files changed, 272 insertions(+), 203 deletions(-) delete mode 100644 src/formatting/XQueryFormatter.ts create mode 100644 src/formatting/xquery-formatting-provider.ts create mode 100644 src/symbols/symbols.ts diff --git a/package-lock.json b/package-lock.json index a186750..0aba0de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,13 @@ { "name": "vscode-basex", - "version": "0.0.27", + "version": "0.0.44", "lockfileVersion": 1, "requires": true, "dependencies": { "@eslint/eslintrc": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.1.0.tgz", - "integrity": "sha512-C1DfL7XX4nPqGd6jcP01W9pVM1HYCuUkFk1432D7F0v3JSlUIeOYn9oCoi3eoLZ+iwBSb29BMFxxny0YrrEZqg==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.2.0.tgz", + "integrity": "sha512-igm9SjJHNEJRiUnecP/1R5T3wKLEJ7pL6e2P+GUSfCd0dGjPYYZve08uzw8L2J8foVHFz+NGu12JxRcU2gGo6w==", "dev": true, "requires": { "ajv": "^6.12.4", @@ -36,9 +36,9 @@ } }, "@humanwhocodes/config-array": { - "version": "0.9.3", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.3.tgz", - "integrity": "sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ==", + "version": "0.9.5", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.9.5.tgz", + "integrity": "sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw==", "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", @@ -79,9 +79,9 @@ } }, "@quodatum/xqlint": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@quodatum/xqlint/-/xqlint-0.0.8.tgz", - "integrity": "sha512-3tTyu5PNjSh8fIxHcFJYIn0dQY3cSYbCcVl6q3hjdHwh8TNr1PiPEnoHMHFWQ9cR5ftIi6+47/h4t6qflKfYnw==", + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/@quodatum/xqlint/-/xqlint-0.0.11.tgz", + "integrity": "sha512-G+pOGhrPRvCrgh3yE+U3lIavQrhPymdS1ILqd1bqgsWthF55c78D2lNDxwBn03PCpB6svh08UefkBBlm1hw3GA==", "requires": { "colors": "1.4.0", "commander": "~2.3.0", @@ -144,9 +144,9 @@ "dev": true }, "@types/vscode": { - "version": "1.64.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.64.0.tgz", - "integrity": "sha512-bSlAWz5WtcSL3cO9tAT/KpEH9rv5OBnm93OIIFwdCshaAiqr2bp1AUyEwW9MWeCvZBHEXc3V0fTYVdVyzDNwHA==", + "version": "1.65.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.65.0.tgz", + "integrity": "sha512-wQhExnh2nEzpjDMSKhUvnNmz3ucpd3E+R7wJkOhBNK3No6fG3VUdmVmMOKD0A8NDZDDDiQcLNxe3oGmX5SjJ5w==", "dev": true }, "@types/xmldom": { @@ -156,14 +156,14 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.12.0.tgz", - "integrity": "sha512-fwCMkDimwHVeIOKeBHiZhRUfJXU8n6xW1FL9diDxAyGAFvKcH4csy0v7twivOQdQdA0KC8TDr7GGRd3L4Lv0rQ==", + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.13.0.tgz", + "integrity": "sha512-vLktb2Uec81fxm/cfz2Hd6QaWOs8qdmVAZXLdOBX6JFJDhf6oDZpMzZ4/LZ6SFM/5DgDcxIMIvy3F+O9yZBuiQ==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.12.0", - "@typescript-eslint/type-utils": "5.12.0", - "@typescript-eslint/utils": "5.12.0", + "@typescript-eslint/scope-manager": "5.13.0", + "@typescript-eslint/type-utils": "5.13.0", + "@typescript-eslint/utils": "5.13.0", "debug": "^4.3.2", "functional-red-black-tree": "^1.0.1", "ignore": "^5.1.8", @@ -173,52 +173,52 @@ } }, "@typescript-eslint/parser": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.12.0.tgz", - "integrity": "sha512-MfSwg9JMBojMUoGjUmX+D2stoQj1CBYTCP0qnnVtu9A+YQXVKNtLjasYh+jozOcrb/wau8TCfWOkQTiOAruBog==", + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.13.0.tgz", + "integrity": "sha512-GdrU4GvBE29tm2RqWOM0P5QfCtgCyN4hXICj/X9ibKED16136l9ZpoJvCL5pSKtmJzA+NRDzQ312wWMejCVVfg==", "dev": true, "requires": { - "@typescript-eslint/scope-manager": "5.12.0", - "@typescript-eslint/types": "5.12.0", - "@typescript-eslint/typescript-estree": "5.12.0", + "@typescript-eslint/scope-manager": "5.13.0", + "@typescript-eslint/types": "5.13.0", + "@typescript-eslint/typescript-estree": "5.13.0", "debug": "^4.3.2" } }, "@typescript-eslint/scope-manager": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.12.0.tgz", - "integrity": "sha512-GAMobtIJI8FGf1sLlUWNUm2IOkIjvn7laFWyRx7CLrv6nLBI7su+B7lbStqVlK5NdLvHRFiJo2HhiDF7Ki01WQ==", + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.13.0.tgz", + "integrity": "sha512-T4N8UvKYDSfVYdmJq7g2IPJYCRzwtp74KyDZytkR4OL3NRupvswvmJQJ4CX5tDSurW2cvCc1Ia1qM7d0jpa7IA==", "dev": true, "requires": { - "@typescript-eslint/types": "5.12.0", - "@typescript-eslint/visitor-keys": "5.12.0" + "@typescript-eslint/types": "5.13.0", + "@typescript-eslint/visitor-keys": "5.13.0" } }, "@typescript-eslint/type-utils": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.12.0.tgz", - "integrity": "sha512-9j9rli3zEBV+ae7rlbBOotJcI6zfc6SHFMdKI9M3Nc0sy458LJ79Os+TPWeBBL96J9/e36rdJOfCuyRSgFAA0Q==", + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.13.0.tgz", + "integrity": "sha512-/nz7qFizaBM1SuqAKb7GLkcNn2buRdDgZraXlkhz+vUGiN1NZ9LzkA595tHHeduAiS2MsHqMNhE2zNzGdw43Yg==", "dev": true, "requires": { - "@typescript-eslint/utils": "5.12.0", + "@typescript-eslint/utils": "5.13.0", "debug": "^4.3.2", "tsutils": "^3.21.0" } }, "@typescript-eslint/types": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.12.0.tgz", - "integrity": "sha512-JowqbwPf93nvf8fZn5XrPGFBdIK8+yx5UEGs2QFAYFI8IWYfrzz+6zqlurGr2ctShMaJxqwsqmra3WXWjH1nRQ==", + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.13.0.tgz", + "integrity": "sha512-LmE/KO6DUy0nFY/OoQU0XelnmDt+V8lPQhh8MOVa7Y5k2gGRd6U9Kp3wAjhB4OHg57tUO0nOnwYQhRRyEAyOyg==", "dev": true }, "@typescript-eslint/typescript-estree": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.12.0.tgz", - "integrity": "sha512-Dd9gVeOqt38QHR0BEA8oRaT65WYqPYbIc5tRFQPkfLquVEFPD1HAtbZT98TLBkEcCkvwDYOAvuSvAD9DnQhMfQ==", + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.13.0.tgz", + "integrity": "sha512-Q9cQow0DeLjnp5DuEDjLZ6JIkwGx3oYZe+BfcNuw/POhtpcxMTy18Icl6BJqTSd+3ftsrfuVb7mNHRZf7xiaNA==", "dev": true, "requires": { - "@typescript-eslint/types": "5.12.0", - "@typescript-eslint/visitor-keys": "5.12.0", + "@typescript-eslint/types": "5.13.0", + "@typescript-eslint/visitor-keys": "5.13.0", "debug": "^4.3.2", "globby": "^11.0.4", "is-glob": "^4.0.3", @@ -227,26 +227,26 @@ } }, "@typescript-eslint/utils": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.12.0.tgz", - "integrity": "sha512-k4J2WovnMPGI4PzKgDtQdNrCnmBHpMUFy21qjX2CoPdoBcSBIMvVBr9P2YDP8jOqZOeK3ThOL6VO/sy6jtnvzw==", + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.13.0.tgz", + "integrity": "sha512-+9oHlPWYNl6AwwoEt5TQryEHwiKRVjz7Vk6kaBeD3/kwHE5YqTGHtm/JZY8Bo9ITOeKutFaXnBlMgSATMJALUQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.9", - "@typescript-eslint/scope-manager": "5.12.0", - "@typescript-eslint/types": "5.12.0", - "@typescript-eslint/typescript-estree": "5.12.0", + "@typescript-eslint/scope-manager": "5.13.0", + "@typescript-eslint/types": "5.13.0", + "@typescript-eslint/typescript-estree": "5.13.0", "eslint-scope": "^5.1.1", "eslint-utils": "^3.0.0" } }, "@typescript-eslint/visitor-keys": { - "version": "5.12.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.12.0.tgz", - "integrity": "sha512-cFwTlgnMV6TgezQynx2c/4/tx9Tufbuo9LPzmWqyRC3QC4qTGkAG1C6pBr0/4I10PAI/FlYunI3vJjIcu+ZHMg==", + "version": "5.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.13.0.tgz", + "integrity": "sha512-HLKEAS/qA1V7d9EzcpLFykTePmOQqOFim8oCvhY3pZgQ8Hi38hYpHd9e5GN6nQBFQNecNhws5wkS9Y5XIO0s/g==", "dev": true, "requires": { - "@typescript-eslint/types": "5.12.0", + "@typescript-eslint/types": "5.13.0", "eslint-visitor-keys": "^3.0.0" } }, @@ -257,9 +257,9 @@ "dev": true }, "@vscode/test-electron": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.1.2.tgz", - "integrity": "sha512-INjJ0YA9RgR1B/xBl8P4sxww4Dy2996f4Xn5oGTFfC0c2Mm45y/1Id8xmfuoba6tR5i8zZaUIHfEYWe7Rt4uZA==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/@vscode/test-electron/-/test-electron-2.1.3.tgz", + "integrity": "sha512-ps/yJ/9ToUZtR1dHfWi1mDXtep1VoyyrmGKC3UnIbScToRQvbUjyy1VMqnMEW3EpMmC3g7+pyThIPtPyCLHyow==", "dev": true, "requires": { "http-proxy-agent": "^4.0.1", @@ -707,162 +707,170 @@ } }, "esbuild": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.23.tgz", - "integrity": "sha512-XjnIcZ9KB6lfonCa+jRguXyRYcldmkyZ99ieDksqW/C8bnyEX299yA4QH2XcgijCgaddEZePPTgvx/2imsq7Ig==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.25.tgz", + "integrity": "sha512-4JHEIOMNFvK09ziiL+iVmldIhLbn49V4NAVo888tcGFKedEZY/Y8YapfStJ6zSE23tzYPKxqKwQBnQoIO0BI/Q==", "dev": true, "requires": { - "esbuild-android-arm64": "0.14.23", - "esbuild-darwin-64": "0.14.23", - "esbuild-darwin-arm64": "0.14.23", - "esbuild-freebsd-64": "0.14.23", - "esbuild-freebsd-arm64": "0.14.23", - "esbuild-linux-32": "0.14.23", - "esbuild-linux-64": "0.14.23", - "esbuild-linux-arm": "0.14.23", - "esbuild-linux-arm64": "0.14.23", - "esbuild-linux-mips64le": "0.14.23", - "esbuild-linux-ppc64le": "0.14.23", - "esbuild-linux-riscv64": "0.14.23", - "esbuild-linux-s390x": "0.14.23", - "esbuild-netbsd-64": "0.14.23", - "esbuild-openbsd-64": "0.14.23", - "esbuild-sunos-64": "0.14.23", - "esbuild-windows-32": "0.14.23", - "esbuild-windows-64": "0.14.23", - "esbuild-windows-arm64": "0.14.23" + "esbuild-android-64": "0.14.25", + "esbuild-android-arm64": "0.14.25", + "esbuild-darwin-64": "0.14.25", + "esbuild-darwin-arm64": "0.14.25", + "esbuild-freebsd-64": "0.14.25", + "esbuild-freebsd-arm64": "0.14.25", + "esbuild-linux-32": "0.14.25", + "esbuild-linux-64": "0.14.25", + "esbuild-linux-arm": "0.14.25", + "esbuild-linux-arm64": "0.14.25", + "esbuild-linux-mips64le": "0.14.25", + "esbuild-linux-ppc64le": "0.14.25", + "esbuild-linux-riscv64": "0.14.25", + "esbuild-linux-s390x": "0.14.25", + "esbuild-netbsd-64": "0.14.25", + "esbuild-openbsd-64": "0.14.25", + "esbuild-sunos-64": "0.14.25", + "esbuild-windows-32": "0.14.25", + "esbuild-windows-64": "0.14.25", + "esbuild-windows-arm64": "0.14.25" } }, + "esbuild-android-64": { + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.25.tgz", + "integrity": "sha512-L5vCUk7TzFbBnoESNoXjU3x9+/+7TDIE/1mTfy/erAfvZAqC+S3sp/Qa9wkypFMcFvN9FzvESkTlpeQDolREtQ==", + "dev": true, + "optional": true + }, "esbuild-android-arm64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.23.tgz", - "integrity": "sha512-k9sXem++mINrZty1v4FVt6nC5BQCFG4K2geCIUUqHNlTdFnuvcqsY7prcKZLFhqVC1rbcJAr9VSUGFL/vD4vsw==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.25.tgz", + "integrity": "sha512-4jv5xPjM/qNm27T5j3ZEck0PvjgQtoMHnz4FzwF5zNP56PvY2CT0WStcAIl6jNlsuDdN63rk2HRBIsO6xFbcFw==", "dev": true, "optional": true }, "esbuild-darwin-64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.23.tgz", - "integrity": "sha512-lB0XRbtOYYL1tLcYw8BoBaYsFYiR48RPrA0KfA/7RFTr4MV7Bwy/J4+7nLsVnv9FGuQummM3uJ93J3ptaTqFug==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.25.tgz", + "integrity": "sha512-TGp8tuudIxOyWd1+8aYPxQmC1ZQyvij/AfNBa35RubixD0zJ1vkKHVAzo0Zao1zcG6pNqiSyzfPto8vmg0s7oA==", "dev": true, "optional": true }, "esbuild-darwin-arm64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.23.tgz", - "integrity": "sha512-yat73Z/uJ5tRcfRiI4CCTv0FSnwErm3BJQeZAh+1tIP0TUNh6o+mXg338Zl5EKChD+YGp6PN+Dbhs7qa34RxSw==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.25.tgz", + "integrity": "sha512-oTcDgdm0MDVEmw2DWu8BV68pYuImpFgvWREPErBZmNA4MYKGuBRaCiJqq6jZmBR1x+3y1DWCjez+5uLtuAm6mw==", "dev": true, "optional": true }, "esbuild-freebsd-64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.23.tgz", - "integrity": "sha512-/1xiTjoLuQ+LlbfjJdKkX45qK/M7ARrbLmyf7x3JhyQGMjcxRYVR6Dw81uH3qlMHwT4cfLW4aEVBhP1aNV7VsA==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.25.tgz", + "integrity": "sha512-ueAqbnMZ8arnuLH8tHwTCQYeptnHOUV7vA6px6j4zjjQwDx7TdP7kACPf3TLZLdJQ3CAD1XCvQ2sPhX+8tacvQ==", "dev": true, "optional": true }, "esbuild-freebsd-arm64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.23.tgz", - "integrity": "sha512-uyPqBU/Zcp6yEAZS4LKj5jEE0q2s4HmlMBIPzbW6cTunZ8cyvjG6YWpIZXb1KK3KTJDe62ltCrk3VzmWHp+iLg==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.25.tgz", + "integrity": "sha512-+ZVWud2HKh+Ob6k/qiJWjBtUg4KmJGGmbvEXXW1SNKS7hW7HU+Zq2ZCcE1akFxOPkVB+EhOty/sSek30tkCYug==", "dev": true, "optional": true }, "esbuild-linux-32": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.23.tgz", - "integrity": "sha512-37R/WMkQyUfNhbH7aJrr1uCjDVdnPeTHGeDhZPUNhfoHV0lQuZNCKuNnDvlH/u/nwIYZNdVvz1Igv5rY/zfrzQ==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.25.tgz", + "integrity": "sha512-3OP/lwV3kCzEz45tobH9nj+uE4ubhGsfx+tn0L26WAGtUbmmcRpqy7XRG/qK7h1mClZ+eguIANcQntYMdYklfw==", "dev": true, "optional": true }, "esbuild-linux-64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.23.tgz", - "integrity": "sha512-H0gztDP60qqr8zoFhAO64waoN5yBXkmYCElFklpd6LPoobtNGNnDe99xOQm28+fuD75YJ7GKHzp/MLCLhw2+vQ==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.25.tgz", + "integrity": "sha512-+aKHdHZmX9qwVlQmu5xYXh7GsBFf4TWrePgeJTalhXHOG7NNuUwoHmketGiZEoNsWyyqwH9rE5BC+iwcLY30Ug==", "dev": true, "optional": true }, "esbuild-linux-arm": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.23.tgz", - "integrity": "sha512-x64CEUxi8+EzOAIpCUeuni0bZfzPw/65r8tC5cy5zOq9dY7ysOi5EVQHnzaxS+1NmV+/RVRpmrzGw1QgY2Xpmw==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.25.tgz", + "integrity": "sha512-aTLcE2VBoLydL943REcAcgnDi3bHtmULSXWLbjtBdtykRatJVSxKMjK9YlBXUZC4/YcNQfH7AxwVeQr9fNxPhw==", "dev": true, "optional": true }, "esbuild-linux-arm64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.23.tgz", - "integrity": "sha512-c4MLOIByNHR55n3KoYf9hYDfBRghMjOiHLaoYLhkQkIabb452RWi+HsNgB41sUpSlOAqfpqKPFNg7VrxL3UX9g==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.25.tgz", + "integrity": "sha512-UxfenPx/wSZx55gScCImPtXekvZQLI2GW3qe5dtlmU7luiqhp5GWPzGeQEbD3yN3xg/pHc671m5bma5Ns7lBHw==", "dev": true, "optional": true }, "esbuild-linux-mips64le": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.23.tgz", - "integrity": "sha512-kHKyKRIAedYhKug2EJpyJxOUj3VYuamOVA1pY7EimoFPzaF3NeY7e4cFBAISC/Av0/tiV0xlFCt9q0HJ68IBIw==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.25.tgz", + "integrity": "sha512-wLWYyqVfYx9Ur6eU5RT92yJVsaBGi5RdkoWqRHOqcJ38Kn60QMlcghsKeWfe9jcYut8LangYZ98xO1LxIoSXrQ==", "dev": true, "optional": true }, "esbuild-linux-ppc64le": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.23.tgz", - "integrity": "sha512-7ilAiJEPuJJnJp/LiDO0oJm5ygbBPzhchJJh9HsHZzeqO+3PUzItXi+8PuicY08r0AaaOe25LA7sGJ0MzbfBag==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.25.tgz", + "integrity": "sha512-0dR6Csl6Zas3g4p9ULckEl8Mo8IInJh33VCJ3eaV1hj9+MHGdmDOakYMN8MZP9/5nl+NU/0ygpd14cWgy8uqRw==", "dev": true, "optional": true }, "esbuild-linux-riscv64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.23.tgz", - "integrity": "sha512-fbL3ggK2wY0D8I5raPIMPhpCvODFE+Bhb5QGtNP3r5aUsRR6TQV+ZBXIaw84iyvKC8vlXiA4fWLGhghAd/h/Zg==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.25.tgz", + "integrity": "sha512-J4d20HDmTrgvhR0bdkDhvvJGaikH3LzXQnNaseo8rcw9Yqby9A90gKUmWpfwqLVNRILvNnAmKLfBjCKU9ajg8w==", "dev": true, "optional": true }, "esbuild-linux-s390x": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.23.tgz", - "integrity": "sha512-GHMDCyfy7+FaNSO8RJ8KCFsnax8fLUsOrj9q5Gi2JmZMY0Zhp75keb5abTFCq2/Oy6KVcT0Dcbyo/bFb4rIFJA==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.25.tgz", + "integrity": "sha512-YI2d5V6nTE73ZnhEKQD7MtsPs1EtUZJ3obS21oxQxGbbRw1G+PtJKjNyur+3t6nzHP9oTg6GHQ3S3hOLLmbDIQ==", "dev": true, "optional": true }, "esbuild-netbsd-64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.23.tgz", - "integrity": "sha512-ovk2EX+3rrO1M2lowJfgMb/JPN1VwVYrx0QPUyudxkxLYrWeBxDKQvc6ffO+kB4QlDyTfdtAURrVzu3JeNdA2g==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.25.tgz", + "integrity": "sha512-TKIVgNWLUOkr+Exrye70XTEE1lJjdQXdM4tAXRzfHE9iBA7LXWcNtVIuSnphTqpanPzTDFarF0yqq4kpbC6miA==", "dev": true, "optional": true }, "esbuild-openbsd-64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.23.tgz", - "integrity": "sha512-uYYNqbVR+i7k8ojP/oIROAHO9lATLN7H2QeXKt2H310Fc8FJj4y3Wce6hx0VgnJ4k1JDrgbbiXM8rbEgQyg8KA==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.25.tgz", + "integrity": "sha512-QgFJ37A15D7NIXBTYEqz29+uw3nNBOIyog+3kFidANn6kjw0GHZ0lEYQn+cwjyzu94WobR+fes7cTl/ZYlHb1A==", "dev": true, "optional": true }, "esbuild-sunos-64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.23.tgz", - "integrity": "sha512-hAzeBeET0+SbScknPzS2LBY6FVDpgE+CsHSpe6CEoR51PApdn2IB0SyJX7vGelXzlyrnorM4CAsRyb9Qev4h9g==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.25.tgz", + "integrity": "sha512-rmWfjUItYIVlqr5EnTH1+GCxXiBOC42WBZ3w++qh7n2cS9Xo0lO5pGSG2N+huOU2fX5L+6YUuJ78/vOYvefeFw==", "dev": true, "optional": true }, "esbuild-windows-32": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.23.tgz", - "integrity": "sha512-Kttmi3JnohdaREbk6o9e25kieJR379TsEWF0l39PQVHXq3FR6sFKtVPgY8wk055o6IB+rllrzLnbqOw/UV60EA==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.25.tgz", + "integrity": "sha512-HGAxVUofl3iUIz9W10Y9XKtD0bNsK9fBXv1D55N/ljNvkrAYcGB8YCm0v7DjlwtyS6ws3dkdQyXadbxkbzaKOA==", "dev": true, "optional": true }, "esbuild-windows-64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.23.tgz", - "integrity": "sha512-JtIT0t8ymkpl6YlmOl6zoSWL5cnCgyLaBdf/SiU/Eg3C13r0NbHZWNT/RDEMKK91Y6t79kTs3vyRcNZbfu5a8g==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.25.tgz", + "integrity": "sha512-TirEohRkfWU9hXLgoDxzhMQD1g8I2mOqvdQF2RS9E/wbkORTAqJHyh7wqGRCQAwNzdNXdg3JAyhQ9/177AadWA==", "dev": true, "optional": true }, "esbuild-windows-arm64": { - "version": "0.14.23", - "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.23.tgz", - "integrity": "sha512-cTFaQqT2+ik9e4hePvYtRZQ3pqOvKDVNarzql0VFIzhc0tru/ZgdLoXd6epLiKT+SzoSce6V9YJ+nn6RCn6SHw==", + "version": "0.14.25", + "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.25.tgz", + "integrity": "sha512-4ype9ERiI45rSh+R8qUoBtaj6kJvUOI7oVLhKqPEpcF4Pa5PpT3hm/mXAyotJHREkHpM87PAJcA442mLnbtlNA==", "dev": true, "optional": true }, @@ -884,12 +892,12 @@ "dev": true }, "eslint": { - "version": "8.9.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.9.0.tgz", - "integrity": "sha512-PB09IGwv4F4b0/atrbcMFboF/giawbBLVC7fyDamk5Wtey4Jh2K+rYaBhCAbUyEI4QzB1ly09Uglc9iCtFaG2Q==", + "version": "8.10.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.10.0.tgz", + "integrity": "sha512-tcI1D9lfVec+R4LE1mNDnzoJ/f71Kl/9Cv4nG47jOueCMBrCCKYXr4AUVS7go6mWYGFD4+EoN6+eXSrEbRzXVw==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.1.0", + "@eslint/eslintrc": "^1.2.0", "@humanwhocodes/config-array": "^0.9.2", "ajv": "^6.10.0", "chalk": "^4.0.0", @@ -2165,9 +2173,9 @@ } }, "typescript": { - "version": "4.5.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.5.5.tgz", - "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", + "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", "dev": true }, "unique-string": { diff --git a/package.json b/package.json index bdd34db..1c86eae 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-basex", "displayName": "BaseX tools", "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code", - "version": "0.0.28", + "version": "0.0.47", "preview": true, "publisher": "quodatum", "author": "Andy Bunce (https://github.com/Quodatum)", @@ -76,19 +76,19 @@ "title": "BaseX Tools Configuration", "type": "object", "properties": { - "basexTools.enableXmlTreeView": { + "basexTools.xmlTree.enableTreeView": { "type": "boolean", "default": true, "description": "Enables the XML Document view in the explorer for XML documents.", "scope": "window" }, - "basexTools.enableXmlTreeViewMetadata": { + "basexTools.xmlTree.enableViewMetadata": { "type": "boolean", "default": true, "description": "Enables attribute and child element counts in the XML Document view.", "scope": "window" }, - "basexTools.enableXmlTreeViewCursorSync": { + "basexTools.xmlTree.enableViewCursorSync": { "type": "boolean", "default": false, "description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.", @@ -100,13 +100,13 @@ "description": "Enforces a space before the forward slash at the end of a self-closing XML tag.", "scope": "resource" }, - "basexTools.ignoreDefaultNamespace": { + "basexTools.xpath.ignoreDefaultNamespace": { "type": "boolean", "default": true, "description": "Ignore default xmlns attributes when evaluating XPath.", "scope": "window" }, - "basexTools.persistXPathQuery": { + "basexTools.xpath.persistXPathQuery": { "type": "boolean", "default": true, "description": "Remember the last XPath query used.", @@ -275,17 +275,17 @@ "@types/node": "^14.18.12", "@types/vscode": "^1.63.0", "@types/xmldom": "^0.1.31", - "@typescript-eslint/eslint-plugin": "^5.12.0", - "@typescript-eslint/parser": "^5.12.0", - "@vscode/test-electron": "^2.1.2", - "esbuild": "^0.14.23", - "eslint": "^8.9.0", + "@typescript-eslint/eslint-plugin": "^5.13.0", + "@typescript-eslint/parser": "^5.13.0", + "@vscode/test-electron": "^2.1.3", + "esbuild": "^0.14.25", + "eslint": "^8.10.0", "glob": "^7.2.0", "mocha": "^9.2.1", - "typescript": "^4.5.4" + "typescript": "^4.6.2" }, "dependencies": { - "@quodatum/xqlint": "^0.0.8", + "@quodatum/xqlint": "^0.0.11", "@xmldom/xmldom": "^0.8.1", "xpath": "0.0.32" } diff --git a/src/common/configuration.ts b/src/common/configuration.ts index c8f141e..4e4346e 100644 --- a/src/common/configuration.ts +++ b/src/common/configuration.ts @@ -4,23 +4,23 @@ const ExtensionTopLevelSection = "basexTools"; export class Configuration { static get enableXmlTreeView(): boolean { - return this._getForWindow("enableXmlTreeView"); + return this._getForWindow("xmlTree.enableTreeView"); } static get enableXmlTreeViewMetadata(): boolean { - return this._getForWindow("enableXmlTreeViewMetadata"); + return this._getForWindow("xmlTree.enableViewMetadata"); } - static get enableXmlTreeViewCursorSync(): boolean { - return this._getForWindow("enableXmlTreeViewCursorSync"); + static get enableViewCursorSync(): boolean { + return this._getForWindow("xmlTree.enableViewCursorSync"); } static get ignoreDefaultNamespace(): boolean { - return this._getForWindow("ignoreDefaultNamespace"); + return this._getForWindow("xpath.ignoreDefaultNamespace"); } static get persistXPathQuery(): boolean { - return this._getForWindow("persistXPathQuery"); + return this._getForWindow("xpath.persistXPathQuery"); } static get xmlFormatterImplementation(): string { diff --git a/src/common/logger.ts b/src/common/logger.ts index 1938181..b391174 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -1,9 +1,9 @@ // debug messages import { OutputChannel, window } from "vscode"; // eslint-disable-next-line @typescript-eslint/no-var-requires -const XQLint = require("@quodatum/xqlint").XQLint; +const ver = require("@quodatum/xqlint").version; -const _channel:OutputChannel = window.createOutputChannel("BaseX log"); +const _channel:OutputChannel = window.createOutputChannel("BaseX"); function logdate(){ return (new Date()).toISOString().slice(0, 19).replace(/-/g, "/").replace("T", " "); } @@ -19,5 +19,5 @@ export class channel { _channel.show } } -channel.log("started, XQLint version: "+XQLint.version); +channel.log("started, XQLint version: "+ver); _channel.show \ No newline at end of file diff --git a/src/completion/xquery-completion-item-provider.ts b/src/completion/xquery-completion-item-provider.ts index 93ad127..73c61b3 100644 --- a/src/completion/xquery-completion-item-provider.ts +++ b/src/completion/xquery-completion-item-provider.ts @@ -24,7 +24,9 @@ export class XQueryCompletionItemProvider implements CompletionItemProvider { case "function": completionItem.kind = CompletionItemKind.Function; + // eslint-disable-next-line no-case-declarations const funcStart = (xqLintCompletionItem.value.indexOf(":") + 1); + // eslint-disable-next-line no-case-declarations const funcEnd = xqLintCompletionItem.value.indexOf("("); completionItem.insertText = xqLintCompletionItem.value.substring(funcStart, funcEnd); diff --git a/src/constants.ts b/src/constants.ts index 9f08f7a..c9478f1 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-namespace */ export namespace commands { export const evaluateXPath = "basexTools.evaluateXPath"; export const executeXQuery = "basexTools.executeXQuery"; diff --git a/src/extension.ts b/src/extension.ts index 50c0cf0..5485279 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,6 @@ import { - commands, languages, window, workspace, ExtensionContext, Memento, - TextEditor, TextEditorSelectionChangeEvent, TextEditorSelectionChangeKind, DiagnosticCollection, TextDocument, TextEdit,Range + commands, languages, window, ExtensionContext, + TextEditor, TextEditorSelectionChangeEvent, TextEditorSelectionChangeKind, DiagnosticCollection } from "vscode"; import { channel } from "./common/logger"; @@ -14,7 +14,8 @@ import { evaluateXPath, getCurrentXPath } from "./xpath/commands"; import { executeXQuery } from "./xquery-execution/commands"; import * as constants from "./constants"; -import { XQueryFormatter } from "./formatting/XQueryFormatter"; +import { XQueryFormatter } from "./formatting/xquery-formatting-provider"; +import { Symbols } from './symbols/symbols'; let diagnosticCollectionXQuery: DiagnosticCollection; @@ -32,30 +33,26 @@ export function activate(context: ExtensionContext) { /* Formatting Features */ const xmlFormattingEditProvider = new XmlFormattingEditProvider(XmlFormatterFactory.getXmlFormatter()); - + const xqueryFormattingEditProvider = new XQueryFormatter(); context.subscriptions.push( commands.registerTextEditorCommand(constants.commands.formatAsXml, formatAsXml), commands.registerTextEditorCommand(constants.commands.xmlToText, xmlToText), commands.registerTextEditorCommand(constants.commands.textToXml, textToXml), commands.registerTextEditorCommand(constants.commands.minifyXml, minifyXml), + languages.registerDocumentFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider), - languages.registerDocumentRangeFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider) + languages.registerDocumentRangeFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider), + + languages.registerDocumentFormattingEditProvider(xqueryDocSelector, xqueryFormattingEditProvider), + languages.registerDocumentRangeFormattingEditProvider(xqueryDocSelector, xqueryFormattingEditProvider) ); - // 👍 XQuery formatter implemented using API - languages.registerDocumentFormattingEditProvider(constants.languageIds.xquery, { - async provideDocumentFormattingEdits(document: TextDocument): Promise { - - try { - const text = XQueryFormatter.format(document.getText()) - const entireDocRange = document.validateRange(new Range(0, 0, document.lineCount, 0)); - return [TextEdit.replace(entireDocRange, text)]; - } catch (e) { - window.showInformationMessage('Format failed -syntax error') - } - } - }); - + + + // symbols + const symbols = new Symbols(); + context.subscriptions.push(languages.registerDocumentSymbolProvider(constants.languageIds.xquery, symbols)); + /* Linting Features */ diagnosticCollectionXQuery = languages.createDiagnosticCollection(constants.diagnosticCollections.xquery); context.subscriptions.push( @@ -97,7 +94,7 @@ export function activate(context: ExtensionContext) { export function deactivate() { // do nothing -}; +} function _handleContextChange(editor: TextEditor): void { const supportedSchemes = [constants.uriSchemes.file, constants.uriSchemes.untitled]; diff --git a/src/formatting/XQueryFormatter.ts b/src/formatting/XQueryFormatter.ts deleted file mode 100644 index 82e2e76..0000000 --- a/src/formatting/XQueryFormatter.ts +++ /dev/null @@ -1,18 +0,0 @@ -// format xquery -import { channel } from "../common/logger"; -import { XQLint, CodeFormatter } from "@quodatum/xqlint"; - - -export class XQueryFormatter { - static format(xquery: string): string { - channel.log("XQueryFormatter"); - const linter = new (XQLint as any)(xquery, { "styleCheck": false }); - channel.appendLine("got linter: " + linter.hasSyntaxError()); - //if(linter.hasSyntaxError()+linter.hasSyntaxError()) throw new Error("XQuery syntax error") - const ast = linter.getAST() - const formatter = new (CodeFormatter as any)(ast); - const formatted = formatter.format().trim(); - channel.log("XQueryFormatter done"); - return formatted; - } -} diff --git a/src/formatting/index.ts b/src/formatting/index.ts index d5956c4..02d5f91 100644 --- a/src/formatting/index.ts +++ b/src/formatting/index.ts @@ -1,3 +1,4 @@ export * from "./xml-formatter"; export * from "./xml-formatting-edit-provider"; export * from "./xml-formatting-options"; +export * from "./xquery-formatting-provider"; diff --git a/src/formatting/xml-formatter.ts b/src/formatting/xml-formatter.ts index 8a61c2f..baa8955 100644 --- a/src/formatting/xml-formatter.ts +++ b/src/formatting/xml-formatter.ts @@ -1,6 +1,6 @@ -import { window, workspace } from "vscode"; -import { Configuration, ExtensionState } from "../common"; + +import { Configuration } from "../common"; import * as constants from "../constants"; import { ClassicXmlFormatter } from "./formatters/classic-xml-formatter"; import { V2XmlFormatter } from "./formatters/v2-xml-formatter"; diff --git a/src/formatting/xquery-formatting-provider.ts b/src/formatting/xquery-formatting-provider.ts new file mode 100644 index 0000000..cd1d4f7 --- /dev/null +++ b/src/formatting/xquery-formatting-provider.ts @@ -0,0 +1,33 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +// format xquery +import { XQLint, CodeFormatter } from "@quodatum/xqlint"; +import { CancellationToken, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, + FormattingOptions, ProviderResult,Range, + TextDocument, TextEdit} from "vscode"; + +import { channel } from "../common/logger"; + +function format(xquery: string,document: TextDocument): string { + channel.log("XQueryFormatter" + document.uri); + const linter = new (XQLint as any)(xquery, { "styleCheck": false }); + channel.appendLine(" linter hasSyntaxError: " + linter.hasSyntaxError()); + //if(linter.hasSyntaxError()+linter.hasSyntaxError()) throw new Error("XQuery syntax error") + const ast = linter.getAST() + const formatter = new (CodeFormatter as any)(ast); + const formatted = formatter.format().trim(); + channel.log("XQueryFormatter done"); + return formatted; +} +export class XQueryFormatter implements DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider{ + provideDocumentFormattingEdits(document: TextDocument, options: FormattingOptions, token: CancellationToken): ProviderResult { + const lastLine = document.lineAt(document.lineCount - 1); + const documentRange = new Range(document.positionAt(0), lastLine.range.end); + return this.provideDocumentRangeFormattingEdits(document, documentRange, options, token); + } + + provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, _options: FormattingOptions, _token: CancellationToken): ProviderResult { + const selected = document.getText(range); + const result = format(selected); + return [TextEdit.replace(range, result)]; + } +} diff --git a/src/symbols/symbols.ts b/src/symbols/symbols.ts new file mode 100644 index 0000000..4dd8c2d --- /dev/null +++ b/src/symbols/symbols.ts @@ -0,0 +1,45 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ +import { XQLint } from '@quodatum/xqlint'; +import * as vscode from 'vscode'; +import { channel } from "../common/logger"; +// +// This class handles Symbols +// +function makeSymbol (name :string,desc :string,icon :vscode.SymbolKind,pos :any) { + const spos = new vscode.Position(pos.sl, pos.sc); + const epos = new vscode.Position(pos.el, pos.ec); + const fullrange=new vscode.Range(spos,epos); + const selrange=new vscode.Range(spos,spos); + return new vscode.DocumentSymbol(name,"var", vscode.SymbolKind.Variable, fullrange, selrange); +} + +export class Symbols implements vscode.DocumentSymbolProvider { + + provideDocumentSymbols = async ( + document: vscode.TextDocument, + token: vscode.CancellationToken + ): Promise => { + channel.log("Symbols: " + document.uri); + const symbols: vscode.DocumentSymbol[] = []; + const text = document.getText(); + const linter = new (XQLint as any)(text, { "styleCheck": false }); + const xqdoc= linter.getXQDoc(); + channel.log(xqdoc.variables); + // type: type, + // pos: pos, + // qname: qname, + // annotations: {} + xqdoc.variables.forEach(v => { + const name = v.name; + const info =makeSymbol(name,"var", vscode.SymbolKind.Variable,v.pos) + symbols.push(info); + }); + xqdoc.functions.forEach(v => { + const name = v.name; + const info =makeSymbol(name,"Fu", vscode.SymbolKind.Function,v.pos) + symbols.push(info); + }); + channel.log("Symbols done" + document.uri); + return symbols; + }; +} -- 2.45.3 From cfc8ba3817f8cb4285f51541684d0f4da0449f52 Mon Sep 17 00:00:00 2001 From: Andy Bunce Date: Mon, 7 Mar 2022 16:37:26 +0000 Subject: [PATCH 2/3] [fix] #6 #3 --- package.json | 217 ++++++++++++++------------- src/CHANGELOG.md | 5 + src/formatting/commands/index.ts | 2 +- src/formatting/commands/textToXml.ts | 33 ---- src/formatting/commands/xmlToText.ts | 35 ++++- src/symbols/symbols.ts | 30 ++-- 6 files changed, 164 insertions(+), 158 deletions(-) create mode 100644 src/CHANGELOG.md delete mode 100644 src/formatting/commands/textToXml.ts diff --git a/package.json b/package.json index 1c86eae..2bf2125 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-basex", "displayName": "BaseX tools", "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code", - "version": "0.0.47", + "version": "0.0.48", "preview": true, "publisher": "quodatum", "author": "Andy Bunce (https://github.com/Quodatum)", @@ -72,107 +72,122 @@ "title": "BaseX Tools: Minify XML" } ], - "configuration": { - "title": "BaseX Tools Configuration", - "type": "object", - "properties": { - "basexTools.xmlTree.enableTreeView": { - "type": "boolean", - "default": true, - "description": "Enables the XML Document view in the explorer for XML documents.", - "scope": "window" - }, - "basexTools.xmlTree.enableViewMetadata": { - "type": "boolean", - "default": true, - "description": "Enables attribute and child element counts in the XML Document view.", - "scope": "window" - }, - "basexTools.xmlTree.enableViewCursorSync": { - "type": "boolean", - "default": false, - "description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.", - "scope": "window" - }, - "basexTools.enforcePrettySelfClosingTagOnFormat": { - "type": "boolean", - "default": false, - "description": "Enforces a space before the forward slash at the end of a self-closing XML tag.", - "scope": "resource" - }, - "basexTools.xpath.ignoreDefaultNamespace": { - "type": "boolean", - "default": true, - "description": "Ignore default xmlns attributes when evaluating XPath.", - "scope": "window" - }, - "basexTools.xpath.persistXPathQuery": { - "type": "boolean", - "default": true, - "description": "Remember the last XPath query used.", - "scope": "window" - }, - "basexTools.removeCommentsOnMinify": { - "type": "boolean", - "default": false, - "description": "Remove XML comments during minification.", - "scope": "resource" - }, - "basexTools.splitAttributesOnFormat": { - "type": "boolean", - "default": false, - "description": "Put each attribute on a new line when formatting XML. Overrides `basexTools.splitXmlnsOnFormat` if set to `true`.", - "scope": "resource" - }, - "basexTools.splitXmlnsOnFormat": { - "type": "boolean", - "default": true, - "description": "Put each xmlns attribute on a new line when formatting XML.", - "scope": "resource" - }, - "basexTools.xmlFormatterImplementation": { - "type": "string", - "enum": [ - "classic", - "v2" - ], - "default": "v2", - "description": "Supported XML Formatters: classic", - "scope": "window" - }, - "basexTools.xqueryExecutionArguments": { - "type": "array", - "default": [ - "-xquery", - "$(script)", - "-in", - "$(input)", - "-out", - "$(input).output.xml" - ], - "description": "Arguments to be passed to the XQuery execution engine.", - "scope": "window" - }, - "basexTools.xqueryExecutionEngine": { - "type": "string", - "default": "", - "description": "The full path to the executable to run when executing XQuery scripts.", - "scope": "window" - }, - "basexTools.xqueryExecutionInputLimit": { - "type": "integer", - "default": 100, - "description": "The maximum number of input files to enumerate when executing XQuery scripts.", - "scope": "window" - }, - "basexTools.xqueryExecutionInputSearchPattern": { - "type": "string", - "default": "**/*.xml", - "description": "The pattern used to search for input XML files when executing XQuery scripts.", - "scope": "window" + "configuration": [ + { + "id": "xmltree", + "title": "XML tree view ", + "properties": { + "basexTools.xmlTree.enableTreeView": { + "type": "boolean", + "default": true, + "description": "Enables the XML Document view in the explorer for XML documents.", + "scope": "window" + }, + "basexTools.xmlTree.enableViewMetadata": { + "type": "boolean", + "default": true, + "description": "Enables attribute and child element counts in the XML Document view.", + "scope": "window" + }, + "basexTools.xmlTree.enableViewCursorSync": { + "type": "boolean", + "default": false, + "description": "Enables auto-reveal of elements in the XML Document view when a start tag is clicked in the editor.", + "scope": "window" + } + } + }, + { + "id": "xpath", + "title": "XPath ", + "properties":{ + "basexTools.xpath.ignoreDefaultNamespace": { + "type": "boolean", + "default": true, + "description": "Ignore default xmlns attributes when evaluating XPath.", + "scope": "window" + }, + "basexTools.xpath.persistXPathQuery": { + "type": "boolean", + "default": true, + "description": "Remember the last XPath query used.", + "scope": "window" + } + } + }, + { + "title": "BaseX Tools ", + "type": "object", + "properties": { + "basexTools.enforcePrettySelfClosingTagOnFormat": { + "type": "boolean", + "default": false, + "description": "Enforces a space before the forward slash at the end of a self-closing XML tag.", + "scope": "resource" + }, + + "basexTools.removeCommentsOnMinify": { + "type": "boolean", + "default": false, + "description": "Remove XML comments during minification.", + "scope": "resource" + }, + "basexTools.splitAttributesOnFormat": { + "type": "boolean", + "default": false, + "description": "Put each attribute on a new line when formatting XML. Overrides `basexTools.splitXmlnsOnFormat` if set to `true`.", + "scope": "resource" + }, + "basexTools.splitXmlnsOnFormat": { + "type": "boolean", + "default": true, + "description": "Put each xmlns attribute on a new line when formatting XML.", + "scope": "resource" + }, + "basexTools.xmlFormatterImplementation": { + "type": "string", + "enum": [ + "classic", + "v2" + ], + "default": "v2", + "description": "Supported XML Formatters: classic", + "scope": "window" + }, + "basexTools.xqueryExecutionArguments": { + "type": "array", + "default": [ + "-xquery", + "$(script)", + "-in", + "$(input)", + "-out", + "$(input).output.xml" + ], + "description": "Arguments to be passed to the XQuery execution engine.", + "scope": "window" + }, + "basexTools.xqueryExecutionEngine": { + "type": "string", + "default": "", + "description": "The full path to the executable to run when executing XQuery scripts.", + "scope": "window" + }, + "basexTools.xqueryExecutionInputLimit": { + "type": "integer", + "default": 100, + "description": "The maximum number of input files to enumerate when executing XQuery scripts.", + "scope": "window" + }, + "basexTools.xqueryExecutionInputSearchPattern": { + "type": "string", + "default": "**/*.xml", + "description": "The pattern used to search for input XML files when executing XQuery scripts.", + "scope": "window" + } } } - }, + ], "grammars": [ { "language": "xquery", @@ -289,4 +304,4 @@ "@xmldom/xmldom": "^0.8.1", "xpath": "0.0.32" } -} +} \ No newline at end of file diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md new file mode 100644 index 0000000..fd3310f --- /dev/null +++ b/src/CHANGELOG.md @@ -0,0 +1,5 @@ +# 0.0.48 +* Fix xmlToText #6 +* FIX outline all vars + +# 0.0.47 diff --git a/src/formatting/commands/index.ts b/src/formatting/commands/index.ts index 3dc6ea2..fe7023a 100644 --- a/src/formatting/commands/index.ts +++ b/src/formatting/commands/index.ts @@ -1,4 +1,4 @@ export * from "./formatAsXml"; export * from "./minifyXml"; export * from "./xmlToText"; -export * from "./textToXml"; + diff --git a/src/formatting/commands/textToXml.ts b/src/formatting/commands/textToXml.ts deleted file mode 100644 index cf6c4ef..0000000 --- a/src/formatting/commands/textToXml.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { workspace } from "vscode"; -import { ProviderResult, Range, TextEdit, TextEditor, Selection } from "vscode"; - -import { NativeCommands } from "../../common"; -import * as constants from "../../constants"; - -import { XmlFormatterFactory } from "../xml-formatter"; -import { XmlFormattingEditProvider } from "../xml-formatting-edit-provider"; -import { XmlFormattingOptionsFactory } from "../xml-formatting-options"; - -export function textToXml(textEditor: TextEditor): void { - textEditor.edit(textEdit => { - const selections = textEditor.selections; - selections.forEach(selection => { - if (selection.isEmpty) { - selection = new Selection( - textEditor.document.positionAt(0), - textEditor.document.positionAt(textEditor.document.getText().length) - ); - } - const txt = textEditor.document.getText(new Range(selection.start, selection.end)); - const transformed = txt - .replace(/</g, "<") - .replace(/>/g, ">") - .replace(/&/g, "&") - // tslint:disable-next-line - .replace(/"/g, '"') - .replace(/'/g, "'"); - - textEdit.replace(selection, transformed); - }); - }); -} diff --git a/src/formatting/commands/xmlToText.ts b/src/formatting/commands/xmlToText.ts index 5dea03f..2551c7c 100644 --- a/src/formatting/commands/xmlToText.ts +++ b/src/formatting/commands/xmlToText.ts @@ -1,12 +1,7 @@ -import { workspace } from "vscode"; -import { ProviderResult, Range, TextEdit, TextEditor, Selection } from "vscode"; -import { NativeCommands } from "../../common"; -import * as constants from "../../constants"; +import { Range, TextEditor, Selection } from "vscode"; + -import { XmlFormatterFactory } from "../xml-formatter"; -import { XmlFormattingEditProvider } from "../xml-formatting-edit-provider"; -import { XmlFormattingOptionsFactory } from "../xml-formatting-options"; export function xmlToText(textEditor: TextEditor): void { textEditor.edit(textEdit => { @@ -20,9 +15,9 @@ export function xmlToText(textEditor: TextEditor): void { } const txt = textEditor.document.getText(new Range(selection.start, selection.end)); const transformed = txt + .replace(/&/g, "&") .replace(//g, ">") - .replace(/&/g, "&") .replace(/"/g, """) .replace(/'/g, "'"); @@ -30,3 +25,27 @@ export function xmlToText(textEditor: TextEditor): void { }); }); } +export function textToXml(textEditor: TextEditor): void { + textEditor.edit(textEdit => { + const selections = textEditor.selections; + selections.forEach(selection => { + if (selection.isEmpty) { + selection = new Selection( + textEditor.document.positionAt(0), + textEditor.document.positionAt(textEditor.document.getText().length) + ); + } + const txt = textEditor.document.getText(new Range(selection.start, selection.end)); + const transformed = txt + .replace(/</g, "<") + .replace(/>/g, ">") + .replace(/&/g, "&") + // tslint:disable-next-line + .replace(/"/g, '"') + .replace(/'/g, "'"); + + textEdit.replace(selection, transformed); + }); + }); +} + diff --git a/src/symbols/symbols.ts b/src/symbols/symbols.ts index 4dd8c2d..9dd1d32 100644 --- a/src/symbols/symbols.ts +++ b/src/symbols/symbols.ts @@ -5,12 +5,12 @@ import { channel } from "../common/logger"; // // This class handles Symbols // -function makeSymbol (name :string,desc :string,icon :vscode.SymbolKind,pos :any) { +function makeSymbol(name: string, description: string, icon: vscode.SymbolKind, pos: any) { const spos = new vscode.Position(pos.sl, pos.sc); const epos = new vscode.Position(pos.el, pos.ec); - const fullrange=new vscode.Range(spos,epos); - const selrange=new vscode.Range(spos,spos); - return new vscode.DocumentSymbol(name,"var", vscode.SymbolKind.Variable, fullrange, selrange); + const fullrange = new vscode.Range(spos, epos); + const selrange = new vscode.Range(spos, spos); + return new vscode.DocumentSymbol(name, description, icon, fullrange, selrange); } export class Symbols implements vscode.DocumentSymbolProvider { @@ -23,23 +23,23 @@ export class Symbols implements vscode.DocumentSymbolProvider { const symbols: vscode.DocumentSymbol[] = []; const text = document.getText(); const linter = new (XQLint as any)(text, { "styleCheck": false }); - const xqdoc= linter.getXQDoc(); - channel.log(xqdoc.variables); + const xqdoc = linter.getXQDoc(); + channel.log("got xqdoc"); // type: type, // pos: pos, // qname: qname, // annotations: {} - xqdoc.variables.forEach(v => { - const name = v.name; - const info =makeSymbol(name,"var", vscode.SymbolKind.Variable,v.pos) - symbols.push(info); + xqdoc.variables.forEach(v => { + const name = v.name; + const info = makeSymbol(name, "var", vscode.SymbolKind.Variable, v.pos) + symbols.push(info); }); - xqdoc.functions.forEach(v => { - const name = v.name; - const info =makeSymbol(name,"Fu", vscode.SymbolKind.Function,v.pos) - symbols.push(info); + xqdoc.functions.forEach(v => { + const name = v.name; + const info = makeSymbol(name, "Fu", vscode.SymbolKind.Function, v.pos) + symbols.push(info); }); - channel.log("Symbols done" + document.uri); + channel.log("Symbols done " + document.uri); return symbols; }; } -- 2.45.3 From 47baf6f2b90ca95951bbe8e0cad854b608d91d36 Mon Sep 17 00:00:00 2001 From: Andy Bunce Date: Tue, 7 Jun 2022 16:29:12 +0100 Subject: [PATCH 3/3] [mod] release 0.5.2 --- package.json | 95 +++++++++------ resources/basex.png | Bin 3049 -> 2861 bytes snippets.jsonc | 120 +++++++++++++++++++ src/common/configuration.ts | 10 +- src/common/logger.ts | 1 + src/constants.ts | 1 + src/extension.ts | 5 +- src/formatting/commands/index.ts | 1 + src/formatting/xquery-formatting-provider.ts | 2 +- src/linting/getAST.ts | 23 ++++ src/linting/index.ts | 1 + src/symbols/symbols.ts | 48 +++++--- src/xquery-execution/child-process.ts | 2 +- 13 files changed, 243 insertions(+), 66 deletions(-) create mode 100644 snippets.jsonc create mode 100644 src/linting/getAST.ts diff --git a/package.json b/package.json index 2bf2125..a446ad6 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-basex", "displayName": "BaseX tools", "description": "BaseX tools: XQuery, XML, XPath Tools for Visual Studio Code", - "version": "0.0.48", + "version": "0.0.52", "preview": true, "publisher": "quodatum", "author": "Andy Bunce (https://github.com/Quodatum)", @@ -12,13 +12,13 @@ "theme": "light" }, "icon": "resources/basex.png", - "homepage": "https://github.com/Quodatum/vscode-xml", + "homepage": "https://github.com/Quodatum/vscode-basex", "repository": { "type": "git", - "url": "git+https://github.com/Quodatum/vscode-xml.git" + "url": "git+https://github.com/Quodatum/vscode-basex.git" }, "bugs": { - "url": "https://github.com/Quodatum/vscode-xml/issues" + "url": "https://github.com/Quodatum/vscode-basex/issues" }, "engines": { "vscode": "^1.63.0" @@ -27,6 +27,7 @@ "Formatters", "Programming Languages", "Linters", + "Snippets", "Other" ], "activationEvents": [ @@ -70,16 +71,21 @@ { "command": "basexTools.minifyXml", "title": "BaseX Tools: Minify XML" + }, + { + "command": "basexTools.getAST", + "title": "BaseX Tools: AST" } ], "configuration": [ { "id": "xmltree", "title": "XML tree view ", + "properties": { "basexTools.xmlTree.enableTreeView": { "type": "boolean", - "default": true, + "default": false, "description": "Enables the XML Document view in the explorer for XML documents.", "scope": "window" }, @@ -114,8 +120,44 @@ "scope": "window" } } - }, - { + },{ + "id": "xquery", + "title": "XQuery ", + "properties":{ + "basexTools.xquery.executionArguments": { + "type": "array", + "default": [ + "-xquery", + "$(script)", + "-in", + "$(input)", + "-out", + "$(input).output.xml" + ], + "description": "Arguments to be passed to the XQuery execution engine.", + "scope": "window" + }, + "basexTools.xquery.executionEngine": { + "type": "string", + "default": "", + "description": "The full path to the executable to run when executing XQuery scripts.", + "scope": "window" + }, + "basexTools.xquery.executionInputLimit": { + "type": "integer", + "default": 100, + "description": "The maximum number of input files to enumerate when executing XQuery scripts.", + "scope": "window" + }, + "basexTools.xquery.executionInputSearchPattern": { + "type": "string", + "default": "**/*.xml", + "description": "The pattern used to search for input XML files when executing XQuery scripts.", + "scope": "window" + } + } + + },{ "title": "BaseX Tools ", "type": "object", "properties": { @@ -153,39 +195,8 @@ "default": "v2", "description": "Supported XML Formatters: classic", "scope": "window" - }, - "basexTools.xqueryExecutionArguments": { - "type": "array", - "default": [ - "-xquery", - "$(script)", - "-in", - "$(input)", - "-out", - "$(input).output.xml" - ], - "description": "Arguments to be passed to the XQuery execution engine.", - "scope": "window" - }, - "basexTools.xqueryExecutionEngine": { - "type": "string", - "default": "", - "description": "The full path to the executable to run when executing XQuery scripts.", - "scope": "window" - }, - "basexTools.xqueryExecutionInputLimit": { - "type": "integer", - "default": 100, - "description": "The maximum number of input files to enumerate when executing XQuery scripts.", - "scope": "window" - }, - "basexTools.xqueryExecutionInputSearchPattern": { - "type": "string", - "default": "**/*.xml", - "description": "The pattern used to search for input XML files when executing XQuery scripts.", - "scope": "window" } - } + } } ], "grammars": [ @@ -195,6 +206,12 @@ "scopeName": "source.xquery" } ], + "snippets": [ + { + "language": "xquery", + "path": "./snippets.jsonc" + } + ], "keybindings": [ { "key": "ctrl+shift+alt+x", diff --git a/resources/basex.png b/resources/basex.png index d737358698c2d40fe477e768ffac3221ea8ea4a0..675f41667c2422d8e32fa61c288965e71b69ee8b 100644 GIT binary patch delta 2838 zcmV+x3+eRf7p)eM83+Ra006Zq04R|mAAbUlP)t-s|NsBJyu5pPd6AEg^z`(yv9aCU z+`PNHPfSd3ZEgPk{+pVbT31)-=jVEOc+=9-WMN@YO-;wg$I{W!r>3T{u&{A%Zu9f= zhlPcZj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AWnYRGlR9H;v)vwfHr1cf6jtQvUWEXkAGO=WRJ)rJLc|ra1|))Hr~Fosc4WgAIvpUrqKbqQ z$(@(Dh57kH)_;Kf@LXXC55N#t*iHaRvf_6!TcjqA8_RcU2;p3+heFnXd?|z~_N>vb zBpluUap{s8Z{(es8DnQBG1L?&LLWY;?r1MhMVv%OE-->A)S2e@AWML9wAspC@o{H< z1Sue|9z0mMx;9t<_J`Dou3${_kHq7m2dzy^n7B-giOa;8 zxJ-J>@~$NVRB!=m9w_4eHan|{lVXZ0oStFGBBg(rI2vARD0SiRMNAza4quZW z2pNe4zCco@2O6PauGpql!~v<5M+LE=5uBxyAr!LIqZJxE+tix4F;X!mE(_b+{|84# VPyfDETkZe=002ovPDHLkV1gVowxs|7 diff --git a/snippets.jsonc b/snippets.jsonc new file mode 100644 index 0000000..2149379 --- /dev/null +++ b/snippets.jsonc @@ -0,0 +1,120 @@ +{ + + "for": { + "prefix": "for", + "body": "for $${1:item} in ${2:expr}" + }, + "return": { + "prefix": "ret", + "body": "return ${1:expr}" + }, + "import": { + "prefix": "import", + "body": "import module namespace ${1:ns} = '${2:http://www.example.com/}';", + "description": "Import module" + }, + "module": { + "prefix": "module", + "body": "module namespace ${1:ns} = '${2:http://www.example.com}';" + }, + "every": { + "prefix": "every", + "body": "every $${1:varname} in ${2:expr} satisfies ${3:expr}" + }, + "some": { + "prefix": "some", + "body": "some $${1:varname} in ${2:expr} satisfies ${3:expr}" + }, + "function": { + "prefix": "df", + "body": [ + "(:~ $${2:name} :)", + "declare function ${1:ns}:${2:name}(){", + "${3:expr}", + "};" + ], + "description": "declare a function" + }, + "declare variable": { + "prefix": "dv", + "body": [ + "(:~ $${1:varname} :)", + "declare variable $${1:varname} := ${2:expr};", + "" + ], + "description": "declare variable" + }, + "switch": { + "prefix": "sw", + "body": [ + "switch(${1:foo})", + "case ${2:foo} return ${3:true}", + "default return ${4:false}" + ], + "description": "switch statement" + }, + "typeswitch": { + "prefix": "type", + "body": [ + "typeswitch(${1:foo})", + "case ${2:foo} return ${3:true}", + "default return ${4:false}" + ], + "description": "typeswitch statement" + }, + "try": { + "prefix": "try", + "body": [ + "try { ${1:expr} } ", + "catch ${2:*} { ${3:expr} }" + ], + "description": "switch statement" + }, + "tumbling": { + "prefix": "tumbling", + "body": [ + "for tumbling window $${1:varname} in ${2:expr}", + "start at $${3:start} when ${4:expr}", + "end at $${5:end} when ${6:expr}", + "return ${7:expr}" + ], + "description": "tumbling window" + }, + "sliding": { + "prefix": "sliding", + "body": [ + "for sliding window $${1:varname} in ${2:expr}", + "start at $${3:start} when ${4:expr}", + "end at $${5:end} when ${6:expr}", + "return ${7:expr}" + ], + "description": "sliding window" + } +} +//snippet if +// if(${1:true}) then ${2:expr} else ${3:true} + +// default return ${4:false} + + +//snippet let +// let $${1:varname} := ${2:expr} +//snippet group +// group by $${1:varname} := ${2:expr} +//snippet order +// order by ${1:expr} ${2:descending} +//snippet stable +// stable order by ${1:expr} +//snippet count +// count $${1:varname} +//snippet ordered +// ordered { ${1:expr} } +//snippet unordered +// unordered { ${1:expr} } +//snippet treat +// treat as ${1:expr} +//snippet castable +// castable as ${1:atomicType} +//snippet cast +// cast as ${1:atomicType} + diff --git a/src/common/configuration.ts b/src/common/configuration.ts index 4e4346e..fbca6b2 100644 --- a/src/common/configuration.ts +++ b/src/common/configuration.ts @@ -11,7 +11,7 @@ export class Configuration { return this._getForWindow("xmlTree.enableViewMetadata"); } - static get enableViewCursorSync(): boolean { + static get enableXmlTreeViewCursorSync(): boolean { return this._getForWindow("xmlTree.enableViewCursorSync"); } @@ -28,19 +28,19 @@ export class Configuration { } static get xqueryExecutionArguments(): string[] { - return this._getForWindow("xqueryExecutionArguments"); + return this._getForWindow("xquery.executionArguments"); } static get xqueryExecutionEngine(): string { - return this._getForWindow("xqueryExecutionEngine"); + return this._getForWindow("xquery.executionEngine"); } static get xqueryExecutionInputLimit(): number { - return this._getForWindow("xqueryExecutionInputLimit"); + return this._getForWindow("xquery.executionInputLimit"); } static get xqueryExecutionInputSearchPattern(): string { - return this._getForWindow("xqueryExecutionInputSearchPattern"); + return this._getForWindow("xquery.executionInputSearchPattern"); } static enforcePrettySelfClosingTagOnFormat(resource: Uri): boolean { diff --git a/src/common/logger.ts b/src/common/logger.ts index b391174..6ca1994 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -4,6 +4,7 @@ import { OutputChannel, window } from "vscode"; const ver = require("@quodatum/xqlint").version; const _channel:OutputChannel = window.createOutputChannel("BaseX"); + function logdate(){ return (new Date()).toISOString().slice(0, 19).replace(/-/g, "/").replace("T", " "); } diff --git a/src/constants.ts b/src/constants.ts index c9478f1..641878c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -7,6 +7,7 @@ export namespace commands { export const textToXml = "basexTools.textToXml"; export const getCurrentXPath = "basexTools.getCurrentXPath"; export const minifyXml = "basexTools.minifyXml"; + export const getAST = "basexTools.getAST"; } export namespace contextKeys { diff --git a/src/extension.ts b/src/extension.ts index 5485279..6efe5f9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -7,8 +7,8 @@ import { channel } from "./common/logger"; import { createDocumentSelector, ExtensionState, Configuration } from "./common"; import { XQueryCompletionItemProvider } from "./completion"; import { XmlFormatterFactory, XmlFormattingEditProvider } from "./formatting"; -import { formatAsXml, minifyXml, xmlToText, textToXml } from "./formatting/commands"; -import { XQueryLinter } from "./linting"; +import { formatAsXml, minifyXml, xmlToText, textToXml } from "./formatting/commands"; +import { XQueryLinter,getAst } from "./linting"; import { XmlTreeDataProvider } from "./tree-view"; import { evaluateXPath, getCurrentXPath } from "./xpath/commands"; import { executeXQuery } from "./xquery-execution/commands"; @@ -39,6 +39,7 @@ export function activate(context: ExtensionContext) { commands.registerTextEditorCommand(constants.commands.xmlToText, xmlToText), commands.registerTextEditorCommand(constants.commands.textToXml, textToXml), commands.registerTextEditorCommand(constants.commands.minifyXml, minifyXml), + commands.registerTextEditorCommand(constants.commands.getAST, getAst), languages.registerDocumentFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider), languages.registerDocumentRangeFormattingEditProvider(xmlXsdDocSelector, xmlFormattingEditProvider), diff --git a/src/formatting/commands/index.ts b/src/formatting/commands/index.ts index fe7023a..8e7437c 100644 --- a/src/formatting/commands/index.ts +++ b/src/formatting/commands/index.ts @@ -2,3 +2,4 @@ export * from "./formatAsXml"; export * from "./minifyXml"; export * from "./xmlToText"; + diff --git a/src/formatting/xquery-formatting-provider.ts b/src/formatting/xquery-formatting-provider.ts index cd1d4f7..0da9ca1 100644 --- a/src/formatting/xquery-formatting-provider.ts +++ b/src/formatting/xquery-formatting-provider.ts @@ -27,7 +27,7 @@ export class XQueryFormatter implements DocumentFormattingEditProvider, Document provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, _options: FormattingOptions, _token: CancellationToken): ProviderResult { const selected = document.getText(range); - const result = format(selected); + const result = format(selected, document); return [TextEdit.replace(range, result)]; } } diff --git a/src/linting/getAST.ts b/src/linting/getAST.ts new file mode 100644 index 0000000..b792df9 --- /dev/null +++ b/src/linting/getAST.ts @@ -0,0 +1,23 @@ + +import { Range, TextEditor, Selection } from "vscode"; +import { channel } from "../common/logger"; +// eslint-disable-next-line @typescript-eslint/no-var-requires +const XQLint = require("@quodatum/xqlint").XQLint; + +export function getAst(textEditor: TextEditor): void { + textEditor.edit(textEdit => { + const selections = textEditor.selections; + selections.forEach(selection => { + if (selection.isEmpty) { + selection = new Selection( + textEditor.document.positionAt(0), + textEditor.document.positionAt(textEditor.document.getText().length) + ); + } + const text = textEditor.document.getText(new Range(selection.start, selection.end)); + const linter = new XQLint(text); + const ast=linter.getAST(); + channel.appendLine(ast); + }); + }); +} \ No newline at end of file diff --git a/src/linting/index.ts b/src/linting/index.ts index 4ab4df0..e7c5add 100644 --- a/src/linting/index.ts +++ b/src/linting/index.ts @@ -1 +1,2 @@ export * from "./xquery-linter"; +export * from "./getAST"; diff --git a/src/symbols/symbols.ts b/src/symbols/symbols.ts index 9dd1d32..62862c4 100644 --- a/src/symbols/symbols.ts +++ b/src/symbols/symbols.ts @@ -1,44 +1,56 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { XQLint } from '@quodatum/xqlint'; -import * as vscode from 'vscode'; +import {SymbolKind, DocumentSymbol, DocumentSymbolProvider, + Range, Position, TextDocument,CancellationToken} from 'vscode'; import { channel } from "../common/logger"; // // This class handles Symbols // -function makeSymbol(name: string, description: string, icon: vscode.SymbolKind, pos: any) { - const spos = new vscode.Position(pos.sl, pos.sc); - const epos = new vscode.Position(pos.el, pos.ec); - const fullrange = new vscode.Range(spos, epos); - const selrange = new vscode.Range(spos, spos); - return new vscode.DocumentSymbol(name, description, icon, fullrange, selrange); +function makeSymbol(name: string, description: string, icon: SymbolKind, pos: any) { + const spos = new Position(pos.sl, pos.sc); + const epos = new Position(pos.el, pos.ec); + const fullrange = new Range(spos, epos); + const selrange = new Range(spos, spos); + return new DocumentSymbol(name, description, icon, fullrange, selrange); } -export class Symbols implements vscode.DocumentSymbolProvider { - +export class Symbols implements DocumentSymbolProvider { provideDocumentSymbols = async ( - document: vscode.TextDocument, - token: vscode.CancellationToken - ): Promise => { + document: TextDocument, + token: CancellationToken + ): Promise => { + channel.log("Symbols: " + document.uri); - const symbols: vscode.DocumentSymbol[] = []; + const symbols: DocumentSymbol[] = []; const text = document.getText(); const linter = new (XQLint as any)(text, { "styleCheck": false }); + const xqdoc = linter.getXQDoc(); channel.log("got xqdoc"); + const prolog=new Range(0,0,0,0) + symbols.push(makeSymbol(xqdoc.moduleNamespace || "Main", xqdoc.description, SymbolKind.Module, prolog)) + + let vars=makeSymbol("Variables", "", SymbolKind.Variable, prolog) + vars.children=[] // type: type, // pos: pos, // qname: qname, // annotations: {} xqdoc.variables.forEach(v => { const name = v.name; - const info = makeSymbol(name, "var", vscode.SymbolKind.Variable, v.pos) - symbols.push(info); + const info = makeSymbol(name, "", SymbolKind.Variable, v.pos) + vars.children.push(info); }); + + const funs=makeSymbol("Variables", "", SymbolKind.Function, prolog) + funs.children=[] xqdoc.functions.forEach(v => { - const name = v.name; - const info = makeSymbol(name, "Fu", vscode.SymbolKind.Function, v.pos) - symbols.push(info); + const name = v.name +"#" + v.params.length; + const info = makeSymbol(name, "", SymbolKind.Function, v.pos) + funs.children.push(info); }); + symbols.push(vars) + symbols.push(funs) channel.log("Symbols done " + document.uri); return symbols; }; diff --git a/src/xquery-execution/child-process.ts b/src/xquery-execution/child-process.ts index 161f963..45db33d 100644 --- a/src/xquery-execution/child-process.ts +++ b/src/xquery-execution/child-process.ts @@ -1,4 +1,4 @@ -const child_process = require("child_process"); +import child_process = require("child_process"); export class ChildProcess { static async spawn(executable: string, args: string[]): Promise { -- 2.45.3