mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-04 07:15:54 +01:00
Adopt prefix private with _ in markdown extension (#165088)
This commit is contained in:
@@ -18,12 +18,12 @@ type DirWatcherEntry = {
|
||||
|
||||
export class FileWatcherManager {
|
||||
|
||||
private readonly fileWatchers = new Map<number, {
|
||||
private readonly _fileWatchers = new Map<number, {
|
||||
readonly watcher: vscode.FileSystemWatcher;
|
||||
readonly dirWatchers: DirWatcherEntry[];
|
||||
}>();
|
||||
|
||||
private readonly dirWatchers = new ResourceMap<{
|
||||
private readonly _dirWatchers = new ResourceMap<{
|
||||
readonly watcher: vscode.FileSystemWatcher;
|
||||
refCount: number;
|
||||
}>();
|
||||
@@ -31,7 +31,7 @@ export class FileWatcherManager {
|
||||
create(id: number, uri: vscode.Uri, watchParentDirs: boolean, listeners: { create?: () => void; change?: () => void; delete?: () => void }): void {
|
||||
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(uri, '*'), !listeners.create, !listeners.change, !listeners.delete);
|
||||
const parentDirWatchers: DirWatcherEntry[] = [];
|
||||
this.fileWatchers.set(id, { watcher, dirWatchers: parentDirWatchers });
|
||||
this._fileWatchers.set(id, { watcher, dirWatchers: parentDirWatchers });
|
||||
|
||||
if (listeners.create) { watcher.onDidCreate(listeners.create); }
|
||||
if (listeners.change) { watcher.onDidChange(listeners.change); }
|
||||
@@ -42,12 +42,12 @@ export class FileWatcherManager {
|
||||
for (let dirUri = Utils.dirname(uri); dirUri.path.length > 1; dirUri = Utils.dirname(dirUri)) {
|
||||
const dirWatcher: DirWatcherEntry = { uri: dirUri, listeners: [] };
|
||||
|
||||
let parentDirWatcher = this.dirWatchers.get(dirUri);
|
||||
let parentDirWatcher = this._dirWatchers.get(dirUri);
|
||||
if (!parentDirWatcher) {
|
||||
const glob = new vscode.RelativePattern(Utils.dirname(dirUri), Utils.basename(dirUri));
|
||||
const parentWatcher = vscode.workspace.createFileSystemWatcher(glob, !listeners.create, true, !listeners.delete);
|
||||
parentDirWatcher = { refCount: 0, watcher: parentWatcher };
|
||||
this.dirWatchers.set(dirUri, parentDirWatcher);
|
||||
this._dirWatchers.set(dirUri, parentDirWatcher);
|
||||
}
|
||||
parentDirWatcher.refCount++;
|
||||
|
||||
@@ -77,16 +77,16 @@ export class FileWatcherManager {
|
||||
}
|
||||
|
||||
delete(id: number): void {
|
||||
const entry = this.fileWatchers.get(id);
|
||||
const entry = this._fileWatchers.get(id);
|
||||
if (entry) {
|
||||
for (const dirWatcher of entry.dirWatchers) {
|
||||
disposeAll(dirWatcher.listeners);
|
||||
|
||||
const dirWatcherEntry = this.dirWatchers.get(dirWatcher.uri);
|
||||
const dirWatcherEntry = this._dirWatchers.get(dirWatcher.uri);
|
||||
if (dirWatcherEntry) {
|
||||
if (--dirWatcherEntry.refCount <= 0) {
|
||||
dirWatcherEntry.watcher.dispose();
|
||||
this.dirWatchers.delete(dirWatcher.uri);
|
||||
this._dirWatchers.delete(dirWatcher.uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,6 @@ export class FileWatcherManager {
|
||||
entry.watcher.dispose();
|
||||
}
|
||||
|
||||
this.fileWatchers.delete(id);
|
||||
this._fileWatchers.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ export class InMemoryDocument implements ITextDocument {
|
||||
|
||||
constructor(
|
||||
public readonly uri: vscode.Uri,
|
||||
private readonly contents: string,
|
||||
private readonly _contents: string,
|
||||
public readonly version = 0,
|
||||
) { }
|
||||
|
||||
getText(): string {
|
||||
return this.contents;
|
||||
return this._contents;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class VsCodeMdWorkspace extends Disposable {
|
||||
|
||||
private readonly _documentCache = new ResourceMap<ITextDocument>();
|
||||
|
||||
private readonly utf8Decoder = new TextDecoder('utf-8');
|
||||
private readonly _utf8Decoder = new TextDecoder('utf-8');
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -45,7 +45,7 @@ export class VsCodeMdWorkspace extends Disposable {
|
||||
}));
|
||||
}
|
||||
|
||||
private isRelevantMarkdownDocument(doc: vscode.TextDocument) {
|
||||
private _isRelevantMarkdownDocument(doc: vscode.TextDocument) {
|
||||
return isMarkdownFile(doc) && doc.uri.scheme !== 'vscode-bulkeditpreview';
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ export class VsCodeMdWorkspace extends Disposable {
|
||||
return existing;
|
||||
}
|
||||
|
||||
const matchingDocument = vscode.workspace.textDocuments.find((doc) => this.isRelevantMarkdownDocument(doc) && doc.uri.toString() === resource.toString());
|
||||
const matchingDocument = vscode.workspace.textDocuments.find((doc) => this._isRelevantMarkdownDocument(doc) && doc.uri.toString() === resource.toString());
|
||||
if (matchingDocument) {
|
||||
this._documentCache.set(resource, matchingDocument);
|
||||
return matchingDocument;
|
||||
@@ -69,7 +69,7 @@ export class VsCodeMdWorkspace extends Disposable {
|
||||
const bytes = await vscode.workspace.fs.readFile(resource);
|
||||
|
||||
// We assume that markdown is in UTF-8
|
||||
const text = this.utf8Decoder.decode(bytes);
|
||||
const text = this._utf8Decoder.decode(bytes);
|
||||
const doc = new InMemoryDocument(resource, text, 0);
|
||||
this._documentCache.set(resource, doc);
|
||||
return doc;
|
||||
|
||||
Reference in New Issue
Block a user