@@ -9,7 +9,7 @@ import { IDisposable } from '../Disposable';
99
1010export default class DefinitionMetadataDocumentProvider implements TextDocumentContentProvider , IDisposable {
1111 readonly scheme = "omnisharp-metadata" ;
12- private _registration : IDisposable ;
12+ private _registration : IDisposable ;
1313 private _documents : Map < string , MetadataResponse > ;
1414 private _documentClosedSubscription : IDisposable ;
1515
@@ -18,36 +18,41 @@ export default class DefinitionMetadataDocumentProvider implements TextDocumentC
1818 this . _documentClosedSubscription = workspace . onDidCloseTextDocument ( this . onTextDocumentClosed , this ) ;
1919 }
2020
21- private onTextDocumentClosed ( document : TextDocument ) : void {
21+ private onTextDocumentClosed ( document : TextDocument ) : void {
2222 this . _documents . delete ( document . uri . toString ( ) ) ;
2323 }
2424
25- public dispose ( ) : void {
25+ public dispose ( ) : void {
2626 this . _registration . dispose ( ) ;
2727 this . _documentClosedSubscription . dispose ( ) ;
2828 this . _documents . clear ( ) ;
2929 }
3030
31- public addMetadataResponse ( metadataResponse : MetadataResponse ) : Uri {
31+ public addMetadataResponse ( metadataResponse : MetadataResponse ) : Uri {
3232 const uri = this . createUri ( metadataResponse . SourceName ) ;
3333 this . _documents . set ( uri . toString ( ) , metadataResponse ) ;
3434
3535 return uri ;
3636 }
3737
38- public getExistingMetadataResponseUri ( sourceName : string ) : Uri {
38+ public getExistingMetadataResponseUri ( sourceName : string ) : Uri {
3939 return this . createUri ( sourceName ) ;
4040 }
4141
42- public register ( ) : void {
42+ public hasMetadataDocument ( sourceName : string ) : boolean {
43+ const uri = this . createUri ( sourceName ) ;
44+ return this . _documents . has ( uri . toString ( ) ) ;
45+ }
46+
47+ public register ( ) : void {
4348 this . _registration = workspace . registerTextDocumentContentProvider ( this . scheme , this ) ;
4449 }
4550
46- public provideTextDocumentContent ( uri : Uri ) : string {
47- return this . _documents . get ( uri . toString ( ) ) . Source ;
51+ public provideTextDocumentContent ( uri : Uri ) : string {
52+ return this . _documents . get ( uri . toString ( ) ) ? .Source ;
4853 }
4954
50- private createUri ( sourceName : string ) : Uri {
55+ private createUri ( sourceName : string ) : Uri {
5156 return Uri . parse ( this . scheme + "://" +
5257 sourceName . replace ( / \\ / g, "/" ) . replace ( / ( .* ) \/ ( .* ) / g, "$1/[metadata] $2" ) ) ;
5358 }
0 commit comments