Skip to content

Commit 4529428

Browse files
committed
Merge pull request #5 from PowerShell/vscode-0.10.0
Update codebase to comply with VSC 0.10.0 APIs
2 parents 8287365 + fa8c650 commit 4529428

20 files changed

+417
-1844
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ bin/
22
out/
33
node_modules/
44
vscode-powershell.zip
5-
vscps-preview.zip
5+
vscps-preview.zip
6+
*.vsix

.vscodeignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
.vscode/**
22
typings/**
3-
node_modules/vscode/**
4-
node_modules/vscode-languageworker/**
3+
node_modules/**
54
**/*.ts
65
.gitignore
76
tsconfig.json
7+
build/**
88
bin/EditorServices.log
9+
bin/DebugService.log
910
bin/*.vshost.*

README.md

+18-35
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,36 @@
11
# Windows PowerShell for Visual Studio Code
22

3-
Windows PowerShell language support for Visual Studio Code.
3+
This extension provides Windows PowerShell language support for Visual Studio Code.
44
More details forthcoming.
55

6-
## Building the code
6+
## Features
77

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

10-
```
11-
npm install
12-
```
13-
14-
The next two steps are required if you have Node.js 5 installed due to some change in npm:
15-
16-
```
17-
cd node_modules\vscode
18-
npm install
19-
```
20-
21-
Now you can compile the code:
22-
23-
```
24-
npm run compile
25-
```
26-
27-
After the initial compile, the source files will be watched and recompiled
28-
when changes are saved.
14+
## Example Scripts
2915

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

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

3423
```
35-
code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
24+
c:\Users\<yourusername>\.vscode\extensions\daviwil.PowerShell\examples
3625
```
37-
38-
If you allow the compiler to continue watching for file changes, you can use
39-
the `Reload Window` command found in the command palette `(Ctrl+Shift+P)`
40-
so that the new source files are loaded.
4126

42-
## Example Scripts
27+
## Contributing to the Code
4328

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

4932
## License
5033

51-
This project is [licensed under the MIT License](LICENSE). Please see the
34+
This extension is [licensed under the MIT License](LICENSE). Please see the
5235
[third-party notices](Third Party Notices.txt) file for details on the third-party
5336
binaries that we include with releases of this project.

docs/development.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Working with the PowerShell extension code
2+
3+
## Building the code
4+
5+
First, install the package dependencies:
6+
7+
```
8+
npm install
9+
```
10+
11+
Now you can compile the code:
12+
13+
```
14+
npm run compile
15+
```
16+
17+
After the initial compile, the source files will be watched and recompiled
18+
when changes are saved.
19+
20+
## Running the compiled code
21+
22+
From a PowerShell or cmd.exe prompt, run the following command:
23+
24+
```
25+
code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
26+
```
27+
28+
If you allow the compiler to continue watching for file changes, you can use
29+
the `Reload Window` command found in the command palette `(Ctrl+Shift+P)`
30+
so that the new source files are loaded.

images/PowerShell_icon.png

10.3 KB
Loading

package.json

+45-14
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,33 @@
11
{
22
"name": "PowerShell",
3-
"version": "0.1.0-preview",
3+
"displayName": "Windows PowerShell Language Support",
4+
"version": "0.1.0",
45
"publisher": "daviwil",
5-
"description": "Windows PowerShell for Visual Studio Code",
6-
"engines": { "vscode": "*" },
6+
"description": "Develop Windows PowerShell scripts in Visual Studio Code!",
7+
"engines": { "vscode": "0.10.x" },
8+
"author": {
9+
"name": "Microsoft Corporation - Development Labs"
10+
},
11+
"license":"SEE LICENSE FILE",
12+
"homepage": "https://github.com/PowerShell/vscode-powershell/README.md",
13+
"categories": [
14+
"Languages",
15+
"Snippets",
16+
"Linters"
17+
],
18+
"icon": "images/PowerShell_icon.png",
19+
"galleryBanner": {
20+
"color": "#ACD1EC",
21+
"theme": "light"
22+
},
23+
"repository": {
24+
"type": "git",
25+
"url": "https://github.com/PowerShell/vscode-powershell.git"
26+
},
727
"main": "./out/powershellMain",
828
"activationEvents": ["onLanguage:PowerShell"],
9-
"dependencies": {
10-
"vscode": "0.9.6"
29+
"devDependencies": {
30+
"vscode": "0.10.0"
1131
},
1232
"scripts": {
1333
"vscode:prepublish": "node ./node_modules/vscode/bin/compile",
@@ -19,13 +39,31 @@
1939
"extensions": [ ".ps1", ".psm1", ".psd1", ".pssc", ".psrc" ],
2040
"aliases": [ "PowerShell", "powershell", "ps", "ps1" ]
2141
}],
42+
"grammars": [{
43+
"language": "PowerShell",
44+
"scopeName": "source.powershell",
45+
"path": "./syntaxes/PowerShell.tmLanguage"
46+
}],
47+
"snippets": [
48+
{
49+
"language": "PowerShell",
50+
"path": "./snippets/PowerShell.json"
51+
}
52+
],
53+
"debuggers": [
54+
{
55+
"type": "PowerShell",
56+
"enableBreakpointsFor": { "languageIds": ["PowerShell"] },
57+
"program": "bin/Microsoft.PowerShell.EditorServices.Host.exe"
58+
}
59+
],
2260
"configuration": {
2361
"type": "object",
2462
"title": "PowerShell Configuration",
2563
"properties": {
2664
"PowerShell.editorServicesHostPath": {
2765
"type": "string",
28-
"default": "bin/Microsoft.PowerShell.EditorServices.Host.exe",
66+
"default": "../bin/Microsoft.PowerShell.EditorServices.Host.exe",
2967
"description": "Specifies the path to the PowerShell Editor Services host executable."
3068
},
3169
"PowerShell.waitForDebugger": {
@@ -39,14 +77,7 @@
3977
"description": "Enables diagnostic logging for the extension."
4078
}
4179
}
42-
},
43-
"debugAdapter": [
44-
{
45-
"type": "PowerShell",
46-
"enableBreakpointsFor": { "languageIds": ["PowerShell"] },
47-
"program": "bin/Microsoft.PowerShell.EditorServices.Host.exe"
48-
}
49-
]
80+
}
5081
},
5182
"private": true
5283
}

src/features/bufferSyncSupport.ts

+12-16
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class SyncedBuffer {
4242
}
4343

4444
onContentChanged(events: vscode.TextDocumentContentChangeEvent[]): void {
45-
var filePath = this.client.asAbsolutePath(this.document.getUri());
45+
var filePath = this.client.asAbsolutePath(this.document.uri);
4646
if (!filePath) {
4747
return;
4848
}
@@ -53,14 +53,10 @@ class SyncedBuffer {
5353
var text = event.text;
5454
var args:Proto.ChangeRequestArgs = {
5555
file: filePath,
56-
//line: range.start.line + 1,
57-
//offset: range.start.character + 1,
58-
//endLine: range.end.line + 1,
59-
//endOffset: range.end.character + 1,
60-
line: range.start.line,
61-
offset: range.start.character,
62-
endLine: range.end.line,
63-
endOffset: range.end.character,
56+
line: range.start.line + 1,
57+
offset: range.start.character + 1,
58+
endLine: range.end.line + 1,
59+
endOffset: range.end.character + 1,
6460
insertString: text
6561
};
6662
this.client.execute('change', args, false);
@@ -90,7 +86,7 @@ class BufferSyncSupport {
9086
vscode.workspace.onDidOpenTextDocument(this.onDidAddDocument, this, this.disposables);
9187
vscode.workspace.onDidCloseTextDocument(this.onDidRemoveDocument, this, this.disposables);
9288
vscode.workspace.onDidChangeTextDocument(this.onDidChangeDocument, this, this.disposables);
93-
vscode.workspace.getTextDocuments().forEach(this.onDidAddDocument, this);
89+
vscode.workspace.textDocuments.forEach(this.onDidAddDocument, this);
9490
}
9591

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

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

104-
if (document.getLanguageId() !== this.modeId) {
100+
if (document.languageId !== this.modeId) {
105101
return;
106102
}
107-
if (document.isUntitled()) {
103+
if (document.isUntitled) {
108104
return;
109105
}
110-
var resource = document.getUri();
106+
var resource = document.uri;
111107
var filepath = this.client.asAbsolutePath(resource);
112108
if (!filepath) {
113109
return;
@@ -117,11 +113,11 @@ class BufferSyncSupport {
117113
syncedBuffer.open();
118114
this.requestDiagnostic(filepath);
119115

120-
this.client.log("Added new document: " + document.getUri());
116+
this.client.log("Added new document: " + document.uri);
121117
}
122118

123119
private onDidRemoveDocument(document: vscode.TextDocument): void {
124-
var filepath:string = this.client.asAbsolutePath(document.getUri());
120+
var filepath:string = this.client.asAbsolutePath(document.uri);
125121
if (!filepath) {
126122
return;
127123
}
@@ -134,7 +130,7 @@ class BufferSyncSupport {
134130
}
135131

136132
private onDidChangeDocument(e: vscode.TextDocumentChangeEvent): void {
137-
var filepath:string = this.client.asAbsolutePath(e.document.getUri());
133+
var filepath:string = this.client.asAbsolutePath(e.document.uri);
138134
if (!filepath) {
139135
return;
140136
}

src/features/commentsSupport.ts

-19
This file was deleted.

src/features/configuration.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export var defaultConfiguration: IConfiguration = {
1717
enableLogging: false
1818
}
1919

20-
export function load(myPluginId: string): Thenable<IConfiguration> {
21-
let configuration = vscode.extensions.getConfigurationMemento(myPluginId);
22-
return configuration.getValues<IConfiguration>(defaultConfiguration);
20+
export function load(myPluginId: string): IConfiguration {
21+
let configuration = vscode.workspace.getConfiguration(myPluginId);
22+
return {
23+
editorServicesHostPath: configuration.get<string>("editorServicesHostPath", "../bin/Microsoft.PowerShell.EditorServices.Host.exe"),
24+
waitForDebugger: configuration.get<boolean>("waitForDebugger", false),
25+
enableLogging: configuration.get<boolean>("enableLogging", false)
26+
}
2327
}

0 commit comments

Comments
 (0)