-
-
Notifications
You must be signed in to change notification settings - Fork 178
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
Showing
17 changed files
with
256 additions
and
20 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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
# Linked packages are problematic during build, npm i during start will fix it | ||
node_modules/@typefox/monaco-editor-react | ||
node_modules/example-client-vite | ||
node_modules/example-client-webpack | ||
node_modules/monaco-languageclient | ||
node_modules/monaco-editor-wrapper | ||
node_modules/monaco-languageclient-examples | ||
node_modules/vscode-ws-jsonrpc | ||
## Linked packages are problematic during build, npm i during start will fix it | ||
#node_modules/@typefox/monaco-editor-react | ||
#node_modules/example-client-vite | ||
#node_modules/example-client-webpack | ||
#node_modules/monaco-languageclient | ||
#node_modules/monaco-editor-wrapper | ||
#node_modules/monaco-languageclient-examples | ||
#node_modules/vscode-ws-jsonrpc | ||
|
||
node_modules |
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
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
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,2 +1,4 @@ | ||
resources/groovy/external | ||
resources/eclipse.jdt.ls/ls | ||
resources/eclipse.jdt.ls/*.tar.gz | ||
resources/vsix |
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,24 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>Java Language Client & Language Server (Web Socket)</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
|
||
<body> | ||
<h2>Java Language Client & Language Server (Web Socket)</h2> | ||
<button type="button" id="button-start">Start</button> | ||
<button type="button" id="button-dispose">Dispose</button> | ||
<div id="monaco-editor-root" style="width:800px;height:600px;border:1px solid grey"></div> | ||
<script type="module"> | ||
import { configureMonacoWorkers, runEclipseJdtLsClient } from "./src/eclipse.jdt.ls/client/main.ts"; | ||
|
||
configureMonacoWorkers(); | ||
runEclipseJdtLsClient(); | ||
</script> | ||
</body> | ||
|
||
</html> |
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,29 @@ | ||
FROM eclipse-temurin:17-jdk | ||
|
||
ARG MLC_PATH=/home/mlc | ||
ARG ECLIPSE_JDT_PATH=${MLC_PATH}/packages/examples/resources/eclipse.jdt.ls/ls | ||
ARG JDT_TAR_URL=https://download.eclipse.org/jdtls/milestones/1.37.0/jdt-language-server-1.37.0-202406271335.tar.gz | ||
ARG JDT_TAR_LOCAL=eclipse.jdt.ls.tar.gz | ||
|
||
RUN apt update \ | ||
&& apt upgrade -y | ||
RUN apt install -y wget | ||
|
||
RUN curl https://get.volta.sh | bash | ||
ENV VOLTA_FEATURE_PNPM=1 | ||
ENV VOLTA_HOME "/root/.volta" | ||
ENV PATH "$VOLTA_HOME/bin:$PATH" | ||
RUN volta install node@20 | ||
|
||
RUN mkdir -p ${MLC_PATH} | ||
|
||
COPY ./ ${MLC_PATH} | ||
|
||
RUN mkdir -p ${ECLIPSE_JDT_PATH} \ | ||
&& cd ${ECLIPSE_JDT_PATH} \ | ||
&& wget -O ${JDT_TAR_LOCAL} ${JDT_TAR_URL} \ | ||
&& tar -xzf ${JDT_TAR_LOCAL} | ||
|
||
WORKDIR ${MLC_PATH} | ||
|
||
CMD ["/bin/bash", "npm i && npm run start:example:server:jdtls"] |
16 changes: 16 additions & 0 deletions
16
packages/examples/resources/eclipse.jdt.ls/docker-compose.yml
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,16 @@ | ||
services: | ||
eclipsejdtls: | ||
build: | ||
dockerfile: ./packages/examples/resources/eclipse.jdt.ls/Dockerfile | ||
context: ../../../.. | ||
environment: | ||
- MLC_PATH=/home/mlc | ||
- JDT_TAR_URL=https://download.eclipse.org/jdtls/milestones/1.37.0/jdt-language-server-1.37.0-202406271335.tar.gz | ||
- JDT_TAR_LOCAL=eclipse.jdt.ls.tar.gz | ||
command: [ | ||
"bash", "-c", "npm i && npm run start:example:server:jdtls" | ||
] | ||
ports: | ||
- 30003:30003 | ||
working_dir: /home/mlc | ||
container_name: eclipsejdtls |
3 changes: 3 additions & 0 deletions
3
packages/examples/resources/eclipse.jdt.ls/workspace/hello.java
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,3 @@ | ||
public static void main (String[] args) { | ||
System.out.println("Hello World!"); | ||
} |
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,24 @@ | ||
FROM gradle:7-jdk17-focal | ||
|
||
ARG MLC_PATH=/home/gradle/mlc | ||
|
||
RUN apt update \ | ||
&& apt upgrade -y \ | ||
&& apt install -y ca-certificates curl gnupg unzip | ||
|
||
RUN mkdir -p /etc/apt/keyrings \ | ||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ | ||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \ | ||
&& apt update \ | ||
&& apt install -y nodejs | ||
RUN curl https://get.volta.sh | bash | ||
ENV VOLTA_FEATURE_PNPM=1 | ||
ENV VOLTA_HOME "/root/.volta" | ||
ENV PATH "$VOLTA_HOME/bin:$PATH" | ||
RUN volta install node@20 | ||
|
||
RUN git clone https://github.com/GroovyLanguageServer/groovy-language-server \ | ||
&& cd groovy-language-server \ | ||
&& ./gradlew build \ | ||
&& cd .. | ||
|
||
RUN mkdir -p /home/gradle/mlc | ||
RUN mkdir -p ${MLC_PATH} | ||
|
||
COPY ./ /home/gradle/mlc/ | ||
COPY ./ ${MLC_PATH} | ||
|
||
WORKDIR /home/gradle/mlc | ||
WORKDIR ${MLC_PATH} |
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,3 @@ | ||
version: '3' | ||
|
||
services: | ||
groovyls: | ||
build: | ||
|
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,86 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2024 TypeFox and others. | ||
* Licensed under the MIT License. See LICENSE in the package root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
import * as vscode from 'vscode'; | ||
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override'; | ||
// this is required syntax highlighting | ||
import '@codingame/monaco-vscode-java-default-extension'; | ||
import { MonacoEditorLanguageClientWrapper, UserConfig } from 'monaco-editor-wrapper'; | ||
import { useWorkerFactory } from 'monaco-editor-wrapper/workerFactory'; | ||
import { RegisteredFileSystemProvider, RegisteredMemoryFile } from '@codingame/monaco-vscode-files-service-override'; | ||
import helloJavaCode from '../../../resources/eclipse.jdt.ls/workspace/hello.java?raw'; | ||
import { eclipseJdtLsConfig } from '../config'; | ||
|
||
export const configureMonacoWorkers = () => { | ||
useWorkerFactory({ | ||
ignoreMapping: true, | ||
workerLoaders: { | ||
editorWorkerService: () => new Worker(new URL('monaco-editor/esm/vs/editor/editor.worker.js', import.meta.url), { type: 'module' }), | ||
} | ||
}); | ||
}; | ||
|
||
export const runEclipseJdtLsClient = () => { | ||
const helloJavaUri = vscode.Uri.file(`${eclipseJdtLsConfig.basePath}/workspace/hello.java`); | ||
const fileSystemProvider = new RegisteredFileSystemProvider(false); | ||
fileSystemProvider.registerFile(new RegisteredMemoryFile(helloJavaUri, helloJavaCode)); | ||
|
||
const userConfig: UserConfig = { | ||
wrapperConfig: { | ||
serviceConfig: { | ||
userServices: { | ||
...getKeybindingsServiceOverride(), | ||
}, | ||
debugLogging: true | ||
}, | ||
editorAppConfig: { | ||
$type: 'extended', | ||
codeResources: { | ||
main: { | ||
text: helloJavaCode, | ||
uri: `${eclipseJdtLsConfig.basePath}/workspace/hello.java` | ||
} | ||
}, | ||
useDiffEditor: false, | ||
userConfiguration: { | ||
json: JSON.stringify({ | ||
'workbench.colorTheme': 'Default Dark Modern', | ||
'editor.guides.bracketPairsHorizontal': 'active' | ||
}) | ||
} | ||
} | ||
}, | ||
languageClientConfig: { | ||
languageId: 'java', | ||
options: { | ||
$type: 'WebSocketUrl', | ||
url: 'ws://localhost:30003/jdtls' | ||
}, | ||
clientOptions: { | ||
documentSelector: ['java'], | ||
workspaceFolder: { | ||
index: 0, | ||
name: 'workspace', | ||
uri: vscode.Uri.parse(`${eclipseJdtLsConfig.basePath}/workspace`) | ||
}, | ||
}, | ||
} | ||
}; | ||
|
||
const wrapper = new MonacoEditorLanguageClientWrapper(); | ||
const htmlElement = document.getElementById('monaco-editor-root'); | ||
|
||
try { | ||
document.querySelector('#button-start')?.addEventListener('click', async () => { | ||
await wrapper.dispose(); | ||
await wrapper.initAndStart(userConfig, htmlElement); | ||
}); | ||
document.querySelector('#button-dispose')?.addEventListener('click', async () => { | ||
await wrapper.dispose(); | ||
}); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}; |
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 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2024 TypeFox and others. | ||
* Licensed under the MIT License. See LICENSE in the package root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
export const eclipseJdtLsConfig = { | ||
port: 30003, | ||
path: '/jdtls', | ||
basePath: '/home/mlc/packages/examples/resources/eclipse.jdt.ls' | ||
}; |
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,8 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2024 TypeFox and others. | ||
* Licensed under the MIT License. See LICENSE in the package root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
import { runEclipseJdtLs } from './main.js'; | ||
|
||
runEclipseJdtLs(); |
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,40 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2024 TypeFox and others. | ||
* Licensed under the MIT License. See LICENSE in the package root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
import { runLanguageServer } from '../../common/node/language-server-runner.js'; | ||
import { LanguageName } from '../../common/node/server-commons.js'; | ||
import { eclipseJdtLsConfig } from '../config.js'; | ||
|
||
export const runEclipseJdtLs = () => { | ||
; | ||
runLanguageServer({ | ||
serverName: 'Eclipse JDT LS', | ||
pathName: eclipseJdtLsConfig.path, | ||
serverPort: eclipseJdtLsConfig.port, | ||
runCommand: LanguageName.java, | ||
runCommandArgs: [ | ||
'-Declipse.application=org.eclipse.jdt.ls.core.id1', | ||
'-Dosgi.bundles.defaultStartLevel=4', | ||
'-Declipse.product=org.eclipse.jdt.ls.core.product', | ||
'-Dlog.level=ALL', | ||
'-Xmx1G', | ||
'--add-modules=ALL-SYSTEM', | ||
'--add-opens', | ||
'java.base/java.util=ALL-UNNAMED', | ||
'--add-opens', | ||
'java.base/java.lang=ALL-UNNAMED', | ||
'-jar', | ||
`${eclipseJdtLsConfig.basePath}/ls/plugins/org.eclipse.equinox.launcher_1.6.900.v20240613-2009.jar`, | ||
'-configuration', | ||
`${eclipseJdtLsConfig.basePath}/ls/config_linux`, | ||
'-data', | ||
`${eclipseJdtLsConfig.basePath}/workspace` | ||
], | ||
wsServerOptions: { | ||
noServer: true, | ||
perMessageDeflate: false | ||
} | ||
}); | ||
}; |
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