|
1 | | -import { extractorEntries } from '#composables/active-extractor' |
2 | 1 | import { VERSION_TRIGGER_CHARACTERS } from '#constants' |
3 | 2 | import { defineExtension, useCommands, watchEffect } from 'reactive-vscode' |
4 | | -import { CodeActionKind, Disposable, languages } from 'vscode' |
| 3 | +import { Disposable, languages } from 'vscode' |
5 | 4 | import { openFileInNpmx } from './commands/open-file-in-npmx' |
6 | 5 | import { openInBrowser } from './commands/open-in-browser' |
| 6 | +import { extractorEntries } from './extractors' |
7 | 7 | import { commands, displayName, version } from './generated-meta' |
8 | | -import { UpgradeProvider } from './providers/code-actions/upgrade' |
9 | | -import { VulnerabilityCodeActionProvider } from './providers/code-actions/vulnerability' |
| 8 | +import { useCodeActions } from './providers/code-actions' |
10 | 9 | import { VersionCompletionItemProvider } from './providers/completion-item/version' |
11 | 10 | import { useDiagnostics } from './providers/diagnostics' |
12 | 11 | import { NpmxHoverProvider } from './providers/hover/npmx' |
@@ -41,34 +40,10 @@ export const { activate, deactivate } = defineExtension(() => { |
41 | 40 | onCleanup(() => Disposable.from(...disposables).dispose()) |
42 | 41 | }) |
43 | 42 |
|
44 | | - watchEffect((onCleanup) => { |
45 | | - if (!config.diagnostics.upgrade) |
46 | | - return |
47 | | - |
48 | | - const provider = new UpgradeProvider() |
49 | | - const options = { providedCodeActionKinds: [CodeActionKind.QuickFix] } |
50 | | - const disposables = extractorEntries.map(({ pattern }) => |
51 | | - languages.registerCodeActionsProvider({ pattern }, provider, options), |
52 | | - ) |
53 | | - |
54 | | - onCleanup(() => Disposable.from(...disposables).dispose()) |
55 | | - }) |
56 | | - |
57 | | - watchEffect((onCleanup) => { |
58 | | - if (!config.diagnostics.vulnerability) |
59 | | - return |
60 | | - |
61 | | - const provider = new VulnerabilityCodeActionProvider() |
62 | | - const options = { providedCodeActionKinds: [CodeActionKind.QuickFix] } |
63 | | - const disposables = extractorEntries.map(({ pattern }) => |
64 | | - languages.registerCodeActionsProvider({ pattern }, provider, options), |
65 | | - ) |
66 | | - |
67 | | - onCleanup(() => Disposable.from(...disposables).dispose()) |
68 | | - }) |
69 | | - |
70 | 43 | useDiagnostics() |
71 | 44 |
|
| 45 | + useCodeActions() |
| 46 | + |
72 | 47 | useCommands({ |
73 | 48 | [commands.openInBrowser]: openInBrowser, |
74 | 49 | [commands.openFileInNpmx]: openFileInNpmx, |
|
0 commit comments