Teach extension how to launch Mono-based OmniSharp server

This commit is contained in:
Dustin Campbell 2016-07-18 11:07:09 -07:00
Родитель 5287323892
Коммит 0e5bdb80c6
2 изменённых файлов: 46 добавлений и 23 удалений

Просмотреть файл

@ -210,7 +210,19 @@ function launchWindows(details: LaunchDetails): Promise<LaunchResult> {
});
}
function launchNix(details: LaunchDetails): Promise<LaunchResult>{
function launchNix(details: LaunchDetails): Promise<LaunchResult> {
if (details.flavor === omnisharp.Flavor.CoreCLR) {
return launchNixCoreCLR(details);
}
else if (details.flavor === omnisharp.Flavor.Mono) {
return launchNixMono(details);
}
else {
throw new Error(`Unexpected OmniSharp flavor: ${details.flavor}`);
}
}
function launchNixCoreCLR(details: LaunchDetails): Promise<LaunchResult> {
return new Promise<LaunchResult>(resolve => {
let process = spawn(details.serverPath, details.args, {
detached: false,
@ -222,29 +234,38 @@ function launchNix(details: LaunchDetails): Promise<LaunchResult>{
command: details.serverPath
});
});
}
// return new Promise((resolve, reject) => {
// hasMono('>=4.0.1').then(hasIt => {
// if (!hasIt) {
// reject(new Error('Cannot start Omnisharp because Mono version >=4.0.1 is required. See http://go.microsoft.com/fwlink/?linkID=534832#_20001'));
// } else {
// resolve();
// }
// });
// }).then(_ => {
// return installOmnisharpIfNeeded();
// }).then(command => {
// let process = spawn(command, args, {
// detached: false,
// // env: details.env,
// cwd
// });
function launchNixMono(details: LaunchDetails): Promise<LaunchResult> {
return new Promise<LaunchResult>((resolve, reject) => {
return canLaunchMono().then(() => {
let args = details.args.slice(0); // create copy of details.args
args.unshift(details.serverPath);
// return {
// process,
// command
// };
// });
let process = spawn('mono', args, {
detached: false,
cwd: details.cwd
});
return resolve({
process,
command: details.serverPath
});
});
});
}
function canLaunchMono(): Promise<void> {
return new Promise<void>((resolve, reject) => {
hasMono('>=4.0.1').then(success => {
if (success) {
return resolve();
}
else {
return reject(new Error('Cannot start Omnisharp because Mono version >=4.0.1 is required.'));
}
});
});
}
export function hasMono(range?: string): Promise<boolean> {

Просмотреть файл

@ -405,7 +405,9 @@ export abstract class OmnisharpServer {
return new Promise<string>((resolve, reject) => {
if (options.path) {
return omnisharp.findServerPath(options.path).catch(err => {
return omnisharp.findServerPath(options.path).then(serverPath => {
return resolve(serverPath);
}).catch(err => {
vscode.window.showWarningMessage(`Invalid "csharp.omnisharp" user setting specified ('${options.path}).`);
return reject(err);
});