Initial work for theia-spring-boot. Fix for PT: #156934110.

This commit is contained in:
BoykoAlex
2018-05-07 21:35:57 -04:00
parent 7f4967d0a6
commit cddb017029
27 changed files with 8866 additions and 263 deletions

View File

@@ -1,6 +0,0 @@
/**/.idea
/**/.iml
/theia-extensions.iml
/**/yarn-error.log
/**/node_modules/
/**/server/

View File

@@ -1,5 +1,4 @@
# CF Manifest YAML editor for Theia IDE
The example of how to build the Theia-based applications with the cf-manifest-yaml.
## Getting started

View File

@@ -3,11 +3,10 @@
*/
import { CfManifestYamlClientContribution } from './language-client-contribution';
import { LanguageClientContribution } from "@theia/languages/lib/browser";
import { LanguageClientContribution } from '@theia/languages/lib/browser';
import { ContainerModule } from 'inversify';
import { ContainerModule } from "inversify";
import "./monaco-contribution";
import './monaco-contribution';
export default new ContainerModule(bind => {
// add your contribution bindings here

View File

@@ -1,4 +1,4 @@
import { injectable, inject } from "inversify";
import { injectable, inject } from 'inversify';
import { BaseLanguageClientContribution, Workspace, Languages, LanguageClientFactory } from '@theia/languages/lib/browser';
import { CF_MANIFEST_YAML_LANGUAGE_ID, CF_MANIFEST_YAML_LANGUAGE_NAME } from '../common';

View File

@@ -0,0 +1,23 @@
/// <reference types='monaco-editor-core/monaco'/>
import {
CF_MANIFEST_YAML_LANGUAGE_ID,
CF_MANIFEST_YAML_LANGUAGE_NAME
} from '../common';
let YAML_LANG_MODULE_PROMISE: monaco.Promise<any>;
monaco.languages.register({
id: CF_MANIFEST_YAML_LANGUAGE_ID,
filenamePatterns: ['*manifest*.yml'],
aliases: [CF_MANIFEST_YAML_LANGUAGE_NAME],
});
monaco.languages.onLanguage(CF_MANIFEST_YAML_LANGUAGE_ID, () => {
if (!YAML_LANG_MODULE_PROMISE) {
YAML_LANG_MODULE_PROMISE = (<any>monaco.languages.getLanguages().find(ext => ext.id === 'yaml')).loader();
}
return YAML_LANG_MODULE_PROMISE.then(mod => {
monaco.languages.setLanguageConfiguration(CF_MANIFEST_YAML_LANGUAGE_ID, mod.conf);
monaco.languages.setMonarchTokensProvider(CF_MANIFEST_YAML_LANGUAGE_ID, mod.language);
})
});

View File

@@ -1,14 +0,0 @@
/// <reference types='monaco-editor-core/monaco'/>
import { CF_MANIFEST_YAML_LANGUAGE_ID, CF_MANIFEST_YAML_LANGUAGE_NAME } from '../../common';
import { conf, language } from "./yaml";
monaco.languages.register({
id: CF_MANIFEST_YAML_LANGUAGE_ID,
filenamePatterns: ['*manifest*.yml'],
aliases: [CF_MANIFEST_YAML_LANGUAGE_NAME],
});
monaco.languages.onLanguage(CF_MANIFEST_YAML_LANGUAGE_ID, () => {
monaco.languages.setLanguageConfiguration(CF_MANIFEST_YAML_LANGUAGE_ID, conf);
monaco.languages.setMonarchTokensProvider(CF_MANIFEST_YAML_LANGUAGE_ID, language);
});

View File

@@ -1,234 +0,0 @@
/// <reference types='monaco-editor-core/monaco'/>
import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration;
import ILanguage = monaco.languages.IMonarchLanguage;
export const conf: IRichLanguageConfiguration = {
comments: {
lineComment: '#'
},
brackets: [
['{', '}'],
['[', ']'],
['(', ')']
],
autoClosingPairs: [
{ open: '{', close: '}' },
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: '"', close: '"' },
{ open: '\'', close: '\'' },
],
surroundingPairs: [
{ open: '{', close: '}' },
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: '"', close: '"' },
{ open: '\'', close: '\'' },
],
// folding: {
// offSide: true
// }
};
export const language = <ILanguage>{
tokenPostfix: '.yaml',
brackets: [
{ token: 'delimiter.bracket', open: '{', close: '}' },
{ token: 'delimiter.square', open: '[', close: ']' }
],
keywords: ['true', 'True', 'TRUE', 'false', 'False', 'FALSE', 'null', 'Null', 'Null', '~'],
numberInteger: /(?:0|[+-]?[0-9]+)/,
numberFloat: /(?:0|[+-]?[0-9]+)(?:\.[0-9]+)?(?:e[-+][1-9][0-9]*)?/,
numberOctal: /0o[0-7]+/,
numberHex: /0x[0-9a-fA-F]+/,
numberInfinity: /[+-]?\.(?:inf|Inf|INF)/,
numberNaN: /\.(?:nan|Nan|NAN)/,
numberDate: /\d{4}-\d\d-\d\d([Tt ]\d\d:\d\d:\d\d(\.\d+)?(( ?[+-]\d\d?(:\d\d)?)|Z)?)?/,
escapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,
tokenizer: {
root: [
{ include: '@whitespace' },
{ include: '@comment' },
// Directive
[/%[^ ]+.*$/, 'meta.directive'],
// Document Markers
[/---/, 'operators.directivesEnd'],
[/\.{3}/, 'operators.documentEnd'],
// Block Structure Indicators
[/[-?:](?= )/, 'operators'],
{ include: '@anchor' },
{ include: '@tagHandle' },
{ include: '@flowCollections' },
{ include: '@blockStyle' },
// Numbers
[/@numberInteger(?![ \t]*\S+)/, 'number'],
[/@numberFloat(?![ \t]*\S+)/, 'number.float'],
[/@numberOctal(?![ \t]*\S+)/, 'number.octal'],
[/@numberHex(?![ \t]*\S+)/, 'number.hex'],
[/@numberInfinity(?![ \t]*\S+)/, 'number.infinity'],
[/@numberNaN(?![ \t]*\S+)/, 'number.nan'],
[/@numberDate(?![ \t]*\S+)/, 'number.date'],
// Key:Value pair
[/(".*?"|'.*?'|.*?)([ \t]*)(:)( |$)/, ['type', 'white', 'operators', 'white']],
{ include: '@flowScalars' },
// String nodes
[/.+$/, {
cases: {
'@keywords': 'keyword',
'@default': 'string'
}
}]
],
// Flow Collection: Flow Mapping
object: [
{ include: '@whitespace' },
{ include: '@comment' },
// Flow Mapping termination
[/\}/, '@brackets', '@pop'],
// Flow Mapping delimiter
[/,/, 'delimiter.comma'],
// Flow Mapping Key:Value delimiter
[/:(?= )/, 'operators'],
// Flow Mapping Key:Value key
[/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/, 'type'],
// Start Flow Style
{ include: '@flowCollections' },
{ include: '@flowScalars' },
// Scalar Data types
{ include: '@tagHandle' },
{ include: '@anchor' },
{ include: '@flowNumber' },
// Other value (keyword or string)
[/[^\},]+/, {
cases: {
'@keywords': 'keyword',
'@default': 'string'
}
}]
],
// Flow Collection: Flow Sequence
array: [
{ include: '@whitespace' },
{ include: '@comment' },
// Flow Sequence termination
[/\]/, '@brackets', '@pop'],
// Flow Sequence delimiter
[/,/, 'delimiter.comma'],
// Start Flow Style
{ include: '@flowCollections' },
{ include: '@flowScalars' },
// Scalar Data types
{ include: '@tagHandle' },
{ include: '@anchor' },
{ include: '@flowNumber' },
// Other value (keyword or string)
[/[^\],]+/, {
cases: {
'@keywords': 'keyword',
'@default': 'string'
}
}]
],
// Flow Scalars (quoted strings)
string: [
[/[^\\"']+/, 'string'],
[/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'],
[/["']/, {
cases: {
'$#==$S2': { token: 'string', next: '@pop' },
'@default': 'string'
}
}]
],
// First line of a Block Style
multiString: [
[/^( +).+$/, 'string', '@multiStringContinued.$1']
],
// Further lines of a Block Style
// Workaround for indentation detection
multiStringContinued: [
[/^( *).+$/, {
cases: {
'$1==$S2': 'string',
'@default': { token: '@rematch', next: '@popall' }
}
}]
],
whitespace: [
[/[ \t\r\n]+/, 'white']
],
// Only line comments
comment: [
[/#.*$/, 'comment']
],
// Start Flow Collections
flowCollections: [
[/\[/, '@brackets', '@array'],
[/\{/, '@brackets', '@object']
],
// Start Flow Scalars (quoted strings)
flowScalars: [
[/"/, 'string', '@string."'],
[/'/, 'string', '@string.\'']
],
// Start Block Scalar
blockStyle: [
[/[>|][0-9]*[+-]?$/, 'operators', '@multiString']
],
// Numbers in Flow Collections (terminate with ,]})
flowNumber: [
[/@numberInteger(?=[ \t]*[,\]\}])/, 'number'],
[/@numberFloat(?=[ \t]*[,\]\}])/, 'number.float'],
[/@numberOctal(?=[ \t]*[,\]\}])/, 'number.octal'],
[/@numberHex(?=[ \t]*[,\]\}])/, 'number.hex'],
[/@numberInfinity(?=[ \t]*[,\]\}])/, 'number.infinity'],
[/@numberNaN(?=[ \t]*[,\]\}])/, 'number.nan'],
[/@numberDate(?=[ \t]*[,\]\}])/, 'number.date']
],
tagHandle: [
[/\![^ ]*/, 'tag']
],
anchor: [
[/[&*][^ ]+/, 'namespace']
]
}
};

View File

@@ -1,3 +0,0 @@
{
"jarUrl": "https://s3-us-west-1.amazonaws.com/s3-test.spring.io/sts4/fatjars/snapshots/manifest-yaml-language-server-0.1.5-201803080105.jar"
}

View File

@@ -0,0 +1,6 @@
node_modules
.browser_modules
lib
*.log
*-app/*
!*-app/package.json

View File

@@ -0,0 +1,60 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Start Browser Backend",
"program": "${workspaceRoot}/browser-app/src-gen/backend/main.js",
"args": [
"--loglevel=debug",
"--port=3000",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js",
"${workspaceRoot}/browser-app/lib/**/*.js",
"${workspaceRoot}/browser-app/src-gen/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "Start Electron Backend",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
"windows": {
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
},
"program": "${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"protocol": "inspector",
"args": [
"--loglevel=debug",
"--hostname=localhost",
"--no-cluster"
],
"env": {
"NODE_ENV": "development"
},
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/electron-app/src-gen/frontend/electron-main.js",
"${workspaceRoot}/electron-app/src-gen/backend/main.js",
"${workspaceRoot}/electron-app/lib/**/*.js",
"${workspaceRoot}/node_modules/@theia/*/lib/**/*.js"
],
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outputCapture": "std"
}
]
}

View File

@@ -0,0 +1,73 @@
# Spring Boot Extension
Spring Boot support extension for Theia IDE
## Getting started
Install [nvm](https://github.com/creationix/nvm#install-script).
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
Install npm and node.
nvm install 8
nvm use 8
Install yarn.
npm install -g yarn
## Running the browser example
yarn rebuild:browser
cd browser-app
yarn start
Open http://localhost:3000 in the browser.
## Running the Electron example
yarn rebuild:electron
cd electron-app
yarn start
## Developing with the browser example
Start watching of the hello world extension.
cd spring-boot
yarn watch
Start watching of the browser example.
yarn rebuild:browser
cd browser-app
yarn watch
Launch `Start Browser Backend` configuration from VS code.
Open http://localhost:3000 in the browser.
## Developing with the Electron example
Start watching of the hello world extension.
cd spring-boot
yarn watch
Start watching of the electron example.
yarn rebuild:electron
cd electron-app
yarn watch
Launch `Start Electron Backend` configuration from VS code.
## Publishing @theia/spring-boot
Create a npm user and login to the npm registry, [more on npm publishing](https://docs.npmjs.com/getting-started/publishing-npm-packages).
npm login
Publish packages with lerna to update versions properly across local packages, [more on publishing with lerna](https://github.com/lerna/lerna#publish).
npx lerna publish

View File

@@ -0,0 +1,32 @@
{
"private": true,
"name": "browser-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "latest",
"@theia/filesystem": "latest",
"@theia/workspace": "latest",
"@theia/preferences": "latest",
"@theia/navigator": "latest",
"@theia/process": "latest",
"@theia/terminal": "latest",
"@theia/editor": "latest",
"@theia/languages": "latest",
"@theia/markers": "latest",
"@theia/monaco": "latest",
"@theia/typescript": "latest",
"@theia/messages": "latest",
"@theia/spring-boot": "0.0.0"
},
"devDependencies": {
"@theia/cli": "latest"
},
"scripts": {
"prepare": "theia build",
"start": "theia start",
"watch": "theia build --watch"
},
"theia": {
"target": "browser"
}
}

View File

@@ -0,0 +1,32 @@
{
"private": true,
"name": "electron-app",
"version": "0.0.0",
"dependencies": {
"@theia/core": "latest",
"@theia/filesystem": "latest",
"@theia/workspace": "latest",
"@theia/preferences": "latest",
"@theia/navigator": "latest",
"@theia/process": "latest",
"@theia/terminal": "latest",
"@theia/editor": "latest",
"@theia/languages": "latest",
"@theia/markers": "latest",
"@theia/monaco": "latest",
"@theia/typescript": "latest",
"@theia/messages": "latest",
"@theia/spring-boot": "0.0.0"
},
"devDependencies": {
"@theia/cli": "latest"
},
"scripts": {
"prepare": "theia build",
"start": "theia start",
"watch": "theia build --watch"
},
"theia": {
"target": "electron"
}
}

View File

@@ -0,0 +1,11 @@
{
"lerna": "2.4.0",
"version": "0.0.0",
"useWorkspaces": true,
"npmClient": "yarn",
"command": {
"run": {
"stream": true
}
}
}

View File

@@ -0,0 +1,14 @@
{
"private": true,
"scripts": {
"prepare": "lerna run prepare",
"rebuild:browser": "theia rebuild:browser",
"rebuild:electron": "theia rebuild:electron"
},
"devDependencies": {
"lerna": "2.4.0"
},
"workspaces": [
"spring-boot", "browser-app", "electron-app"
]
}

View File

@@ -0,0 +1,38 @@
{
"name": "@theia/spring-boot",
"keywords": [
"theia-extension"
],
"version": "0.0.0",
"files": [
"lib",
"src"
],
"dependencies": {
"@theia/core": "latest",
"@theia/languages": "latest",
"@theia/monaco": "latest",
"@theia/java": "latest",
"@pivotal-tools/jvm-launch-utils": "0.0.11",
"@types/glob": "^5.0.30",
"glob": "^7.1.2"
},
"devDependencies": {
"rimraf": "latest",
"typescript": "latest",
"download": "^6.2.5"
},
"scripts": {
"prepare": "yarn run clean && yarn run download && yarn run build",
"download": "node script.js",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w"
},
"theiaExtensions": [
{
"frontend": "lib/browser/spring-boot-frontend-module",
"backend": "lib/node/spring-boot-backend-module"
}
]
}

View File

@@ -0,0 +1,3 @@
{
"jarUrl": "https://s3-us-west-1.amazonaws.com/s3-test.spring.io/sts4/fatjars/snapshots/spring-boot-language-server-0.2.1-201805050150.jar"
}

View File

@@ -0,0 +1,34 @@
const fs = require('fs');
const path = require('path');
const url = require('url');
const glob = require('glob');
const download = require('download');
const PROPERTIES = require('./properties.json');
let fileExists = function(path) {
return new Promise((resolve, reject) => {
fs.access(path, fs.R_OK, error => {
resolve(!error || error.code !== 'ENOENT');
})
});
};
const serverHome = path.join(__dirname, 'server');
const filePaths = glob.sync('spring-boot-language-server*.jar', { cwd: serverHome });
if (filePaths.length === 0) {
const serverDownloadUrl = PROPERTIES.jarUrl;
const fileName = path.basename(url.parse(serverDownloadUrl).pathname);
const localFileName = path.join(serverHome, fileName.startsWith('spring-boot-language-server') ? fileName : 'spring-boot-language-server.jar');
console.log(`Downloading ${serverDownloadUrl} to ${localFileName}`);
fileExists(serverHome)
.then(doesExist => { if (!doesExist) fs.mkdir(serverHome) })
.then(() => download(serverDownloadUrl))
.then(data => fs.writeFileSync(localFileName, data))
.then(() => fileExists(localFileName))
.then(doesExist => { if (!doesExist) throw Error(`Failed to install the ${this.getServerName()} language server`); })
.then(() => console.log(`Successfully downloaded ${serverDownloadUrl}`));
}

View File

@@ -0,0 +1,39 @@
import { injectable, inject } from 'inversify';
import { BaseLanguageClientContribution, Workspace, Languages, LanguageClientFactory } from '@theia/languages/lib/browser';
import {
SPRING_BOOT_SERVER_ID,
SPRING_BOOT_SERVER_NAME,
BOOT_PROPERTIES_YAML_LANGUAGE_ID,
BOOT_PROPERTIES_LANGUAGE_ID
} from '../common';
import { DocumentSelector } from '@theia/languages/lib/common';
import { JAVA_LANGUAGE_ID } from '@theia/java/lib/common';
@injectable()
export class SpringBootClientContribution extends BaseLanguageClientContribution {
readonly id = SPRING_BOOT_SERVER_ID;
readonly name = SPRING_BOOT_SERVER_NAME;
constructor(
@inject(Workspace) protected readonly workspace: Workspace,
@inject(Languages) protected readonly languages: Languages,
@inject(LanguageClientFactory) protected readonly languageClientFactory: LanguageClientFactory,
) {
super(workspace, languages, languageClientFactory);
}
protected get documentSelector(): DocumentSelector | undefined {
return [JAVA_LANGUAGE_ID, BOOT_PROPERTIES_YAML_LANGUAGE_ID, BOOT_PROPERTIES_LANGUAGE_ID];
}
protected get globPatterns() {
return [
'**/*.java',
'**/application*.yml',
'**/bootstrap*.yml',
'**/application*.properties',
'**/bootstrap*.properties'
];
}
}

View File

@@ -0,0 +1,26 @@
/// <reference types='monaco-editor-core/monaco'/>
import {
BOOT_PROPERTIES_LANGUAGE_ID,
BOOT_PROPERTIES_LANGUAGE_NAME,
} from '../common';
// Boot .properties file language registration
let PROPERTIES_LANG_MODULE_PROMISE: monaco.Promise<any>;
monaco.languages.register({
id: BOOT_PROPERTIES_LANGUAGE_ID,
filenamePatterns: ['application*.properties', 'bootstrap*.properties'],
aliases: [BOOT_PROPERTIES_LANGUAGE_NAME, BOOT_PROPERTIES_LANGUAGE_ID],
});
monaco.languages.onLanguage(BOOT_PROPERTIES_LANGUAGE_ID, () => {
if (!PROPERTIES_LANG_MODULE_PROMISE) {
PROPERTIES_LANG_MODULE_PROMISE = (<any>monaco.languages.getLanguages().find(ext => ext.id === 'ini')).loader();
}
return PROPERTIES_LANG_MODULE_PROMISE.then(mod => {
monaco.languages.setLanguageConfiguration(BOOT_PROPERTIES_LANGUAGE_ID, mod.conf);
monaco.languages.setMonarchTokensProvider(BOOT_PROPERTIES_LANGUAGE_ID, mod.language);
})
});

View File

@@ -0,0 +1,25 @@
/// <reference types='monaco-editor-core/monaco'/>
import {
BOOT_PROPERTIES_YAML_LANGUAGE_ID,
BOOT_PROPERTIES_YAML_LANGUAGE_NAME
} from '../common';
// Boot .yml file language registration
let YAML_LANG_MODULE_PROMISE: monaco.Promise<any>;
monaco.languages.register({
id: BOOT_PROPERTIES_YAML_LANGUAGE_ID,
filenamePatterns: ['application*.yml', 'bootstrap*.yml'],
aliases: [BOOT_PROPERTIES_YAML_LANGUAGE_NAME, BOOT_PROPERTIES_YAML_LANGUAGE_ID],
});
monaco.languages.onLanguage(BOOT_PROPERTIES_YAML_LANGUAGE_ID, () => {
if (!YAML_LANG_MODULE_PROMISE) {
YAML_LANG_MODULE_PROMISE = (<any>monaco.languages.getLanguages().find(ext => ext.id === 'yaml')).loader();
}
return YAML_LANG_MODULE_PROMISE.then(mod => {
monaco.languages.setLanguageConfiguration(BOOT_PROPERTIES_YAML_LANGUAGE_ID, mod.conf);
monaco.languages.setMonarchTokensProvider(BOOT_PROPERTIES_YAML_LANGUAGE_ID, mod.language);
})
});

View File

@@ -0,0 +1,11 @@
import { SpringBootClientContribution} from './language-client-contribution';
import { LanguageClientContribution } from '@theia/languages/lib/browser';
import { ContainerModule } from 'inversify';
import './monaco-yaml-contribution';
import './monaco-properties-contribution';
export default new ContainerModule(bind => {
// add your contribution bindings here
bind(LanguageClientContribution).to(SpringBootClientContribution).inSingletonScope();
});

View File

@@ -0,0 +1,8 @@
export const SPRING_BOOT_SERVER_ID = 'spring-boot';
export const SPRING_BOOT_SERVER_NAME = 'Spring-Boot';
export const BOOT_PROPERTIES_YAML_LANGUAGE_ID = 'spring-boot-properties-yaml';
export const BOOT_PROPERTIES_YAML_LANGUAGE_NAME = 'Spring-Boot-Properties-YAML';
export const BOOT_PROPERTIES_LANGUAGE_ID = 'spring-boot-properties';
export const BOOT_PROPERTIES_LANGUAGE_NAME = 'Spring-Boot-Properties';

View File

@@ -0,0 +1,7 @@
import { ContainerModule } from 'inversify';
import { LanguageServerContribution } from '@theia/languages/lib/node';
import { SpringBootLsContribution } from './spring-boot-ls-contribution';
export default new ContainerModule(bind => {
bind(LanguageServerContribution).to(SpringBootLsContribution).inSingletonScope();
});

View File

@@ -0,0 +1,84 @@
import * as path from 'path';
import * as glob from 'glob';
import { injectable } from 'inversify';
// import { DEBUG_MODE } from '@theia/core/lib/node';
import { IConnection, BaseLanguageServerContribution } from '@theia/languages/lib/node';
import { SPRING_BOOT_SERVER_ID, SPRING_BOOT_SERVER_NAME } from '../common';
import { findJdk } from '@pivotal-tools/jvm-launch-utils';
@injectable()
export class SpringBootLsContribution extends BaseLanguageServerContribution {
readonly id = SPRING_BOOT_SERVER_ID;
readonly name = SPRING_BOOT_SERVER_NAME;
start(clientConnection: IConnection): void {
const serverPath = path.resolve(__dirname, '../../server');
const jarPaths = glob.sync('spring-boot-language-server*.jar', { cwd: serverPath });
if (jarPaths.length === 0) {
throw new Error('The Spring Boot server launcher is not found.');
}
const jarPath = path.resolve(serverPath, jarPaths[0]);
findJdk()
.catch(error => {
throw new Error('Error trying to find JVM');
})
.then(jvm => {
if (!jvm) {
throw new Error("Couldn't locate java in $JAVA_HOME or $PATH");
}
let version = jvm.getMajorVersion();
if (version<1) {
throw new Error(
'No compatible Java Runtime Environment found. The Java Runtime Environment is either below version "1.8" or is missing from the system'
);
}
if (!jvm.isJdk()) {
// TODO: show message that functionality is limited for non-JDK
// this.showErrorMessage(
// '"Boot-Java" Package Functionality Limited',
// 'JAVA_HOME or PATH environment variable seems to point to a JRE. A JDK is required, hence Boot Hints are unavailable.'
// );
}
this.startSocketServer().then(server => {
const socket = this.accept(server);
// this.logInfo('logs at ' + path.resolve(workspacePath, '.metadata', '.log'));
const env = Object.create(process.env);
env.CLIENT_HOST = server.address().address;
env.CLIENT_PORT = server.address().port;
const command = jvm.getJavaExecutable();
const args = [
'-Dsts.lsp.client=theia',
'-Dlsp.completions.indentation.enable=true',
'-Dlsp.yaml.completions.errors.disable=true',
'-Dorg.slf4j.simpleLogger.logFile=boot-java.log',
'-Dorg.slf4j.simpleLogger.defaultLogLevel=debug'
];
args.push(`-Dserver.port=${env.CLIENT_PORT}`);
// if (DEBUG_MODE) {
args.push(
'-Xdebug',
'-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7999',
'-Dlog.level=ALL'
);
// }
args.push(
'-jar', jarPath,
);
this.createProcessSocketConnection(socket, socket, command, args, { env })
.then(serverConnection => this.forward(clientConnection, serverConnection));
});
});
}
}

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"strict": true,
"experimentalDecorators": true,
"noUnusedLocals": true,
"emitDecoratorMetadata": true,
"downlevelIteration": true,
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"lib": [
"es6",
"dom"
],
"sourceMap": true,
"rootDir": "src",
"outDir": "lib"
},
"include": [
"src"
]
}

File diff suppressed because it is too large Load Diff