summaryrefslogtreecommitdiff
path: root/lib/Main.ts
blob: 205b20ba99233f9efb05184a600f27015c413884 (plain)
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
'use strict';
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';


const JAVA_MODE: vscode.DocumentFilter = { language: 'java', scheme: 'file' };

let diagnosticCollection: vscode.DiagnosticCollection;

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(ctx: vscode.ExtensionContext) {
	diagnosticCollection = vscode.languages.createDiagnosticCollection('java');
	ctx.subscriptions.push(diagnosticCollection);
    
	startBuildOnSaveWatcher(ctx.subscriptions);
}

function startBuildOnSaveWatcher(subscriptions: vscode.Disposable[]) {
	vscode.workspace.onDidSaveTextDocument(document => {
		if (document.languageId !== 'java') 
			return;
            
		let javaConfig = vscode.workspace.getConfiguration('java');
		let textEditor = vscode.window.activeTextEditor;
        
        runBuilds(document, javaConfig);
	}, null, subscriptions);
}

function runBuilds(document: vscode.TextDocument, javaConfig: vscode.WorkspaceConfiguration) {
    console.log('Check ' + document.fileName);
}

// this method is called when your extension is deactivated
export function deactivate() {
}