<commit_before>// Copyright (c) <NAME>. All rights reserved.
// Licensed under the Apache License, Version 2.0. 
// See LICENSE.txt in the project root for complete license information.

///<reference path='typings/node/node.d.ts'/>
///<reference path='node_modules/typescript/bin/typescript.d.ts'/>
///<reference path='node_modules/typescript/bin/typescript_internal.d.ts'/>

import ts = require("typescript");
import harness = require("./harness");

// __dirname + a file to put path references in.. :-(
declare var __dirname : string;
var defaultLibs  = __dirname + "/defaultLibs.d.ts";

// TS has its own declarations for node-specific stuff, so we
// need to extend those instead of referencing node.d.ts
//declare module process {
//  export var stdin : any;
//}

function switchToForwardSlashes(path: string) {
    return path.replace(/\\/g, "/");
}

// some approximated subsets..
interface ReadlineHandlers {
  on(event: string, listener: (event:string)=>void) : ReadlineHandlers;
  close() : void;
}
interface Readline {
  createInterface(options:any) : ReadlineHandlers;
}

// bypass import, we don't want to drop out of the global module;
// use fixed readline (https://github.com/joyent/node/issues/3305),
// fixed version should be in nodejs from about v0.9.9/v0.8.19?
var readline:Readline = require("./readline");

var EOL = require("os").EOL;

/** TypeScript Services Server,
    an interactive commandline tool
    for getting info on .ts projects */
class TSS {
  public compilerOptions: ts.CompilerOptions;
  public compilerHost: ts.CompilerHost;
  public program: ts.Program;
  public fileNames: string[];
  public lsHost : ts.LanguageServiceHost;
  public ls : ts.LanguageService;
  public rootFile : string;
//  public resolutionResult : ts.ReferenceResolutionResult;
  public lastError;

  constructor (public prettyJSON: boolean = false) { } // NOTE: call setup

  private fileNameToContent:ts.Map<string>;
  private snapshots:ts.Map<ts.IScriptSnapshot>;
  private fileNameToScript:ts.Map<harness.ScriptInfo>;

  /**
   * @param line 1 based index
   * @param col 1 based index
  */
  public lineColToPosition(fileName: string, line: number, col: number): number {
      var script: harness.ScriptInfo = this.fileNameToScript[fileName];

      return ts.computePositionFromLineAndCharacter(script.lineMap,line, col);
  }

  /**
   * @param line 1 based index
   * @param col 1 based index
  */
  private positionToLineCol(fileName: string, position: number): ts.LineAndCharacter {
      var script: harness.ScriptInfo = this.fileNameToScript[fileName];

      return ts.computeLineAndCharacterOfPosition(script.lineMap,position);
  }

  private updateScript(fileName: string, content: string) {
      var script = this.fileNameToScript[fileName];
      if (script !== null) {
        script.updateContent(content);
      } else {<commit_msg>follow yet more arbitrary API changes<commit_after>// Copyright (c) <NAME>. All rights reserved.
// Licensed under the Apache License, Version 2.0. 
// See LICENSE.txt in the project root for complete license information.

///<reference path='typings/node/node.d.ts'/>
///<reference path='node_modules/typescript/bin/typescript.d.ts'/>
///<reference path='node_modules/typescript/bin/typescript_internal.d.ts'/>

import ts = require("typescript");
import harness = require("./harness");

// __dirname + a file to put path references in.. :-(
declare var __dirname : string;
var defaultLibs  = __dirname + "/defaultLibs.d.ts";

// TS has its own declarations for node-specific stuff, so we
// need to extend those instead of referencing node.d.ts
//declare module process {
//  export var stdin : any;
//}

function switchToForwardSlashes(path: string) {
    return path.replace(/\\/g, "/");
}

// some approximated subsets..
interface ReadlineHandlers {
  on(event: string, listener: (event:string)=>void) : ReadlineHandlers;
  close() : void;
}
interface Readline {
  createInterface(options:any) : ReadlineHandlers;
}

// bypass import, we don't want to drop out of the global module;
// use fixed readline (https://github.com/joyent/node/issues/3305),
// fixed version should be in nodejs from about v0.9.9/v0.8.19?
var readline:Readline = require("./readline");

var EOL = require("os").EOL;

/** TypeScript Services Server,
    an interactive commandline tool
    for getting info on .ts projects */
class TSS {
  public compilerOptions: ts.CompilerOptions;
  public compilerHost: ts.CompilerHost;
  public program: ts.Program;
  public fileNames: string[];
  public lsHost : ts.LanguageServiceHost;
  public ls : ts.LanguageService;
  public rootFile : string;
//  public resolutionResult : ts.ReferenceResolutionResult;
  public lastError;

  constructor (public prettyJSON: boolean = false) { } // NOTE: call setup

  private fileNameToContent:ts.Map<string>;
  private snapshots:ts.Map<ts.IScriptSnapshot>;
  private fileNameToScript:ts.Map<harness.ScriptInfo>;

  /**
   * @param line 1 based index
   * @param col 1 based index
   */
  public lineColToPosition(fileName: string, line: number, col: number): number {
      var script: harness.ScriptInfo = this.fileNameToScript[fileName];

      return ts.computePositionOfLineAndCharacter(script.lineMap,line-1, col-1);
  }

  /**
   * @returns {line,character} 1 based indices
   */
  private positionToLineCol(fileName: string, position: number): ts.LineAndCharacter {
      var script: harness.ScriptInfo = this.fileNameToScript[fileName];

      var lineChar = ts.computeLineAndCharacterOfPosition(script.lineMap,position);

      return {line: lineChar.line+1, character: lineChar.character+1 };
  }

  private updateScript(fileName: string, content: string) {
      var script = this.fileNameToScript[fileName];
      if (script !== null) {
        script.updateContent(content);
      } else {
{'fraction_non_alphanumeric': 0.12150334649047537, 'fraction_numerical': 0.0063497511584005495, 'mean_word_length': 3.9982847341337906, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, 'https://': 2, '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': '5137595', 'n_tokens_mistral': 1744, 'n_tokens_neox': 1711, 'n_words': 494}