clean up coreServices

This commit is contained in:
Mohamed Hegazy 2014-07-24 14:36:23 -07:00
parent 6ed29c2367
commit 4a4c74958d
3 changed files with 7 additions and 63 deletions

View File

@ -1,49 +0,0 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
///<reference path='classifier.ts' />
///<reference path='languageService.ts' />
///<reference path='formatting\formatting.ts' />
// Access to "Debug" object
var debugObjectHost = (<any>this);
module TypeScript.Services {
export interface ICoreServicesHost {
logger: TypeScript.Logger;
}
export class CoreServices {
constructor (public host: ICoreServicesHost) {
}
public getPreProcessedFileInfo(fileName: string, sourceText: TypeScript.IScriptSnapshot): TypeScript.IPreProcessedFileInfo {
return TypeScript.preProcessFile(fileName, sourceText);
}
public getDefaultCompilationSettings(): ts.CompilerOptions {
return getDefaultCompilerOptions();
}
public collectGarbage(): void {
if (!debugObjectHost || !debugObjectHost.CollectGarbage) {
throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.This_version_of_the_Javascript_runtime_does_not_support_the_0_function, ['collectGarbage()']));
}
debugObjectHost.CollectGarbage();
}
}
}

View File

@ -14,9 +14,8 @@
//
///<reference path='typescriptServices.ts' />
var debugObjectHost = (<any>this);
module TypeScript.Services {
export interface IScriptSnapshotShim {
// Get's a portion of the script snapshot specified by [start, end).
getText(start: number, end: number): string;
@ -805,17 +804,12 @@ module TypeScript.Services {
}
class CoreServicesShimObject extends ShimBase implements CoreServicesShim {
public logger: TypeScript.Logger;
public services: CoreServices;
constructor(factory: ShimFactory, public host: ICoreServicesHost) {
constructor(factory: ShimFactory, public host: Logger) {
super(factory);
this.logger = this.host.logger;
this.services = new CoreServices(this.host);
}
private forwardJSONCall(actionDescription: string, action: () => any): any {
return forwardJSONCall(this.logger, actionDescription, action);
return forwardJSONCall(this.host, actionDescription, action);
}
///
@ -825,7 +819,7 @@ module TypeScript.Services {
return this.forwardJSONCall(
"getPreProcessedFileInfo(\"" + fileName + "\")",
() => {
var result = this.services.getPreProcessedFileInfo(fileName, sourceText);
var result = TypeScript.preProcessFile(fileName, sourceText);
return result;
});
}
@ -837,7 +831,7 @@ module TypeScript.Services {
return this.forwardJSONCall(
"getDefaultCompilationSettings()",
() => {
return compilerOptionsToCompilationSettings(this.services.getDefaultCompilationSettings());
return compilerOptionsToCompilationSettings(getDefaultCompilerOptions());
});
}
}
@ -868,12 +862,12 @@ module TypeScript.Services {
}
}
public createCoreServicesShim(host: ICoreServicesHost): CoreServicesShim {
public createCoreServicesShim(host: Logger): CoreServicesShim {
try {
return new CoreServicesShimObject(this, host);
}
catch (err) {
logInternalError(host.logger, err);
logInternalError(host, err);
throw err;
}
}

View File

@ -22,7 +22,6 @@
/// <reference path='syntax\incrementalParser.ts' />
/// <reference path='coreServices.ts' />
/// <reference path='classifier.ts' />
/// <reference path='languageService.ts' />
/// <reference path='pullLanguageService.ts' />