forked from PowerShell/vscode-powershell
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.ts
139 lines (121 loc) · 4.46 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
'use strict';
import vscode = require('vscode');
import utils = require('./utils');
import Settings = require('./settings');
import { Logger, LogLevel } from './logging';
import { IFeature } from './feature';
import { SessionManager } from './session';
import { PowerShellLanguageId } from './utils';
import { ConsoleFeature } from './features/Console';
import { ExamplesFeature } from './features/Examples';
import { OpenInISEFeature } from './features/OpenInISE';
import { ExpandAliasFeature } from './features/ExpandAlias';
import { ShowHelpFeature } from './features/ShowOnlineHelp';
import { CodeActionsFeature } from './features/CodeActions';
import { RemoteFilesFeature } from './features/RemoteFiles';
import { DebugSessionFeature } from './features/DebugSession';
import { PickPSHostProcessFeature } from './features/DebugSession';
import { SelectPSSARulesFeature } from './features/SelectPSSARules';
import { FindModuleFeature } from './features/PowerShellFindModule';
import { NewFileOrProjectFeature } from './features/NewFileOrProject';
import { ExtensionCommandsFeature } from './features/ExtensionCommands';
import { DocumentFormatterFeature } from './features/DocumentFormatter';
// NOTE: We will need to find a better way to deal with the required
// PS Editor Services version...
var requiredEditorServicesVersion = "0.11.0";
var logger: Logger = undefined;
var sessionManager: SessionManager = undefined;
var extensionFeatures: IFeature[] = [];
// Clean up the session file just in case one lingers from a previous session
utils.deleteSessionFile();
export function activate(context: vscode.ExtensionContext): void {
vscode.languages.setLanguageConfiguration(
PowerShellLanguageId,
{
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\'\"\,\.\<\>\/\?\s]+)/g,
indentationRules: {
// ^(.*\*/)?\s*\}.*$
decreaseIndentPattern: /^(.*\*\/)?\s*\}.*$/,
// ^.*\{[^}"']*$
increaseIndentPattern: /^.*\{[^}"']*$/
},
comments: {
lineComment: '#',
blockComment: ['<#', '#>']
},
brackets: [
['{', '}'],
['[', ']'],
['(', ')'],
],
onEnterRules: [
{
// e.g. /** | */
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
afterText: /^\s*\*\/$/,
action: { indentAction: vscode.IndentAction.IndentOutdent, appendText: ' * ' }
},
{
// e.g. /** ...|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
action: { indentAction: vscode.IndentAction.None, appendText: ' * ' }
},
{
// e.g. * ...|
beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
action: { indentAction: vscode.IndentAction.None, appendText: '* ' }
},
{
// e.g. */|
beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
action: { indentAction: vscode.IndentAction.None, removeText: 1 }
},
{
// e.g. *-----*/|
beforeText: /^(\t|(\ \ ))*\ \*[^/]*\*\/\s*$/,
action: { indentAction: vscode.IndentAction.None, removeText: 1 }
}
]
});
// Create the logger
logger = new Logger();
// Create features
extensionFeatures = [
new ConsoleFeature(),
new ExamplesFeature(),
new OpenInISEFeature(),
new ExpandAliasFeature(),
new ShowHelpFeature(),
new FindModuleFeature(),
new ExtensionCommandsFeature(),
new SelectPSSARulesFeature(),
new CodeActionsFeature(),
new NewFileOrProjectFeature(),
new DocumentFormatterFeature(),
new RemoteFilesFeature(),
new DebugSessionFeature(),
new PickPSHostProcessFeature()
];
sessionManager =
new SessionManager(
requiredEditorServicesVersion,
logger,
extensionFeatures);
var extensionSettings = Settings.load(utils.PowerShellLanguageId);
if (extensionSettings.startAutomatically) {
sessionManager.start();
}
}
export function deactivate(): void {
// Clean up all extension features
extensionFeatures.forEach(feature => {
feature.dispose();
});
// Dispose of the current session
sessionManager.dispose();
// Dispose of the logger
logger.dispose();
}