-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathextension.js
More file actions
29 lines (26 loc) · 1.1 KB
/
extension.js
File metadata and controls
29 lines (26 loc) · 1.1 KB
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
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
var vscode = require('vscode');
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {
var symbolProvider = {
provideDocumentSymbols: function(document, token) {
var symInfos = [];
// parse the document for functions
for(var i = 0; i < document.lineCount; ++i) {
var line = document.lineAt(i);
var regex = /::([^\(]+)\(([^\)]+)\)?[\s\{]*$/gm;
var arr = regex.exec(line.text);
if(arr == null) continue;
var commentIdx = line.text.indexOf('//');
if(commentIdx > -1 && commentIdx < line.text.indexOf('::')) continue;
var symInfo = new vscode.SymbolInformation(arr[1], vscode.SymbolKind.Function, new vscode.Range(new vscode.Position(i, 0), new vscode.Position(i, 0)));
symInfos.push(symInfo);
}
return symInfos;
}
};
vscode.languages.registerDocumentSymbolProvider('cpp', symbolProvider);
}
exports.activate = activate;