<commit_before>'use strict';
import * as vscode from 'vscode';

import { MavensMateClient, Options } from '../src/mavensmate/mavensMateClient';
import { CommandEventRouter } from '../src/mavensmate/commandEventRouter';
import { MavensMateStatus } from '../src/vscode/mavensMateStatus';
import { ClientStatus } from '../src/vscode/clientStatus';
import { MavensMateChannel } from '../src/vscode/mavensMateChannel';
import { CommandRegistrar } from '../src/vscode/commandRegistrar';
import { hasProjectSettings, getProjectSettings } from '../src/mavensmate/projectSettings';

let mavensMateClientOptions: Options;

let mavensMateClient: MavensMateClient;
let mavensMateStatus: MavensMateStatus;
let commandRegistrar: CommandRegistrar;
let mavensMateContext: vscode.ExtensionContext;
let mavensMateChannel: MavensMateChannel;
let commandEventRouter: CommandEventRouter;
let clientStatus: ClientStatus;
let mavensMateConfiguration: vscode.WorkspaceConfiguration;

let languagesToCompileOnSave = new Set<string>(['apex', 'visualforce', 'metadata', 'xml', 'javascript']);

export function activate(context: vscode.ExtensionContext) {
    mavensMateContext = context;
    mavensMateChannel = MavensMateChannel.Create();

    mavensMateChannel.appendStatus('MavensMate is activating');

    mavensMateConfiguration = vscode.workspace.getConfiguration()
    mavensMateClientOptions = {
        baseURL: mavensMateConfiguration.get<string>('mavensMateDesktop.baseURL')
    };

    return hasProjectSettings()
        .then(instantiateWithProject, instantiate)
        .then(subscribeToEvents)
        .then(activateMavensMate);
}

function instantiateWithProject(){
    let projectSettings = getProjectSettings();
    mavensMateClientOptions.projectId = projectSettings.id;
    mavensMateChannel.appendStatus(`Instantiating with Project: ${projectSettings.project_name} (${ projectSettings.instanceUrl })`);
    instantiate();
}

function instantiate(){
    mavensMateChannel.appendStatus('Instantiating Supporting Extension Elements');
    mavensMateClient = MavensMateClient.Create(mavensMateClientOptions);
    mavensMateStatus = MavensMateStatus.Create(mavensMateClient, mavensMateChannel);
    commandEventRouter = CommandEventRouter.Create(mavensMateChannel);
    clientStatus = ClientStatus.Create();

    commandRegistrar = CommandRegistrar.Create(mavensMateClient, mavensMateContext, 
        mavensMateChannel, commandEventRouter);

    mavensMateContext.subscriptions.push(commandEventRouter);
}

function subscribeToEvents(){
    let saveEvent = vscode.workspace.onDidSaveTextDocument((textDocument) => {
        if(textDocument.languageId in languagesToCompileOnSave){
            vscode.commands.executeCommand('mavensmate.compileFile', textDocument.uri);
        }
    });
    mavensMateContext.subscriptions.push(saveEvent);

    mavensMateChannel.appendStatus('Subscribed to events');
}

function activateMavensMate(){
    commandRegistrar.registerCommands();
    mavensMateChannel.appendStatus('Commands registered');
    return mavensMateStatus.updateAppStatus();
}

export function deactivate() {
    mavensMateChannel.appendStatus('Deactivating');
}

process.on("unhandledRejection", function(reason, promise) {
    console.error(reason);<commit_msg>resolves issue where languageId/languagesToCompileOnSave check was not configured properly<commit_after>'use strict';
import * as vscode from 'vscode';

import { MavensMateClient, Options } from '../src/mavensmate/mavensMateClient';
import { CommandEventRouter } from '../src/mavensmate/commandEventRouter';
import { MavensMateStatus } from '../src/vscode/mavensMateStatus';
import { ClientStatus } from '../src/vscode/clientStatus';
import { MavensMateChannel } from '../src/vscode/mavensMateChannel';
import { CommandRegistrar } from '../src/vscode/commandRegistrar';
import { hasProjectSettings, getProjectSettings } from '../src/mavensmate/projectSettings';

let mavensMateClientOptions: Options;

let mavensMateClient: MavensMateClient;
let mavensMateStatus: MavensMateStatus;
let commandRegistrar: CommandRegistrar;
let mavensMateContext: vscode.ExtensionContext;
let mavensMateChannel: MavensMateChannel;
let commandEventRouter: CommandEventRouter;
let clientStatus: ClientStatus;
let mavensMateConfiguration: vscode.WorkspaceConfiguration;

let languagesToCompileOnSave = new Set<string>(['apex', 'visualforce', 'metadata', 'xml', 'javascript']);

export function activate(context: vscode.ExtensionContext) {
    mavensMateContext = context;
    mavensMateChannel = MavensMateChannel.Create();

    mavensMateChannel.appendStatus('MavensMate is activating');

    mavensMateConfiguration = vscode.workspace.getConfiguration()
    mavensMateClientOptions = {
        baseURL: mavensMateConfiguration.get<string>('mavensMateDesktop.baseURL')
    };

    return hasProjectSettings()
        .then(instantiateWithProject, instantiate)
        .then(subscribeToEvents)
        .then(activateMavensMate);
}

function instantiateWithProject(){
    let projectSettings = getProjectSettings();
    mavensMateClientOptions.projectId = projectSettings.id;
    mavensMateChannel.appendStatus(`Instantiating with Project: ${projectSettings.project_name} (${ projectSettings.instanceUrl })`);
    instantiate();
}

function instantiate(){
    mavensMateChannel.appendStatus('Instantiating Supporting Extension Elements');
    mavensMateClient = MavensMateClient.Create(mavensMateClientOptions);
    mavensMateStatus = MavensMateStatus.Create(mavensMateClient, mavensMateChannel);
    commandEventRouter = CommandEventRouter.Create(mavensMateChannel);
    clientStatus = ClientStatus.Create();

    commandRegistrar = CommandRegistrar.Create(mavensMateClient, mavensMateContext, 
        mavensMateChannel, commandEventRouter);

    mavensMateContext.subscriptions.push(commandEventRouter);
}

function subscribeToEvents(){
    let saveEvent = vscode.workspace.onDidSaveTextDocument((textDocument) => {
        if(languagesToCompileOnSave.has(textDocument.languageId)){
            vscode.commands.executeCommand('mavensmate.compileFile', textDocument.uri);
        }
    });
    mavensMateContext.subscriptions.push(saveEvent);

    mavensMateChannel.appendStatus('Subscribed to events');
}

function activateMavensMate(){
    commandRegistrar.registerCommands();
    mavensMateChannel.appendStatus('Commands registered');
    return mavensMateStatus.updateAppStatus();
}

export function deactivate() {
    mavensMateChannel.appendStatus('Deactivating');
}

process.on("unhandledRejection", function(reason, promise) {
    console.error(reason);
{'fraction_non_alphanumeric': 0.10149977276170277, 'fraction_numerical': 0.0, 'mean_word_length': 5.942166140904312, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3778590', 'n_tokens_mistral': 2016, 'n_tokens_neox': 1978, 'n_words': 319}