Add Logger definition to services.ts

This commit is contained in:
Mohamed Hegazy
2014-07-29 12:14:42 -07:00
parent 70b8a569d9
commit 4afbcf7b18
2 changed files with 17 additions and 9 deletions
+12 -4
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);
+5 -5
View File
@@ -40,7 +40,7 @@ module TypeScript.Services {
//
// Public interface of the host of a language service shim instance.
//
export interface LanguageServiceShimHost extends TypeScript.Logger {
export interface LanguageServiceShimHost extends Logger {
getCompilationSettings(): string;
// Returns a JSON encoded value of the type:
@@ -249,7 +249,7 @@ module TypeScript.Services {
return settings;
}
function logInternalError(logger: TypeScript.Logger, err: Error) {
function logInternalError(logger: Logger, err: Error) {
logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message);
}
@@ -389,7 +389,7 @@ module TypeScript.Services {
}
}
function simpleForwardCall(logger: TypeScript.Logger, actionDescription: string, action: () => any): any {
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any): any {
logger.log(actionDescription);
var start = Date.now();
var result = action();
@@ -405,7 +405,7 @@ module TypeScript.Services {
return result;
}
function forwardJSONCall(logger: TypeScript.Logger, actionDescription: string, action: () => any): string {
function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any): string {
try {
var result = simpleForwardCall(logger, actionDescription, action);
return JSON.stringify({ result: result });
@@ -430,7 +430,7 @@ module TypeScript.Services {
}
class LanguageServiceShimObject extends ShimBase implements LanguageServiceShim {
private logger: TypeScript.Logger;
private logger: Logger;
constructor(factory: ShimFactory,
private host: LanguageServiceShimHost,