Skip to content

Commit 33867c5

Browse files
authored
Adopt prefix private with _ in markdown extension (microsoft#165088)
1 parent b97827d commit 33867c5

29 files changed

+374
-355
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"rules": {
3+
"@typescript-eslint/naming-convention": [
4+
"warn",
5+
{
6+
"selector": "default",
7+
"modifiers": ["private"],
8+
"format": null,
9+
"leadingUnderscore": "require"
10+
},
11+
{
12+
"selector": "default",
13+
"modifiers": ["public"],
14+
"format": null,
15+
"leadingUnderscore": "forbid"
16+
}
17+
]
18+
}
19+
}

extensions/markdown-language-features/src/client/fileWatchingManager.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ type DirWatcherEntry = {
1818

1919
export class FileWatcherManager {
2020

21-
private readonly fileWatchers = new Map<number, {
21+
private readonly _fileWatchers = new Map<number, {
2222
readonly watcher: vscode.FileSystemWatcher;
2323
readonly dirWatchers: DirWatcherEntry[];
2424
}>();
2525

26-
private readonly dirWatchers = new ResourceMap<{
26+
private readonly _dirWatchers = new ResourceMap<{
2727
readonly watcher: vscode.FileSystemWatcher;
2828
refCount: number;
2929
}>();
3030

3131
create(id: number, uri: vscode.Uri, watchParentDirs: boolean, listeners: { create?: () => void; change?: () => void; delete?: () => void }): void {
3232
const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(uri, '*'), !listeners.create, !listeners.change, !listeners.delete);
3333
const parentDirWatchers: DirWatcherEntry[] = [];
34-
this.fileWatchers.set(id, { watcher, dirWatchers: parentDirWatchers });
34+
this._fileWatchers.set(id, { watcher, dirWatchers: parentDirWatchers });
3535

3636
if (listeners.create) { watcher.onDidCreate(listeners.create); }
3737
if (listeners.change) { watcher.onDidChange(listeners.change); }
@@ -42,12 +42,12 @@ export class FileWatcherManager {
4242
for (let dirUri = Utils.dirname(uri); dirUri.path.length > 1; dirUri = Utils.dirname(dirUri)) {
4343
const dirWatcher: DirWatcherEntry = { uri: dirUri, listeners: [] };
4444

45-
let parentDirWatcher = this.dirWatchers.get(dirUri);
45+
let parentDirWatcher = this._dirWatchers.get(dirUri);
4646
if (!parentDirWatcher) {
4747
const glob = new vscode.RelativePattern(Utils.dirname(dirUri), Utils.basename(dirUri));
4848
const parentWatcher = vscode.workspace.createFileSystemWatcher(glob, !listeners.create, true, !listeners.delete);
4949
parentDirWatcher = { refCount: 0, watcher: parentWatcher };
50-
this.dirWatchers.set(dirUri, parentDirWatcher);
50+
this._dirWatchers.set(dirUri, parentDirWatcher);
5151
}
5252
parentDirWatcher.refCount++;
5353

@@ -77,23 +77,23 @@ export class FileWatcherManager {
7777
}
7878

7979
delete(id: number): void {
80-
const entry = this.fileWatchers.get(id);
80+
const entry = this._fileWatchers.get(id);
8181
if (entry) {
8282
for (const dirWatcher of entry.dirWatchers) {
8383
disposeAll(dirWatcher.listeners);
8484

85-
const dirWatcherEntry = this.dirWatchers.get(dirWatcher.uri);
85+
const dirWatcherEntry = this._dirWatchers.get(dirWatcher.uri);
8686
if (dirWatcherEntry) {
8787
if (--dirWatcherEntry.refCount <= 0) {
8888
dirWatcherEntry.watcher.dispose();
89-
this.dirWatchers.delete(dirWatcher.uri);
89+
this._dirWatchers.delete(dirWatcher.uri);
9090
}
9191
}
9292
}
9393

9494
entry.watcher.dispose();
9595
}
9696

97-
this.fileWatchers.delete(id);
97+
this._fileWatchers.delete(id);
9898
}
9999
}

extensions/markdown-language-features/src/client/inMemoryDocument.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ export class InMemoryDocument implements ITextDocument {
1010

1111
constructor(
1212
public readonly uri: vscode.Uri,
13-
private readonly contents: string,
13+
private readonly _contents: string,
1414
public readonly version = 0,
1515
) { }
1616

1717
getText(): string {
18-
return this.contents;
18+
return this._contents;
1919
}
2020
}

extensions/markdown-language-features/src/client/workspace.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class VsCodeMdWorkspace extends Disposable {
2121

2222
private readonly _documentCache = new ResourceMap<ITextDocument>();
2323

24-
private readonly utf8Decoder = new TextDecoder('utf-8');
24+
private readonly _utf8Decoder = new TextDecoder('utf-8');
2525

2626
constructor() {
2727
super();
@@ -45,7 +45,7 @@ export class VsCodeMdWorkspace extends Disposable {
4545
}));
4646
}
4747

48-
private isRelevantMarkdownDocument(doc: vscode.TextDocument) {
48+
private _isRelevantMarkdownDocument(doc: vscode.TextDocument) {
4949
return isMarkdownFile(doc) && doc.uri.scheme !== 'vscode-bulkeditpreview';
5050
}
5151

@@ -55,7 +55,7 @@ export class VsCodeMdWorkspace extends Disposable {
5555
return existing;
5656
}
5757

58-
const matchingDocument = vscode.workspace.textDocuments.find((doc) => this.isRelevantMarkdownDocument(doc) && doc.uri.toString() === resource.toString());
58+
const matchingDocument = vscode.workspace.textDocuments.find((doc) => this._isRelevantMarkdownDocument(doc) && doc.uri.toString() === resource.toString());
5959
if (matchingDocument) {
6060
this._documentCache.set(resource, matchingDocument);
6161
return matchingDocument;
@@ -69,7 +69,7 @@ export class VsCodeMdWorkspace extends Disposable {
6969
const bytes = await vscode.workspace.fs.readFile(resource);
7070

7171
// We assume that markdown is in UTF-8
72-
const text = this.utf8Decoder.decode(bytes);
72+
const text = this._utf8Decoder.decode(bytes);
7373
const doc = new InMemoryDocument(resource, text, 0);
7474
this._documentCache.set(resource, doc);
7575
return doc;

extensions/markdown-language-features/src/commandManager.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ export interface Command {
1212
}
1313

1414
export class CommandManager {
15-
private readonly commands = new Map<string, vscode.Disposable>();
15+
private readonly _commands = new Map<string, vscode.Disposable>();
1616

1717
public dispose() {
18-
for (const registration of this.commands.values()) {
18+
for (const registration of this._commands.values()) {
1919
registration.dispose();
2020
}
21-
this.commands.clear();
21+
this._commands.clear();
2222
}
2323

2424
public register<T extends Command>(command: T): vscode.Disposable {
25-
this.registerCommand(command.id, command.execute, command);
25+
this._registerCommand(command.id, command.execute, command);
2626
return new vscode.Disposable(() => {
27-
this.commands.delete(command.id);
27+
this._commands.delete(command.id);
2828
});
2929
}
3030

31-
private registerCommand(id: string, impl: (...args: any[]) => void, thisArg?: any) {
32-
if (this.commands.has(id)) {
31+
private _registerCommand(id: string, impl: (...args: any[]) => void, thisArg?: any) {
32+
if (this._commands.has(id)) {
3333
return;
3434
}
3535

36-
this.commands.set(id, vscode.commands.registerCommand(id, impl, thisArg));
36+
this._commands.set(id, vscode.commands.registerCommand(id, impl, thisArg));
3737
}
3838
}

extensions/markdown-language-features/src/commands/refreshPreview.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ export class RefreshPreviewCommand implements Command {
1111
public readonly id = 'markdown.preview.refresh';
1212

1313
public constructor(
14-
private readonly webviewManager: MarkdownPreviewManager,
15-
private readonly engine: MarkdownItEngine
14+
private readonly _webviewManager: MarkdownPreviewManager,
15+
private readonly _engine: MarkdownItEngine
1616
) { }
1717

1818
public execute() {
19-
this.engine.cleanCache();
20-
this.webviewManager.refresh();
19+
this._engine.cleanCache();
20+
this._webviewManager.refresh();
2121
}
2222
}

extensions/markdown-language-features/src/commands/reloadPlugins.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export class ReloadPlugins implements Command {
1111
public readonly id = 'markdown.api.reloadPlugins';
1212

1313
public constructor(
14-
private readonly webviewManager: MarkdownPreviewManager,
15-
private readonly engine: MarkdownItEngine,
14+
private readonly _webviewManager: MarkdownPreviewManager,
15+
private readonly _engine: MarkdownItEngine,
1616
) { }
1717

1818
public execute(): void {
19-
this.engine.reloadPlugins();
20-
this.engine.cleanCache();
21-
this.webviewManager.refresh();
19+
this._engine.reloadPlugins();
20+
this._engine.cleanCache();
21+
this._webviewManager.refresh();
2222
}
2323
}

extensions/markdown-language-features/src/commands/renderDocument.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ export class RenderDocument implements Command {
1111
public readonly id = 'markdown.api.render';
1212

1313
public constructor(
14-
private readonly engine: MarkdownItEngine
14+
private readonly _engine: MarkdownItEngine
1515
) { }
1616

1717
public async execute(document: ITextDocument | string): Promise<string> {
18-
return (await (this.engine.render(document))).html;
18+
return (await (this._engine.render(document))).html;
1919
}
2020
}

extensions/markdown-language-features/src/commands/showPreview.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ export class ShowPreviewCommand implements Command {
5454
public readonly id = 'markdown.showPreview';
5555

5656
public constructor(
57-
private readonly webviewManager: MarkdownPreviewManager,
58-
private readonly telemetryReporter: TelemetryReporter
57+
private readonly _webviewManager: MarkdownPreviewManager,
58+
private readonly _telemetryReporter: TelemetryReporter
5959
) { }
6060

6161
public execute(mainUri?: vscode.Uri, allUris?: vscode.Uri[], previewSettings?: DynamicPreviewSettings) {
6262
for (const uri of Array.isArray(allUris) ? allUris : [mainUri]) {
63-
showPreview(this.webviewManager, this.telemetryReporter, uri, {
63+
showPreview(this._webviewManager, this._telemetryReporter, uri, {
6464
sideBySide: false,
6565
locked: previewSettings && previewSettings.locked
6666
});
@@ -72,12 +72,12 @@ export class ShowPreviewToSideCommand implements Command {
7272
public readonly id = 'markdown.showPreviewToSide';
7373

7474
public constructor(
75-
private readonly webviewManager: MarkdownPreviewManager,
76-
private readonly telemetryReporter: TelemetryReporter
75+
private readonly _webviewManager: MarkdownPreviewManager,
76+
private readonly _telemetryReporter: TelemetryReporter
7777
) { }
7878

7979
public execute(uri?: vscode.Uri, previewSettings?: DynamicPreviewSettings) {
80-
showPreview(this.webviewManager, this.telemetryReporter, uri, {
80+
showPreview(this._webviewManager, this._telemetryReporter, uri, {
8181
sideBySide: true,
8282
locked: previewSettings && previewSettings.locked
8383
});
@@ -89,12 +89,12 @@ export class ShowLockedPreviewToSideCommand implements Command {
8989
public readonly id = 'markdown.showLockedPreviewToSide';
9090

9191
public constructor(
92-
private readonly webviewManager: MarkdownPreviewManager,
93-
private readonly telemetryReporter: TelemetryReporter
92+
private readonly _webviewManager: MarkdownPreviewManager,
93+
private readonly _telemetryReporter: TelemetryReporter
9494
) { }
9595

9696
public execute(uri?: vscode.Uri) {
97-
showPreview(this.webviewManager, this.telemetryReporter, uri, {
97+
showPreview(this._webviewManager, this._telemetryReporter, uri, {
9898
sideBySide: true,
9999
locked: true
100100
});

extensions/markdown-language-features/src/commands/showPreviewSecuritySelector.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ export class ShowPreviewSecuritySelectorCommand implements Command {
1313
public readonly id = 'markdown.showPreviewSecuritySelector';
1414

1515
public constructor(
16-
private readonly previewSecuritySelector: PreviewSecuritySelector,
17-
private readonly previewManager: MarkdownPreviewManager
16+
private readonly _previewSecuritySelector: PreviewSecuritySelector,
17+
private readonly _previewManager: MarkdownPreviewManager
1818
) { }
1919

2020
public execute(resource: string | undefined) {
21-
if (this.previewManager.activePreviewResource) {
22-
this.previewSecuritySelector.showSecuritySelectorForResource(this.previewManager.activePreviewResource);
21+
if (this._previewManager.activePreviewResource) {
22+
this._previewSecuritySelector.showSecuritySelectorForResource(this._previewManager.activePreviewResource);
2323
} else if (resource) {
2424
const source = vscode.Uri.parse(resource);
25-
this.previewSecuritySelector.showSecuritySelectorForResource(source.query ? vscode.Uri.parse(source.query) : source);
25+
this._previewSecuritySelector.showSecuritySelectorForResource(source.query ? vscode.Uri.parse(source.query) : source);
2626
} else if (vscode.window.activeTextEditor && isMarkdownFile(vscode.window.activeTextEditor.document)) {
27-
this.previewSecuritySelector.showSecuritySelectorForResource(vscode.window.activeTextEditor.document.uri);
27+
this._previewSecuritySelector.showSecuritySelectorForResource(vscode.window.activeTextEditor.document.uri);
2828
}
2929
}
3030
}

0 commit comments

Comments
 (0)