Skip to content

Commit f8eb847

Browse files
committed
Refactor private properties to use underscore prefix convention for consistency across all context providers
1 parent c633f1a commit f8eb847

8 files changed

Lines changed: 390 additions & 330 deletions

File tree

‎packages/vscode/src/constants/edit-format-instructions.ts‎

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ GREETING = "Hello, World!"
1010
1111
def show_greeting():
1212
print(GREETING)
13-
\`\`\``
13+
\`\`\`
1414
15-
export const EDIT_FORMAT_INSTRUCTIONS_TRUNCATED = `${intro}, followed by a markdown code block with file's contents. As a space saving measure, unchanged function bodies (code inside {}) should be replaced with ellipsis comments. Example:
15+
### Deleted file: \`src/examples/weekdays.py\`
16+
`
17+
18+
export const EDIT_FORMAT_INSTRUCTIONS_TRUNCATED = `${intro}, followed by a markdown code block with file's contents. As a space saving measure, truncate blocks like unchanged function bodies (code inside {}) by replacing with ellipsis comments. Example:
1619
Updated the greeting text.
1720
1821
### Updated file: \`src/examples/hello.js\`
@@ -28,7 +31,28 @@ function getDuration() {
2831
function showGreeting() {
2932
// ...
3033
}
31-
\`\`\``
34+
\`\`\`
35+
36+
Updated the purpose text.
37+
38+
### Updated file: \`src/README.md\`
39+
40+
\`\`\`markdown
41+
## Purpose
42+
43+
Greet user saying "Hello, World!", for a duration of 5 seconds.
44+
45+
## License
46+
47+
<!-- ... --->
48+
49+
## Author
50+
51+
<!-- ... --->
52+
\`\`\`
53+
54+
### Deleted file: \`src/examples/weekdays.js\`
55+
`
3256

3357
export const EDIT_FORMAT_INSTRUCTIONS_DIFF = `${intro}, followed by a unified diff within a markdown code block. Example:
3458
Updated the greeting text.
@@ -44,7 +68,22 @@ Updated the greeting text.
4468
4569
def show_greeting():
4670
print(GREETING)
47-
\`\`\``
71+
\`\`\`
72+
73+
Created a simple calculator with addition and subtraction.
74+
75+
### Created file: \`src/examples/calculator.py\`
76+
77+
\`\`\`python
78+
def add(a, b):
79+
return a + b
80+
81+
def subtract(a, b):
82+
return a - b
83+
\`\`\`
84+
85+
### Deleted file: \`src/examples/weekdays.py\`
86+
`
4887

4988
export const EDIT_FORMAT_INSTRUCTIONS_BEFORE_AFTER = `${intro}, followed by a markdown code block showing the original and updated code snippets with Git-style merge conflict markers. Example:
5089
Changed greeting to wishes.
@@ -56,12 +95,15 @@ Changed greeting to wishes.
5695
GREETING = "Welcome everyone!"
5796
=======
5897
WISHES = "Have a nice day!"
59-
>>>>>>> UPDATED
98+
>>>>>>> REPLACE
6099
<<<<<<< SEARCH
61100
def show_greeting():
62101
print(GREETING)
63102
=======
64103
def show_wishes():
65104
print(WISHES)
66-
>>>>>>> UPDATED
67-
\`\`\``
105+
>>>>>>> REPLACE
106+
\`\`\`
107+
108+
### Deleted file: \`src/examples/weekdays.py\`
109+
`

‎packages/vscode/src/context/providers/context/context-provider.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export class ContextProvider implements vscode.TreeDataProvider<FileItem> {
99
FileItem | undefined | null | void
1010
> = this._onDidChangeTreeData.event
1111

12-
private disposable: vscode.Disposable
12+
private _disposable: vscode.Disposable
1313

14-
constructor(private workspaceProvider: WorkspaceProvider) {
15-
this.disposable = this.workspaceProvider.onDidChangeTreeData(() =>
14+
constructor(private _workspace_provider: WorkspaceProvider) {
15+
this._disposable = this._workspace_provider.onDidChangeTreeData(() =>
1616
this.refresh()
1717
)
1818
}
@@ -22,15 +22,15 @@ export class ContextProvider implements vscode.TreeDataProvider<FileItem> {
2222
}
2323

2424
getTreeItem(element: FileItem): vscode.TreeItem | Thenable<vscode.TreeItem> {
25-
return this.workspaceProvider.getTreeItem(element)
25+
return this._workspace_provider.getTreeItem(element)
2626
}
2727

2828
getChildren(element?: FileItem): vscode.ProviderResult<FileItem[]> {
29-
return this.workspaceProvider.getContextViewChildren(element)
29+
return this._workspace_provider.getContextViewChildren(element)
3030
}
3131

3232
dispose() {
33-
this.disposable.dispose()
33+
this._disposable.dispose()
3434
this._onDidChangeTreeData.dispose()
3535
}
3636
}

‎packages/vscode/src/context/providers/open-editors/open-editors-provider.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ export class OpenEditorsProvider
2828
readonly onDidChangeCheckedFiles = this._on_did_change_checked_files.event
2929
private _shared_state: SharedFileState
3030
private _config_change_handler: vscode.Disposable
31-
private workspace_provider: WorkspaceProvider
31+
private _workspace_provider: WorkspaceProvider
3232

3333
constructor(
3434
workspace_folders: vscode.WorkspaceFolder[],
3535
workspace_provider: WorkspaceProvider
3636
) {
3737
this._workspace_roots = workspace_folders.map((folder) => folder.uri.fsPath)
3838
this._shared_state = SharedFileState.get_instance()
39-
this.workspace_provider = workspace_provider
39+
this._workspace_provider = workspace_provider
4040

4141
this._workspace_change_handler =
42-
this.workspace_provider.onDidChangeTreeData(() => this.refresh())
42+
this._workspace_provider.onDidChangeTreeData(() => this.refresh())
4343

4444
this._update_preview_tabs_state()
4545

@@ -86,7 +86,7 @@ export class OpenEditorsProvider
8686
const checked_files = this.get_checked_files()
8787

8888
const files_to_uncheck = checked_files.filter((file_path) =>
89-
this.workspace_provider.is_ignored_by_patterns(file_path)
89+
this._workspace_provider.is_ignored_by_patterns(file_path)
9090
)
9191

9292
for (const file_path of files_to_uncheck) {
@@ -250,7 +250,7 @@ export class OpenEditorsProvider
250250

251251
const file_name = path.basename(file_path)
252252

253-
if (this.workspace_provider.is_ignored_by_patterns(file_path)) {
253+
if (this._workspace_provider.is_ignored_by_patterns(file_path)) {
254254
continue
255255
}
256256

@@ -283,10 +283,10 @@ export class OpenEditorsProvider
283283
description = path.basename(workspace_root)
284284
}
285285

286-
const range = this.workspace_provider.get_range(file_path)
286+
const range = this._workspace_provider.get_range(file_path)
287287
const token_count =
288-
this.workspace_provider.get_cached_token_count(file_path) ||
289-
(await this.workspace_provider.calculate_file_tokens(file_path))
288+
this._workspace_provider.get_cached_token_count(file_path) ||
289+
(await this._workspace_provider.calculate_file_tokens(file_path))
290290

291291
const item = new FileItem(
292292
file_name,
@@ -373,7 +373,7 @@ export class OpenEditorsProvider
373373

374374
if (!this._is_file_in_any_workspace(file_path)) continue
375375

376-
if (this.workspace_provider.is_ignored_by_patterns(file_path)) continue
376+
if (this._workspace_provider.is_ignored_by_patterns(file_path)) continue
377377

378378
this._checked_items.set(file_path, vscode.TreeItemCheckboxState.Checked)
379379

@@ -407,7 +407,7 @@ export class OpenEditorsProvider
407407
for (const file_path of file_paths) {
408408
if (!fs.existsSync(file_path)) continue
409409

410-
if (this.workspace_provider.is_ignored_by_patterns(file_path)) continue
410+
if (this._workspace_provider.is_ignored_by_patterns(file_path)) continue
411411

412412
this._checked_items.set(file_path, vscode.TreeItemCheckboxState.Checked)
413413

‎packages/vscode/src/context/providers/websites-provider.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class WebsitesProvider
5252
private _onDidChangeCheckedWebsites = new vscode.EventEmitter<void>()
5353
readonly onDidChangeCheckedWebsites = this._onDidChangeCheckedWebsites.event
5454

55-
constructor(private context: vscode.ExtensionContext) {
55+
constructor(private _context: vscode.ExtensionContext) {
5656
this.onDidChangeCheckedWebsites(() => this.save_checked_websites_state())
5757
}
5858

@@ -158,14 +158,14 @@ export class WebsitesProvider
158158
}
159159
private async save_checked_websites_state(): Promise<void> {
160160
const checked_urls = this.get_checked_websites().map((w) => w.url)
161-
await this.context.workspaceState.update(
161+
await this._context.workspaceState.update(
162162
CONTEXT_CHECKED_URLS_STATE_KEY,
163163
checked_urls
164164
)
165165
}
166166

167167
public load_checked_websites_state(): void {
168-
const checked_urls = this.context.workspaceState.get<string[]>(
168+
const checked_urls = this._context.workspaceState.get<string[]>(
169169
CONTEXT_CHECKED_URLS_STATE_KEY
170170
)
171171
if (checked_urls) {

‎packages/vscode/src/context/providers/websites/websites-provider.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class WebsitesProvider
5252
private _onDidChangeCheckedWebsites = new vscode.EventEmitter<void>()
5353
readonly onDidChangeCheckedWebsites = this._onDidChangeCheckedWebsites.event
5454

55-
constructor(private context: vscode.ExtensionContext) {
55+
constructor(private _context: vscode.ExtensionContext) {
5656
this.onDidChangeCheckedWebsites(() => this.save_checked_websites_state())
5757
}
5858

@@ -158,14 +158,14 @@ export class WebsitesProvider
158158
}
159159
private async save_checked_websites_state(): Promise<void> {
160160
const checked_urls = this.get_checked_websites().map((w) => w.url)
161-
await this.context.workspaceState.update(
161+
await this._context.workspaceState.update(
162162
CONTEXT_CHECKED_URLS_STATE_KEY,
163163
checked_urls
164164
)
165165
}
166166

167167
public load_checked_websites_state(): void {
168-
const checked_urls = this.context.workspaceState.get<string[]>(
168+
const checked_urls = this._context.workspaceState.get<string[]>(
169169
CONTEXT_CHECKED_URLS_STATE_KEY
170170
)
171171
if (checked_urls) {

0 commit comments

Comments
 (0)