-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
108096e
commit 84f6805
Showing
9 changed files
with
319 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as vscode from 'vscode'; | ||
import { DevProxyInstall } from './types'; | ||
|
||
export const registerCodeActions = (context: vscode.ExtensionContext) => { | ||
const devProxyInstall = context.globalState.get<DevProxyInstall>('devProxyInstall'); | ||
if (!devProxyInstall) { | ||
return; | ||
} | ||
context.subscriptions.push( | ||
vscode.languages.registerCodeActionsProvider('json', { | ||
provideCodeActions: (document, range, context, token) => { | ||
const diagnostic = context.diagnostics.find(diagnostic => { | ||
return diagnostic.code === 'invalidSchema'; | ||
}); | ||
if (diagnostic) { | ||
const fix = new vscode.CodeAction('Update schema', vscode.CodeActionKind.QuickFix); | ||
fix.edit = new vscode.WorkspaceEdit(); | ||
fix.edit.replace( | ||
document.uri, | ||
new vscode.Range( | ||
diagnostic.range.start, | ||
diagnostic.range.end | ||
), | ||
`$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v${devProxyInstall.version}/rc.schema.json",` | ||
); | ||
return [fix]; | ||
} | ||
} | ||
})); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
import * as vscode from 'vscode'; | ||
import { registerCommands } from './commands'; | ||
import { detectDevProxyInstall } from './detect'; | ||
import { handleStartNotification, processNotification } from './notifications'; | ||
import { registerDocumentListeners } from './documents'; | ||
import { registerCodeLens } from './codelens'; | ||
import { createStatusBar, updateStatusBar } from './statusbar'; | ||
import { registerCodeActions } from './codeactions'; | ||
import { updateGlobalState } from './state'; | ||
|
||
export const activate = async (context: vscode.ExtensionContext): Promise<vscode.ExtensionContext> => { | ||
const statusBar = createStatusBar(context); | ||
await updateGlobalState(context); | ||
|
||
export const activate = async (context: vscode.ExtensionContext) => { | ||
const collection = vscode.languages.createDiagnosticCollection('Dev Proxy'); | ||
let statusBar = createStatusBar(context); | ||
registerDocumentListeners(context, collection); | ||
registerCommands(context); | ||
registerCodeActions(context); | ||
registerCodeLens(context); | ||
|
||
const devProxyInstall = await detectDevProxyInstall(); | ||
const notification = handleStartNotification(devProxyInstall); | ||
registerCommands(context); | ||
const notification = handleStartNotification(context); | ||
processNotification(notification); | ||
updateStatusBar(statusBar, devProxyInstall); | ||
|
||
updateStatusBar(context, statusBar); | ||
return context; | ||
}; | ||
|
||
export const deactivate = () => { }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as vscode from 'vscode'; | ||
import { detectDevProxyInstall } from './detect'; | ||
import { testDevProxyInstall } from './constants'; | ||
|
||
export const updateGlobalState = async (context: vscode.ExtensionContext) => { | ||
context.extensionMode === vscode.ExtensionMode.Test | ||
? context.globalState.update('devProxyInstall', testDevProxyInstall) | ||
: context.globalState.update('devProxyInstall', await detectDevProxyInstall()); | ||
}; |
Oops, something went wrong.