forked from Triumph-Tech/vscode-lava-syntax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
57 lines (57 loc) · 2.91 KB
/
main.js
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
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.activate = void 0;
const vscode_1 = require("vscode");
const vscode = require("vscode");
const providers_1 = require("./src/providers");
function getRockWeb(workspace) {
return __awaiter(this, void 0, void 0, function* () {
const foundFiles = yield workspace.findFiles('**/web.config');
const argconfigDirs = foundFiles
.map((file) => file.path.replace(/web\.config$/, ''));
argconfigDirs.sort((a, b) => a.split('/').length - b.split('/').length);
return argconfigDirs[0]; //pick the shortest number of segments (top of tree)
});
}
function getConnectionStrings(workspace) {
return __awaiter(this, void 0, void 0, function* () {
const rockWebPath = yield getRockWeb(workspace);
return `${rockWebPath}web.ConnectionStrings.config`;
});
}
function activate(context) {
return __awaiter(this, void 0, void 0, function* () {
let documentSelector;
documentSelector = "lava";
const actions = ['openconnectionstrings'];
actions.forEach(action => {
let disposable = vscode_1.commands.registerCommand(`rock-lava.${action}`, () => __awaiter(this, void 0, void 0, function* () {
if (action == 'openconnectionstrings') {
const connectionStringFile = yield getConnectionStrings(vscode_1.workspace);
try {
yield vscode_1.workspace.fs.stat(vscode.Uri.parse(connectionStringFile));
vscode_1.commands.executeCommand('vscode.open', vscode.Uri.parse(connectionStringFile));
}
catch (_a) {
vscode_1.window.showInformationMessage(`Rock Connection Strings file does not exist.`);
}
}
}));
context.subscriptions.push(disposable);
});
let filterProvider = (0, providers_1.getFilterProvider)(documentSelector);
let snippetProvider = (0, providers_1.getSnippetProvider)(documentSelector);
context.subscriptions.push(filterProvider, snippetProvider); // , childrenProvider, textProvider
});
}
exports.activate = activate;
//# sourceMappingURL=main.js.map