move TypeScriptServicesFactory to shims.ts

This commit is contained in:
Mohamed Hegazy 2014-07-24 11:42:55 -07:00
parent 580eaebad3
commit 02fa159d7c
2 changed files with 104 additions and 106 deletions

View file

@ -838,4 +838,99 @@ module TypeScript.Services {
});
}
}
export class TypeScriptServicesFactory implements IShimFactory {
private _shims: IShim[] = [];
private documentRegistry: DocumentRegistry = new DocumentRegistry();
public createPullLanguageService(host: TypeScript.Services.LanguageServiceHost): TypeScript.Services.LanguageService {
try {
return TypeScript.Services.createLanguageService(host, this.documentRegistry);
}
catch (err) {
TypeScript.Services.logInternalError(host, err);
throw err;
}
}
public createLanguageServiceShim(host: ILanguageServiceShimHost): ILanguageServiceShim {
try {
var hostAdapter = new LanguageServiceShimHostAdapter(host);
var pullLanguageService = this.createPullLanguageService(hostAdapter);
return new LanguageServiceShim(this, host, pullLanguageService);
}
catch (err) {
TypeScript.Services.logInternalError(host, err);
throw err;
}
}
public createClassifier(host: TypeScript.Services.IClassifierHost): TypeScript.Services.Classifier {
try {
return new TypeScript.Services.Classifier(host);
}
catch (err) {
TypeScript.Services.logInternalError(host, err);
throw err;
}
}
public createClassifierShim(host: TypeScript.Services.IClassifierHost): ClassifierShim {
try {
return new ClassifierShim(this, host);
}
catch (err) {
TypeScript.Services.logInternalError(host, err);
throw err;
}
}
public createCoreServices(host: TypeScript.Services.ICoreServicesHost): TypeScript.Services.CoreServices {
try {
return new TypeScript.Services.CoreServices(host);
}
catch (err) {
TypeScript.Services.logInternalError(host.logger, err);
throw err;
}
}
public createCoreServicesShim(host: TypeScript.Services.ICoreServicesHost): CoreServicesShim {
try {
return new CoreServicesShim(this, host);
}
catch (err) {
TypeScript.Services.logInternalError(host.logger, err);
throw err;
}
}
public close(): void {
// Forget all the registered shims
this._shims = [];
this.documentRegistry = new DocumentRegistry();
}
public registerShim(shim: IShim): void {
this._shims.push(shim);
}
public unregisterShim(shim: IShim): void {
for (var i = 0, n = this._shims.length; i < n; i++) {
if (this._shims[i] === shim) {
delete this._shims[i];
return;
}
}
throw TypeScript.Errors.invalidOperation();
}
}
}
/// TODO: this is used by VS, clean this up on both sides of the interfrace
module Services {
export var TypeScriptServicesFactory = TypeScript.Services.TypeScriptServicesFactory;
}

View file

@ -130,100 +130,3 @@ module TypeScript {
return true;
}
}
module TypeScript.Services {
export class TypeScriptServicesFactory implements IShimFactory {
private _shims: IShim[] = [];
private documentRegistry: DocumentRegistry = new DocumentRegistry();
public createPullLanguageService(host: TypeScript.Services.LanguageServiceHost): TypeScript.Services.LanguageService {
try {
return TypeScript.Services.createLanguageService(host, this.documentRegistry);
}
catch (err) {
TypeScript.Services.logInternalError(host, err);
throw err;
}
}
public createLanguageServiceShim(host: ILanguageServiceShimHost): ILanguageServiceShim {
try {
var hostAdapter = new LanguageServiceShimHostAdapter(host);
var pullLanguageService = this.createPullLanguageService(hostAdapter);
return new LanguageServiceShim(this, host, pullLanguageService);
}
catch (err) {
TypeScript.Services.logInternalError(host, err);
throw err;
}
}
public createClassifier(host: TypeScript.Services.IClassifierHost): TypeScript.Services.Classifier {
try {
return new TypeScript.Services.Classifier(host);
}
catch (err) {
TypeScript.Services.logInternalError(host, err);
throw err;
}
}
public createClassifierShim(host: TypeScript.Services.IClassifierHost): ClassifierShim {
try {
return new ClassifierShim(this, host);
}
catch (err) {
TypeScript.Services.logInternalError(host, err);
throw err;
}
}
public createCoreServices(host: TypeScript.Services.ICoreServicesHost): TypeScript.Services.CoreServices {
try {
return new TypeScript.Services.CoreServices(host);
}
catch (err) {
TypeScript.Services.logInternalError(host.logger, err);
throw err;
}
}
public createCoreServicesShim(host: TypeScript.Services.ICoreServicesHost): CoreServicesShim {
try {
return new CoreServicesShim(this, host);
}
catch (err) {
TypeScript.Services.logInternalError(host.logger, err);
throw err;
}
}
public close(): void {
// Forget all the registered shims
this._shims = [];
this.documentRegistry = new DocumentRegistry();
}
public registerShim(shim: IShim): void {
this._shims.push(shim);
}
public unregisterShim(shim: IShim): void {
for(var i =0, n = this._shims.length; i<n; i++) {
if (this._shims[i] === shim) {
delete this._shims[i];
return;
}
}
throw TypeScript.Errors.invalidOperation();
}
}
}
module Services {
export var TypeScriptServicesFactory = TypeScript.Services.TypeScriptServicesFactory;
}