@@ -9,14 +9,15 @@ import * as nls from 'vscode-nls';
9
9
import { CommandManager } from '../commandManager' ;
10
10
import { ILogger } from '../logging' ;
11
11
import { MdTableOfContentsProvider } from '../tableOfContents' ;
12
+ import { ITextDocument } from '../types/textDocument' ;
12
13
import { Delayer } from '../util/async' ;
13
14
import { noopToken } from '../util/cancellation' ;
14
15
import { Disposable } from '../util/dispose' ;
15
16
import { isMarkdownFile , looksLikeMarkdownPath } from '../util/file' ;
16
17
import { Limiter } from '../util/limiter' ;
17
18
import { ResourceMap } from '../util/resourceMap' ;
18
19
import { MdTableOfContentsWatcher } from '../util/tableOfContentsWatcher' ;
19
- import { MdWorkspaceContents , SkinnyTextDocument } from '../workspaceContents ' ;
20
+ import { IMdWorkspace } from '../workspace ' ;
20
21
import { InternalHref , LinkDefinitionSet , MdLink , MdLinkProvider , MdLinkSource } from './documentLinks' ;
21
22
import { MdReferencesProvider , tryResolveLinkPath } from './references' ;
22
23
@@ -305,7 +306,7 @@ export class DiagnosticManager extends Disposable {
305
306
public readonly ready : Promise < void > ;
306
307
307
308
constructor (
308
- private readonly workspaceContents : MdWorkspaceContents ,
309
+ private readonly workspace : IMdWorkspace ,
309
310
private readonly computer : DiagnosticComputer ,
310
311
private readonly configuration : DiagnosticConfiguration ,
311
312
private readonly reporter : DiagnosticReporter ,
@@ -322,17 +323,17 @@ export class DiagnosticManager extends Disposable {
322
323
this . rebuild ( ) ;
323
324
} ) ) ;
324
325
325
- this . _register ( workspaceContents . onDidCreateMarkdownDocument ( doc => {
326
+ this . _register ( workspace . onDidCreateMarkdownDocument ( doc => {
326
327
this . triggerDiagnostics ( doc . uri ) ;
327
328
// Links in other files may have become valid
328
329
this . triggerForReferencingFiles ( doc . uri ) ;
329
330
} ) ) ;
330
331
331
- this . _register ( workspaceContents . onDidChangeMarkdownDocument ( doc => {
332
+ this . _register ( workspace . onDidChangeMarkdownDocument ( doc => {
332
333
this . triggerDiagnostics ( doc . uri ) ;
333
334
} ) ) ;
334
335
335
- this . _register ( workspaceContents . onDidDeleteMarkdownDocument ( uri => {
336
+ this . _register ( workspace . onDidDeleteMarkdownDocument ( uri => {
336
337
this . triggerForReferencingFiles ( uri ) ;
337
338
} ) ) ;
338
339
@@ -352,7 +353,7 @@ export class DiagnosticManager extends Disposable {
352
353
}
353
354
} ) ) ;
354
355
355
- this . tableOfContentsWatcher = this . _register ( new MdTableOfContentsWatcher ( workspaceContents , tocProvider , delay / 2 ) ) ;
356
+ this . tableOfContentsWatcher = this . _register ( new MdTableOfContentsWatcher ( workspace , tocProvider , delay / 2 ) ) ;
356
357
this . _register ( this . tableOfContentsWatcher . onTocChanged ( e => {
357
358
return this . triggerForReferencingFiles ( e . uri ) ;
358
359
} ) ) ;
@@ -379,7 +380,7 @@ export class DiagnosticManager extends Disposable {
379
380
this . pendingDiagnostics . clear ( ) ;
380
381
}
381
382
382
- private async recomputeDiagnosticState ( doc : SkinnyTextDocument , token : vscode . CancellationToken ) : Promise < { diagnostics : readonly vscode . Diagnostic [ ] ; links : readonly MdLink [ ] ; config : DiagnosticOptions } > {
383
+ private async recomputeDiagnosticState ( doc : ITextDocument , token : vscode . CancellationToken ) : Promise < { diagnostics : readonly vscode . Diagnostic [ ] ; links : readonly MdLink [ ] ; config : DiagnosticOptions } > {
383
384
this . logger . verbose ( 'DiagnosticManager' , `recomputeDiagnosticState - ${ doc . uri } ` ) ;
384
385
385
386
const config = this . configuration . getOptions ( doc . uri ) ;
@@ -394,7 +395,7 @@ export class DiagnosticManager extends Disposable {
394
395
this . pendingDiagnostics . clear ( ) ;
395
396
396
397
await Promise . all ( pending . map ( async resource => {
397
- const doc = await this . workspaceContents . getOrLoadMarkdownDocument ( resource ) ;
398
+ const doc = await this . workspace . getOrLoadMarkdownDocument ( resource ) ;
398
399
if ( doc ) {
399
400
await this . inFlightDiagnostics . trigger ( doc . uri , async ( token ) => {
400
401
if ( this . reporter . areDiagnosticsEnabled ( doc . uri ) ) {
@@ -419,7 +420,7 @@ export class DiagnosticManager extends Disposable {
419
420
( async ( ) => {
420
421
// TODO: This pulls in all md files in the workspace. Instead we only care about opened text documents.
421
422
// Need a new way to handle that.
422
- const allDocs = await this . workspaceContents . getAllMarkdownDocuments ( ) ;
423
+ const allDocs = await this . workspace . getAllMarkdownDocuments ( ) ;
423
424
await Promise . all ( Array . from ( allDocs , doc => this . triggerDiagnostics ( doc . uri ) ) ) ;
424
425
} ) ( )
425
426
) ;
@@ -475,12 +476,12 @@ class FileLinkMap {
475
476
export class DiagnosticComputer {
476
477
477
478
constructor (
478
- private readonly workspaceContents : MdWorkspaceContents ,
479
+ private readonly workspace : IMdWorkspace ,
479
480
private readonly linkProvider : MdLinkProvider ,
480
481
private readonly tocProvider : MdTableOfContentsProvider ,
481
482
) { }
482
483
483
- public async getDiagnostics ( doc : SkinnyTextDocument , options : DiagnosticOptions , token : vscode . CancellationToken ) : Promise < { readonly diagnostics : vscode . Diagnostic [ ] ; readonly links : readonly MdLink [ ] } > {
484
+ public async getDiagnostics ( doc : ITextDocument , options : DiagnosticOptions , token : vscode . CancellationToken ) : Promise < { readonly diagnostics : vscode . Diagnostic [ ] ; readonly links : readonly MdLink [ ] } > {
484
485
const { links, definitions } = await this . linkProvider . getLinks ( doc ) ;
485
486
if ( token . isCancellationRequested || ! options . enabled ) {
486
487
return { links, diagnostics : [ ] } ;
@@ -496,7 +497,7 @@ export class DiagnosticComputer {
496
497
} ;
497
498
}
498
499
499
- private async validateFragmentLinks ( doc : SkinnyTextDocument , options : DiagnosticOptions , links : readonly MdLink [ ] , token : vscode . CancellationToken ) : Promise < vscode . Diagnostic [ ] > {
500
+ private async validateFragmentLinks ( doc : ITextDocument , options : DiagnosticOptions , links : readonly MdLink [ ] , token : vscode . CancellationToken ) : Promise < vscode . Diagnostic [ ] > {
500
501
const severity = toSeverity ( options . validateFragmentLinks ) ;
501
502
if ( typeof severity === 'undefined' ) {
502
503
return [ ] ;
@@ -567,7 +568,7 @@ export class DiagnosticComputer {
567
568
return ;
568
569
}
569
570
570
- const resolvedHrefPath = await tryResolveLinkPath ( path , this . workspaceContents ) ;
571
+ const resolvedHrefPath = await tryResolveLinkPath ( path , this . workspace ) ;
571
572
if ( ! resolvedHrefPath ) {
572
573
const msg = localize ( 'invalidPathLink' , 'File does not exist at path: {0}' , path . fsPath ) ;
573
574
for ( const link of links ) {
@@ -595,7 +596,7 @@ export class DiagnosticComputer {
595
596
}
596
597
597
598
private isMarkdownPath ( resolvedHrefPath : vscode . Uri ) {
598
- return this . workspaceContents . hasMarkdownDocument ( resolvedHrefPath ) || looksLikeMarkdownPath ( resolvedHrefPath ) ;
599
+ return this . workspace . hasMarkdownDocument ( resolvedHrefPath ) || looksLikeMarkdownPath ( resolvedHrefPath ) ;
599
600
}
600
601
601
602
private isIgnoredLink ( options : DiagnosticOptions , link : string ) : boolean {
@@ -652,7 +653,7 @@ class AddToIgnoreLinksQuickFixProvider implements vscode.CodeActionProvider {
652
653
653
654
export function registerDiagnosticSupport (
654
655
selector : vscode . DocumentSelector ,
655
- workspaceContents : MdWorkspaceContents ,
656
+ workspace : IMdWorkspace ,
656
657
linkProvider : MdLinkProvider ,
657
658
commandManager : CommandManager ,
658
659
referenceProvider : MdReferencesProvider ,
@@ -661,8 +662,8 @@ export function registerDiagnosticSupport(
661
662
) : vscode . Disposable {
662
663
const configuration = new VSCodeDiagnosticConfiguration ( ) ;
663
664
const manager = new DiagnosticManager (
664
- workspaceContents ,
665
- new DiagnosticComputer ( workspaceContents , linkProvider , tocProvider ) ,
665
+ workspace ,
666
+ new DiagnosticComputer ( workspace , linkProvider , tocProvider ) ,
666
667
configuration ,
667
668
new DiagnosticCollectionReporter ( ) ,
668
669
referenceProvider ,
0 commit comments