<commit_before>import { MavensMateClient } from '../../src/mavensmate/mavensMateClient';
import vscode = require('vscode');
import Command from './command';
import ClientCommands = require('../mavensmate/clientCommands');
import ClientCommandEventHandler from './clientCommandEventHandler';
import Promise = require('bluebird');

let clientCommands = ClientCommands.list();

export class CommandInvoker {
    client: MavensMateClient;
    eventHandlers: ClientCommandEventHandler[];
    command: Command;
    invokeProxy: (args?: any) => Promise<any>;
    invokeTextEditorProxy: (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) => Promise<any>;

    static Create(client: MavensMateClient, command: Command, eventHandlers: ClientCommandEventHandler[]){
        return new CommandInvoker(client, command, eventHandlers);
    }

    constructor(client: MavensMateClient, command: Command, eventHandlers: ClientCommandEventHandler[]){
        this.client = client;
        this.eventHandlers = eventHandlers;
        this.command = command;
        this.invokeProxy = (selectedResource?: vscode.Uri) => {
            return this.invoke.apply(this, [selectedResource]); 
        }
        this.invokeTextEditorProxy = (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) => { 
            return this.invokeTextEditor.apply(this, [textEditor, edit]); 
        }
    }

    invoke(selectedResource?: vscode.Uri){
        let preparedCommand = this.prepareCommand(this.command, selectedResource);
        return this.sendCommand(preparedCommand);
    }

    private prepareCommand(commandToPrepare: Command, documentUri: vscode.Uri): Command{
        console.log(documentUri);
        if(documentUri && documentUri.scheme === 'file'){
            this.setCommandPath(this.command, documentUri.fsPath);
        }
        return commandToPrepare;
    }

    private setCommandPath(commandToPrepare: Command, path: string){
        commandToPrepare.body.paths = [path];
    }

    private sendCommand(commandToSend: Command) {        
        this.handleOnStart(commandToSend);
        
        return this.client.sendCommand(this.command).then((result) => {
            return this.handleOnSuccess(this.command, result);
        }, (result) => {
            return this.handleOnError(this.command, result);
        });
    }

    private handleOnStart(command: Command){
        let onStartPromises: Promise<any>[] = [];

        for(let eventHandler of this.eventHandlers){
            onStartPromises.push(eventHandler.onStart(command));
        }

        return Promise.all(onStartPromises);
    }

    private handleOnSuccess(command: Command, result){
        let onSuccessPromises: Promise<any>[] = [];

        for(let eventHandler of this.eventHandlers){
            onSuccessPromises.push(eventHandler.onSuccess(command, result));
        }

        return Promise.all(onSuccessPromises);
    }

    private handleOnError(command: Command, result){
        let onErrorPromises: Promise<any>[] = [];

        for(let eventHandler of this.eventHandlers){
            onErrorPromises.push(eventHandler.onError(command, result));
        }

        return Promise.all(onErrorPromises);
    }


    private sendoAuthProjectCommand(){
        let oauthCommand = ClientCommands.list()['mavensmate.oAuthProject'];
        this.sendCommand(oauthCommand);
    }

    invokeTextEditor(textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit){
        console.log('invokeTextEditor');
        console.log(textEditor);
        console.log(textEditor.document);
        let documentUri: vscode.Uri = textEditor.document.uri;
        return this.invoke(documentUri);
    }
}<commit_msg>Remove unnecessary logging<commit_after>import { MavensMateClient } from '../../src/mavensmate/mavensMateClient';
import vscode = require('vscode');
import Command from './command';
import ClientCommands = require('../mavensmate/clientCommands');
import ClientCommandEventHandler from './clientCommandEventHandler';
import Promise = require('bluebird');

let clientCommands = ClientCommands.list();

export class CommandInvoker {
    client: MavensMateClient;
    eventHandlers: ClientCommandEventHandler[];
    command: Command;
    invokeProxy: (args?: any) => Promise<any>;
    invokeTextEditorProxy: (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) => Promise<any>;

    static Create(client: MavensMateClient, command: Command, eventHandlers: ClientCommandEventHandler[]){
        return new CommandInvoker(client, command, eventHandlers);
    }

    constructor(client: MavensMateClient, command: Command, eventHandlers: ClientCommandEventHandler[]){
        this.client = client;
        this.eventHandlers = eventHandlers;
        this.command = command;
        this.invokeProxy = (selectedResource?: vscode.Uri) => {
            return this.invoke.apply(this, [selectedResource]); 
        }
        this.invokeTextEditorProxy = (textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit) => { 
            return this.invokeTextEditor.apply(this, [textEditor, edit]); 
        }
    }

    invoke(selectedResource?: vscode.Uri){
        let preparedCommand = this.prepareCommand(this.command, selectedResource);
        return this.sendCommand(preparedCommand);
    }

    private prepareCommand(commandToPrepare: Command, documentUri: vscode.Uri): Command{
        if(documentUri && documentUri.scheme === 'file'){
            this.setCommandPath(this.command, documentUri.fsPath);
        }
        return commandToPrepare;
    }

    private setCommandPath(commandToPrepare: Command, path: string){
        commandToPrepare.body.paths = [path];
    }

    private sendCommand(commandToSend: Command) {        
        this.handleOnStart(commandToSend);
        
        return this.client.sendCommand(this.command).then((result) => {
            return this.handleOnSuccess(this.command, result);
        }, (result) => {
            return this.handleOnError(this.command, result);
        });
    }

    private handleOnStart(command: Command){
        let onStartPromises: Promise<any>[] = [];

        for(let eventHandler of this.eventHandlers){
            onStartPromises.push(eventHandler.onStart(command));
        }

        return Promise.all(onStartPromises);
    }

    private handleOnSuccess(command: Command, result){
        let onSuccessPromises: Promise<any>[] = [];

        for(let eventHandler of this.eventHandlers){
            onSuccessPromises.push(eventHandler.onSuccess(command, result));
        }

        return Promise.all(onSuccessPromises);
    }

    private handleOnError(command: Command, result){
        let onErrorPromises: Promise<any>[] = [];

        for(let eventHandler of this.eventHandlers){
            onErrorPromises.push(eventHandler.onError(command, result));
        }

        return Promise.all(onErrorPromises);
    }


    private sendoAuthProjectCommand(){
        let oauthCommand = ClientCommands.list()['mavensmate.oAuthProject'];
        this.sendCommand(oauthCommand);
    }

    invokeTextEditor(textEditor: vscode.TextEditor, edit: vscode.TextEditorEdit){
        let documentUri: vscode.Uri = textEditor.document.uri;
        return this.invoke(documentUri);
    }
}
{'fraction_non_alphanumeric': 0.11206064782908338, 'fraction_numerical': 0.0, 'mean_word_length': 3.2884160756501184, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7567424', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1980, 'n_words': 370}