Skip to content

Update codebase to comply with VSC 0.10.0 APIs #5

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 1 commit into from
Nov 10, 2015
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bin/
out/
node_modules/
vscode-powershell.zip
vscps-preview.zip
vscps-preview.zip
*.vsix
5 changes: 3 additions & 2 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.vscode/**
typings/**
node_modules/vscode/**
node_modules/vscode-languageworker/**
node_modules/**
**/*.ts
.gitignore
tsconfig.json
build/**
bin/EditorServices.log
bin/DebugService.log
bin/*.vshost.*
53 changes: 18 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,36 @@
# Windows PowerShell for Visual Studio Code

Windows PowerShell language support for Visual Studio Code.
This extension provides Windows PowerShell language support for Visual Studio Code.
More details forthcoming.

## Building the code
## Features

First, install the package dependencies:
- IntelliSense for cmdlets and more
- Rule-based analysis provided by [Windows PowerShell Script Analyzer](http://github.com/PowerShell/PSScriptAnalyzer)
- Go to Definition for cmdlets and variables
- Find References of cmdlets and variables
- Local script debugging!

```
npm install
```

The next two steps are required if you have Node.js 5 installed due to some change in npm:

```
cd node_modules\vscode
npm install
```

Now you can compile the code:

```
npm run compile
```

After the initial compile, the source files will be watched and recompiled
when changes are saved.
## Example Scripts

## Running the compiled code
There are some example scripts in the extension's `examples` folder that you can
use to discover PowerShell editing and debugging functionality. Please
check out the included [README.md](examples/README.md) file to learn more about
how to use them.

From a PowerShell or cmd.exe prompt, run the following command:
This folder can be found at the following path:

```
code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
c:\Users\<yourusername>\.vscode\extensions\daviwil.PowerShell\examples
```

If you allow the compiler to continue watching for file changes, you can use
the `Reload Window` command found in the command palette `(Ctrl+Shift+P)`
so that the new source files are loaded.

## Example Scripts
## Contributing to the Code

There are some example scripts in the `examples` folder that you can
use to discover PowerShell editing and debugging functionality. Please
check out the [README.md](examples/README.md) file to learn more about
how to use them.
Check out the [development documentation](docs/development.md) for more details
on how to contribute to this extension!

## License

This project is [licensed under the MIT License](LICENSE). Please see the
This extension is [licensed under the MIT License](LICENSE). Please see the
[third-party notices](Third Party Notices.txt) file for details on the third-party
binaries that we include with releases of this project.
30 changes: 30 additions & 0 deletions docs/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Working with the PowerShell extension code

## Building the code

First, install the package dependencies:

```
npm install
```

Now you can compile the code:

```
npm run compile
```

After the initial compile, the source files will be watched and recompiled
when changes are saved.

## Running the compiled code

From a PowerShell or cmd.exe prompt, run the following command:

```
code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
```

If you allow the compiler to continue watching for file changes, you can use
the `Reload Window` command found in the command palette `(Ctrl+Shift+P)`
so that the new source files are loaded.
Binary file added images/PowerShell_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 45 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
{
"name": "PowerShell",
"version": "0.1.0-preview",
"displayName": "Windows PowerShell Language Support",
"version": "0.1.0",
"publisher": "daviwil",
"description": "Windows PowerShell for Visual Studio Code",
"engines": { "vscode": "*" },
"description": "Develop Windows PowerShell scripts in Visual Studio Code!",
"engines": { "vscode": "0.10.x" },
"author": {
"name": "Microsoft Corporation - Development Labs"
},
"license":"SEE LICENSE FILE",
"homepage": "https://github.com/PowerShell/vscode-powershell/README.md",
"categories": [
"Languages",
"Snippets",
"Linters"
],
"icon": "images/PowerShell_icon.png",
"galleryBanner": {
"color": "#ACD1EC",
"theme": "light"
},
"repository": {
"type": "git",
"url": "https://github.com/PowerShell/vscode-powershell.git"
},
"main": "./out/powershellMain",
"activationEvents": ["onLanguage:PowerShell"],
"dependencies": {
"vscode": "0.9.6"
"devDependencies": {
"vscode": "0.10.0"
},
"scripts": {
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
Expand All @@ -19,13 +39,31 @@
"extensions": [ ".ps1", ".psm1", ".psd1", ".pssc", ".psrc" ],
"aliases": [ "PowerShell", "powershell", "ps", "ps1" ]
}],
"grammars": [{
"language": "PowerShell",
"scopeName": "source.powershell",
"path": "./syntaxes/PowerShell.tmLanguage"
}],
"snippets": [
{
"language": "PowerShell",
"path": "./snippets/PowerShell.json"
}
],
"debuggers": [
{
"type": "PowerShell",
"enableBreakpointsFor": { "languageIds": ["PowerShell"] },
"program": "bin/Microsoft.PowerShell.EditorServices.Host.exe"
}
],
"configuration": {
"type": "object",
"title": "PowerShell Configuration",
"properties": {
"PowerShell.editorServicesHostPath": {
"type": "string",
"default": "bin/Microsoft.PowerShell.EditorServices.Host.exe",
"default": "../bin/Microsoft.PowerShell.EditorServices.Host.exe",
"description": "Specifies the path to the PowerShell Editor Services host executable."
},
"PowerShell.waitForDebugger": {
Expand All @@ -39,14 +77,7 @@
"description": "Enables diagnostic logging for the extension."
}
}
},
"debugAdapter": [
{
"type": "PowerShell",
"enableBreakpointsFor": { "languageIds": ["PowerShell"] },
"program": "bin/Microsoft.PowerShell.EditorServices.Host.exe"
}
]
}
},
"private": true
}
28 changes: 12 additions & 16 deletions src/features/bufferSyncSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SyncedBuffer {
}

onContentChanged(events: vscode.TextDocumentContentChangeEvent[]): void {
var filePath = this.client.asAbsolutePath(this.document.getUri());
var filePath = this.client.asAbsolutePath(this.document.uri);
if (!filePath) {
return;
}
Expand All @@ -53,14 +53,10 @@ class SyncedBuffer {
var text = event.text;
var args:Proto.ChangeRequestArgs = {
file: filePath,
//line: range.start.line + 1,
//offset: range.start.character + 1,
//endLine: range.end.line + 1,
//endOffset: range.end.character + 1,
line: range.start.line,
offset: range.start.character,
endLine: range.end.line,
endOffset: range.end.character,
line: range.start.line + 1,
offset: range.start.character + 1,
endLine: range.end.line + 1,
endOffset: range.end.character + 1,
insertString: text
};
this.client.execute('change', args, false);
Expand Down Expand Up @@ -90,7 +86,7 @@ class BufferSyncSupport {
vscode.workspace.onDidOpenTextDocument(this.onDidAddDocument, this, this.disposables);
vscode.workspace.onDidCloseTextDocument(this.onDidRemoveDocument, this, this.disposables);
vscode.workspace.onDidChangeTextDocument(this.onDidChangeDocument, this, this.disposables);
vscode.workspace.getTextDocuments().forEach(this.onDidAddDocument, this);
vscode.workspace.textDocuments.forEach(this.onDidAddDocument, this);
}

public dispose(): void {
Expand All @@ -101,13 +97,13 @@ class BufferSyncSupport {

private onDidAddDocument(document: vscode.TextDocument): void {

if (document.getLanguageId() !== this.modeId) {
if (document.languageId !== this.modeId) {
return;
}
if (document.isUntitled()) {
if (document.isUntitled) {
return;
}
var resource = document.getUri();
var resource = document.uri;
var filepath = this.client.asAbsolutePath(resource);
if (!filepath) {
return;
Expand All @@ -117,11 +113,11 @@ class BufferSyncSupport {
syncedBuffer.open();
this.requestDiagnostic(filepath);

this.client.log("Added new document: " + document.getUri());
this.client.log("Added new document: " + document.uri);
}

private onDidRemoveDocument(document: vscode.TextDocument): void {
var filepath:string = this.client.asAbsolutePath(document.getUri());
var filepath:string = this.client.asAbsolutePath(document.uri);
if (!filepath) {
return;
}
Expand All @@ -134,7 +130,7 @@ class BufferSyncSupport {
}

private onDidChangeDocument(e: vscode.TextDocumentChangeEvent): void {
var filepath:string = this.client.asAbsolutePath(e.document.getUri());
var filepath:string = this.client.asAbsolutePath(e.document.uri);
if (!filepath) {
return;
}
Expand Down
19 changes: 0 additions & 19 deletions src/features/commentsSupport.ts

This file was deleted.

10 changes: 7 additions & 3 deletions src/features/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export var defaultConfiguration: IConfiguration = {
enableLogging: false
}

export function load(myPluginId: string): Thenable<IConfiguration> {
let configuration = vscode.extensions.getConfigurationMemento(myPluginId);
return configuration.getValues<IConfiguration>(defaultConfiguration);
export function load(myPluginId: string): IConfiguration {
let configuration = vscode.workspace.getConfiguration(myPluginId);
return {
editorServicesHostPath: configuration.get<string>("editorServicesHostPath", "../bin/Microsoft.PowerShell.EditorServices.Host.exe"),
waitForDebugger: configuration.get<boolean>("waitForDebugger", false),
enableLogging: configuration.get<boolean>("enableLogging", false)
}
}
Loading