Skip to content

Commit 6c3356a

Browse files
committed
Reorganizes code structure
- Splits models & utils into separate files to reduce coupling - Relocates VS Code-specific utilities into system/-webview/
1 parent 61e07e0 commit 6c3356a

File tree

451 files changed

+4641
-4479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

451 files changed

+4641
-4479
lines changed

eslint.config.mjs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ export default ts.config(
317317
{
318318
name: 'extension:node',
319319
files: ['src/**/*'],
320-
ignores: ['src/webviews/apps/**/*', 'src/env/browser/**/*'],
320+
ignores: ['**/webview/**/*', 'src/test/**/*', 'src/webviews/apps/**/*', 'src/env/browser/**/*'],
321321
languageOptions: {
322322
globals: {
323323
...globals.node,
@@ -358,7 +358,7 @@ export default ts.config(
358358
{
359359
name: 'extension:browser',
360360
files: ['src/**/*'],
361-
ignores: ['src/webviews/apps/**/*', 'src/env/node/**/*'],
361+
ignores: ['**/webview/**/*', 'src/test/**/*', 'src/webviews/apps/**/*', 'src/env/node/**/*'],
362362
languageOptions: {
363363
globals: {
364364
...globals.worker,
@@ -381,19 +381,19 @@ export default ts.config(
381381
// Keep in sync with `src/webviews/apps/tsconfig.json`
382382
files: [
383383
'src/webviews/apps/**/*',
384-
'src/@types/**/*',
385-
'src/env/browser/**/*',
386-
'src/plus/gk/account/promos.ts',
387-
'src/plus/gk/account/subscription.ts',
388384
'src/webviews/**/protocol.ts',
385+
'src/**/models/**/*.ts',
386+
'src/**/utils/**/*.ts',
387+
'src/@types/**/*',
389388
'src/config.ts',
390389
'src/constants.ts',
391390
'src/constants.*.ts',
391+
'src/env/browser/**/*',
392392
'src/features.ts',
393-
'src/subscription.ts',
394-
'src/system/*.ts',
395-
'src/system/decorators/log.ts',
393+
'src/system/**/*.ts',
394+
'**/webview/**/*',
396395
],
396+
ignores: ['**/-webview/**/*'],
397397
languageOptions: {
398398
globals: {
399399
...globals.browser,
@@ -414,13 +414,13 @@ export default ts.config(
414414
{
415415
patterns: [
416416
{
417-
group: ['react-dom'],
418-
importNames: ['Container'],
419-
message: 'Use our Container instead',
417+
group: ['Container'],
418+
message: "Can't use `Container` in webviews",
419+
allowTypeImports: true,
420420
},
421421
{
422422
group: ['vscode'],
423-
message: "Can't use vscode in webviews",
423+
message: "Can't use `vscode` in webviews",
424424
allowTypeImports: true,
425425
},
426426
],

src/ai/aiProviderService.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import type { AIGenerateDraftEventData, Sources, TelemetryEvents } from '../cons
55
import type { Container } from '../container';
66
import { CancellationError } from '../errors';
77
import type { GitCommit } from '../git/models/commit';
8-
import { assertsCommitHasFullDetails, isCommit } from '../git/models/commit';
8+
import { isCommit } from '../git/models/commit';
99
import type { GitRevisionReference } from '../git/models/reference';
1010
import type { Repository } from '../git/models/repository';
1111
import { isRepository } from '../git/models/repository';
1212
import { uncommitted, uncommittedStaged } from '../git/models/revision';
13+
import { assertsCommitHasFullDetails } from '../git/utils/commit.utils';
1314
import { showAIModelPicker } from '../quickpicks/aiModelPicker';
15+
import { configuration } from '../system/-webview/configuration';
16+
import type { Storage } from '../system/-webview/storage';
17+
import { supportedInVSCodeVersion } from '../system/-webview/utils';
1418
import { getSettledValue } from '../system/promise';
1519
import { getPossessiveForm } from '../system/string';
16-
import { configuration } from '../system/vscode/configuration';
17-
import type { Storage } from '../system/vscode/storage';
18-
import { supportedInVSCodeVersion } from '../system/vscode/utils';
1920
import type { TelemetryService } from '../telemetry/telemetry';
2021
import { AnthropicProvider } from './anthropicProvider';
2122
import { GeminiProvider } from './geminiProvider';

src/ai/openAICompatibleProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import type { AIProviders } from '../constants.ai';
44
import type { TelemetryEvents } from '../constants.telemetry';
55
import type { Container } from '../container';
66
import { CancellationError } from '../errors';
7+
import { configuration } from '../system/-webview/configuration';
78
import { sum } from '../system/iterable';
89
import { interpolate } from '../system/string';
9-
import { configuration } from '../system/vscode/configuration';
1010
import type { AIModel, AIProvider } from './aiProviderService';
1111
import { getMaxCharacters, getOrPromptApiKey, showDiffTruncationWarning } from './aiProviderService';
1212
import {

src/ai/openaiProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { configuration } from '../system/vscode/configuration';
1+
import { configuration } from '../system/-webview/configuration';
22
import type { AIModel } from './aiProviderService';
33
import { OpenAICompatibleProvider } from './openAICompatibleProvider';
44

src/ai/vscodeProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import type { CancellationToken, LanguageModelChat, LanguageModelChatSelector }
22
import { CancellationTokenSource, LanguageModelChatMessage, lm } from 'vscode';
33
import type { TelemetryEvents } from '../constants.telemetry';
44
import type { Container } from '../container';
5+
import { configuration } from '../system/-webview/configuration';
56
import { sum } from '../system/iterable';
67
import { capitalize, getPossessiveForm, interpolate } from '../system/string';
7-
import { configuration } from '../system/vscode/configuration';
88
import type { AIModel, AIProvider } from './aiProviderService';
99
import { getMaxCharacters, showDiffTruncationWarning } from './aiProviderService';
1010
import {

src/annotations/annotationProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { Disposable, window } from 'vscode';
33
import type { FileAnnotationType } from '../config';
44
import type { AnnotationStatus } from '../constants';
55
import type { Container } from '../container';
6+
import { getTabUri } from '../system/-webview/utils';
67
import { Logger } from '../system/logger';
78
import type { Deferred } from '../system/promise';
89
import { defer } from '../system/promise';
9-
import { getTabUri } from '../system/vscode/utils';
1010
import type { TrackedGitDocument } from '../trackers/trackedDocument';
1111
import type { Decoration } from './annotations';
1212

src/annotations/annotations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import type { Colors } from '../constants.colors';
1313
import type { CommitFormatOptions } from '../git/formatters/commitFormatter';
1414
import { CommitFormatter } from '../git/formatters/commitFormatter';
1515
import type { GitCommit } from '../git/models/commit';
16+
import { configuration } from '../system/-webview/configuration';
1617
import { scale, toRgba } from '../system/color';
1718
import { getWidth, interpolate, pad } from '../system/string';
18-
import { configuration } from '../system/vscode/configuration';
1919
import type { BlameFontOptions } from './gutterBlameAnnotationProvider';
2020

2121
export interface ComputedHeatmap {

src/annotations/blameAnnotationProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { GitUri } from '../git/gitUri';
66
import type { GitBlame } from '../git/models/blame';
77
import type { GitCommit } from '../git/models/commit';
88
import { changesMessage, detailsMessage } from '../hovers/hovers';
9+
import { configuration } from '../system/-webview/configuration';
910
import { log } from '../system/decorators/log';
10-
import { configuration } from '../system/vscode/configuration';
1111
import type { TrackedGitDocument } from '../trackers/trackedDocument';
1212
import type { DidChangeStatusCallback } from './annotationProvider';
1313
import { AnnotationProviderBase } from './annotationProvider';

src/annotations/fileAnnotationController.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ import type { AnnotationsToggleMode, FileAnnotationType } from '../config';
2525
import type { AnnotationStatus } from '../constants';
2626
import type { Colors, CoreColors } from '../constants.colors';
2727
import type { Container } from '../container';
28+
import { registerCommand } from '../system/-webview/command';
29+
import { configuration } from '../system/-webview/configuration';
30+
import { setContext } from '../system/-webview/context';
31+
import type { KeyboardScope } from '../system/-webview/keyboard';
32+
import { UriSet } from '../system/-webview/uriMap';
33+
import { isTrackableTextEditor } from '../system/-webview/utils';
2834
import { debug, log } from '../system/decorators/log';
2935
import { once } from '../system/event';
3036
import type { Deferrable } from '../system/function';
3137
import { debounce } from '../system/function';
3238
import { find } from '../system/iterable';
3339
import { basename } from '../system/path';
34-
import { registerCommand } from '../system/vscode/command';
35-
import { configuration } from '../system/vscode/configuration';
36-
import { setContext } from '../system/vscode/context';
37-
import type { KeyboardScope } from '../system/vscode/keyboard';
38-
import { UriSet } from '../system/vscode/uriMap';
39-
import { isTrackableTextEditor } from '../system/vscode/utils';
4040
import type {
4141
DocumentBlameStateChangeEvent,
4242
DocumentDirtyIdleTriggerEvent,

src/annotations/gutterBlameAnnotationProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import type { Container } from '../container';
66
import type { CommitFormatOptions } from '../git/formatters/commitFormatter';
77
import { CommitFormatter } from '../git/formatters/commitFormatter';
88
import type { GitCommit } from '../git/models/commit';
9+
import { configuration } from '../system/-webview/configuration';
910
import { filterMap } from '../system/array';
1011
import { log } from '../system/decorators/log';
1112
import { first } from '../system/iterable';
1213
import { getLogScope } from '../system/logger.scope';
1314
import { maybeStopWatch } from '../system/stopwatch';
1415
import type { TokenOptions } from '../system/string';
1516
import { getTokensFromTemplate, getWidth } from '../system/string';
16-
import { configuration } from '../system/vscode/configuration';
1717
import type { TrackedGitDocument } from '../trackers/trackedDocument';
1818
import type { AnnotationContext, AnnotationState, DidChangeStatusCallback } from './annotationProvider';
1919
import { applyHeatmap, getGutterDecoration, getGutterRenderOptions } from './annotations';

0 commit comments

Comments
 (0)