Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion spx-gui/src/components/editor/code-editor/lsp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -254,6 +254,17 @@ export class SpxLSPClient extends Disposable {
)
}

async workspaceExecuteCommandXGoGetProperties(
ctx: RequestContext,
...params: xgoGetProperties.Arguments
): Promise<xgoGetProperties.Result> {
return this.executeCommand<xgoGetProperties.Arguments, xgoGetProperties.Result>(
ctx,
xgoGetProperties.command,
...params
)
}

async textDocumentDocumentLink(
ctx: RequestContext,
params: lsp.DocumentLinkParams
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing Convenience Method: Consider adding a higher-level getProperties wrapper method following the established pattern in this codebase.

Existing patterns:

  • getInputSlots (line 428) wraps workspaceExecuteCommandXGoGetInputSlots
  • getCompletionItems (line 421) wraps textDocumentCompletion
  • getResourceReferences (line 389) wraps textDocumentDocumentLink

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.

Expand Down
21 changes: 21 additions & 0 deletions spx-gui/src/components/editor/code-editor/lsp/spxls/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
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
/** The kind of property. */
kind: 'field' | 'method'
/** Optional documentation for the property. */
doc?: string
}
export type Result = XGoProperty[]
}