<commit_before>'use strict';
var path = require('path');
var vscode = require('vscode');
var vscode_languageclient = require('vscode-languageclient');
function activate(context) {
    console.log("Activated");
    var serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
    var debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };
    var serverOptions = {
        run: { module: serverModule, transport: vscode_languageclient.TransportKind.ipc },
        debug: { module: serverModule, transport: vscode_languageclient.TransportKind.ipc, options: debugOptions }
    };
    // Options to control the language client
    var clientOptions = {
        // Register the server for plain text documents
        documentSelector: ['javascript'],
        synchronize: {
            // Synchronize the setting section 'languageServerExample' to the server
            configurationSection: 'orionToolsServer',
            // Notify the server about file changes to '.clientrc files contain in the workspace
            fileEvents: vscode.workspace.createFileSystemWatcher('**/.clientrc')
        }
    };
    // Create the language client and start the client.
    var client = new vscode_languageclient.LanguageClient('orion-tools-server', serverOptions, clientOptions);
    var disposable = client.start();
    // Push the disposable to the context's subscriptions so that the 
    // client can be deactivated on extension deactivation
    context.subscriptions.push(disposable);
    
    var bugsHover = [];
    var firstTime = true;
    var statusBarE = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
    var statusBarW = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
    var lintWindow = vscode.window.createOutputChannel("Orion Linter");
    
    context.subscriptions.push(statusBarE);
    context.subscriptions.push(statusBarW);
    context.subscriptions.push(lintWindow);

    client.onNotification({method:"testNotification"}, function(output){
        var status = output.pop();
        var tempE = status.errorNum <= 1 ? "JSError: " : "JSErrors: "; 
        var tempW = status.warningNum <= 1 ? "JSWarning: " : "JSWarnings: ";
        var tempIconE = status.errorNum === 0 ? "$(check) " : "$(x) ";
        var tempIconW = status.warningNum === 0 ? "$(check) " : "$(alert) ";
        statusBarE.text = tempIconE + tempE + status.errorNum;
        statusBarW.text = tempIconW + tempW + status.warningNum;
        
        var messageToShow = "";
        for(var i = 0; i < output.length; i++){
            var problem = output[i];
            var tempStart = new vscode.Position(problem.range.start.line, problem.range.start.character);
            var tempEnd = new vscode.Position(problem.range.end.line, problem.range.end.character);
            bugsHover.push({start: tempStart, end:tempEnd, hover: new vscode.Hover(problem.message)});
            messageToShow = messageToShow + tempStart.line + ":" + tempStart.character + " " + problem.message + "\n";
        };
        // console.log((status.errorNum + status.warningNum) === 0);
        if ((status.errorNum + status.warningNum) === 0 && !firstTime){
            lintWindow.clear();
            lintWindow.append("No Errors and Warnings");
            // lintWindow.hide(); // This method does not work as expected: it is not hiding the outputchannel
            
        } else if ((status.errorNum + status.warningNum) > 0 ) {
            lintWindow.clear();
            lintWindow.show(true);
            setTimeout(function() {
                lintWindow.append(messageToShow);
            }, 500);
            
            
        }
        
        bugsHover = [];
        if (firstTime){  
            statusBarE.color = "#faebd7";
            statusBarW.color = "#faebd7";
            statusBarE.show();
            statusBarW.show();statusBarE.color = "#faebd7";
            statusBarE.color = "#faebd7";
            statusBarE.show();
            statusBarW.show();
            var disposable = vscode.languages.registerHoverProvider("javascript", {
                provideHover: function (document, position, token) {
                    for (var index = 0; index < bugsHover.length; index++) {
                        var hover = bugsHover[index];
                        if (position.isAfterOrEqual(hover.start) && position.isBeforeOrEqual(hover.end)){
                            return hover.hover;
                        }
                    }
                    return null;
                }
            }); 
            context.subscriptions.push(disposable);<commit_msg>Fix the bug where outputchannel message may be repeated when user input too fast.<commit_after>'use strict';
var path = require('path');
var vscode = require('vscode');
var vscode_languageclient = require('vscode-languageclient');
function activate(context) {
    console.log("Activated");
    var serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
    var debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };
    var serverOptions = {
        run: { module: serverModule, transport: vscode_languageclient.TransportKind.ipc },
        debug: { module: serverModule, transport: vscode_languageclient.TransportKind.ipc, options: debugOptions }
    };
    // Options to control the language client
    var clientOptions = {
        // Register the server for plain text documents
        documentSelector: ['javascript'],
        synchronize: {
            // Synchronize the setting section 'languageServerExample' to the server
            configurationSection: 'orionToolsServer',
            // Notify the server about file changes to '.clientrc files contain in the workspace
            fileEvents: vscode.workspace.createFileSystemWatcher('**/.clientrc')
        }
    };
    // Create the language client and start the client.
    var client = new vscode_languageclient.LanguageClient('orion-tools-server', serverOptions, clientOptions);
    var disposable = client.start();
    // Push the disposable to the context's subscriptions so that the 
    // client can be deactivated on extension deactivation
    context.subscriptions.push(disposable);
    
    var bugsHover = [];
    var firstTime = true;
    var statusBarE = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
    var statusBarW = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
    var lintWindow = vscode.window.createOutputChannel("Orion Linter");
    
    context.subscriptions.push(statusBarE);
    context.subscriptions.push(statusBarW);
    context.subscriptions.push(lintWindow);
    
    var lastJob = null;
    client.onNotification({method:"testNotification"}, function(output){
        var status = output.pop();
        var tempE = status.errorNum <= 1 ? "JSError: " : "JSErrors: "; 
        var tempW = status.warningNum <= 1 ? "JSWarning: " : "JSWarnings: ";
        var tempIconE = status.errorNum === 0 ? "$(check) " : "$(x) ";
        var tempIconW = status.warningNum === 0 ? "$(check) " : "$(alert) ";
        statusBarE.text = tempIconE + tempE + status.errorNum;
        statusBarW.text = tempIconW + tempW + status.warningNum;
        
        var messageToShow = "";
        lintWindow.show(true);
        if (lastJob !== null) {
            clearTimeout(lastJob);
        }
        output.sort(function(a, b){
           if (a.range.start.line > b.range.start.line){
               return 1;
           } else if (a.range.start.line === b.range.start.line){
               if(a.range.start.character > b.range.start.character){
                   return 1
               } else if (a.range.start.character === b.range.start.character){
                   return 0
               } else {
                   return -1;
               }
           } else {
               return -1;
           }
        });
        for(var i = 0; i < output.length; i++){
            var problem = output[i];
            var tempStart = new vscode.Position(problem.range.start.line, problem.range.start.character);
            var tempEnd = new vscode.Position(problem.range.end.line, problem.range.end.character);
            bugsHover.push({start: tempStart, end:tempEnd, hover: new vscode.Hover(problem.message)});
            messageToShow = messageToShow + "[ORION] " + tempStart.line + ":" + tempStart.character + " " + problem.rawMessage + "\n";
        };
        // console.log((status.errorNum + status.warningNum) === 0);
        if ((status.errorNum + status.warningNum) === 0 && !firstTime){
            lintWindow.clear();
            lintWindow.append("No Errors and Warnings");
            // lintWindow.hide(); // This method does not work as expected: it is not hiding the outputchannel
            
        } else if ((status.errorNum + status.warningNum) > 0 ) {
            lastJob = setTimeout(function() {
                lintWindow.clear();
                lintWindow.append(messageToShow);
            }, 500);
        }
        
        bugsHover = [];
        if (firstTime){  
            statusBarE.color = "#faebd7";
            statusBarW.color = "#faebd7";
            statusBarE.show();
            statusBarW.show();statusBarE.color = "#faebd7";
            statusBarE.color = "#faebd7";
            statusBarE.show();
            statusBarW.show();
            var disposable = vscode.languages.registerHoverProvider("javascript", {
                provideHover: function (document, position, token) {
                    for (var index = 0; index < bugsHover.length; index++) {
                        var hover = bugsHover[index];
                        if (position.isAfterOrEqual(hover.start) && position.isBeforeOrEqual(hover.end)){
                            return hover.hover;
                        }
                    }
                    return null;
                }
            }); 
            context.subscriptions.push(disposable);
{'fraction_non_alphanumeric': 0.11903566047212456, 'fraction_numerical': 0.0045203415369161224, 'mean_word_length': 2.2335173757713545, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 7, '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': '6456781', 'n_tokens_mistral': 2766, 'n_tokens_neox': 2659, 'n_words': 608}