-
Notifications
You must be signed in to change notification settings - Fork 50
feat(lsp): add xgoGetProperties command for lsp #2837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ import { | |
| } from '../common' | ||
| import { XGoLanguageClient, type IConnection, ResponseError } from './spxls/client' | ||
| import type { Files as SpxlsFiles, RequestMessage, ResponseMessage, NotificationMessage } from './spxls' | ||
| import { xgoGetInputSlots, xgoRenameResources } from './spxls/commands' | ||
| import { xgoGetInputSlots, xgoGetProperties, xgoRenameResources } from './spxls/commands' | ||
| import { | ||
| type CompletionItem, | ||
| isDocumentLinkForResourceReference, | ||
|
|
@@ -254,6 +254,17 @@ export class SpxLSPClient extends Disposable { | |
| ) | ||
| } | ||
|
|
||
| async workspaceExecuteCommandXGoGetProperties( | ||
| ctx: RequestContext, | ||
| ...params: xgoGetProperties.Arguments | ||
| ): Promise<xgoGetProperties.Result> { | ||
go-wyvern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return this.executeCommand<xgoGetProperties.Arguments, xgoGetProperties.Result>( | ||
go-wyvern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ctx, | ||
| xgoGetProperties.command, | ||
| ...params | ||
| ) | ||
| } | ||
|
|
||
| async textDocumentDocumentLink( | ||
| ctx: RequestContext, | ||
| params: lsp.DocumentLinkParams | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing Convenience Method: Consider adding a higher-level Existing patterns:
Suggested implementation: async getProperties(ctx: RequestContext, target: string): Promise<xgoGetProperties.XGoProperty[]> {
const result = await this.workspaceExecuteCommandXGoGetProperties(ctx, { target })
if (result == null) return []
return result
}This would provide a cleaner API and improve maintainability. |
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -30,3 +30,24 @@ export namespace xgoGetInputSlots { | |||||
| } | ||||||
| export type Result = XGoInputSlot[] | null | ||||||
| } | ||||||
|
|
||||||
| export namespace xgoGetProperties { | ||||||
| export const command = 'xgo.getProperties' | ||||||
| type XGoGetPropertiesParams = { | ||||||
| /** The target name, for example `Game` or a specific sprite name. */ | ||||||
| target: string | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Input Validation: The Security consideration: While the LSP runs in a sandboxed Web Worker, adding validation provides defense in depth if the WASM language server has vulnerabilities in string handling. Recommendation:
|
||||||
| } | ||||||
| export type Arguments = [XGoGetPropertiesParams] | ||||||
| /** A property of a target type. */ | ||||||
| export type XGoProperty = { | ||||||
| /** The property name. */ | ||||||
| name: string | ||||||
| /** The property type as a string. */ | ||||||
| type: string | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Documentation Enhancement: Consider adding more detailed JSDoc for the
This would help developers understand what to expect from the API response. |
||||||
| /** The kind of property. */ | ||||||
| kind: 'field' | 'method' | ||||||
| /** Optional documentation for the property. */ | ||||||
| doc?: string | ||||||
| } | ||||||
| export type Result = XGoProperty[] | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency with other commands like
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type Safety Issue: The Current:
Recommendation: Change to |
||||||
| } | ||||||
|
Comment on lines
+34
to
+53
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming Inconsistency: The method name
workspaceExecuteCommandXGoGetProperty(singular) doesn't match the command namespacexgoGetProperties(plural) or the command string'xgo.getProperties'.This breaks the established pattern in the codebase:
xgoGetInputSlots→workspaceExecuteCommandXGoGetInputSlots✅xgoRenameResources→workspaceExecuteCommandXGoRenameResources✅xgoGetProperties→workspaceExecuteCommandXGoGetProperty❌Recommendation: Rename to
workspaceExecuteCommandXGoGetProperties(plural) for consistency.