<commit_before>'use strict';

import { spawn } from 'child_process';
import { Socket } from 'net';

import { workspace, Disposable, ExtensionContext, commands, window } from 'vscode';
import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind, StreamInfo } from 'vscode-languageclient';

const LSPort = 8123;  // TODO: make configurable
const EnableExtensionDebugging : boolean = <boolean> workspace.getConfiguration('somns').get('debugMode');

function getServerOptions(context: ExtensionContext): ServerOptions {
	const javaCmd = '/usr/bin/java';
	const bootCP = ['-Xbootclasspath/a',
		context.asAbsolutePath('out/server/som.jar'),
		context.asAbsolutePath('out/server/truffle-api.jar'),
		context.asAbsolutePath('out/server/truffle-debug.jar'),
		context.asAbsolutePath('out/server/somns-deps.jar')]

  const javaClasspass = [
		context.asAbsolutePath('out/server/guava-19.0.jar'),
		context.asAbsolutePath('out/server/org.eclipse.xtend.lib-2.10.0.jar'),
		context.asAbsolutePath('out/server/org.eclipse.xtext.xbase.lib-2.10.0.jar'),
		context.asAbsolutePath('out/server/som-language-server.jar')]
	const somLib = '-Dsom.langserv.core-lib=' + context.asAbsolutePath('out/server/core-lib')

	let javaArgs = [
		bootCP.join(':'),
		'-cp', javaClasspass.join(':'),
		somLib,
		'som.langserv.ServerLauncher'];

	if (EnableExtensionDebugging || true) {
		javaArgs = ['-ea', '-esa',
								'-Xdebug',
								'-Xrunjdwp:transport=dt_socket,quiet=y,server=y,suspend=n,address=8000'
							 ].concat(javaArgs);
	}

	return {
		run:   { command: javaCmd, args: javaArgs },
		debug: { command: javaCmd, args: javaArgs }
	}
}

function startLanguageServer(context: ExtensionContext,
													   resolve: (value?: StreamInfo | PromiseLike<StreamInfo>) => void,
														 reject: (reason?: any) => void) {
	const serverOptions: any = getServerOptions(context);
	const lsProc = spawn(serverOptions.run.command, serverOptions.run.args);
	let sawServerStarted = false;
	lsProc.stdout.on('data', data => {<commit_msg>Remove debugging hack<commit_after>'use strict';

import { spawn } from 'child_process';
import { Socket } from 'net';

import { workspace, Disposable, ExtensionContext, commands, window } from 'vscode';
import { LanguageClient, LanguageClientOptions, SettingMonitor, ServerOptions, TransportKind, StreamInfo } from 'vscode-languageclient';

const LSPort = 8123;  // TODO: make configurable
const EnableExtensionDebugging : boolean = <boolean> workspace.getConfiguration('somns').get('debugMode');

function getServerOptions(context: ExtensionContext): ServerOptions {
	const javaCmd = '/usr/bin/java';
	const bootCP = ['-Xbootclasspath/a',
		context.asAbsolutePath('out/server/som.jar'),
		context.asAbsolutePath('out/server/truffle-api.jar'),
		context.asAbsolutePath('out/server/truffle-debug.jar'),
		context.asAbsolutePath('out/server/somns-deps.jar')]

  const javaClasspass = [
		context.asAbsolutePath('out/server/guava-19.0.jar'),
		context.asAbsolutePath('out/server/org.eclipse.xtend.lib-2.10.0.jar'),
		context.asAbsolutePath('out/server/org.eclipse.xtext.xbase.lib-2.10.0.jar'),
		context.asAbsolutePath('out/server/som-language-server.jar')]
	const somLib = '-Dsom.langserv.core-lib=' + context.asAbsolutePath('out/server/core-lib')

	let javaArgs = [
		bootCP.join(':'),
		'-cp', javaClasspass.join(':'),
		somLib,
		'som.langserv.ServerLauncher'];

	if (EnableExtensionDebugging) {
		javaArgs = ['-ea', '-esa',
								'-Xdebug',
								'-Xrunjdwp:transport=dt_socket,quiet=y,server=y,suspend=n,address=8000'
							 ].concat(javaArgs);
	}

	return {
		run:   { command: javaCmd, args: javaArgs },
		debug: { command: javaCmd, args: javaArgs }
	}
}

function startLanguageServer(context: ExtensionContext,
													   resolve: (value?: StreamInfo | PromiseLike<StreamInfo>) => void,
														 reject: (reason?: any) => void) {
	const serverOptions: any = getServerOptions(context);
	const lsProc = spawn(serverOptions.run.command, serverOptions.run.args);
	let sawServerStarted = false;
	lsProc.stdout.on('data', data => {
{'fraction_non_alphanumeric': 0.1533203125, 'fraction_numerical': 0.00927734375, 'mean_word_length': 4.827880512091038, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '6308195', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1308, 'n_words': 229}