-
Notifications
You must be signed in to change notification settings - Fork 511
/
Copy pathmain.ts
121 lines (104 loc) · 3.66 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
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
'use strict';
import vscode = require('vscode');
import { Logger, LogLevel } from './logging';
import { IFeature } from './feature';
import { SessionManager } from './session';
import { PowerShellLanguageId } from './utils';
import { ConsoleFeature } from './features/Console';
import { OpenInISEFeature } from './features/OpenInISE';
import { NewFileOrProjectFeature } from './features/NewFileOrProject';
import { ExpandAliasFeature } from './features/ExpandAlias';
import { ShowHelpFeature } from './features/ShowOnlineHelp';
import { FindModuleFeature } from './features/PowerShellFindModule';
import { ExtensionCommandsFeature } from './features/ExtensionCommands';
import { SelectPSSARulesFeature } from './features/SelectPSSARules';
import { CodeActionsFeature } from './features/CodeActions';
// NOTE: We will need to find a better way to deal with the required
// PS Editor Services version...
var requiredEditorServicesVersion = "0.8.0";
var logger: Logger = undefined;
var sessionManager: SessionManager = undefined;
var extensionFeatures: IFeature[] = [];
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 OpenInISEFeature(),
new ExpandAliasFeature(),
new ShowHelpFeature(),
new FindModuleFeature(),
new ExtensionCommandsFeature(),
new SelectPSSARulesFeature(),
new CodeActionsFeature(),
new NewFileOrProjectFeature()
];
sessionManager =
new SessionManager(
requiredEditorServicesVersion,
logger,
extensionFeatures);
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();
}