@knodes/typedoc-pluginutils
Version:
A set of utilities for TypeDoc plugins
53 lines • 1.7 kB
TypeScript
interface ISourceEdit {
from: number;
source: string;
replacement: string;
}
export interface ISourceMap {
line: number;
column: number;
layers: SourceMapLayer[];
pos: number;
}
export declare class SourceMapLayer {
readonly label: string;
readonly originalText: string;
private readonly _parentLayer?;
readonly editions: ISourceEdit[];
private _resultingText;
get resultingText(): string;
constructor(label: string, originalText: string, _parentLayer?: SourceMapLayer | undefined);
/**
* Add a new edition to this layer.
*
* @param from - The position where the edit starts.
* @param source - The original content.
* @param replacement - The replacement content.
*/
addEdition(from: number, source: string, replacement: string): void;
/**
* Return a string describing the position of the given index in the source file.
*
* @param sourceFile - The source file name.
* @param index - The char index.
* @returns a string like `"hello.ts:42:84" (in expansion of @tag1 ⇒ @tag2)"
*/
sourceHint(sourceFile: string | undefined, index: number): string;
/**
* Map the given {@link pos} in the 1st layer's content.
*
* @param pos - The character index.
* @param mapSelf - A flag indicating if this layer's editions should be mapped.
* @returns the source map.
*/
private _getSourceMap;
/**
* Remap the given position in this layer's editions.
*
* @param pos - The character position.
* @returns the mapped position.
*/
private _remapSelfEditPos;
}
export {};
//# sourceMappingURL=source-map-layer.d.ts.map