<commit_before>// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import {window, commands, Disposable, ExtensionContext, StatusBarAlignment, StatusBarItem, TextDocument, Range, Position, DecorationRenderOptions} from 'vscode'; 

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: ExtensionContext) {

	console.log('"vscode-todo-highlighter" is now active!');window.showInformationMessage('running!');

	let highlighter = new Highlighter();
    let controller = new Controller(highlighter);
    
    // Add to list of disposed items when deactivated
	context.subscriptions.push(controller);
    context.subscriptions.push(highlighter);
}

// this method is called when your extension is deactivated
export function deactivate() {
}

class Dcr implements DecorationRenderOptions {
    color: string;
    
    constructor(color: string) {
        this.color = color;
    }
}

class Highlighter {
    public update() {
        let editor = window.activeTextEditor;
        if(!editor) {
            return;
        }
        
        let doc = editor.document;
        let todo_list = this.getTodo(doc);
        if(todo_list.length > 0) {
            let options = new Dcr('blue');
            // TODO: bug here!
            editor.setDecorations(window.createTextEditorDecorationType(options), [todo_list[0]]);
            console.log(todo_list);
        }
    }
    
    private getTodo(doc: TextDocument): Range[] {
        let docContent = doc.getText(); 
 
        // Parse out unwanted whitespace so the split is accurate 
        docContent = docContent.replace(/(< ([^>]+)<)/g, '').replace(/\s+/g, ' '); 
        docContent = docContent.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); 
        
        let results : Range[] = [];
        if (docContent != "") {
            let regex = /\/\/todo/g, match, indices = [];
            while (match = regex.exec(docContent)) {
                indices.push(match.index);
            }
            let count = 0;
            for(let m of indices) {
                results.push(new Range(doc.positionAt(m), doc.positionAt(m + 6)));
                count++;
            }
            if(count) {
                console.log(`detected ${count} TODOs`);
            }
        } 
          
        return results; 
    }
    
    dispose() {}
}

class Controller {
    private _highlighter: Highlighter;
    private _disposable: Disposable;
    
    constructor(highlighter: Highlighter) {
        this._highlighter = highlighter;
        
        let subscriptions: Disposable[] = [];
        window.onDidChangeTextEditorSelection(this._onEvent, this, subscriptions);
        window.onDidChangeActiveTextEditor(this._onEvent, this, subscriptions);
        
        // Run highlighter for current file
        this._highlighter.update();
        
        this._disposable = Disposable.from(...subscriptions);
    }
    
    private _onEvent() {
        this._highlighter.update();
    }
    
    dispose() {}
}<commit_msg>Change class name<commit_after>// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import {window, commands, Disposable, ExtensionContext, StatusBarAlignment, StatusBarItem, TextDocument, Range, Position, DecorationRenderOptions, DecorationOptions, MarkedString} from 'vscode'; 

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: ExtensionContext) {

	console.log('"vscode-todo-highlighter" is now active!');window.showInformationMessage('running!');

	let highlighter = new Highlighter();
    let controller = new Controller(highlighter);
    
    // Add to list of disposed items when deactivated
	context.subscriptions.push(controller);
    context.subscriptions.push(highlighter);
}

// this method is called when your extension is deactivated
export function deactivate() {
}

class DcOps implements DecorationRenderOptions {
    color: string;
    
    constructor(color: string) {
        this.color = color;
    }
}

class Highlighter {
    public update() {
        let editor = window.activeTextEditor;
        if(!editor) {
            return;
        }
        
        let doc = editor.document;
        let todo_list = this.getTodo(doc);
        if(todo_list.length > 0) {
            let options = new DcOps('blue');
            // TODO: bug here!
            editor.setDecorations(window.createTextEditorDecorationType(options), [todo_list[0]]);
            console.log(todo_list);
        }
    }
    
    private getTodo(doc: TextDocument): Range[] {
        let docContent = doc.getText(); 
 
        // Parse out unwanted whitespace so the split is accurate 
        docContent = docContent.replace(/(< ([^>]+)<)/g, '').replace(/\s+/g, ' '); 
        docContent = docContent.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); 
        
        let results : Range[] = [];
        if (docContent != "") {
            let regex = /\/\/todo/g, match, indices = [];
            while (match = regex.exec(docContent)) {
                indices.push(match.index);
            }
            let count = 0;
            for(let m of indices) {
                results.push(new Range(doc.positionAt(m), doc.positionAt(m + 6)));
                count++;
            }
            if(count) {
                console.log(`detected ${count} TODOs`);
            }
        } 
          
        return results; 
    }
    
    dispose() {}
}

class Controller {
    private _highlighter: Highlighter;
    private _disposable: Disposable;
    
    constructor(highlighter: Highlighter) {
        this._highlighter = highlighter;
        
        let subscriptions: Disposable[] = [];
        window.onDidChangeTextEditorSelection(this._onEvent, this, subscriptions);
        window.onDidChangeActiveTextEditor(this._onEvent, this, subscriptions);
        
        // Run highlighter for current file
        this._highlighter.update();
        
        this._disposable = Disposable.from(...subscriptions);
    }
    
    private _onEvent() {
        this._highlighter.update();
    }
    
    dispose() {}
}
{'fraction_non_alphanumeric': 0.11339075959279561, 'fraction_numerical': 0.0012529365700861394, 'mean_word_length': 2.3002583979328164, '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': '4179156', 'n_tokens_mistral': 1811, 'n_tokens_neox': 1749, 'n_words': 448}