<commit_before>package vshaxe;

import vscode.*;
import Vscode.*;
import haxe.Constraints.Function;

class Main {
    var context:ExtensionContext;
    var serverDisposable:Disposable;
    var hxFileWatcher:FileSystemWatcher;
    var vshaxeChannel:OutputChannel;
    var displayConfig:DisplayConfiguration;
    var client:LanguageClient;

    function new(ctx) {
        context = ctx;

        displayConfig = new DisplayConfiguration(ctx);
        new InitProject(ctx);

        registerCommand("haxe.restartLanguageServer", restartLanguageServer);
        registerCommand("haxe.applyFixes", applyFixes);
        registerCommand("haxe.showReferences", showReferences);
        registerCommand("haxe.runGlobalDiagnostics", runGlobalDiagnostics);

        startLanguageServer();
    }

    function registerCommand(command:String, callback:Function) {
        context.subscriptions.push(commands.registerCommand(command, callback));
    }

    function applyFixes(uri:String, version:Int, edits:Array<TextEdit>) {
        var editor = window.activeTextEditor;
        if (editor == null || editor.document.uri.toString() != uri)
            return;

        // TODO:
        // if (editor.document.version != version) {
        //     window.showInformationMessage("Fix is outdated and cannot be applied to the document");
        //     return;
        // }

        editor.edit(function(mutator) {
            for (edit in edits) {
                var range = new Range(edit.range.start.line, edit.range.start.character, edit.range.end.line, edit.range.end.character);
                mutator.delete(range);
                mutator.insert(range.start, edit.newText);
            }
        });
    }

    function showReferences(uri:String, position:Position, locations:Array<Location>) {
        inline function copyPosition(position) return new Position(position.line, position.character);
        // this is retarded
        var locations = locations.map(function(location)
            return new Location(Uri.parse(cast location.uri), new Range(copyPosition(location.range.start), copyPosition(location.range.end)))<commit_msg>All commands start with "haxe."...<commit_after>package vshaxe;

import vscode.*;
import Vscode.*;
import haxe.Constraints.Function;

class Main {
    var context:ExtensionContext;
    var serverDisposable:Disposable;
    var hxFileWatcher:FileSystemWatcher;
    var vshaxeChannel:OutputChannel;
    var displayConfig:DisplayConfiguration;
    var client:LanguageClient;

    function new(ctx) {
        context = ctx;

        displayConfig = new DisplayConfiguration(ctx);
        new InitProject(ctx);

        registerCommand("restartLanguageServer", restartLanguageServer);
        registerCommand("applyFixes", applyFixes);
        registerCommand("showReferences", showReferences);
        registerCommand("runGlobalDiagnostics", runGlobalDiagnostics);

        startLanguageServer();
    }

    function registerCommand(command:String, callback:Function) {
        context.subscriptions.push(commands.registerCommand("haxe." + command, callback));
    }

    function applyFixes(uri:String, version:Int, edits:Array<TextEdit>) {
        var editor = window.activeTextEditor;
        if (editor == null || editor.document.uri.toString() != uri)
            return;

        // TODO:
        // if (editor.document.version != version) {
        //     window.showInformationMessage("Fix is outdated and cannot be applied to the document");
        //     return;
        // }

        editor.edit(function(mutator) {
            for (edit in edits) {
                var range = new Range(edit.range.start.line, edit.range.start.character, edit.range.end.line, edit.range.end.character);
                mutator.delete(range);
                mutator.insert(range.start, edit.newText);
            }
        });
    }

    function showReferences(uri:String, position:Position, locations:Array<Location>) {
        inline function copyPosition(position) return new Position(position.line, position.character);
        // this is retarded
        var locations = locations.map(function(location)
            return new Location(Uri.parse(cast location.uri), new Range(copyPosition(location.range.start), copyPosition(location.range.end)))
{'fraction_non_alphanumeric': 0.10666666666666667, 'fraction_numerical': 0.0, 'mean_word_length': 2.9962616822429906, 'pattern_counts': {'":': 0, '<': 7, '<?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': '188866', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1098, 'n_words': 230}