diff --git a/Jenkinsfile b/Jenkinsfile index 9076cb680c..43333675f3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -164,6 +164,7 @@ pipeline { container('node') { dir('clients/cobol-lsp-vscode-extension') { sh 'npm ci --ignore-scripts' + sh 'npm run postinstall' } } } diff --git a/clients/cobol-lsp-vscode-extension/package-lock.json b/clients/cobol-lsp-vscode-extension/package-lock.json index 53b1baf716..fcbfb61abc 100644 --- a/clients/cobol-lsp-vscode-extension/package-lock.json +++ b/clients/cobol-lsp-vscode-extension/package-lock.json @@ -1599,6 +1599,12 @@ "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.1.tgz", "integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==" }, + "@yarnpkg/lockfile": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz", + "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==", + "dev": true + }, "@zowe/cli": { "version": "6.33.3", "resolved": "https://registry.npmjs.org/@zowe/cli/-/cli-6.33.3.tgz", @@ -3139,6 +3145,15 @@ "locate-path": "^2.0.0" } }, + "find-yarn-workspace-root": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz", + "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==", + "dev": true, + "requires": { + "micromatch": "^4.0.2" + } + }, "flatted": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.2.tgz", @@ -3451,7 +3466,6 @@ "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", - "optional": true, "requires": { "safer-buffer": ">= 2.1.2 < 3.0.0" } @@ -3526,6 +3540,23 @@ "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" }, + "is-ci": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-2.0.0.tgz", + "integrity": "sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w==", + "dev": true, + "requires": { + "ci-info": "^2.0.0" + }, + "dependencies": { + "ci-info": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", + "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", + "dev": true + } + } + }, "is-core-module": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.0.tgz", @@ -3535,6 +3566,12 @@ "has": "^1.0.3" } }, + "is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", @@ -3579,6 +3616,15 @@ "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, + "is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "requires": { + "is-docker": "^2.0.0" + } + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -6378,6 +6424,15 @@ "prebuild-install": "^6.0.0" } }, + "klaw-sync": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz", + "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11" + } + }, "kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -6723,6 +6778,12 @@ "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, + "nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true + }, "node-abi": { "version": "2.30.1", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.30.1.tgz", @@ -6966,6 +7027,16 @@ "mimic-fn": "^2.1.0" } }, + "open": { + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", + "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", + "dev": true, + "requires": { + "is-docker": "^2.0.0", + "is-wsl": "^2.1.1" + } + }, "opener": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/opener/-/opener-1.5.2.tgz", @@ -7109,6 +7180,104 @@ "parse5": "^6.0.1" } }, + "patch-package": { + "version": "6.4.7", + "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-6.4.7.tgz", + "integrity": "sha512-S0vh/ZEafZ17hbhgqdnpunKDfzHQibQizx9g8yEf5dcVk3KOflOfdufRXQX8CSEkyOQwuM/bNz1GwKvFj54kaQ==", + "dev": true, + "requires": { + "@yarnpkg/lockfile": "^1.1.0", + "chalk": "^2.4.2", + "cross-spawn": "^6.0.5", + "find-yarn-workspace-root": "^2.0.0", + "fs-extra": "^7.0.1", + "is-ci": "^2.0.0", + "klaw-sync": "^6.0.0", + "minimist": "^1.2.0", + "open": "^7.4.2", + "rimraf": "^2.6.3", + "semver": "^5.6.0", + "slash": "^2.0.0", + "tmp": "^0.0.33" + }, + "dependencies": { + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true + }, + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + }, + "shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, + "requires": { + "shebang-regex": "^1.0.0" + } + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true + }, + "tmp": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", + "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.2" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", diff --git a/clients/cobol-lsp-vscode-extension/package.json b/clients/cobol-lsp-vscode-extension/package.json index e3fd3ac6a4..f867e95e3b 100644 --- a/clients/cobol-lsp-vscode-extension/package.json +++ b/clients/cobol-lsp-vscode-extension/package.json @@ -166,6 +166,144 @@ "description": "Default list of USS paths to search for copybooks\nZowe Explorer version 1.15.0 or higher is required to download copybooks from the mainframe", "uniqueItems": true }, + "cobol-lsp.cpy-manager.copybook-file-encoding": { + "type": "string", + "markdownDescription": "The encoding for the copybooks. Alternatively edit in .vscode\\settings.json. Other supported encodings can be found at [supported encodings](https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings) ", + "enum": [ + "utf8", + "ucs2", + "utf16le", + "ascii", + "base64", + "UTF7", + "UTF7-IMAP", + "UTF-16BE", + "UTF-16", + "UCS-4", + "UTF-32", + "UTF-32LE", + "UTF-32BE", + "ISO-8859-1", + "ISO-8859-2", + "ISO-8859-3", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-6", + "ISO-8859-7", + "ISO-8859-8", + "ISO-8859-9", + "ISO-8859-10", + "ISO-8859-11", + "ISO-8859-12", + "ISO-8859-13", + "ISO-8859-14", + "ISO-8859-15", + "ISO-8859-16", + "cp437", + "cp720", + "cp737", + "cp775", + "cp808", + "cp850", + "cp852", + "cp855", + "cp856", + "cp857", + "cp858", + "cp860", + "cp861", + "cp862", + "cp863", + "cp864", + "cp865", + "cp866", + "cp869", + "cp922", + "cp1046", + "cp1124", + "cp1125", + "cp1129", + "cp1133", + "cp1161", + "cp1162", + "cp1163", + "cp1047", + "cp1140", + "cp1147", + "cp1148", + "cp037", + "cp500", + "iso646cn", + "iso646jp" + ], + "enumDescriptions": [ + "utf8", + "ucs2", + "utf16le", + "ascii", + "base64", + "UTF7", + "UTF7-IMAP", + "UTF-16BE", + "UTF-16", + "UCS-4", + "UTF-32", + "UTF-32LE", + "UTF-32BE", + "ISO-8859-1", + "ISO-8859-2", + "ISO-8859-3", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-6", + "ISO-8859-7", + "ISO-8859-8", + "ISO-8859-9", + "ISO-8859-10", + "ISO-8859-11", + "ISO-8859-12", + "ISO-8859-13", + "ISO-8859-14", + "ISO-8859-15", + "ISO-8859-16", + "IBM-437", + "IBM-720", + "IBM-737", + "IBM-775", + "IBM-808", + "IBM-850", + "IBM-852", + "IBM-855", + "IBM-856", + "IBM-857", + "IBM-858", + "IBM-860", + "IBM-861", + "IBM-862", + "IBM-863", + "IBM-864", + "IBM-865", + "IBM-866", + "IBM-869", + "IBM-922", + "IBM-1046", + "IBM-1124", + "IBM-1125", + "IBM-1129", + "IBM-1133", + "IBM-1161", + "IBM-1162", + "IBM-1163", + "IBM-1047", + "IBM-1140", + "IBM-1147", + "IBM-1148", + "IBM-037", + "IBM-500", + "iso646cn", + "iso646jp" + ] + }, "cobol-lsp.subroutine-manager.paths-local": { "type": "array", "items": { @@ -268,6 +406,7 @@ }, "scripts": { "vscode:prepublish": "npm run compile", + "postinstall": "patch-package", "compile": "tsc -p ./", "watch": "tsc -watch -p ./", "test": "jest -w 1 --unhandled-rejections=strict", @@ -276,6 +415,7 @@ }, "dependencies": { "@zowe/zowe-explorer-api": "^1.17.0", + "iconv-lite": "^0.6.3", "vscode-extension-telemetry": "0.1.6", "vscode-languageclient": "5.2.1" }, @@ -285,6 +425,7 @@ "@types/vscode": "^1.56.0", "jest": "^27.0.0", "jest-sonar-reporter": "^2.0.0", + "patch-package": "^6.4.7", "ts-jest": "^27.0.0", "tslint": "^5.18.0", "tslint-sonarts": "^1.9.0", diff --git a/clients/cobol-lsp-vscode-extension/patches/iconv-lite+0.6.3.patch b/clients/cobol-lsp-vscode-extension/patches/iconv-lite+0.6.3.patch new file mode 100644 index 0000000000..ab71d14c1d --- /dev/null +++ b/clients/cobol-lsp-vscode-extension/patches/iconv-lite+0.6.3.patch @@ -0,0 +1,49 @@ +diff --git a/node_modules/iconv-lite/encodings/sbcs-data.js b/node_modules/iconv-lite/encodings/sbcs-data.js +index 066f904..243fe1b 100644 +--- a/node_modules/iconv-lite/encodings/sbcs-data.js ++++ b/node_modules/iconv-lite/encodings/sbcs-data.js +@@ -27,6 +27,44 @@ module.exports = { + "chars": "\x80\x81éâ\x84à\x86çêëèïî\x8d\x8e\x8f\x90\u0651\u0652ô¤ـûùءآأؤ£إئابةتثجحخدذرزسشص«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀ضطظعغفµقكلمنهوىي≡\u064b\u064c\u064d\u064e\u064f\u0650≈°∙·√ⁿ²■\u00a0" + }, + ++ "037": "ebcdic037", ++ "cp037": "ebcdic037", ++ "cp37": "ebcdic037", ++ "ebcdic37": "ebcdic037", ++ "ebcdic037": { ++ "type": "_sbcs", ++ "chars": "\u0000\u0001\u0002\u0003\u009C\u0009\u0086\u007F\u0097\u008D\u008E\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u009D\u000A\u0008\u0087\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F\u0080\u0081\u0082\u0083\u0084\u000A\u0017\u001B\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5\u00E7\u00F1\u00A2\u002E\u003C\u0028\u002B\u007C\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF\u00EC\u00DF\u0021\u0024\u002A\u0029\u003B\u00AC\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u0060\u003A\u0023\u0040\u0027\u003D\u0022\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u00A4\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE\u005E\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC\u00BD\u00BE\u005B\u005D\u00AF\u00A8\u00B4\u00D7\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF\u005C\u00F7\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" ++ }, ++ "1140": "ebcdic1140", ++ "cp1140": "ebcdic1140", ++ "ebcdic1140": { ++ "type": "_sbcs", ++ "chars": "\u0000\u0001\u0002\u0003\u009C\u0009\u0086\u007F\u0097\u008D\u008E\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u009D\u000A\u0008\u0087\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F\u0080\u0081\u0082\u0083\u0084\u000A\u0017\u001B\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5\u00E7\u00F1\u00A2\u002E\u003C\u0028\u002B\u007C\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF\u00EC\u00DF\u0021\u0024\u002A\u0029\u003B\u00AC\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u0060\u003A\u0023\u0040\u0027\u003D\u0022\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE\u005E\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC\u00BD\u00BE\u005B\u005D\u00AF\u00A8\u00B4\u00D7\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF\u005C\u00F7\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" ++ }, ++ "500": "ebcdic500", ++ "cp500": "ebcdic500", ++ "ebcdic500": { ++ "type": "_sbcs", ++ "chars": "\u0000\u0001\u0002\u0003\u009C\u0009\u0086\u007F\u0097\u008D\u008E\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u009D\u000A\u0008\u0087\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F\u0080\u0081\u0082\u0083\u0084\u000A\u0017\u001B\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5\u00E7\u00F1\u005B\u002E\u003C\u0028\u002B\u0021\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF\u00EC\u00DF\u005D\u0024\u002A\u0029\u003B\u005E\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u0060\u003A\u0023\u0040\u0027\u003D\u0022\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u00A4\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE\u00A2\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC\u00BD\u00BE\u00AC\u007C\u00AF\u00A8\u00B4\u00D7\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF\u005C\u00F7\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" ++ }, ++ "1148": "ebcdic1148", ++ "cp1148": "ebcdic1148", ++ "ebcdic1148": { ++ "type": "_sbcs", ++ "chars": "\u0000\u0001\u0002\u0003\u009C\u0009\u0086\u007F\u0097\u008D\u008E\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u009D\u000A\u0008\u0087\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F\u0080\u0081\u0082\u0083\u0084\u000A\u0017\u001B\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5\u00E7\u00F1\u005B\u002E\u003C\u0028\u002B\u0021\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF\u00EC\u00DF\u005D\u0024\u002A\u0029\u003B\u005E\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u0060\u003A\u0023\u0040\u0027\u003D\u0022\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE\u00A2\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC\u00BD\u00BE\u00AC\u007C\u00AF\u00A8\u00B4\u00D7\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF\u005C\u00F7\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" ++ }, ++ "1147" : "ebcdic1147", ++ "cp1147": "ebcdic1147", ++ "ebcdic1147": { ++ "type": "_sbcs", ++ "chars": "\u0000\u0001\u0002\u0003\u009C\u0009\u0086\u007F\u0097\u008D\u008E\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u009D\u000A\u0008\u0087\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F\u0080\u0081\u0082\u0083\u0084\u000A\u0017\u001B\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A\u0020\u00A0\u00E2\u00E4\u0040\u00E1\u00E3\u00E5\u005C\u00F1\u00B0\u002E\u003C\u0028\u002B\u0021\u0026\u007B\u00EA\u00EB\u007D\u00ED\u00EE\u00EF\u00EC\u00DF\u00A7\u0024\u002A\u0029\u003B\u005E\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5\u00C7\u00D1\u00F9\u002C\u0025\u005F\u003E\u003F\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u00B5\u003A\u00A3\u00E0\u0027\u003D\u0022\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1\u005B\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u20AC\u0060\u00A8\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A\u00A1\u00BF\u00D0\u00DD\u00DE\u00AE\u00A2\u0023\u00A5\u00B7\u00A9\u005D\u00B6\u00BC\u00BD\u00BE\u00AC\u007C\u00AF\u007E\u00B4\u00D7\u00E9\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5\u00E8\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u00B9\u00FB\u00FC\u00A6\u00FA\u00FF\u00E7\u00F7\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" ++ }, ++ "1047" : "ebcdic1047", ++ "cp1047": "ebcdic1047", ++ "ebcdic1047": { ++ "type": "_sbcs", ++ "chars": "\u0000\u0001\u0002\u0003\u009C\u0009\u0086\u007F\u0097\u008D\u008E\u000B\u000C\u000D\u000E\u000F\u0010\u0011\u0012\u0013\u009D\u000A\u0008\u0087\u0018\u0019\u0092\u008F\u001C\u001D\u001E\u001F\u0080\u0081\u0082\u0083\u0084\u000A\u0017\u001B\u0088\u0089\u008A\u008B\u008C\u0005\u0006\u0007\u0090\u0091\u0016\u0093\u0094\u0095\u0096\u0004\u0098\u0099\u009A\u009B\u0014\u0015\u009E\u001A\u0020\u00A0\u00E2\u00E4\u00E0\u00E1\u00E3\u00E5\u00E7\u00F1\u00A2\u002E\u003C\u0028\u002B\u007C\u0026\u00E9\u00EA\u00EB\u00E8\u00ED\u00EE\u00EF\u00EC\u00DF\u0021\u0024\u002A\u0029\u003B\u005E\u002D\u002F\u00C2\u00C4\u00C0\u00C1\u00C3\u00C5\u00C7\u00D1\u00A6\u002C\u0025\u005F\u003E\u003F\u00F8\u00C9\u00CA\u00CB\u00C8\u00CD\u00CE\u00CF\u00CC\u0060\u003A\u0023\u0040\u0027\u003D\u0022\u00D8\u0061\u0062\u0063\u0064\u0065\u0066\u0067\u0068\u0069\u00AB\u00BB\u00F0\u00FD\u00FE\u00B1\u00B0\u006A\u006B\u006C\u006D\u006E\u006F\u0070\u0071\u0072\u00AA\u00BA\u00E6\u00B8\u00C6\u00A4\u00B5\u007E\u0073\u0074\u0075\u0076\u0077\u0078\u0079\u007A\u00A1\u00BF\u00D0\u005B\u00DE\u00AE\u00AC\u00A3\u00A5\u00B7\u00A9\u00A7\u00B6\u00BC\u00BD\u00BE\u00DD\u00A8\u00AF\u005D\u00B4\u00D7\u007B\u0041\u0042\u0043\u0044\u0045\u0046\u0047\u0048\u0049\u00AD\u00F4\u00F6\u00F2\u00F3\u00F5\u007D\u004A\u004B\u004C\u004D\u004E\u004F\u0050\u0051\u0052\u00B9\u00FB\u00FC\u00F9\u00FA\u00FF\u00E7\u00F7\u0053\u0054\u0055\u0056\u0057\u0058\u0059\u005A\u00B2\u00D4\u00D6\u00D2\u00D3\u00D5\u0030\u0031\u0032\u0033\u0034\u0035\u0036\u0037\u0038\u0039\u00B3\u00DB\u00DC\u00D9\u00DA\u009F" ++ }, + // Aliases of generated encodings. + "ascii8bit": "ascii", + "usascii": "ascii", diff --git a/clients/cobol-lsp-vscode-extension/src/__tests__/EncodingIconvTest.spec.ts b/clients/cobol-lsp-vscode-extension/src/__tests__/EncodingIconvTest.spec.ts new file mode 100644 index 0000000000..2fb9d84337 --- /dev/null +++ b/clients/cobol-lsp-vscode-extension/src/__tests__/EncodingIconvTest.spec.ts @@ -0,0 +1,15 @@ +import * as iconv from "iconv-lite"; + +describe('Test iconv lib correctly decodes a binary buffer', () => { + + it('checks iconv-lite decodes correctly for patched ebcdic encodings 1147 / 037/ 1047', () => { + expect(iconv.decode(Buffer.from([0xF3, 0xF0, 0xF0, 0x9F, 0x40, 0x40]), "cp1147")).toBe("300€ "); + expect(iconv.decode(Buffer.from([0xF3, 0xF0, 0xF0, 0xBA, 0xBB, 0xB0]), "cp037")).toBe("300[]^"); + expect(iconv.decode(Buffer.from([0xF3, 0xF0, 0xF0, 0xBA, 0xBB, 0xB0]), "cp1047")).toBe("300ݨ¬"); + }); + + it('check iconv-lite decodes correctly for out of box provided encodings (ISO-8859-5)', () => { + const testData = Buffer.from('\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef', 'binary'); + expect(iconv.decode(testData, "iso88595")).toBe("АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя") + }) +}); diff --git a/clients/cobol-lsp-vscode-extension/src/__tests__/services/copybook/CopybookDownloadServiceTest.spec.ts b/clients/cobol-lsp-vscode-extension/src/__tests__/services/copybook/CopybookDownloadServiceTest.spec.ts index d5fd8145ab..c9fa72cb0b 100644 --- a/clients/cobol-lsp-vscode-extension/src/__tests__/services/copybook/CopybookDownloadServiceTest.spec.ts +++ b/clients/cobol-lsp-vscode-extension/src/__tests__/services/copybook/CopybookDownloadServiceTest.spec.ts @@ -91,24 +91,12 @@ beforeEach(() => { jest.mock("../../../services/reporter/TelemetryService"); describe("Test fetchCopybook against bad and correct configurations", () => { - const fsPath = "/projects"; - - beforeEach(() => { - (vscode.workspace.workspaceFolders as any) = [{ uri: { fsPath } } as any]; - }) - - it("check workspace", () => { - expect(CopybookDownloadService.checkWorkspace()).toEqual(true); - (vscode.workspace.workspaceFolders as any) = []; - expect(CopybookDownloadService.checkWorkspace()).toEqual(false); - }); - it("downloadCopybookFromMFUsingZowe is correctly invokes USS API's", async () => { ZoweVsCodeExtension.getZoweExplorerApi = getZoweExplorerMock(); + SettingsService.getCopybookFileEncoding = jest.fn().mockReturnValue("1147"); await (CopybookDownloadService as any).downloadCopybookFromMFUsingZowe("HLQ.DSN1", copybookProfile, true); expect(getUSSContentsMock).toBeCalledWith(`HLQ.DSN1/copybook`, { - encoding: "UTF-8", - binary: false, + binary: true, file: Path.join(CopybookURI.createDatasetPath(profile, "HLQ.DSN1"), "copybook"), returnEtag: true, }); @@ -118,7 +106,7 @@ describe("Test fetchCopybook against bad and correct configurations", () => { ZoweVsCodeExtension.getZoweExplorerApi = getZoweExplorerMock(); await (CopybookDownloadService as any).downloadCopybookFromMFUsingZowe("HLQ.DSN1", copybookProfile); expect(getContentMock).toBeCalledWith(`HLQ.DSN1(copybook)`, { - encoding: undefined, + binary: true, file: Path.join(CopybookURI.createDatasetPath(profile, "HLQ.DSN1"), "copybook"), returnEtag: true, }); diff --git a/clients/cobol-lsp-vscode-extension/src/services/Settings.ts b/clients/cobol-lsp-vscode-extension/src/services/Settings.ts index df0b36632a..7b6bb1b15b 100644 --- a/clients/cobol-lsp-vscode-extension/src/services/Settings.ts +++ b/clients/cobol-lsp-vscode-extension/src/services/Settings.ts @@ -96,7 +96,7 @@ export class SettingsService { * @returns a list of dsn path */ public static getDsnPath(dialectType: string): string[] { - return vscode.workspace.getConfiguration(SETTINGS_CPY_SECTION).get(PATHS_ZOWE); + return vscode.workspace.getConfiguration(SETTINGS_CPY_SECTION).get(PATHS_ZOWE); } /** @@ -129,4 +129,12 @@ export class SettingsService { dataList.forEach(d => result.push(d.replace("$" + variable, value))) return result; } -} \ No newline at end of file + + /** + * Return the code page for the copybook file encoding supplied by user + * @returns string + */ + public static getCopybookFileEncoding() { + return vscode.workspace.getConfiguration(SETTINGS_CPY_SECTION).get("copybook-file-encoding") + } +} diff --git a/clients/cobol-lsp-vscode-extension/src/services/copybook/CopybookDownloadService.ts b/clients/cobol-lsp-vscode-extension/src/services/copybook/CopybookDownloadService.ts index f944f8cb4c..2f5f74d8ff 100644 --- a/clients/cobol-lsp-vscode-extension/src/services/copybook/CopybookDownloadService.ts +++ b/clients/cobol-lsp-vscode-extension/src/services/copybook/CopybookDownloadService.ts @@ -24,6 +24,7 @@ import { SettingsService } from "../Settings"; import { ProfileUtils } from "../util/ProfileUtils"; import { CopybookURI } from "./CopybookURI"; import { CopybookProfile, DownloadQueue } from "./DownloadQueue"; +import * as iconv from "iconv-lite" const experimentTag = "experiment-tag"; export class CopybookDownloadService implements vscode.Disposable { @@ -112,20 +113,32 @@ export class CopybookDownloadService implements vscode.Disposable { .getExplorerExtenderApi() .getProfilesCache() .loadNamedProfile(profileName); + const downloadBinary = !!SettingsService.getCopybookFileEncoding(); + const filePath = Path.join(CopybookURI.createDatasetPath(profileName, dataset), copybook); + + const downloadOptions = { + file: filePath, + binary: downloadBinary, + returnEtag: true, + } + if (!SettingsService.getCopybookFileEncoding()) { + (downloadOptions as any).encoding = loadedProfile.profile.encoding; + } if (isUSS) { - await zoweExplorerApi.getUssApi(loadedProfile).getContents(`${dataset}/${copybook}`, { - encoding: loadedProfile.profile.encoding || "UTF-8", - binary: false, - file: Path.join(CopybookURI.createDatasetPath(profileName, dataset), copybook), - returnEtag: true, - }); + await zoweExplorerApi.getUssApi(loadedProfile).getContents(`${dataset}/${copybook}`, downloadOptions); } else { - await zoweExplorerApi.getMvsApi(loadedProfile).getContents(`${dataset}(${copybook})`, { - encoding: loadedProfile.profile.encoding, - file: Path.join(CopybookURI.createDatasetPath(profileName, dataset), copybook), - returnEtag: true, - }); + await zoweExplorerApi.getMvsApi(loadedProfile).getContents(`${dataset}(${copybook})`, downloadOptions); + } + + if (downloadBinary) { + let newContent = iconv.decode(fs.readFileSync(filePath), SettingsService.getCopybookFileEncoding() as string) + if(!isUSS) { + // Based on assumption - Most of source code on z/OS is 80 characters per record - JCL, HLASM, COBOL + // Can be exposed later on as a setting. + newContent = newContent.replace(/.{80}/g, `$&\n`); + } + fs.writeFileSync(filePath, newContent); } } @@ -261,7 +274,7 @@ export class CopybookDownloadService implements vscode.Disposable { } return true; } - + private async process(progress: vscode.Progress<{ message?: string; increment?: number }>, element: CopybookProfile, errors: Set, startTime: number) { { @@ -303,13 +316,17 @@ export class CopybookDownloadService implements vscode.Disposable { } toDownload.map(cp => cp.copybook).forEach(cb => errors.add(cb)); try { - for (const dataset of SettingsService.getUssPath(SettingsService.DEFAULT_DIALECT)) { + for (const dataset of SettingsService.getDsnPath(SettingsService.DEFAULT_DIALECT)) { await CopybookDownloadService.handleCopybooks(dataset, toDownload, errors, progress); } const toDownloadUSS = toDownload.filter(cp => errors.has(cp.copybook)).map(cp => cp); const quiteModeOffCopybooks = toDownloadUSS.filter(cp => !cp.quiet).map(cp => cp.copybook); - errors = new Set([...errors].filter(cp => quiteModeOffCopybooks.includes(cp))); + errors.forEach(ele => { + if (!quiteModeOffCopybooks.includes(ele)) { + errors.delete(ele); + } + }) if (toDownloadUSS.length > 0) { for (const ussPath of SettingsService.getUssPath(SettingsService.DEFAULT_DIALECT)) { await CopybookDownloadService.handleCopybooks(ussPath, toDownloadUSS, errors, progress, true);