<commit_before>define(function (require, exports, module) {
    "use strict";

    /** --- MODULES --- **/
    var CommandManager = brackets.getModule("command/CommandManager"),
        Menus = brackets.getModule("command/Menus"),
        DocumentManager = brackets.getModule("document/DocumentManager"),
        EditorManager = brackets.getModule("editor/EditorManager"),
        ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
        NodeConnection = brackets.getModule("utils/NodeConnection"),
        Dialogs = brackets.getModule("widgets/Dialogs"),
        ansi = require("ansi"),
        nodeConnection = new NodeConnection(),
        NodeMenuID = "node-menu",
        NodeMenu = Menus.addMenu("Node.js", NodeMenuID),
        source = null,
        NODE_SETTINGS_DIALOG_ID = "node-settings-dialog",
        NODE_INSTALL_DIALOG_ID = "node-install-dialog",
        NODE_EXEC_DIALOG_ID = "node-exec-dialog",
        LS_PREFIX = "node-";


    /**
     * Shortcuts for localstorage with prefix
     */
    function get(name) {
        return localStorage.getItem(LS_PREFIX + name);
    }

    function set(name, value) {
        return localStorage.setItem(LS_PREFIX + name, value);
    }

    function rm(name) {
        return localStorage.removeItem(LS_PREFIX + name);
    }

    /**
     * Load the configuration
     */
    var config = JSON.parse(require("text!config.json"));

    /**
     * Start the node server
     */
    nodeConnection.connect(true).then(function () {
        nodeConnection.loadDomains(
            [ExtensionUtils.getModulePath(module, "server.js")],
            true
        ).then(
            function () {
                console.log("[brackets-nodejs] Connected to nodejs");
            }
        ).fail(
            function () {
                console.log("[brackets-nodejs] Failed to connect to nodejs. The server may be up because of another instance");
            }
        );
    });

    /**
     * The ConnectionManager helps to build and run request to execute a file on the serverside
     */
    var ConnectionManager = {

        /**
         * Creates a new EventSource
         *
         * @param (optional): Command name
         * @param (optional): Execute in the current working directory
         */
        // This need to be inside quotes since new is a reserved word
        "new": function (command, useCwd) {

            if (source && source.close) source.close();
            
            // Current document
            var doc = DocumentManager.getCurrentDocument();
            if(!doc.file.isFile) return;
            
            // Build url
            var url = "http://" + config.host + ":" + config.port + "/?command=" + encodeURIComponent(command);
            if(useCwd) {
                url += "&cwd=" + doc.file.parentPath;
            }
            
            // Server should be running
            source = new EventSource(url);

            source.addEventListener("message", function (msg) {<commit_msg>Encode cwd to make it URI safe<commit_after>define(function (require, exports, module) {
    "use strict";

    /** --- MODULES --- **/
    var CommandManager = brackets.getModule("command/CommandManager"),
        Menus = brackets.getModule("command/Menus"),
        DocumentManager = brackets.getModule("document/DocumentManager"),
        EditorManager = brackets.getModule("editor/EditorManager"),
        ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
        NodeConnection = brackets.getModule("utils/NodeConnection"),
        Dialogs = brackets.getModule("widgets/Dialogs"),
        ansi = require("ansi"),
        nodeConnection = new NodeConnection(),
        NodeMenuID = "node-menu",
        NodeMenu = Menus.addMenu("Node.js", NodeMenuID),
        source = null,
        NODE_SETTINGS_DIALOG_ID = "node-settings-dialog",
        NODE_INSTALL_DIALOG_ID = "node-install-dialog",
        NODE_EXEC_DIALOG_ID = "node-exec-dialog",
        LS_PREFIX = "node-";


    /**
     * Shortcuts for localstorage with prefix
     */
    function get(name) {
        return localStorage.getItem(LS_PREFIX + name);
    }

    function set(name, value) {
        return localStorage.setItem(LS_PREFIX + name, value);
    }

    function rm(name) {
        return localStorage.removeItem(LS_PREFIX + name);
    }

    /**
     * Load the configuration
     */
    var config = JSON.parse(require("text!config.json"));

    /**
     * Start the node server
     */
    nodeConnection.connect(true).then(function () {
        nodeConnection.loadDomains(
            [ExtensionUtils.getModulePath(module, "server.js")],
            true
        ).then(
            function () {
                console.log("[brackets-nodejs] Connected to nodejs");
            }
        ).fail(
            function () {
                console.log("[brackets-nodejs] Failed to connect to nodejs. The server may be up because of another instance");
            }
        );
    });

    /**
     * The ConnectionManager helps to build and run request to execute a file on the serverside
     */
    var ConnectionManager = {

        /**
         * Creates a new EventSource
         *
         * @param (optional): Command name
         * @param (optional): Execute in the current working directory
         */
        // This need to be inside quotes since new is a reserved word
        "new": function (command, useCwd) {

            if (source && source.close) source.close();
            
            // Current document
            var doc = DocumentManager.getCurrentDocument();
            if(!doc.file.isFile) return;
            
            // Build url
            var url = "http://" + config.host + ":" + config.port + "/?command=" + encodeURIComponent(command);
            if(useCwd) {
                url += "&cwd=" + encodeURIComponent(doc.file.parentPath);
            }
            
            // Server should be running
            source = new EventSource(url);

            source.addEventListener("message", function (msg) {
{'fraction_non_alphanumeric': 0.11770540585220697, 'fraction_numerical': 0.0, 'mean_word_length': 2.0144494270054807, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '267391', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1577, 'n_words': 376}