|
1 | | -import { format } from "./commands/format" |
2 | | -import * as vscode from "vscode" |
| 1 | +import { format } from "./commands/format"; |
| 2 | +import * as vscode from "vscode"; |
3 | 3 | import { |
4 | 4 | createOutputChannel, |
5 | 5 | onDidChangeConfiguration, |
6 | 6 | registerCommand, |
7 | | -} from "./utilities/common/vscodeapi" |
| 7 | +} from "./utilities/common/vscodeapi"; |
8 | 8 | import { |
9 | 9 | registerLogger, |
10 | 10 | traceError, |
11 | 11 | traceInfo, |
12 | 12 | traceVerbose, |
13 | | -} from "./utilities/common/log" |
14 | | -import { onDidChangePythonInterpreter } from "./utilities/common/python" |
15 | | -import { LSPClient } from "./lsp/lsp" |
16 | | -import { AuthenticationProviderTobikoCloud } from "./auth/auth" |
17 | | -import { signOut } from "./commands/signout" |
18 | | -import { signIn } from "./commands/signin" |
19 | | -import { signInSpecifyFlow } from "./commands/signinSpecifyFlow" |
20 | | -import { isErr } from "./utilities/functional/result" |
21 | | -import { handleNotSginedInError } from "./utilities/errors" |
22 | | -import { startWebServer, WebServer } from "./web-server/server" |
23 | | -import { LineagePanel } from "./webviews/lineagePanel" |
| 13 | +} from "./utilities/common/log"; |
| 14 | +import { onDidChangePythonInterpreter } from "./utilities/common/python"; |
| 15 | +import { LSPClient } from "./lsp/lsp"; |
| 16 | +import { AuthenticationProviderTobikoCloud } from "./auth/auth"; |
| 17 | +import { signOut } from "./commands/signout"; |
| 18 | +import { signIn } from "./commands/signin"; |
| 19 | +import { signInSpecifyFlow } from "./commands/signinSpecifyFlow"; |
| 20 | +import { isErr } from "./utilities/functional/result"; |
| 21 | +import { handleNotSginedInError } from "./utilities/errors"; |
| 22 | +import { startWebServer, WebServer } from "./web-server/server"; |
| 23 | +import { LineagePanel } from "./webviews/lineagePanel"; |
24 | 24 |
|
25 | | -let lspClient: LSPClient | undefined |
| 25 | +let lspClient: LSPClient | undefined; |
26 | 26 | let webServer: WebServer | undefined; |
27 | 27 |
|
28 | 28 | // This method is called when your extension is activated |
29 | 29 | // Your extension is activated the very first time the command is executed |
30 | 30 | export async function activate(context: vscode.ExtensionContext) { |
31 | | - const extensionOutputChannel = createOutputChannel("sqlmesh") |
| 31 | + const extensionOutputChannel = createOutputChannel("sqlmesh"); |
32 | 32 | context.subscriptions.push( |
33 | 33 | extensionOutputChannel, |
34 | 34 | registerLogger(extensionOutputChannel) |
35 | | - ) |
36 | | - traceInfo("Activating SQLMesh extension") |
| 35 | + ); |
| 36 | + traceInfo("Activating SQLMesh extension"); |
37 | 37 |
|
38 | | - const webServerOutputChannel = createOutputChannel("sqlmesh-webserver") |
| 38 | + const webServerOutputChannel = createOutputChannel("sqlmesh-webserver"); |
39 | 39 | context.subscriptions.push( |
40 | 40 | webServerOutputChannel, |
41 | 41 | registerLogger(webServerOutputChannel) |
42 | | - ) |
| 42 | + ); |
43 | 43 |
|
44 | | - traceInfo("Registering authentication provider") |
45 | | - const authProvider = new AuthenticationProviderTobikoCloud() |
| 44 | + traceInfo("Registering authentication provider"); |
| 45 | + const authProvider = new AuthenticationProviderTobikoCloud(); |
46 | 46 | context.subscriptions.push( |
47 | 47 | vscode.authentication.registerAuthenticationProvider( |
48 | 48 | AuthenticationProviderTobikoCloud.id, |
49 | 49 | AuthenticationProviderTobikoCloud.name, |
50 | 50 | authProvider, |
51 | 51 | { supportsMultipleAccounts: false } |
52 | 52 | ) |
53 | | - ) |
54 | | - traceInfo("Authentication provider registered") |
| 53 | + ); |
| 54 | + traceInfo("Authentication provider registered"); |
55 | 55 |
|
56 | 56 | context.subscriptions.push( |
57 | 57 | vscode.commands.registerCommand("sqlmesh.signin", signIn(authProvider)) |
58 | | - ) |
| 58 | + ); |
59 | 59 | context.subscriptions.push( |
60 | 60 | vscode.commands.registerCommand( |
61 | 61 | "sqlmesh.signinSpecifyFlow", |
62 | 62 | signInSpecifyFlow(authProvider) |
63 | 63 | ) |
64 | | - ) |
| 64 | + ); |
65 | 65 | context.subscriptions.push( |
66 | 66 | vscode.commands.registerCommand("sqlmesh.signout", signOut(authProvider)) |
67 | | - ) |
| 67 | + ); |
68 | 68 | context.subscriptions.push( |
69 | 69 | vscode.commands.registerCommand("sqlmesh.format", format(authProvider)) |
70 | | - ) |
71 | | - // Register the webview |
72 | | - const lineagePanel = new LineagePanel( |
73 | | - context.extensionUri, |
74 | | - () => webServer?.url ?? "" |
75 | | - ); |
76 | | - context.subscriptions.push( |
77 | | - vscode.window.registerWebviewViewProvider( |
78 | | - LineagePanel.viewType, |
79 | | - lineagePanel |
80 | | - ) |
81 | | - ); |
| 70 | + ); |
| 71 | + // Register the webview |
| 72 | + const lineagePanel = new LineagePanel( |
| 73 | + context.extensionUri, |
| 74 | + () => webServer?.url ?? "" |
| 75 | + ); |
| 76 | + context.subscriptions.push( |
| 77 | + vscode.window.registerWebviewViewProvider( |
| 78 | + LineagePanel.viewType, |
| 79 | + lineagePanel |
| 80 | + ) |
| 81 | + ); |
82 | 82 |
|
83 | | - lspClient = new LSPClient() |
84 | | - const result = await lspClient.start() |
| 83 | + lspClient = new LSPClient(); |
| 84 | + const result = await lspClient.start(); |
85 | 85 | if (isErr(result)) { |
86 | | - handleNotSginedInError(authProvider) |
| 86 | + handleNotSginedInError(authProvider); |
87 | 87 | } |
88 | | - context.subscriptions.push(lspClient) |
| 88 | + context.subscriptions.push(lspClient); |
89 | 89 |
|
90 | 90 | // start web server |
91 | | - const webServerResult = await startWebServer(webServerOutputChannel) |
| 91 | + const webServerResult = await startWebServer(webServerOutputChannel); |
92 | 92 | if (!isErr(webServerResult)) { |
93 | | - webServer = webServerResult.value |
| 93 | + webServer = webServerResult.value; |
94 | 94 | } else { |
95 | | - traceError("Failed to start web server", webServerResult.error) |
| 95 | + traceError("Failed to start web server", webServerResult.error); |
96 | 96 | } |
97 | 97 |
|
98 | 98 | const restart = async () => { |
99 | 99 | if (webServer) { |
100 | 100 | webServer.stop(); |
101 | 101 | webServer = undefined; |
102 | | - const webServerResult = await startWebServer(webServerOutputChannel) |
| 102 | + const webServerResult = await startWebServer(webServerOutputChannel); |
103 | 103 | if (!isErr(webServerResult)) { |
104 | | - webServer = webServerResult.value |
| 104 | + webServer = webServerResult.value; |
105 | 105 | } else { |
106 | | - traceError("Failed to start web server", webServerResult.error) |
| 106 | + traceError("Failed to start web server", webServerResult.error); |
107 | 107 | } |
108 | 108 | } |
109 | 109 | if (lspClient) { |
110 | | - traceVerbose("Restarting LSP client") |
111 | | - const restartResult = await lspClient.restart() |
| 110 | + traceVerbose("Restarting LSP client"); |
| 111 | + const restartResult = await lspClient.restart(); |
112 | 112 | if (isErr(restartResult)) { |
113 | | - handleNotSginedInError(authProvider) |
| 113 | + handleNotSginedInError(authProvider); |
114 | 114 | } |
115 | 115 | } |
116 | | - } |
| 116 | + }; |
117 | 117 |
|
118 | 118 | context.subscriptions.push( |
119 | 119 | onDidChangePythonInterpreter(async () => { |
120 | | - await restart() |
| 120 | + await restart(); |
121 | 121 | }), |
122 | 122 | onDidChangeConfiguration(async () => { |
123 | | - await restart() |
| 123 | + await restart(); |
124 | 124 | }), |
125 | 125 | registerCommand(`sqlmesh.restart`, async () => { |
126 | | - await restart() |
| 126 | + await restart(); |
127 | 127 | }) |
128 | | - ) |
| 128 | + ); |
129 | 129 |
|
130 | | - traceInfo("Extension activated") |
| 130 | + traceInfo("Extension activated"); |
131 | 131 | } |
132 | 132 |
|
133 | 133 | // This method is called when your extension is deactivated |
134 | 134 | export async function deactivate() { |
135 | 135 | if (lspClient) { |
136 | | - await lspClient.dispose() |
| 136 | + await lspClient.dispose(); |
137 | 137 | } |
138 | 138 | if (webServer) { |
139 | 139 | webServer.stop(); |
|
0 commit comments