Skip to content

Commit

Permalink
Remove VDFTextDocument TDependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cooolbros committed Jan 22, 2025
1 parent da52263 commit f1c7941
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 27 deletions.
4 changes: 2 additions & 2 deletions packages/server/src/VDF/Popfile/PopfileLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { firstValueFrom, Subscription } from "rxjs"
import { FoldingRange, FoldingRangeKind, InlayHint, InlayHintKind, InlayHintRequest, type Connection, type FoldingRangeParams, type InlayHintParams, type TextDocumentChangeEvent } from "vscode-languageserver"
import type { TextDocumentRequestParams } from "../../LanguageServer"
import { VDFLanguageServer } from "../VDFLanguageServer"
import { PopfileTextDocument, type PopfileTextDocumentDependencies } from "./PopfileTextDocument"
import { PopfileTextDocument } from "./PopfileTextDocument"
import colours from "./colours.json"

export class PopfileLanguageServer extends VDFLanguageServer<"popfile", PopfileTextDocument, PopfileTextDocumentDependencies> {
export class PopfileLanguageServer extends VDFLanguageServer<"popfile", PopfileTextDocument> {

private vscript = false

Expand Down
5 changes: 1 addition & 4 deletions packages/server/src/VDF/Popfile/PopfileTextDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import colours from "./colours.json"
import keys from "./keys.json"
import values from "./values.json"

export interface PopfileTextDocumentDependencies {
}

export class PopfileTextDocument extends VDFTextDocument<PopfileTextDocument, PopfileTextDocumentDependencies> {
export class PopfileTextDocument extends VDFTextDocument<PopfileTextDocument> {

public static readonly Schema: VDFTextDocumentSchema = {
keys: keys,
Expand Down
9 changes: 4 additions & 5 deletions packages/server/src/VDF/VDFLanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { LanguageServer, type CompletionFiles, type TextDocumentRequestParams }
import type { TextDocumentInit } from "../TextDocumentBase"
import type { VDFTextDocument, VDFTextDocumentDependencies } from "./VDFTextDocument"

export interface VDFLanguageServerConfiguration<TDocument extends VDFTextDocument<TDocument, TDependencies>, TDependencies> {
export interface VDFLanguageServerConfiguration<TDocument extends VDFTextDocument<TDocument>> {
name: "popfile" | "vdf" | "vmt"
servers: Set<VSCodeVDFLanguageID>
capabilities: ServerCapabilities
Expand All @@ -22,15 +22,14 @@ export interface VDFLanguageServerConfiguration<TDocument extends VDFTextDocumen

export abstract class VDFLanguageServer<
TLanguageId extends Extract<VSCodeVDFLanguageID, "popfile" | "vdf" | "vmt">,
TDocument extends VDFTextDocument<TDocument, TDependencies>,
TDependencies
TDocument extends VDFTextDocument<TDocument>,
> extends LanguageServer<TLanguageId, TDocument, VDFDocumentSymbols, VDFTextDocumentDependencies> {

protected readonly VDFLanguageServerConfiguration: VDFLanguageServerConfiguration<TDocument, TDependencies>
protected readonly VDFLanguageServerConfiguration: VDFLanguageServerConfiguration<TDocument>

private readonly documentsColours: Map<string, Map<string, (colour: Color) => string>>

constructor(languageId: TLanguageId, name: z.infer<typeof VSCodeVDFLanguageNameSchema>[TLanguageId], connection: Connection, VDFLanguageServerConfiguration: VDFLanguageServerConfiguration<TDocument, TDependencies>) {
constructor(languageId: TLanguageId, name: z.infer<typeof VSCodeVDFLanguageNameSchema>[TLanguageId], connection: Connection, VDFLanguageServerConfiguration: VDFLanguageServerConfiguration<TDocument>) {
super(languageId, name, connection, {
servers: VDFLanguageServerConfiguration.servers,
capabilities: {
Expand Down
8 changes: 4 additions & 4 deletions packages/server/src/VDF/VDFTextDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function resolveFileDetail(detail: string, configuration: VDFTextDocumentSchema[
).substring(1)
}

export interface VDFTextDocumentConfiguration<TDocument extends VDFTextDocument<TDocument, TDependencies>, TDependencies> {
export interface VDFTextDocumentConfiguration<TDocument extends VDFTextDocument<TDocument>> {
relativeFolderPath: string | null
VDFParserOptions: VDFParserOptions
keyTransform: (key: string) => string,
Expand Down Expand Up @@ -121,9 +121,9 @@ export interface DefinitionResult {
nameRange?: VDFRange
}

export abstract class VDFTextDocument<TDocument extends VDFTextDocument<TDocument, TDependencies>, TDependencies> extends TextDocumentBase<VDFDocumentSymbols, VDFTextDocumentDependencies> {
export abstract class VDFTextDocument<TDocument extends VDFTextDocument<TDocument>> extends TextDocumentBase<VDFDocumentSymbols, VDFTextDocumentDependencies> {

public readonly configuration: VDFTextDocumentConfiguration<TDocument, TDependencies>
public readonly configuration: VDFTextDocumentConfiguration<TDocument>

public readonly links$: Observable<(Omit<DocumentLink, "data"> & { data: { uri: Uri; resolve: () => Promise<Uri | null> } })[]>
public readonly colours$: Observable<(ColorInformation & { stringify(colour: Color): string })[]>
Expand All @@ -134,7 +134,7 @@ export abstract class VDFTextDocument<TDocument extends VDFTextDocument<TDocumen
fileSystem$: Observable<TeamFortress2FileSystem>,
documents: TextDocuments<TDocument>,
refCountDispose: (dispose: () => void) => void,
configuration: VDFTextDocumentConfiguration<TDocument, TDependencies>,
configuration: VDFTextDocumentConfiguration<TDocument>,
) {
super(init, documentConfiguration$, fileSystem$, refCountDispose, {
getDocumentSymbols: (text) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/VDF/VGUI/VGUILanguageServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { type Connection, type TextDocumentChangeEvent } from "vscode-languagese
import { z } from "zod"
import { References } from "../../DefinitionReferences"
import { VDFLanguageServer } from "../VDFLanguageServer"
import { VGUITextDocument, type VGUITextDocumentDependencies } from "./VGUITextDocument"
import { VGUITextDocument } from "./VGUITextDocument"
import { VGUIWorkspace } from "./VGUIWorkspace"

export class VGUILanguageServer extends VDFLanguageServer<"vdf", VGUITextDocument, VGUITextDocumentDependencies> {
export class VGUILanguageServer extends VDFLanguageServer<"vdf", VGUITextDocument> {

private readonly workspaces: Map<string, VGUIWorkspace>

Expand Down
5 changes: 1 addition & 4 deletions packages/server/src/VDF/VGUI/VGUITextDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import { LanguageTokensSchema } from "./schemas/LanguageTokensSchema"
import { SourceSchemeSchema } from "./schemas/SourceSchemeSchema"
import { VGUISchema } from "./schemas/VGUISchema"

export interface VGUITextDocumentDependencies {
}

export class VGUITextDocument extends VDFTextDocument<VGUITextDocument, VGUITextDocumentDependencies> {
export class VGUITextDocument extends VDFTextDocument<VGUITextDocument> {

public static KeyTransform = (key: string) => key.replace(/_(minmode|override|(lo|hi)def)$/, "")
public readonly workspace: VGUIWorkspace | null
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/VDF/VMT/VMTLanguageServer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type Connection } from "vscode-languageserver"
import type { WorkspaceBase } from "../../WorkspaceBase"
import { VDFLanguageServer } from "../VDFLanguageServer"
import { VMTTextDocument, type VMTTextDocumentDependencies } from "./VMTTextDocument"
import { VMTTextDocument } from "./VMTTextDocument"
import { VMTWorkspace } from "./VMTWorkspace"

export class VMTLanguageServer extends VDFLanguageServer<"vmt", VMTTextDocument, VMTTextDocumentDependencies> {
export class VMTLanguageServer extends VDFLanguageServer<"vmt", VMTTextDocument> {

private readonly workspaces: Map<string, VMTWorkspace>

Expand Down
5 changes: 1 addition & 4 deletions packages/server/src/VDF/VMT/VMTTextDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ import { VDFTextDocument, type VDFTextDocumentDependencies, type VDFTextDocument
import keys from "./keys.json"
import values from "./values.json"

export interface VMTTextDocumentDependencies {
}

export class VMTTextDocument extends VDFTextDocument<VMTTextDocument, VMTTextDocumentDependencies> {
export class VMTTextDocument extends VDFTextDocument<VMTTextDocument> {

public readonly workspace: WorkspaceBase | null

Expand Down

0 comments on commit f1c7941

Please sign in to comment.