Skip to content

Minor bug fixes for 0.5.0 #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,20 @@
"type": "object",
"title": "PowerShell Configuration",
"properties": {
"powershell.useX86Host": {
"type": "boolean",
"default": false,
"description": "If true, causes the 32-bit language service to be used on 64-bit Windows. On 32-bit Windows this setting has no effect. This setting does not affect the debugger which has its own architecture configuration."
},
"powershell.scriptAnalysis.enable": {
"type": "boolean",
"default": true,
"description": "Enables real-time script analysis using PowerShell Script Analyzer."
},
"powershell.developer.editorServicesHostPath": {
"type": "string",
"default": "../bin/Microsoft.PowerShell.EditorServices.Host.exe",
"description": "Specifies the path to the PowerShell Editor Services host executable."
"default": "../bin/",
"description": "Specifies the path to the folder containing the PowerShell Editor Services host executables."
},
"powershell.developer.editorServicesLogLevel": {
"type": "string",
Expand Down
98 changes: 62 additions & 36 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

'use strict';

import os = require('os');
import path = require('path');
import vscode = require('vscode');
import settingsManager = require('./settings');
Expand Down Expand Up @@ -64,45 +65,57 @@ export function activate(context: vscode.ExtensionContext): void {
}
});

let args = [];
if (settings.developer.editorServicesWaitForDebugger) {
args.push('/waitForDebugger');
}
if (settings.developer.editorServicesLogLevel) {
args.push('/logLevel:' + settings.developer.editorServicesLogLevel)
}

let serverPath = resolveLanguageServerPath(settings);
let serverOptions = {
run: {
command: serverPath,
args: args
},
debug: {
command: serverPath,
args: ['/waitForDebugger']
// The language server is only available on Windows
if (os.platform() == "win32")
{
let args = [];
if (settings.developer.editorServicesWaitForDebugger) {
args.push('/waitForDebugger');
}
};

let clientOptions: LanguageClientOptions = {
documentSelector: [PowerShellLanguageId],
synchronize: {
configurationSection: PowerShellLanguageId,
//fileEvents: vscode.workspace.createFileSystemWatcher('**/.eslintrc')
if (settings.developer.editorServicesLogLevel) {
args.push('/logLevel:' + settings.developer.editorServicesLogLevel)
}
}

languageServerClient =
new LanguageClient(
'PowerShell Editor Services',
serverOptions,
clientOptions);
try
{
let serverPath = resolveLanguageServerPath(settings);
let serverOptions = {
run: {
command: serverPath,
args: args
},
debug: {
command: serverPath,
args: ['/waitForDebugger']
}
};

let clientOptions: LanguageClientOptions = {
documentSelector: [PowerShellLanguageId],
synchronize: {
configurationSection: PowerShellLanguageId,
//fileEvents: vscode.workspace.createFileSystemWatcher('**/.eslintrc')
}
}

languageServerClient =
new LanguageClient(
'PowerShell Editor Services',
serverOptions,
clientOptions);

languageServerClient.onReady().then(
() => registerFeatures(),
(reason) => vscode.window.showErrorMessage("Could not start language service: " + reason));
languageServerClient.onReady().then(
() => registerFeatures(),
(reason) => vscode.window.showErrorMessage("Could not start language service: " + reason));

languageServerClient.start();
languageServerClient.start();
}
catch (e)
{
vscode.window.showErrorMessage(
"The language service could not be started: " + e);
}
}
}

function registerFeatures() {
Expand All @@ -128,11 +141,17 @@ function resolveLanguageServerPath(settings: settingsManager.ISettings): string
if (editorServicesHostPath) {
console.log("Found Editor Services path from config: " + editorServicesHostPath);

// Does the path end in a .exe? Alert the user if so.
if (path.extname(editorServicesHostPath) != '') {
throw "The editorServicesHostPath setting must point to a directory, not a file.";
}

// Make the path absolute if it's not
editorServicesHostPath =
path.resolve(
__dirname,
editorServicesHostPath);
editorServicesHostPath,
getHostExeName(settings.useX86Host));

console.log(" Resolved path to: " + editorServicesHostPath);
}
Expand All @@ -143,10 +162,17 @@ function resolveLanguageServerPath(settings: settingsManager.ISettings): string
__dirname,
'..',
'bin',
'Microsoft.PowerShell.EditorServices.Host.exe');
getHostExeName(settings.useX86Host));

console.log("Using default Editor Services path: " + editorServicesHostPath);
}

return editorServicesHostPath;
}

function getHostExeName(useX86Host: boolean): string {
// The useX86Host setting is only relevant on 64-bit OS
var is64BitOS = process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432');
var archText = useX86Host && is64BitOS ? ".x86" : "";
return "Microsoft.PowerShell.EditorServices.Host" + archText + ".exe";
}
4 changes: 3 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface IDeveloperSettings {
}

export interface ISettings {
useX86Host?: boolean,
scriptAnalysis?: IScriptAnalysisSettings,
developer?: IDeveloperSettings,
}
Expand All @@ -29,12 +30,13 @@ export function load(myPluginId: string): ISettings {
};

let defaultDeveloperSettings = {
editorServicesHostPath: "../bin/Microsoft.PowerShell.EditorServices.Host.exe",
editorServicesHostPath: "../bin/",
editorServicesLogLevel: "Normal",
editorServicesWaitForDebugger: false
}

return {
useX86Host: configuration.get<boolean>("useX86Host", false),
scriptAnalysis: configuration.get<IScriptAnalysisSettings>("scriptAnalysis", defaultScriptAnalysisSettings),
developer: configuration.get<IDeveloperSettings>("developer", defaultDeveloperSettings)
}
Expand Down