Add Logger definition to services.ts

This commit is contained in:
Mohamed Hegazy
2014-07-24 16:01:51 -07:00
parent 70b8a569d9
commit 4afbcf7b18
2 changed files with 17 additions and 9 deletions

View File

@@ -305,10 +305,19 @@ module ts {
module TypeScript.Services {
export interface Logger {
information(): boolean;
debug(): boolean;
warning(): boolean;
error(): boolean;
fatal(): boolean;
log(s: string): void;
}
//
// Public interface of the host of a language service instance.
//
export interface LanguageServiceHost extends TypeScript.Logger {
export interface LanguageServiceHost extends Logger {
getCompilationSettings(): ts.CompilerOptions;
getScriptFileNames(): string[];
getScriptVersion(fileName: string): number;
@@ -1201,7 +1210,6 @@ module TypeScript.Services {
}
export function createLanguageService(host: LanguageServiceHost, documentRegistry: IDocumentRegistry): LanguageService {
var logger: TypeScript.Logger = host;
var _syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host);
var formattingRulesProvider: Formatting.RulesProvider;
var hostCache: HostCache; // A cache of all the information about the files on the host side.
@@ -1386,7 +1394,7 @@ module TypeScript.Services {
var sourceUnit = document.sourceUnit();
if (CompletionHelpers.isCompletionListBlocker(document.syntaxTree().sourceUnit(), position)) {
logger.log("Returning an empty list because completion was blocked.");
host.log("Returning an empty list because completion was blocked.");
return null;
}
@@ -1793,7 +1801,7 @@ module TypeScript.Services {
function getFormattingManager(filename: string, options: FormatCodeOptions) {
// Ensure rules are initialized and up to date wrt to formatting options
if (formattingRulesProvider == null) {
formattingRulesProvider = new TypeScript.Services.Formatting.RulesProvider(logger);
formattingRulesProvider = new TypeScript.Services.Formatting.RulesProvider(host);
}
formattingRulesProvider.ensureUpToDate(options);

View File

@@ -40,7 +40,7 @@ module TypeScript.Services {
}
//
// Public interface of the host of a language service shim instance.
// Public interface of the host of a language service shim instance.
//
export interface LanguageServiceShimHost extends Logger {
getCompilationSettings(): string;
@@ -249,7 +249,7 @@ module TypeScript.Services {
// settings.useCaseSensitiveFileResolution = options.useCaseSensitiveFileResolution;
settings.codepage = options.codepage;
return settings;
}
}
function logInternalError(logger: Logger, err: Error) {
logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message);
@@ -389,7 +389,7 @@ module TypeScript.Services {
public getParentDirectory(path: string): string {
return this.shimHost.getParentDirectory(path);
}
}
}
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any): any {
logger.log(actionDescription);
@@ -405,7 +405,7 @@ module TypeScript.Services {
logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'");
}
return result;
}
}
function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any): string {
try {
@@ -430,7 +430,7 @@ module TypeScript.Services {
this.factory.unregisterShim(this);
}
}
class LanguageServiceShimObject extends ShimBase implements LanguageServiceShim {
private logger: Logger;