@player-tools/json-language-server 0.10.0-next.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +15 -16
- package/src/utils.ts +2 -2
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-server/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-server/src/utils.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport type { InitializeParams } from \"vscode-languageserver\";\nimport {\n createConnection,\n ProposedFeatures,\n TextDocuments,\n DidChangeConfigurationNotification,\n TextDocumentSyncKind,\n} from \"vscode-languageserver\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { PlayerLanguageService } from \"@player-tools/json-language-service\";\nimport fs from \"fs\";\nimport { runAndCatch } from \"./utils\";\n\nexport * from \"./utils\";\n\nconst dateFormat = new Intl.DateTimeFormat(\"en\", {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour12: false,\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n});\n\nconst logFilePath =\n process.argv.length === 4 &&\n fs.existsSync(process.argv[3]) &&\n process.argv[3];\n\n/** Format a log message to work in the console */\nconst formatLog = (a: unknown): string => {\n const msg = typeof a === \"string\" ? a : JSON.stringify(a);\n const date = new Date();\n return `${dateFormat.format(date)},$${date.getMilliseconds()} | ${msg} \\n`;\n};\n\nconst fileLog = logFilePath\n ? (a: unknown) =>\n fs.appendFile(logFilePath, formatLog(a), () => {\n /* do nothing */\n })\n : () => {\n /* do nothing */\n };\n\nconst service = new PlayerLanguageService();\n\nconst connection = createConnection(ProposedFeatures.all);\nconst documents = new TextDocuments(TextDocument);\n\nlet hasConfigurationCapability = false;\n\nprocess.on(\"unhandledRejection\", (e: Error) => {\n console.error(e.message);\n});\nprocess.on(\"uncaughtException\", (e: Error) => {\n console.error(e.message);\n});\n\nconsole.log = (a: Error) => {\n fileLog(a);\n connection.console.log(JSON.stringify(a, null, 2));\n};\n\nconsole.error = (a: Error) => {\n fileLog(a);\n connection.console.error(JSON.stringify(a, null, 2));\n};\n\n/** Handle validating a text-document and returning the response back to the extension */\nasync function validate(textDocument: TextDocument): Promise<void> {\n const diagnostics = await service.validateTextDocument(textDocument);\n\n if (diagnostics) {\n connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });\n }\n}\n\nconnection.onInitialize((params: InitializeParams) => {\n const { capabilities } = params;\n\n // Does the client support the `workspace/configuration` request?\n // If not, we will fall back using global settings\n hasConfigurationCapability = Boolean(\n capabilities.workspace && Boolean(capabilities.workspace.configuration)\n );\n\n fileLog(\"Initialized Player LSP Server\");\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Full,\n codeActionProvider: true,\n definitionProvider: true,\n completionProvider: {\n resolveProvider: false,\n triggerCharacters: ['\"', \":\"],\n },\n documentFormattingProvider: true,\n documentRangeFormattingProvider: true,\n hoverProvider: true,\n },\n };\n});\n\nconnection.onCompletion(async (textDocumentPosition, token) => {\n return runAndCatch(\n () => {\n const document = documents.get(textDocumentPosition.textDocument.uri);\n if (document !== undefined) {\n return service.getCompletionsAtPosition(\n document,\n textDocumentPosition.position\n );\n }\n\n return null;\n },\n token,\n null\n );\n});\n\nconnection.onHover(async (hoverParams, token) => {\n return runAndCatch(\n () => {\n const document = documents.get(hoverParams.textDocument.uri);\n if (document !== undefined) {\n return service.getHoverInfoAtPosition(document, hoverParams.position);\n }\n\n return null;\n },\n token,\n null\n );\n});\n\nconnection.onCompletionResolve((item, token) =>\n runAndCatch(() => service.resolveCompletionItem(item), token, item)\n);\n\nconnection.onDocumentFormatting((formattingParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(formattingParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.formatTextDocument(document, formattingParams.options);\n }\n\n return undefined;\n },\n token,\n null\n )\n);\n\nconnection.onDocumentRangeFormatting((formattingParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(formattingParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.formatTextDocument(\n document,\n formattingParams.options,\n formattingParams.range\n );\n }\n\n return undefined;\n },\n token,\n null\n )\n);\n\nconnection.onDefinition((definitionParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(definitionParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.getDefinitionAtPosition(\n document,\n definitionParams.position\n );\n }\n\n return undefined;\n },\n token,\n null\n )\n);\n\nconnection.onInitialized(() => {\n if (hasConfigurationCapability) {\n // Register for all configuration changes.\n connection.client.register(\n DidChangeConfigurationNotification.type,\n undefined\n );\n }\n});\n\nconnection.onCodeAction((codeAction) => {\n const document = documents.get(codeAction.textDocument.uri);\n if (!document) {\n return [];\n }\n\n return service.getCodeActionsInRange(document, codeAction.context);\n});\n\ndocuments.onDidClose((change) => {\n service.onClose(change.document);\n});\n\ndocuments.onDidChangeContent((change) => {\n validate(change.document);\n});\n\nconnection.onNotification(\n \"player/setAssetBundles\",\n (assetBundles: Array<string>) => {\n // Don't trust data over the wire\n if (Array.isArray(assetBundles)) {\n console.log(\"Updating asset type bundles\");\n service.setAssetTypes(assetBundles);\n }\n }\n);\n\nfileLog(\"Starting Player LSP Server\");\n\ndocuments.listen(connection);\nconnection.listen();\n","import type { CancellationToken } from \"vscode-languageserver\";\nimport { ResponseError } from \"vscode-languageserver\";\n\n/** Get a cancellation error */\nfunction cancel() {\n return new ResponseError(\n -32800 /* ErrorCodes.RequestCancelled */,\n \"Request cancelled\"\n );\n}\n\n/** Run the given function and handle being cancelled */\nexport async function runAndCatch<T>(\n func: () => Promise<T> | T,\n token: CancellationToken,\n errorVal: T\n): Promise<T | ResponseError<any>> {\n if (token.isCancellationRequested) {\n return cancel();\n }\n\n try {\n const result = await func();\n if (token.isCancellationRequested) {\n return cancel();\n }\n\n return result;\n } catch (e) {\n return errorVal;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gCAMO;AACP,gDAA6B;AAC7B,mCAAsC;AACtC,gBAAe;;;ACVf,mCAA8B;AAG9B,SAAS,SAAS;AAChB,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAGA,eAAsB,YACpB,MACA,OACA,UACiC;AACjC,MAAI,MAAM,yBAAyB;AACjC,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI;AACF,UAAM,SAAS,MAAM,KAAK;AAC1B,QAAI,MAAM,yBAAyB;AACjC,aAAO,OAAO;AAAA,IAChB;AAEA,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;;;ADfA,IAAM,aAAa,IAAI,KAAK,eAAe,MAAM;AAAA,EAC/C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV,CAAC;AAED,IAAM,cACJ,QAAQ,KAAK,WAAW,KACxB,UAAAC,QAAG,WAAW,QAAQ,KAAK,CAAC,CAAC,KAC7B,QAAQ,KAAK,CAAC;AAGhB,IAAM,YAAY,CAAC,MAAuB;AACxC,QAAM,MAAM,OAAO,MAAM,WAAW,IAAI,KAAK,UAAU,CAAC;AACxD,QAAM,OAAO,oBAAI,KAAK;AACtB,SAAO,GAAG,WAAW,OAAO,IAAI,CAAC,KAAK,KAAK,gBAAgB,CAAC,MAAM,GAAG;AAAA;AACvE;AAEA,IAAM,UAAU,cACZ,CAAC,MACC,UAAAA,QAAG,WAAW,aAAa,UAAU,CAAC,GAAG,MAAM;AAE/C,CAAC,IACH,MAAM;AAEN;AAEJ,IAAM,UAAU,IAAI,mDAAsB;AAE1C,IAAM,iB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ACb;AAAA,UACA,iBAAiB;AAAA,QACnB;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,WAAW,cAAc,MAAM;AAC7B,MAAI,4BAA4B;AAE9B,eAAW,OAAO;AAAA,MAChB,iEAAmC;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,WAAW,aAAa,CAAC,eAAe;AACtC,QAAM,WAAW,UAAU,IAAI,WAAW,aAAa,GAAG;AAC1D,MAAI,CAAC,UAAU;AACb,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,QAAQ,sBAAsB,UAAU,WAAW,OAAO;AACnE,CAAC;AAED,UAAU,WAAW,CAAC,WAAW;AAC/B,UAAQ,QAAQ,OAAO,QAAQ;AACjC,CAAC;AAED,UAAU,mBAAmB,CAAC,WAAW;AACvC,WAAS,OAAO,QAAQ;AAC1B,CAAC;AAED,WAAW;AAAA,EACT;AAAA,EACA,CAAC,iBAAgC;AAE/B,QAAI,MAAM,QAAQ,YAAY,GAAG;AAC/B,cAAQ,IAAI,6BAA6B;AACzC,cAAQ,cAAc,YAAY;AAAA,IACpC;AAAA,EACF;AACF;AAEA,QAAQ,4BAA4B;AAEpC,UAAU,OAAO,UAAU;AAC3B,WAAW,OAAO;","names":["import_vscode_languageserver","fs"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-server/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-server/src/utils.ts"],"sourcesContent":["import type { InitializeParams } from \"vscode-languageserver\";\nimport {\n createConnection,\n ProposedFeatures,\n TextDocuments,\n DidChangeConfigurationNotification,\n TextDocumentSyncKind,\n} from \"vscode-languageserver\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { PlayerLanguageService } from \"@player-tools/json-language-service\";\nimport fs from \"fs\";\nimport { runAndCatch } from \"./utils\";\n\nexport * from \"./utils\";\n\nconst dateFormat = new Intl.DateTimeFormat(\"en\", {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour12: false,\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n});\n\nconst logFilePath =\n process.argv.length === 4 &&\n fs.existsSync(process.argv[3]) &&\n process.argv[3];\n\n/** Format a log message to work in the console */\nconst formatLog = (a: unknown): string => {\n const msg = typeof a === \"string\" ? a : JSON.stringify(a);\n const date = new Date();\n return `${dateFormat.format(date)},$${date.getMilliseconds()} | ${msg} \\n`;\n};\n\nconst fileLog = logFilePath\n ? (a: unknown) =>\n fs.appendFile(logFilePath, formatLog(a), () => {\n /* do nothing */\n })\n : () => {\n /* do nothing */\n };\n\nconst service = new PlayerLanguageService();\n\nconst connection = createConnection(ProposedFeatures.all);\nconst documents = new TextDocuments(TextDocument);\n\nlet hasConfigurationCapability = false;\n\nprocess.on(\"unhandledRejection\", (e: Error) => {\n console.error(e.message);\n});\nprocess.on(\"uncaughtException\", (e: Error) => {\n console.error(e.message);\n});\n\nconsole.log = (a: Error) => {\n fileLog(a);\n connection.console.log(JSON.stringify(a, null, 2));\n};\n\nconsole.error = (a: Error) => {\n fileLog(a);\n connection.console.error(JSON.stringify(a, null, 2));\n};\n\n/** Handle validating a text-document and returning the response back to the extension */\nasync function validate(textDocument: TextDocument): Promise<void> {\n const diagnostics = await service.validateTextDocument(textDocument);\n\n if (diagnostics) {\n connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });\n }\n}\n\nconnection.onInitialize((params: InitializeParams) => {\n const { capabilities } = params;\n\n // Does the client support the `workspace/configuration` request?\n // If not, we will fall back using global settings\n hasConfigurationCapability = Boolean(\n capabilities.workspace && Boolean(capabilities.workspace.configuration),\n );\n\n fileLog(\"Initialized Player LSP Server\");\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Full,\n codeActionProvider: true,\n definitionProvider: true,\n completionProvider: {\n resolveProvider: false,\n triggerCharacters: ['\"', \":\"],\n },\n documentFormattingProvider: true,\n documentRangeFormattingProvider: true,\n hoverProvider: true,\n },\n };\n});\n\nconnection.onCompletion(async (textDocumentPosition, token) => {\n return runAndCatch(\n () => {\n const document = documents.get(textDocumentPosition.textDocument.uri);\n if (document !== undefined) {\n return service.getCompletionsAtPosition(\n document,\n textDocumentPosition.position,\n );\n }\n\n return null;\n },\n token,\n null,\n );\n});\n\nconnection.onHover(async (hoverParams, token) => {\n return runAndCatch(\n () => {\n const document = documents.get(hoverParams.textDocument.uri);\n if (document !== undefined) {\n return service.getHoverInfoAtPosition(document, hoverParams.position);\n }\n\n return null;\n },\n token,\n null,\n );\n});\n\nconnection.onCompletionResolve((item, token) =>\n runAndCatch(() => service.resolveCompletionItem(item), token, item),\n);\n\nconnection.onDocumentFormatting((formattingParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(formattingParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.formatTextDocument(document, formattingParams.options);\n }\n\n return undefined;\n },\n token,\n null,\n ),\n);\n\nconnection.onDocumentRangeFormatting((formattingParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(formattingParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.formatTextDocument(\n document,\n formattingParams.options,\n formattingParams.range,\n );\n }\n\n return undefined;\n },\n token,\n null,\n ),\n);\n\nconnection.onDefinition((definitionParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(definitionParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.getDefinitionAtPosition(\n document,\n definitionParams.position,\n );\n }\n\n return undefined;\n },\n token,\n null,\n ),\n);\n\nconnection.onInitialized(() => {\n if (hasConfigurationCapability) {\n // Register for all configuration changes.\n connection.client.register(\n DidChangeConfigurationNotification.type,\n undefined,\n );\n }\n});\n\nconnection.onCodeAction((codeAction) => {\n const document = documents.get(codeAction.textDocument.uri);\n if (!document) {\n return [];\n }\n\n return service.getCodeActionsInRange(document, codeAction.context);\n});\n\ndocuments.onDidClose((change) => {\n service.onClose(change.document);\n});\n\ndocuments.onDidChangeContent((change) => {\n validate(change.document);\n});\n\nconnection.onNotification(\n \"player/setAssetBundles\",\n (assetBundles: Array<string>) => {\n // Don't trust data over the wire\n if (Array.isArray(assetBundles)) {\n console.log(\"Updating asset type bundles\");\n service.setAssetTypes(assetBundles);\n }\n },\n);\n\nfileLog(\"Starting Player LSP Server\");\n\ndocuments.listen(connection);\nconnection.listen();\n","import type { CancellationToken } from \"vscode-languageserver\";\nimport { ResponseError } from \"vscode-languageserver\";\n\n/** Get a cancellation error */\nfunction cancel() {\n return new ResponseError(\n -32800 /* ErrorCodes.RequestCancelled */,\n \"Request cancelled\",\n );\n}\n\n/** Run the given function and handle being cancelled */\nexport async function runAndCatch<T>(\n func: () => Promise<T> | T,\n token: CancellationToken,\n errorVal: T,\n): Promise<T | ResponseError<any>> {\n if (token.isCancellationRequested) {\n return cancel();\n }\n\n try {\n const result = await func();\n if (token.isCancellationRequested) {\n return cancel();\n }\n\n return result;\n } catch (e) {\n return errorVal;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,IAAAA,gCAMO;AACP,gDAA6B;AAC7B,mCAAsC;AACtC,gBAAe;;;ACTf,mCAA8B;AAG9B,SAAS,SAAS;AAChB,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAGA,eAAsB,YACpB,MACA,OACA,UACiC;AACjC,MAAI,MAAM,yBAAyB;AACjC,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI;AACF,UAAM,SAAS,MAAM,KAAK;AAC1B,QAAI,MAAM,yBAAyB;AACjC,aAAO,OAAO;AAAA,IAChB;AAEA,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;;;ADhBA,IAAM,aAAa,IAAI,KAAK,eAAe,MAAM;AAAA,EAC/C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;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6BAA6B;AACzC,cAAQ,cAAc,YAAY;AAAA,IACpC;AAAA,EACF;AACF;AAEA,QAAQ,4BAA4B;AAEpC,UAAU,OAAO,UAAU;AAC3B,WAAW,OAAO;","names":["import_vscode_languageserver","fs"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-server/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-server/src/utils.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport type { InitializeParams } from \"vscode-languageserver\";\nimport {\n createConnection,\n ProposedFeatures,\n TextDocuments,\n DidChangeConfigurationNotification,\n TextDocumentSyncKind,\n} from \"vscode-languageserver\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { PlayerLanguageService } from \"@player-tools/json-language-service\";\nimport fs from \"fs\";\nimport { runAndCatch } from \"./utils\";\n\nexport * from \"./utils\";\n\nconst dateFormat = new Intl.DateTimeFormat(\"en\", {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour12: false,\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n});\n\nconst logFilePath =\n process.argv.length === 4 &&\n fs.existsSync(process.argv[3]) &&\n process.argv[3];\n\n/** Format a log message to work in the console */\nconst formatLog = (a: unknown): string => {\n const msg = typeof a === \"string\" ? a : JSON.stringify(a);\n const date = new Date();\n return `${dateFormat.format(date)},$${date.getMilliseconds()} | ${msg} \\n`;\n};\n\nconst fileLog = logFilePath\n ? (a: unknown) =>\n fs.appendFile(logFilePath, formatLog(a), () => {\n /* do nothing */\n })\n : () => {\n /* do nothing */\n };\n\nconst service = new PlayerLanguageService();\n\nconst connection = createConnection(ProposedFeatures.all);\nconst documents = new TextDocuments(TextDocument);\n\nlet hasConfigurationCapability = false;\n\nprocess.on(\"unhandledRejection\", (e: Error) => {\n console.error(e.message);\n});\nprocess.on(\"uncaughtException\", (e: Error) => {\n console.error(e.message);\n});\n\nconsole.log = (a: Error) => {\n fileLog(a);\n connection.console.log(JSON.stringify(a, null, 2));\n};\n\nconsole.error = (a: Error) => {\n fileLog(a);\n connection.console.error(JSON.stringify(a, null, 2));\n};\n\n/** Handle validating a text-document and returning the response back to the extension */\nasync function validate(textDocument: TextDocument): Promise<void> {\n const diagnostics = await service.validateTextDocument(textDocument);\n\n if (diagnostics) {\n connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });\n }\n}\n\nconnection.onInitialize((params: InitializeParams) => {\n const { capabilities } = params;\n\n // Does the client support the `workspace/configuration` request?\n // If not, we will fall back using global settings\n hasConfigurationCapability = Boolean(\n capabilities.workspace && Boolean(capabilities.workspace.configuration)\n );\n\n fileLog(\"Initialized Player LSP Server\");\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Full,\n codeActionProvider: true,\n definitionProvider: true,\n completionProvider: {\n resolveProvider: false,\n triggerCharacters: ['\"', \":\"],\n },\n documentFormattingProvider: true,\n documentRangeFormattingProvider: true,\n hoverProvider: true,\n },\n };\n});\n\nconnection.onCompletion(async (textDocumentPosition, token) => {\n return runAndCatch(\n () => {\n const document = documents.get(textDocumentPosition.textDocument.uri);\n if (document !== undefined) {\n return service.getCompletionsAtPosition(\n document,\n textDocumentPosition.position\n );\n }\n\n return null;\n },\n token,\n null\n );\n});\n\nconnection.onHover(async (hoverParams, token) => {\n return runAndCatch(\n () => {\n const document = documents.get(hoverParams.textDocument.uri);\n if (document !== undefined) {\n return service.getHoverInfoAtPosition(document, hoverParams.position);\n }\n\n return null;\n },\n token,\n null\n );\n});\n\nconnection.onCompletionResolve((item, token) =>\n runAndCatch(() => service.resolveCompletionItem(item), token, item)\n);\n\nconnection.onDocumentFormatting((formattingParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(formattingParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.formatTextDocument(document, formattingParams.options);\n }\n\n return undefined;\n },\n token,\n null\n )\n);\n\nconnection.onDocumentRangeFormatting((formattingParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(formattingParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.formatTextDocument(\n document,\n formattingParams.options,\n formattingParams.range\n );\n }\n\n return undefined;\n },\n token,\n null\n )\n);\n\nconnection.onDefinition((definitionParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(definitionParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.getDefinitionAtPosition(\n document,\n definitionParams.position\n );\n }\n\n return undefined;\n },\n token,\n null\n )\n);\n\nconnection.onInitialized(() => {\n if (hasConfigurationCapability) {\n // Register for all configuration changes.\n connection.client.register(\n DidChangeConfigurationNotification.type,\n undefined\n );\n }\n});\n\nconnection.onCodeAction((codeAction) => {\n const document = documents.get(codeAction.textDocument.uri);\n if (!document) {\n return [];\n }\n\n return service.getCodeActionsInRange(document, codeAction.context);\n});\n\ndocuments.onDidClose((change) => {\n service.onClose(change.document);\n});\n\ndocuments.onDidChangeContent((change) => {\n validate(change.document);\n});\n\nconnection.onNotification(\n \"player/setAssetBundles\",\n (assetBundles: Array<string>) => {\n // Don't trust data over the wire\n if (Array.isArray(assetBundles)) {\n console.log(\"Updating asset type bundles\");\n service.setAssetTypes(assetBundles);\n }\n }\n);\n\nfileLog(\"Starting Player LSP Server\");\n\ndocuments.listen(connection);\nconnection.listen();\n","import type { CancellationToken } from \"vscode-languageserver\";\nimport { ResponseError } from \"vscode-languageserver\";\n\n/** Get a cancellation error */\nfunction cancel() {\n return new ResponseError(\n -32800 /* ErrorCodes.RequestCancelled */,\n \"Request cancelled\"\n );\n}\n\n/** Run the given function and handle being cancelled */\nexport async function runAndCatch<T>(\n func: () => Promise<T> | T,\n token: CancellationToken,\n errorVal: T\n): Promise<T | ResponseError<any>> {\n if (token.isCancellationRequested) {\n return cancel();\n }\n\n try {\n const result = await func();\n if (token.isCancellationRequested) {\n return cancel();\n }\n\n return result;\n } catch (e) {\n return errorVal;\n }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AA,IACA;AAAA,EACF;AACF;AAEA,WAAW,cAAc,MAAM;AAC7B,MAAI,4BAA4B;AAE9B,eAAW,OAAO;AAAA,MAChB,mCAAmC;AAAA,MACnC;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAED,WAAW,aAAa,CAAC,eAAe;AACtC,QAAM,WAAW,UAAU,IAAI,WAAW,aAAa,GAAG;AAC1D,MAAI,CAAC,UAAU;AACb,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,QAAQ,sBAAsB,UAAU,WAAW,OAAO;AACnE,CAAC;AAED,UAAU,WAAW,CAAC,WAAW;AAC/B,UAAQ,QAAQ,OAAO,QAAQ;AACjC,CAAC;AAED,UAAU,mBAAmB,CAAC,WAAW;AACvC,WAAS,OAAO,QAAQ;AAC1B,CAAC;AAED,WAAW;AAAA,EACT;AAAA,EACA,CAAC,iBAAgC;AAE/B,QAAI,MAAM,QAAQ,YAAY,GAAG;AAC/B,cAAQ,IAAI,6BAA6B;AACzC,cAAQ,cAAc,YAAY;AAAA,IACpC;AAAA,EACF;AACF;AAEA,QAAQ,4BAA4B;AAEpC,UAAU,OAAO,UAAU;AAC3B,WAAW,OAAO;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-server/src/index.ts","../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-server/src/utils.ts"],"sourcesContent":["import type { InitializeParams } from \"vscode-languageserver\";\nimport {\n createConnection,\n ProposedFeatures,\n TextDocuments,\n DidChangeConfigurationNotification,\n TextDocumentSyncKind,\n} from \"vscode-languageserver\";\nimport { TextDocument } from \"vscode-languageserver-textdocument\";\nimport { PlayerLanguageService } from \"@player-tools/json-language-service\";\nimport fs from \"fs\";\nimport { runAndCatch } from \"./utils\";\n\nexport * from \"./utils\";\n\nconst dateFormat = new Intl.DateTimeFormat(\"en\", {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour12: false,\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n});\n\nconst logFilePath =\n process.argv.length === 4 &&\n fs.existsSync(process.argv[3]) &&\n process.argv[3];\n\n/** Format a log message to work in the console */\nconst formatLog = (a: unknown): string => {\n const msg = typeof a === \"string\" ? a : JSON.stringify(a);\n const date = new Date();\n return `${dateFormat.format(date)},$${date.getMilliseconds()} | ${msg} \\n`;\n};\n\nconst fileLog = logFilePath\n ? (a: unknown) =>\n fs.appendFile(logFilePath, formatLog(a), () => {\n /* do nothing */\n })\n : () => {\n /* do nothing */\n };\n\nconst service = new PlayerLanguageService();\n\nconst connection = createConnection(ProposedFeatures.all);\nconst documents = new TextDocuments(TextDocument);\n\nlet hasConfigurationCapability = false;\n\nprocess.on(\"unhandledRejection\", (e: Error) => {\n console.error(e.message);\n});\nprocess.on(\"uncaughtException\", (e: Error) => {\n console.error(e.message);\n});\n\nconsole.log = (a: Error) => {\n fileLog(a);\n connection.console.log(JSON.stringify(a, null, 2));\n};\n\nconsole.error = (a: Error) => {\n fileLog(a);\n connection.console.error(JSON.stringify(a, null, 2));\n};\n\n/** Handle validating a text-document and returning the response back to the extension */\nasync function validate(textDocument: TextDocument): Promise<void> {\n const diagnostics = await service.validateTextDocument(textDocument);\n\n if (diagnostics) {\n connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });\n }\n}\n\nconnection.onInitialize((params: InitializeParams) => {\n const { capabilities } = params;\n\n // Does the client support the `workspace/configuration` request?\n // If not, we will fall back using global settings\n hasConfigurationCapability = Boolean(\n capabilities.workspace && Boolean(capabilities.workspace.configuration),\n );\n\n fileLog(\"Initialized Player LSP Server\");\n return {\n capabilities: {\n textDocumentSync: TextDocumentSyncKind.Full,\n codeActionProvider: true,\n definitionProvider: true,\n completionProvider: {\n resolveProvider: false,\n triggerCharacters: ['\"', \":\"],\n },\n documentFormattingProvider: true,\n documentRangeFormattingProvider: true,\n hoverProvider: true,\n },\n };\n});\n\nconnection.onCompletion(async (textDocumentPosition, token) => {\n return runAndCatch(\n () => {\n const document = documents.get(textDocumentPosition.textDocument.uri);\n if (document !== undefined) {\n return service.getCompletionsAtPosition(\n document,\n textDocumentPosition.position,\n );\n }\n\n return null;\n },\n token,\n null,\n );\n});\n\nconnection.onHover(async (hoverParams, token) => {\n return runAndCatch(\n () => {\n const document = documents.get(hoverParams.textDocument.uri);\n if (document !== undefined) {\n return service.getHoverInfoAtPosition(document, hoverParams.position);\n }\n\n return null;\n },\n token,\n null,\n );\n});\n\nconnection.onCompletionResolve((item, token) =>\n runAndCatch(() => service.resolveCompletionItem(item), token, item),\n);\n\nconnection.onDocumentFormatting((formattingParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(formattingParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.formatTextDocument(document, formattingParams.options);\n }\n\n return undefined;\n },\n token,\n null,\n ),\n);\n\nconnection.onDocumentRangeFormatting((formattingParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(formattingParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.formatTextDocument(\n document,\n formattingParams.options,\n formattingParams.range,\n );\n }\n\n return undefined;\n },\n token,\n null,\n ),\n);\n\nconnection.onDefinition((definitionParams, token) =>\n runAndCatch(\n () => {\n const document = documents.get(definitionParams.textDocument.uri);\n\n if (document !== undefined) {\n return service.getDefinitionAtPosition(\n document,\n definitionParams.position,\n );\n }\n\n return undefined;\n },\n token,\n null,\n ),\n);\n\nconnection.onInitialized(() => {\n if (hasConfigurationCapability) {\n // Register for all configuration changes.\n connection.client.register(\n DidChangeConfigurationNotification.type,\n undefined,\n );\n }\n});\n\nconnection.onCodeAction((codeAction) => {\n const document = documents.get(codeAction.textDocument.uri);\n if (!document) {\n return [];\n }\n\n return service.getCodeActionsInRange(document, codeAction.context);\n});\n\ndocuments.onDidClose((change) => {\n service.onClose(change.document);\n});\n\ndocuments.onDidChangeContent((change) => {\n validate(change.document);\n});\n\nconnection.onNotification(\n \"player/setAssetBundles\",\n (assetBundles: Array<string>) => {\n // Don't trust data over the wire\n if (Array.isArray(assetBundles)) {\n console.log(\"Updating asset type bundles\");\n service.setAssetTypes(assetBundles);\n }\n },\n);\n\nfileLog(\"Starting Player LSP Server\");\n\ndocuments.listen(connection);\nconnection.listen();\n","import type { CancellationToken } from \"vscode-languageserver\";\nimport { ResponseError } from \"vscode-languageserver\";\n\n/** Get a cancellation error */\nfunction cancel() {\n return new ResponseError(\n -32800 /* ErrorCodes.RequestCancelled */,\n \"Request cancelled\",\n );\n}\n\n/** Run the given function and handle being cancelled */\nexport async function runAndCatch<T>(\n func: () => Promise<T> | T,\n token: CancellationToken,\n errorVal: T,\n): Promise<T | ResponseError<any>> {\n if (token.isCancellationRequested) {\n return cancel();\n }\n\n try {\n const result = await func();\n if (token.isCancellationRequested) {\n return cancel();\n }\n\n return result;\n } catch (e) {\n return errorVal;\n }\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,OAAO,QAAQ;;;ACTf,SAAS,qBAAqB;AAG9B,SAAS,SAAS;AAChB,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAGA,eAAsB,YACpB,MACA,OACA,UACiC;AACjC,MAAI,MAAM,yBAAyB;AACjC,WAAO,OAAO;AAAA,EAChB;AAEA,MAAI;AACF,UAAM,SAAS,MAAM,KAAK;AAC1B,QAAI,MAAM,yBAAyB;AACjC,aAAO,OAAO;AAAA,IAChB;AAEA,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;;;ADhBA,IAAM,aAAa,IAAI,KAAK,eAAe,MAAM;AAAA,EAC/C,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AACV,CAAC;AAED,IAAM,cACJ,QAAQ,KAA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AC3B,WAAW,OAAO;","names":[]}
|
package/package.json
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
"types"
|
|
7
7
|
],
|
|
8
8
|
"name": "@player-tools/json-language-server",
|
|
9
|
-
"version": "0.10.0
|
|
9
|
+
"version": "0.10.0",
|
|
10
10
|
"main": "dist/cjs/index.cjs",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@player-tools/json-language-service": "0.10.0
|
|
12
|
+
"@player-tools/json-language-service": "0.10.0",
|
|
13
13
|
"vscode-languageserver": "^6.1.1",
|
|
14
14
|
"vscode-languageserver-textdocument": "^1.0.1",
|
|
15
15
|
"tslib": "^2.6.2"
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import type { InitializeParams } from "vscode-languageserver";
|
|
3
2
|
import {
|
|
4
3
|
createConnection,
|
|
@@ -84,7 +83,7 @@ connection.onInitialize((params: InitializeParams) => {
|
|
|
84
83
|
// Does the client support the `workspace/configuration` request?
|
|
85
84
|
// If not, we will fall back using global settings
|
|
86
85
|
hasConfigurationCapability = Boolean(
|
|
87
|
-
capabilities.workspace && Boolean(capabilities.workspace.configuration)
|
|
86
|
+
capabilities.workspace && Boolean(capabilities.workspace.configuration),
|
|
88
87
|
);
|
|
89
88
|
|
|
90
89
|
fileLog("Initialized Player LSP Server");
|
|
@@ -111,14 +110,14 @@ connection.onCompletion(async (textDocumentPosition, token) => {
|
|
|
111
110
|
if (document !== undefined) {
|
|
112
111
|
return service.getCompletionsAtPosition(
|
|
113
112
|
document,
|
|
114
|
-
textDocumentPosition.position
|
|
113
|
+
textDocumentPosition.position,
|
|
115
114
|
);
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
return null;
|
|
119
118
|
},
|
|
120
119
|
token,
|
|
121
|
-
null
|
|
120
|
+
null,
|
|
122
121
|
);
|
|
123
122
|
});
|
|
124
123
|
|
|
@@ -133,12 +132,12 @@ connection.onHover(async (hoverParams, token) => {
|
|
|
133
132
|
return null;
|
|
134
133
|
},
|
|
135
134
|
token,
|
|
136
|
-
null
|
|
135
|
+
null,
|
|
137
136
|
);
|
|
138
137
|
});
|
|
139
138
|
|
|
140
139
|
connection.onCompletionResolve((item, token) =>
|
|
141
|
-
runAndCatch(() => service.resolveCompletionItem(item), token, item)
|
|
140
|
+
runAndCatch(() => service.resolveCompletionItem(item), token, item),
|
|
142
141
|
);
|
|
143
142
|
|
|
144
143
|
connection.onDocumentFormatting((formattingParams, token) =>
|
|
@@ -153,8 +152,8 @@ connection.onDocumentFormatting((formattingParams, token) =>
|
|
|
153
152
|
return undefined;
|
|
154
153
|
},
|
|
155
154
|
token,
|
|
156
|
-
null
|
|
157
|
-
)
|
|
155
|
+
null,
|
|
156
|
+
),
|
|
158
157
|
);
|
|
159
158
|
|
|
160
159
|
connection.onDocumentRangeFormatting((formattingParams, token) =>
|
|
@@ -166,15 +165,15 @@ connection.onDocumentRangeFormatting((formattingParams, token) =>
|
|
|
166
165
|
return service.formatTextDocument(
|
|
167
166
|
document,
|
|
168
167
|
formattingParams.options,
|
|
169
|
-
formattingParams.range
|
|
168
|
+
formattingParams.range,
|
|
170
169
|
);
|
|
171
170
|
}
|
|
172
171
|
|
|
173
172
|
return undefined;
|
|
174
173
|
},
|
|
175
174
|
token,
|
|
176
|
-
null
|
|
177
|
-
)
|
|
175
|
+
null,
|
|
176
|
+
),
|
|
178
177
|
);
|
|
179
178
|
|
|
180
179
|
connection.onDefinition((definitionParams, token) =>
|
|
@@ -185,15 +184,15 @@ connection.onDefinition((definitionParams, token) =>
|
|
|
185
184
|
if (document !== undefined) {
|
|
186
185
|
return service.getDefinitionAtPosition(
|
|
187
186
|
document,
|
|
188
|
-
definitionParams.position
|
|
187
|
+
definitionParams.position,
|
|
189
188
|
);
|
|
190
189
|
}
|
|
191
190
|
|
|
192
191
|
return undefined;
|
|
193
192
|
},
|
|
194
193
|
token,
|
|
195
|
-
null
|
|
196
|
-
)
|
|
194
|
+
null,
|
|
195
|
+
),
|
|
197
196
|
);
|
|
198
197
|
|
|
199
198
|
connection.onInitialized(() => {
|
|
@@ -201,7 +200,7 @@ connection.onInitialized(() => {
|
|
|
201
200
|
// Register for all configuration changes.
|
|
202
201
|
connection.client.register(
|
|
203
202
|
DidChangeConfigurationNotification.type,
|
|
204
|
-
undefined
|
|
203
|
+
undefined,
|
|
205
204
|
);
|
|
206
205
|
}
|
|
207
206
|
});
|
|
@@ -231,7 +230,7 @@ connection.onNotification(
|
|
|
231
230
|
console.log("Updating asset type bundles");
|
|
232
231
|
service.setAssetTypes(assetBundles);
|
|
233
232
|
}
|
|
234
|
-
}
|
|
233
|
+
},
|
|
235
234
|
);
|
|
236
235
|
|
|
237
236
|
fileLog("Starting Player LSP Server");
|
package/src/utils.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ResponseError } from "vscode-languageserver";
|
|
|
5
5
|
function cancel() {
|
|
6
6
|
return new ResponseError(
|
|
7
7
|
-32800 /* ErrorCodes.RequestCancelled */,
|
|
8
|
-
"Request cancelled"
|
|
8
|
+
"Request cancelled",
|
|
9
9
|
);
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@ function cancel() {
|
|
|
13
13
|
export async function runAndCatch<T>(
|
|
14
14
|
func: () => Promise<T> | T,
|
|
15
15
|
token: CancellationToken,
|
|
16
|
-
errorVal: T
|
|
16
|
+
errorVal: T,
|
|
17
17
|
): Promise<T | ResponseError<any>> {
|
|
18
18
|
if (token.isCancellationRequested) {
|
|
19
19
|
return cancel();
|