-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from davelopez/refactor_multi_server
Add multi language server support
- Loading branch information
Showing
71 changed files
with
743 additions
and
174 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
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,21 +1,29 @@ | ||
import { ExtensionContext, Uri } from "vscode"; | ||
import { LanguageClientOptions } from "vscode-languageclient"; | ||
import { LanguageClient } from "vscode-languageclient/browser"; | ||
import { buildLanguageClientOptions, initExtension } from "../common"; | ||
import { buildBasicLanguageClientOptions, initExtension } from "../common"; | ||
import { Constants } from "../common/constants"; | ||
|
||
export function activate(context: ExtensionContext): void { | ||
const client = buildWebLanguageClient(context); | ||
const nativeLanguageClient = createWebWorkerLanguageClient( | ||
Constants.NATIVE_WORKFLOW_LANGUAGE_ID, | ||
Uri.joinPath(context.extensionUri, "server/gx-workflow-ls-native/dist/web/nativeServer.js") | ||
); | ||
const gxFormat2LanguageClient = createWebWorkerLanguageClient( | ||
Constants.GXFORMAT2_WORKFLOW_LANGUAGE_ID, | ||
Uri.joinPath(context.extensionUri, "server/gx-workflow-ls-format2/dist/web/gxFormat2Server.js") | ||
); | ||
|
||
initExtension(context, client); | ||
initExtension(context, nativeLanguageClient, gxFormat2LanguageClient); | ||
} | ||
|
||
export function deactivate(): void { | ||
// Nothing to do yet | ||
} | ||
|
||
function buildWebLanguageClient(context: ExtensionContext): LanguageClient { | ||
const clientOptions: LanguageClientOptions = buildLanguageClientOptions(); | ||
const serverPath = Uri.joinPath(context.extensionUri, "server/dist/web/nativeServer.js"); | ||
const worker = new Worker(serverPath.toString()); | ||
return new LanguageClient("galaxy-workflow-language-client-native", "Galaxy Workflows LS", clientOptions, worker); | ||
function createWebWorkerLanguageClient(languageId: string, serverUri: Uri): LanguageClient { | ||
const documentSelector = [{ language: languageId }]; | ||
const clientOptions: LanguageClientOptions = buildBasicLanguageClientOptions(documentSelector); | ||
const worker = new Worker(serverUri.toString()); | ||
return new LanguageClient(`${languageId}-language-client`, `Galaxy Workflows (${languageId})`, clientOptions, worker); | ||
} |
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
File renamed without changes.
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 was deleted.
Oops, something went wrong.
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,5 +1,6 @@ | ||
/* eslint-disable @typescript-eslint/no-namespace */ | ||
export namespace Constants { | ||
export const NATIVE_WORKFLOW_LANGUAGE_ID = "galaxyworkflow"; | ||
export const GXFORMAT2_WORKFLOW_LANGUAGE_ID = "gxformat2"; | ||
export const CLEAN_WORKFLOW_DOCUMENT_SCHEME = "galaxy-clean-workflow"; | ||
} |
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,56 @@ | ||
import { commands, ExtensionContext } from "vscode"; | ||
import { CommonLanguageClient, DocumentSelector, LanguageClientOptions } from "vscode-languageclient"; | ||
import { setupCommands } from "../commands/setup"; | ||
import { CleanWorkflowDocumentProvider } from "../providers/cleanWorkflowDocumentProvider"; | ||
import { CleanWorkflowProvider } from "../providers/cleanWorkflowProvider"; | ||
import { GitProvider } from "../providers/git"; | ||
import { BuiltinGitProvider } from "../providers/git/gitProvider"; | ||
|
||
export function buildBasicLanguageClientOptions(documentSelector: DocumentSelector): LanguageClientOptions { | ||
// Options to control the language client | ||
const clientOptions: LanguageClientOptions = { | ||
documentSelector, | ||
synchronize: {}, | ||
initializationOptions: {}, | ||
}; | ||
return clientOptions; | ||
} | ||
|
||
export function initExtension( | ||
context: ExtensionContext, | ||
nativeClient: CommonLanguageClient, | ||
gxFormat2Client: CommonLanguageClient | ||
): void { | ||
const gitProvider = initGitProvider(context); | ||
|
||
// Setup native workflow language features | ||
setupProviders(context, nativeClient, gitProvider); | ||
setupCommands(context, nativeClient, gitProvider); | ||
startLanguageClient(context, nativeClient); | ||
|
||
// Setup gxformat2 language features | ||
startLanguageClient(context, gxFormat2Client); | ||
} | ||
|
||
function initGitProvider(context: ExtensionContext): BuiltinGitProvider { | ||
const gitProvider = new BuiltinGitProvider(); | ||
gitProvider.initialize().then(() => { | ||
commands.executeCommand("setContext", "galaxy-workflows.gitProviderInitialized", gitProvider.isInitialized); | ||
console.log(`${context.extension.id} Git initialized is ${gitProvider.isInitialized}.`); | ||
}); | ||
return gitProvider; | ||
} | ||
|
||
function startLanguageClient(context: ExtensionContext, languageClient: CommonLanguageClient): void { | ||
const disposable = languageClient.start(); | ||
context.subscriptions.push(disposable); | ||
|
||
languageClient.onReady().then(() => { | ||
console.log(`${context.extension.id} ${languageClient.outputChannel.name} server is ready.`); | ||
}); | ||
} | ||
|
||
function setupProviders(context: ExtensionContext, client: CommonLanguageClient, gitProvider: GitProvider): void { | ||
const cleanWorkflowProvider = new CleanWorkflowProvider(client, gitProvider); | ||
CleanWorkflowDocumentProvider.register(context, cleanWorkflowProvider); | ||
} |
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.