From 5819fd4fd4c8c645d9bdabaa9f670a1e5f93449f Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Sat, 19 Jul 2014 10:45:54 -0700 Subject: [PATCH] Change classes into interfaces --- src/services/breakpoints.ts | 15 +- .../getScriptLexicalStructureWalker.ts | 27 ++-- src/services/languageService.ts | 140 ++++++++---------- 3 files changed, 92 insertions(+), 90 deletions(-) diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index c1e3535d432..237df5afce0 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -10,7 +10,10 @@ module TypeScript.Services.Breakpoints { } if (childElements.length == 0) { - return new SpanInfo(TypeScript.start(parentElement), TypeScript.end(parentElement)); + return { + minChar: TypeScript.start(parentElement), + limChar: TypeScript.end(parentElement) + }; } var start: number; @@ -25,11 +28,17 @@ module TypeScript.Services.Breakpoints { } } - return new SpanInfo(start, end); + return { + minChar: start, + limChar: end + }; } function createBreakpointSpanInfoWithLimChar(startElement: TypeScript.ISyntaxElement, limChar: number): SpanInfo { - return new SpanInfo(start(startElement), limChar); + return { + minChar: start(startElement), + limChar: limChar + }; } class BreakpointResolver { diff --git a/src/services/getScriptLexicalStructureWalker.ts b/src/services/getScriptLexicalStructureWalker.ts index c62ef11136d..66d930784dd 100644 --- a/src/services/getScriptLexicalStructureWalker.ts +++ b/src/services/getScriptLexicalStructureWalker.ts @@ -81,17 +81,17 @@ module TypeScript.Services { return; } - var item = new NavigateToItem(); - item.name = name; - item.kind = kind; - item.matchKind = MatchKind.exact; - item.fileName = this.fileName; - item.kindModifiers = this.getKindModifiers(modifiers); - item.minChar = start(node); - item.limChar = end(node); - item.containerName = this.nameStack.join("."); - item.containerKind = this.kindStack.length === 0 ? "" : TypeScript.ArrayUtilities.last(this.kindStack); - + var item: NavigateToItem = { + name: name, + kind: kind, + matchKind: MatchKind.exact, + fileName: this.fileName, + kindModifiers: this.getKindModifiers(modifiers), + minChar: start(node), + limChar: end(node), + containerName: this.nameStack.join("."), + containerKind: this.kindStack.length === 0 ? "" : TypeScript.ArrayUtilities.last(this.kindStack), + }; this.currentScope.items[key] = item; this.currentScope.itemNames.push(key); } @@ -104,7 +104,10 @@ module TypeScript.Services { Debug.assert(item !== undefined); var start = TypeScript.start(node); - var span = new SpanInfo(start, start + width(node)); + var span: SpanInfo = { + minChar: start, + limChar: start + width(node) + }; if (item.additionalSpans) { diff --git a/src/services/languageService.ts b/src/services/languageService.ts index efaf0283373..de526c9ee6b 100644 --- a/src/services/languageService.ts +++ b/src/services/languageService.ts @@ -78,7 +78,7 @@ module TypeScript.Services { getEmitOutput(fileName: string): TypeScript.EmitOutput; - getSyntaxTree(fileName: string): TypeScript.SyntaxTree; + //getSyntaxTree(fileName: string): TypeScript.SyntaxTree; dispose(): void; } @@ -87,31 +87,24 @@ module TypeScript.Services { logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); } - export class ReferenceEntry { - public fileName: string = "" - public minChar: number = -1; - public limChar: number = -1; - public isWriteAccess: boolean = false; - - constructor(fileName: string, minChar: number, limChar: number, isWriteAccess: boolean) { - this.fileName = fileName; - this.minChar = minChar; - this.limChar = limChar; - this.isWriteAccess = isWriteAccess; - } + export interface ReferenceEntry { + fileName: string; + minChar: number; + limChar: number; + isWriteAccess: boolean; } - export class NavigateToItem { - public name: string = ""; - public kind: string = ""; // see ScriptElementKind - public kindModifiers: string = ""; // see ScriptElementKindModifier, comma separated - public matchKind: string = ""; - public fileName: string = ""; - public minChar: number = -1; - public limChar: number = -1; - public additionalSpans: SpanInfo[] = null; - public containerName: string = ""; - public containerKind: string = ""; // see ScriptElementKind + export interface NavigateToItem { + name: string; + kind: string; // see ScriptElementKind + kindModifiers: string; // see ScriptElementKindModifier, comma separated + matchKind: string; + fileName: string; + minChar: number; + limChar: number; + additionalSpans?: SpanInfo[]; + containerName: string; + containerKind: string; // see ScriptElementKind } export class TextEdit { @@ -169,73 +162,69 @@ module TypeScript.Services { } } - export class DefinitionInfo { - constructor( - public fileName: string, - public minChar: number, - public limChar: number, - public kind: string, - public name: string, - public containerKind: string, - public containerName: string) { - } + export interface DefinitionInfo { + fileName: string; + minChar: number; + limChar: number; + kind: string; + name: string; + containerKind: string; + containerName: string; } - export class TypeInfo { - constructor( - public memberName: TypeScript.MemberName, - public docComment: string, - public fullSymbolName: string, - public kind: string, - public minChar: number, - public limChar: number) { - } + export interface TypeInfo { + memberName: TypeScript.MemberName; + docComment: string; + fullSymbolName: string; + kind: string; + minChar: number; + limChar: number; } - export class SpanInfo { - constructor(public minChar: number, public limChar: number, public text: string = null) { - } + export interface SpanInfo { + minChar: number; + limChar: number; + // text?: string; } - export class SignatureInfo { - public actual: ActualSignatureInfo; - public formal: FormalSignatureItemInfo[] = []; // Formal signatures - public activeFormal: number; // Index of the "best match" formal signature + export interface SignatureInfo { + actual: ActualSignatureInfo; + formal: FormalSignatureItemInfo[]; // Formal signatures + activeFormal: number; // Index of the "best match" formal signature } - export class FormalSignatureItemInfo { - public signatureInfo: string; - public typeParameters: FormalTypeParameterInfo[] = []; - public parameters: FormalParameterInfo[] = []; // Array of parameters - public docComment: string; // Help for the signature + export interface FormalSignatureItemInfo { + signatureInfo: string; + typeParameters: FormalTypeParameterInfo[]; + parameters: FormalParameterInfo[]; // Array of parameters + docComment: string; // Help for the signature } - export class FormalTypeParameterInfo { - public name: string; // Type parameter name - public docComment: string; // Comments that contain help for the parameter - public minChar: number; // minChar for parameter info in the formal signature info string - public limChar: number; // lim char for parameter info in the formal signature info string + export interface FormalTypeParameterInfo { + name: string; // Type parameter name + docComment: string; // Comments that contain help for the parameter + minChar: number; // minChar for parameter info in the formal signature info string + limChar: number; // lim char for parameter info in the formal signature info string } - export class FormalParameterInfo { - public name: string; // Parameter name - public isVariable: boolean; // true if parameter is var args - public docComment: string; // Comments that contain help for the parameter - public minChar: number; // minChar for parameter info in the formal signature info string - public limChar: number; // lim char for parameter info in the formal signature info string + export interface FormalParameterInfo { + name: string; // Parameter name + isVariable: boolean; // true if parameter is var args + docComment: string; // Comments that contain help for the parameter + minChar: number; // minChar for parameter info in the formal signature info string + limChar: number; // lim char for parameter info in the formal signature info string } - export class ActualSignatureInfo { - public parameterMinChar: number; - public parameterLimChar: number; - public currentParameterIsTypeParameter: boolean; // current parameter is a type argument or a normal argument - public currentParameter: number; // Index of active parameter in "parameters" or "typeParamters" array + export interface ActualSignatureInfo { + parameterMinChar: number; + parameterLimChar: number; + currentParameterIsTypeParameter: boolean; // current parameter is a type argument or a normal argument + currentParameter: number; // Index of active parameter in "parameters" or "typeParamters" array } - export class CompletionInfo { - public maybeInaccurate = false; - public isMemberCompletion = false; - public entries: CompletionEntry[] = []; + export interface CompletionInfo { + isMemberCompletion: boolean; + entries: CompletionEntry[]; } export interface CompletionEntry { @@ -254,6 +243,7 @@ module TypeScript.Services { } + // TODO: move these to enums export class ScriptElementKind { static unknown = "";