33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 * ------------------------------------------------------------------------------------------ */
55
6- import * as minimatch from 'minimatch' ;
7-
86import {
97 Disposable , languages as Languages , window as Window , workspace as Workspace , CancellationToken , ProviderResult , Diagnostic as VDiagnostic ,
108 CancellationTokenSource , TextDocument , CancellationError , Event as VEvent , EventEmitter , DiagnosticCollection , Uri , workspace , NotebookCell
@@ -15,11 +13,12 @@ import {
1513 DidSaveTextDocumentNotification , DidCloseTextDocumentNotification , LinkedMap , Touch , RAL , TextDocumentFilter , PreviousResultId ,
1614 DiagnosticRegistrationOptions , DiagnosticServerCancellationData , DocumentDiagnosticParams , DocumentDiagnosticRequest , DocumentDiagnosticReportKind ,
1715 WorkspaceDocumentDiagnosticReport , WorkspaceDiagnosticRequest , WorkspaceDiagnosticParams , DiagnosticOptions , DiagnosticRefreshRequest , DiagnosticTag ,
18- NotebookDocumentSyncRegistrationType ,
19- type GlobPattern
16+ NotebookDocumentSyncRegistrationType
2017} from 'vscode-languageserver-protocol' ;
2118
2219import { generateUuid } from './utils/uuid' ;
20+ import { matchGlobPattern } from './utils/globPattern' ;
21+
2322import {
2423 TextDocumentLanguageFeature , FeatureClient , LSPCancellationError , type TabsModel
2524} from './features' ;
@@ -756,27 +755,6 @@ class BackgroundScheduler implements Disposable {
756755 }
757756}
758757
759- export namespace $GlobPattern {
760- export function match ( pattern : GlobPattern , resource : Uri ) : boolean {
761- let miniMatchPattern : string ;
762- if ( typeof pattern === 'string' ) {
763- miniMatchPattern = pattern . replace ( / \\ / g, '/' ) ;
764- } else {
765- try {
766- const baseUri = Uri . parse ( typeof pattern . baseUri === 'string' ? pattern . baseUri : pattern . baseUri . uri ) ;
767- miniMatchPattern = baseUri . with ( { path : baseUri . path + '/' + pattern . pattern } ) . fsPath . replace ( / \\ / g, '/' ) ;
768- } catch ( error ) {
769- return false ;
770- }
771- }
772- const matcher = new minimatch . Minimatch ( miniMatchPattern , { noext : true } ) ;
773- if ( ! matcher . makeRe ( ) ) {
774- return false ;
775- }
776- return matcher . match ( resource . fsPath ) ;
777- }
778- }
779-
780758class DiagnosticFeatureProviderImpl implements DiagnosticProviderShape {
781759
782760 public readonly disposable : Disposable ;
@@ -802,7 +780,7 @@ class DiagnosticFeatureProviderImpl implements DiagnosticProviderShape {
802780 if ( filter . scheme !== undefined && filter . scheme !== '*' && filter . scheme !== resource . scheme ) {
803781 return false ;
804782 }
805- if ( filter . pattern !== undefined && ! $GlobPattern . match ( filter . pattern , resource ) ) {
783+ if ( filter . pattern !== undefined && ! matchGlobPattern ( filter . pattern , resource ) ) {
806784 return false ;
807785 }
808786 return true ;
0 commit comments