UNPKG

6.83 kBTypeScriptView Raw
1/**
2 * Represents a reference to a declaration.
3 * @beta
4 */
5export declare class DeclarationReference {
6 private _source;
7 private _navigation;
8 private _symbol;
9 constructor(source?: ModuleSource | GlobalSource, navigation?: Navigation.Locals | Navigation.Exports, symbol?: SymbolReference);
10 get source(): ModuleSource | GlobalSource | undefined;
11 get navigation(): Navigation.Locals | Navigation.Exports | undefined;
12 get symbol(): SymbolReference | undefined;
13 get isEmpty(): boolean;
14 static parse(text: string): DeclarationReference;
15 static parseComponent(text: string): Component;
16 /**
17 * Determines whether the provided string is a well-formed symbol navigation component string.
18 */
19 static isWellFormedComponentString(text: string): boolean;
20 /**
21 * Escapes a string for use as a symbol navigation component. If the string contains any of `!.#~:,"{}()@` or starts
22 * with `[`, it is enclosed in quotes.
23 */
24 static escapeComponentString(text: string): string;
25 /**
26 * Unescapes a string used as a symbol navigation component.
27 */
28 static unescapeComponentString(text: string): string;
29 /**
30 * Determines whether the provided string is a well-formed module source string. The string may not
31 * have a trailing `!` character.
32 */
33 static isWellFormedModuleSourceString(text: string): boolean;
34 /**
35 * Escapes a string for use as a module source. If the string contains any of `!"` it is enclosed in quotes.
36 */
37 static escapeModuleSourceString(text: string): string;
38 /**
39 * Unescapes a string used as a module source. The string may not have a trailing `!` character.
40 */
41 static unescapeModuleSourceString(text: string): string;
42 static empty(): DeclarationReference;
43 static package(packageName: string, importPath?: string): DeclarationReference;
44 static module(path: string, userEscaped?: boolean): DeclarationReference;
45 static global(): DeclarationReference;
46 static from(base: DeclarationReference | undefined): DeclarationReference;
47 withSource(source: ModuleSource | GlobalSource | undefined): DeclarationReference;
48 withNavigation(navigation: Navigation.Locals | Navigation.Exports | undefined): DeclarationReference;
49 withSymbol(symbol: SymbolReference | undefined): DeclarationReference;
50 withComponentPath(componentPath: ComponentPath): DeclarationReference;
51 withMeaning(meaning: Meaning | undefined): DeclarationReference;
52 withOverloadIndex(overloadIndex: number | undefined): DeclarationReference;
53 addNavigationStep(navigation: Navigation, component: ComponentLike): DeclarationReference;
54 toString(): string;
55}
56/**
57 * Indicates the symbol table from which to resolve the next symbol component.
58 * @beta
59 */
60export declare const enum Navigation {
61 Exports = ".",
62 Members = "#",
63 Locals = "~"
64}
65/**
66 * Represents a module.
67 * @beta
68 */
69export declare class ModuleSource {
70 readonly escapedPath: string;
71 private _path;
72 private _pathComponents;
73 constructor(path: string, userEscaped?: boolean);
74 get path(): string;
75 get packageName(): string;
76 get scopeName(): string;
77 get unscopedPackageName(): string;
78 get importPath(): string;
79 static fromScopedPackage(scopeName: string | undefined, unscopedPackageName: string, importPath?: string): ModuleSource;
80 static fromPackage(packageName: string, importPath?: string): ModuleSource;
81 private static _fromPackageName;
82 toString(): string;
83 private _getOrParsePathComponents;
84}
85/**
86 * Represents the global scope.
87 * @beta
88 */
89export declare class GlobalSource {
90 static readonly instance: GlobalSource;
91 private constructor();
92 toString(): string;
93}
94/**
95 * @beta
96 */
97export declare type Component = ComponentString | ComponentReference;
98/**
99 * @beta
100 */
101export declare namespace Component {
102 function from(value: ComponentLike): Component;
103}
104/**
105 * @beta
106 */
107export declare type ComponentLike = Component | DeclarationReference | string;
108/**
109 * @beta
110 */
111export declare class ComponentString {
112 readonly text: string;
113 constructor(text: string, userEscaped?: boolean);
114 toString(): string;
115}
116/**
117 * @beta
118 */
119export declare class ComponentReference {
120 readonly reference: DeclarationReference;
121 constructor(reference: DeclarationReference);
122 static parse(text: string): ComponentReference;
123 withReference(reference: DeclarationReference): ComponentReference;
124 toString(): string;
125}
126/**
127 * @beta
128 */
129export declare type ComponentPath = ComponentRoot | ComponentNavigation;
130/**
131 * @beta
132 */
133export declare abstract class ComponentPathBase {
134 readonly component: Component;
135 constructor(component: Component);
136 addNavigationStep(this: ComponentPath, navigation: Navigation, component: ComponentLike): ComponentPath;
137 abstract toString(): string;
138}
139/**
140 * @beta
141 */
142export declare class ComponentRoot extends ComponentPathBase {
143 withComponent(component: ComponentLike): ComponentRoot;
144 toString(): string;
145}
146/**
147 * @beta
148 */
149export declare class ComponentNavigation extends ComponentPathBase {
150 readonly parent: ComponentPath;
151 readonly navigation: Navigation;
152 constructor(parent: ComponentPath, navigation: Navigation, component: Component);
153 withParent(parent: ComponentPath): ComponentNavigation;
154 withNavigation(navigation: Navigation): ComponentNavigation;
155 withComponent(component: ComponentLike): ComponentNavigation;
156 toString(): string;
157}
158/**
159 * @beta
160 */
161export declare const enum Meaning {
162 Class = "class",
163 Interface = "interface",
164 TypeAlias = "type",
165 Enum = "enum",
166 Namespace = "namespace",
167 Function = "function",
168 Variable = "var",
169 Constructor = "constructor",
170 Member = "member",
171 Event = "event",
172 CallSignature = "call",
173 ConstructSignature = "new",
174 IndexSignature = "index",
175 ComplexType = "complex"
176}
177/**
178 * @beta
179 */
180export interface ISymbolReferenceOptions {
181 meaning?: Meaning;
182 overloadIndex?: number;
183}
184/**
185 * Represents a reference to a TypeScript symbol.
186 * @beta
187 */
188export declare class SymbolReference {
189 readonly componentPath: ComponentPath | undefined;
190 readonly meaning: Meaning | undefined;
191 readonly overloadIndex: number | undefined;
192 constructor(component: ComponentPath | undefined, { meaning, overloadIndex }?: ISymbolReferenceOptions);
193 static empty(): SymbolReference;
194 withComponentPath(componentPath: ComponentPath | undefined): SymbolReference;
195 withMeaning(meaning: Meaning | undefined): SymbolReference;
196 withOverloadIndex(overloadIndex: number | undefined): SymbolReference;
197 addNavigationStep(navigation: Navigation, component: ComponentLike): SymbolReference;
198 toString(): string;
199}
200//# sourceMappingURL=DeclarationReference.d.ts.map
\No newline at end of file