@bscotch/gml-parser
Version:
A parser for GML (GameMaker Language) files for programmatic manipulation and analysis of GameMaker projects.
130 lines • 6.04 kB
TypeScript
import type { Pathy } from '@bscotch/pathy';
import type { JsdocSummary } from './jsdoc.js';
import { ObjectEvent } from './lib.objects.js';
import { type GmlParsed } from './parser.js';
import type { Asset } from './project.asset.js';
import { Diagnostic, DiagnosticCollectionName, DiagnosticCollections } from './project.diagnostics.js';
import { FunctionArgRange, IPosition, IRange, LinePosition, Position, Range, Reference, Scope, StructNewMemberRange } from './project.location.js';
import type { Signifier } from './signifiers.js';
import { type StructType } from './types.js';
/** Represenation of a GML code file. */
export declare class Code {
readonly asset: Asset;
readonly path: Pathy<string>;
readonly $tag = "gmlFile";
readonly scopes: Scope[];
readonly jsdocs: JsdocSummary[];
protected diagnostics: DiagnosticCollections;
/** List of all symbol references in this file, in order of appearance. */
protected _refs: Reference[];
/** Ranges representing function call arguments,
* in order of appearance. Useful for signature help. */
protected _functionArgRanges: FunctionArgRange[];
/** Ranges representing locations where new struct
* members could be added. Useful for autocomplete. */
protected _structNewMemberRanges: StructNewMemberRange[];
/** List of function calls, where each root item is a list
* of argument ranges for that call. Useful for diagnostics.*/
protected _functionCalls: FunctionArgRange[][];
protected _rangesAreSorted: boolean;
content: string;
protected _parsed: GmlParsed;
/** For object events, whether or not `event_inherited` is unambiguously being called */
callsSuper: boolean;
constructor(asset: Asset, path: Pathy<string>);
/**
* If this is the Create event for an object, that object's
* variables. Else undefined. Used for determining the initial
* "definitive self" during code processing.
*/
get definitiveSelf(): StructType | undefined;
/** When set to `true`, this file will be flagged for reprocessing. */
set dirty(value: boolean);
get isScript(): boolean;
get isObjectEvent(): boolean;
get isCreateEvent(): boolean;
get isStepEvent(): boolean;
get project(): import("./project.js").Project;
get startPosition(): Position;
/**
* If this is an object event and Stitch knows about
* its type, return the info about that event.
*/
get objectEventInfo(): ObjectEvent | undefined;
/** A zero-length range at the start of the file. */
get startRange(): Range;
protected isInRange(range: {
start: IPosition;
end: IPosition;
}, offset: number | LinePosition): boolean;
protected isBeforeRange(range: IRange, offset: number | LinePosition): boolean;
getTextAt(offsetStart: number, offsetEnd: number): string;
getReferenceAt(offset: number): Reference | undefined;
getReferenceAt(position: LinePosition): Reference | undefined;
getReferenceAt(line: number, column: number): Reference | undefined;
getJsdocAt(offset: number | LinePosition, column?: number): JsdocSummary | undefined;
getFunctionArgRangeAt(offset: number | LinePosition, column?: number): FunctionArgRange | undefined;
getStructNewMemberRangeAt(offset: number | LinePosition, column?: number): StructNewMemberRange | undefined;
getScopeRangeAt(offset: number | LinePosition, column?: number): Scope | undefined;
getInScopeSymbolsAt(offset: number | LinePosition, column?: number): Signifier[];
getDiagnostics(): {
GLOBAL_SELF: Diagnostic[];
INVALID_OPERATION: Diagnostic[];
JSDOC_MISMATCH: Diagnostic[];
MISSING_EVENT_INHERITED: Diagnostic[];
MISSING_REQUIRED_ARGUMENT: Diagnostic[];
SYNTAX_ERROR: Diagnostic[];
TOO_MANY_ARGUMENTS: Diagnostic[];
UNDECLARED_VARIABLE_REFERENCE: Diagnostic[];
UNDECLARED_GLOBAL_REFERENCE: Diagnostic[];
JSDOC: Diagnostic[];
UNUSED: Diagnostic[];
};
get refs(): Reference[];
get functionArgRanges(): FunctionArgRange[];
get structNewMemberRanges(): StructNewMemberRange[];
get name(): string;
get basename(): string;
get cst(): import("chevrotain").CstNode;
/**
* Load the file and parse it, resulting in an updated
* CST for future steps. If content is directly provided,
* it will be used instead of reading from disk. This
* is useful for editors that want to provide a live preview.
*/
parse(content?: string): Promise<void>;
/**
* Replace all refs for a signifier with a new name,
* followed by fully reprocessing the file.
*/
renameSignifier(signifier: Signifier, newName: string): Promise<void>;
clearDiagnosticCollection(collection: DiagnosticCollectionName): void;
protected clearAllDiagnostics(): void;
addDiagnostic(collection: DiagnosticCollectionName, diagnostic: Diagnostic): void;
addRef(ref: Reference): void;
addStructNewMemberRange(range: StructNewMemberRange): void;
addFunctionArgRange(range: FunctionArgRange): void;
addFunctionCall(call: FunctionArgRange[]): void;
protected sortRanges(): void;
protected initializeScopeRanges(): void;
protected reset(): void;
protected removeFromYy(): Promise<void>;
remove(): Promise<void>;
/**
* Reprocess after a modification to the file. Optionally
* provide new content to use instead of reading from disk.
*/
reload(content?: string, options?: {
reloadDirty?: boolean;
}): Promise<void>;
protected discoverEventInheritanceWarnings(): void;
protected computeFunctionCallDiagnostics(): void;
protected computeUndeclaredSymbolDiagnostics(): void;
protected computeJsdocDiagnostics(): void;
computeUnusedSymbolDiagnostics(): void;
/** Update and emit diagnostics */
updateDiagnostics(): Diagnostic[];
updateGlobals(): void;
updateAllSymbols(): void;
}
//# sourceMappingURL=project.code.d.ts.map