mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-28 04:23:32 +01:00
Rename types in the markdown extension (#152905)
Renames in the markdown extension This renames some types and splits up some files as part of an exploration towards a proper LSP. Changes: - `SkinnyTextDocument` -> `ITextDocument` - Moved `ITextDocument` to own file - `MdWorkspaceContents` -> `IMdWorkspace`
This commit is contained in:
@@ -7,10 +7,11 @@ import * as vscode from 'vscode';
|
||||
import { ILogger } from './logging';
|
||||
import { IMdParser } from './markdownEngine';
|
||||
import { githubSlugifier, Slug, Slugifier } from './slugify';
|
||||
import { ITextDocument } from './types/textDocument';
|
||||
import { Disposable } from './util/dispose';
|
||||
import { isMarkdownFile } from './util/file';
|
||||
import { MdDocumentInfoCache } from './util/workspaceCache';
|
||||
import { MdWorkspaceContents, SkinnyTextDocument } from './workspaceContents';
|
||||
import { IMdWorkspace } from './workspace';
|
||||
|
||||
export interface TocEntry {
|
||||
readonly slug: Slug;
|
||||
@@ -64,12 +65,12 @@ export interface TocEntry {
|
||||
|
||||
export class TableOfContents {
|
||||
|
||||
public static async create(parser: IMdParser, document: SkinnyTextDocument,): Promise<TableOfContents> {
|
||||
public static async create(parser: IMdParser, document: ITextDocument,): Promise<TableOfContents> {
|
||||
const entries = await this.buildToc(parser, document);
|
||||
return new TableOfContents(entries, parser.slugifier);
|
||||
}
|
||||
|
||||
public static async createForDocumentOrNotebook(parser: IMdParser, document: SkinnyTextDocument): Promise<TableOfContents> {
|
||||
public static async createForDocumentOrNotebook(parser: IMdParser, document: ITextDocument): Promise<TableOfContents> {
|
||||
if (document.uri.scheme === 'vscode-notebook-cell') {
|
||||
const notebook = vscode.workspace.notebookDocuments
|
||||
.find(notebook => notebook.getCells().some(cell => cell.document === document));
|
||||
@@ -90,7 +91,7 @@ export class TableOfContents {
|
||||
return this.create(parser, document);
|
||||
}
|
||||
|
||||
private static async buildToc(parser: IMdParser, document: SkinnyTextDocument): Promise<TocEntry[]> {
|
||||
private static async buildToc(parser: IMdParser, document: ITextDocument): Promise<TocEntry[]> {
|
||||
const toc: TocEntry[] = [];
|
||||
const tokens = await parser.tokenize(document);
|
||||
|
||||
@@ -183,11 +184,11 @@ export class MdTableOfContentsProvider extends Disposable {
|
||||
|
||||
constructor(
|
||||
parser: IMdParser,
|
||||
workspaceContents: MdWorkspaceContents,
|
||||
workspace: IMdWorkspace,
|
||||
private readonly logger: ILogger,
|
||||
) {
|
||||
super();
|
||||
this._cache = this._register(new MdDocumentInfoCache<TableOfContents>(workspaceContents, doc => {
|
||||
this._cache = this._register(new MdDocumentInfoCache<TableOfContents>(workspace, doc => {
|
||||
this.logger.verbose('TableOfContentsProvider', `create - ${doc.uri}`);
|
||||
return TableOfContents.create(parser, doc);
|
||||
}));
|
||||
@@ -197,7 +198,7 @@ export class MdTableOfContentsProvider extends Disposable {
|
||||
return await this._cache.get(resource) ?? TableOfContents.empty;
|
||||
}
|
||||
|
||||
public getForDocument(doc: SkinnyTextDocument): Promise<TableOfContents> {
|
||||
public getForDocument(doc: ITextDocument): Promise<TableOfContents> {
|
||||
return this._cache.getForDocument(doc);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user