Skip to content

Commit

Permalink
[WIP] run a binary server
Browse files Browse the repository at this point in the history
Signed-off-by: Fred Bricon <[email protected]>
  • Loading branch information
fbricon authored and datho7561 committed Aug 25, 2020
1 parent bd92979 commit d8478a5
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.ts]
[*.js]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
34 changes: 32 additions & 2 deletions src/javaServerStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,23 @@ export function prepareExecutable(requirements: RequirementsData, xmlJavaExtensi
options.env = process.env;
options.stdio = 'pipe';
executable.options = options;
executable.command = path.resolve(requirements.java_home + '/bin/java');
executable.args = prepareParams(requirements, xmlJavaExtensions, context);
const useBinary = getXMLConfiguration().get("server.binary.enabled", false);
if (useBinary) {
//TODO handle case when other extensions contributing jars expect to force JVM mode
const binaryPath = findServerBinary();
if (binaryPath) {
executable.command = binaryPath;
} else {
//TODO handle missing binary
console.log("Missing xml.server.binary.path");
}
//TODO handle binary args
}
// Fall back to JVM Mode
if(!(executable.command)) {
executable.command = path.resolve(requirements.java_home + '/bin/java');
executable.args = prepareParams(requirements, xmlJavaExtensions, context);
}
return executable;
}

Expand Down Expand Up @@ -78,6 +93,21 @@ function prepareParams(requirements: RequirementsData, xmlJavaExtensions: string
return params;
}

function findServerBinary(): string {
const config = getXMLConfiguration();
let binaryPath:string = config.get("server.binary.path");
if (!binaryPath) {
let server_home: string = path.resolve(__dirname, '../server');
let binariesFound: Array<string> = glob.sync('**/lemminx*', { cwd: server_home });
if (binariesFound.length) {
binaryPath = path.resolve(server_home, binariesFound[0]);
}
//TODO handle missing binary
}
return (binaryPath)?binaryPath: null;
}


function startedInDebugMode(): boolean {
const args = (process as any).execArgv as string[];
return hasDebugFlag(args);
Expand Down
1 change: 1 addition & 0 deletions src/requirements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface ErrorData {
*
*/
export async function resolveRequirements(context: ExtensionContext): Promise<RequirementsData> {
//TODO Handle different requirements if using binary
const javaHome = await checkJavaRuntime(context);
const javaVersion = await checkJavaVersion(javaHome);
return Promise.resolve({ 'java_home': javaHome, 'java_version': javaVersion});
Expand Down

0 comments on commit d8478a5

Please sign in to comment.