mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 10:55:15 -06:00
commit
5fb50d8314
@ -409,7 +409,7 @@ module ts {
|
||||
// Build up the list of examples.
|
||||
var padding = makePadding(marginLength);
|
||||
output += getDiagnosticText(Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine;
|
||||
output += padding + "tsc --out foo.js foo.ts" + sys.newLine;
|
||||
output += padding + "tsc --out file.js file.ts" + sys.newLine;
|
||||
output += padding + "tsc @args.txt" + sys.newLine;
|
||||
output += sys.newLine;
|
||||
|
||||
|
||||
@ -1633,7 +1633,7 @@ module FourSlash {
|
||||
|
||||
public verifyTodoComments(descriptors: string[], spans: TextSpan[]) {
|
||||
var actual = this.languageService.getTodoComments(this.activeFile.fileName,
|
||||
descriptors.map(d => new ts.TodoCommentDescriptor(d, 0)));
|
||||
descriptors.map(d => { return { text: d, priority: 0 }; }));
|
||||
|
||||
if (actual.length !== spans.length) {
|
||||
throw new Error('verifyTodoComments failed - expected total spans to be ' + spans.length + ', but was ' + actual.length);
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
|
||||
// See LICENSE.txt in the project root for complete license information.
|
||||
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.Services.Breakpoints {
|
||||
function createBreakpointSpanInfo(parentElement: TypeScript.ISyntaxElement, ...childElements: TypeScript.ISyntaxElement[]): TextSpan {
|
||||
if (!parentElement) {
|
||||
|
||||
@ -112,9 +112,11 @@ module TypeScript.Services.Formatting {
|
||||
|
||||
//
|
||||
// TODO: Change the ILanguageService interface to return TextEditInfo (with start, and length) instead of TextEdit (with minChar and limChar)
|
||||
formattingEdits.forEach((item) => {
|
||||
var edit = new ts.TextChange(new TextSpan(item.position, item.length), item.replaceWith);
|
||||
result.push(edit);
|
||||
formattingEdits.forEach(item => {
|
||||
result.push({
|
||||
span: new TextSpan(item.position, item.length),
|
||||
newText: item.replaceWith
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.Services {
|
||||
export class NavigationBarItemGetter {
|
||||
@ -152,6 +151,19 @@ module TypeScript.Services {
|
||||
}
|
||||
}
|
||||
|
||||
private getNavigationBarItem(text: string, kind: string, kindModifiers: string, spans: TypeScript.TextSpan[], childItems?: ts.NavigationBarItem[], indent: number = 0): ts.NavigationBarItem {
|
||||
return {
|
||||
text: text,
|
||||
kind: kind,
|
||||
kindModifiers: kindModifiers,
|
||||
spans: spans,
|
||||
childItems: childItems,
|
||||
indent: indent,
|
||||
bolded: false,
|
||||
grayed: false
|
||||
};
|
||||
}
|
||||
|
||||
private createChildItem(node: ISyntaxNode): ts.NavigationBarItem {
|
||||
switch (node.kind()) {
|
||||
case SyntaxKind.Parameter:
|
||||
@ -159,62 +171,62 @@ module TypeScript.Services {
|
||||
if (parameter.modifiers.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return new ts.NavigationBarItem(parameter.identifier.text(), ts.ScriptElementKind.memberVariableElement, this.getKindModifiers(parameter.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem(parameter.identifier.text(), ts.ScriptElementKind.memberVariableElement, this.getKindModifiers(parameter.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.MemberFunctionDeclaration:
|
||||
var memberFunction = <MemberFunctionDeclarationSyntax>node;
|
||||
return new ts.NavigationBarItem(memberFunction.propertyName.text(), ts.ScriptElementKind.memberFunctionElement, this.getKindModifiers(memberFunction.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem(memberFunction.propertyName.text(), ts.ScriptElementKind.memberFunctionElement, this.getKindModifiers(memberFunction.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.GetAccessor:
|
||||
var getAccessor = <GetAccessorSyntax>node;
|
||||
return new ts.NavigationBarItem(getAccessor.propertyName.text(), ts.ScriptElementKind.memberGetAccessorElement, this.getKindModifiers(getAccessor.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem(getAccessor.propertyName.text(), ts.ScriptElementKind.memberGetAccessorElement, this.getKindModifiers(getAccessor.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.SetAccessor:
|
||||
var setAccessor = <SetAccessorSyntax>node;
|
||||
return new ts.NavigationBarItem(setAccessor.propertyName.text(), ts.ScriptElementKind.memberSetAccessorElement, this.getKindModifiers(setAccessor.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem(setAccessor.propertyName.text(), ts.ScriptElementKind.memberSetAccessorElement, this.getKindModifiers(setAccessor.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.IndexSignature:
|
||||
var indexSignature = <IndexSignatureSyntax>node;
|
||||
return new ts.NavigationBarItem("[]", ts.ScriptElementKind.indexSignatureElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem("[]", ts.ScriptElementKind.indexSignatureElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.EnumElement:
|
||||
var enumElement = <EnumElementSyntax>node;
|
||||
return new ts.NavigationBarItem(enumElement.propertyName.text(), ts.ScriptElementKind.memberVariableElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem(enumElement.propertyName.text(), ts.ScriptElementKind.memberVariableElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.CallSignature:
|
||||
var callSignature = <CallSignatureSyntax>node;
|
||||
return new ts.NavigationBarItem("()", ts.ScriptElementKind.callSignatureElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem("()", ts.ScriptElementKind.callSignatureElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.ConstructSignature:
|
||||
var constructSignature = <ConstructSignatureSyntax>node;
|
||||
return new ts.NavigationBarItem("new()", ts.ScriptElementKind.constructSignatureElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem("new()", ts.ScriptElementKind.constructSignatureElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.MethodSignature:
|
||||
var methodSignature = <MethodSignatureSyntax>node;
|
||||
return new ts.NavigationBarItem(methodSignature.propertyName.text(), ts.ScriptElementKind.memberFunctionElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem(methodSignature.propertyName.text(), ts.ScriptElementKind.memberFunctionElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.PropertySignature:
|
||||
var propertySignature = <PropertySignatureSyntax>node;
|
||||
return new ts.NavigationBarItem(propertySignature.propertyName.text(), ts.ScriptElementKind.memberVariableElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem(propertySignature.propertyName.text(), ts.ScriptElementKind.memberVariableElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
var functionDeclaration = <FunctionDeclarationSyntax>node;
|
||||
if (!this.isTopLevelFunctionDeclaration(functionDeclaration)) {
|
||||
return new ts.NavigationBarItem(functionDeclaration.identifier.text(), ts.ScriptElementKind.functionElement, this.getKindModifiers(functionDeclaration.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem(functionDeclaration.identifier.text(), ts.ScriptElementKind.functionElement, this.getKindModifiers(functionDeclaration.modifiers), [TextSpan.fromBounds(start(node), end(node))]);
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.MemberVariableDeclaration:
|
||||
var memberVariableDeclaration = <MemberVariableDeclarationSyntax>node;
|
||||
return new ts.NavigationBarItem(memberVariableDeclaration.variableDeclarator.propertyName.text(), ts.ScriptElementKind.memberVariableElement, this.getKindModifiers(memberVariableDeclaration.modifiers), [TextSpan.fromBounds(start(memberVariableDeclaration.variableDeclarator), end(memberVariableDeclaration.variableDeclarator))]);
|
||||
return this.getNavigationBarItem(memberVariableDeclaration.variableDeclarator.propertyName.text(), ts.ScriptElementKind.memberVariableElement, this.getKindModifiers(memberVariableDeclaration.modifiers), [TextSpan.fromBounds(start(memberVariableDeclaration.variableDeclarator), end(memberVariableDeclaration.variableDeclarator))]);
|
||||
|
||||
case SyntaxKind.VariableDeclarator:
|
||||
var variableDeclarator = <VariableDeclaratorSyntax>node;
|
||||
return new ts.NavigationBarItem(variableDeclarator.propertyName.text(), ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(variableDeclarator), end(variableDeclarator))]);
|
||||
return this.getNavigationBarItem(variableDeclarator.propertyName.text(), ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(variableDeclarator), end(variableDeclarator))]);
|
||||
|
||||
case SyntaxKind.ConstructorDeclaration:
|
||||
var constructorDeclaration = <ConstructorDeclarationSyntax>node;
|
||||
return new ts.NavigationBarItem("constructor", ts.ScriptElementKind.constructorImplementationElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
return this.getNavigationBarItem("constructor", ts.ScriptElementKind.constructorImplementationElement, ts.ScriptElementKindModifier.none, [TextSpan.fromBounds(start(node), end(node))]);
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -273,7 +285,7 @@ module TypeScript.Services {
|
||||
|
||||
var childItems = this.getItemsWorker(() => this.getChildNodes(node.moduleElements), n => this.createChildItem(n));
|
||||
|
||||
return new ts.NavigationBarItem(moduleNames.join("."),
|
||||
return this.getNavigationBarItem(moduleNames.join("."),
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
[TextSpan.fromBounds(start(node), end(node))],
|
||||
@ -284,7 +296,7 @@ module TypeScript.Services {
|
||||
private createFunctionItem(node: FunctionDeclarationSyntax) {
|
||||
var childItems = this.getItemsWorker(() => node.block.statements, n => this.createChildItem(n));
|
||||
|
||||
return new ts.NavigationBarItem(node.identifier.text(),
|
||||
return this.getNavigationBarItem(node.identifier.text(),
|
||||
ts.ScriptElementKind.functionElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
[TextSpan.fromBounds(start(node), end(node))],
|
||||
@ -300,7 +312,7 @@ module TypeScript.Services {
|
||||
}
|
||||
|
||||
this.hasGlobalNode = true;
|
||||
return new ts.NavigationBarItem("<global>",
|
||||
return this.getNavigationBarItem("<global>",
|
||||
ts.ScriptElementKind.moduleElement,
|
||||
ts.ScriptElementKindModifier.none,
|
||||
[TextSpan.fromBounds(start(node), end(node))],
|
||||
@ -317,7 +329,7 @@ module TypeScript.Services {
|
||||
: node.classElements;
|
||||
|
||||
var childItems = this.getItemsWorker(() => nodes, n => this.createChildItem(n));
|
||||
return new ts.NavigationBarItem(
|
||||
return this.getNavigationBarItem(
|
||||
node.identifier.text(),
|
||||
ts.ScriptElementKind.classElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
@ -328,7 +340,7 @@ module TypeScript.Services {
|
||||
|
||||
private createEnumItem(node: TypeScript.EnumDeclarationSyntax): ts.NavigationBarItem {
|
||||
var childItems = this.getItemsWorker(() => node.enumElements, n => this.createChildItem(n));
|
||||
return new ts.NavigationBarItem(
|
||||
return this.getNavigationBarItem(
|
||||
node.identifier.text(),
|
||||
ts.ScriptElementKind.enumElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
@ -339,7 +351,7 @@ module TypeScript.Services {
|
||||
|
||||
private createIterfaceItem(node: TypeScript.InterfaceDeclarationSyntax): ts.NavigationBarItem {
|
||||
var childItems = this.getItemsWorker(() => node.body.typeMembers, n => this.createChildItem(n));
|
||||
return new ts.NavigationBarItem(
|
||||
return this.getNavigationBarItem(
|
||||
node.identifier.text(),
|
||||
ts.ScriptElementKind.interfaceElement,
|
||||
this.getKindModifiers(node.modifiers),
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript.Indentation {
|
||||
export function columnForEndOfTokenAtPosition(syntaxTree: SyntaxTree, position: number, options: FormattingOptions): number {
|
||||
|
||||
@ -13,8 +13,6 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module ts {
|
||||
|
||||
export interface OutliningSpan {
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
/////<reference path='es5compat.ts' />
|
||||
/////<reference path='..\compiler\typescript.ts' />
|
||||
|
||||
//// document.ts depends on incrementalParser.ts being run first.
|
||||
/////<reference path='..\compiler\syntax\incrementalParser.ts' />
|
||||
/////<reference path='document.ts' />
|
||||
|
||||
/////<reference path='syntaxUtilities.generated.ts' />
|
||||
/////<reference path='coreServices.ts' />
|
||||
/////<reference path='classifier.ts' />
|
||||
/////<reference path='compilerState.ts' />
|
||||
/////<reference path='indentation.ts' />
|
||||
/////<reference path='languageService.ts' />
|
||||
/////<reference path='completionHelpers.ts' />
|
||||
/////<reference path='keywordCompletions.ts' />
|
||||
/////<reference path='signatureInfoHelpers.ts' />
|
||||
/////<reference path='completionSession.ts' />
|
||||
/////<reference path='pullLanguageService.ts' />
|
||||
/////<reference path='findReferenceHelpers.ts' />
|
||||
/////<reference path='shims.ts' />
|
||||
/////<reference path='formatting\formatting.ts' />
|
||||
/////<reference path='outliningElementsCollector.ts' />
|
||||
/////<reference path='braceMatcher.ts' />
|
||||
/////<reference path='indenter.ts' />
|
||||
/////<reference path='breakpoints.ts' />
|
||||
/////<reference path='getScriptLexicalStructureWalker.ts' />
|
||||
@ -306,7 +306,7 @@ module ts {
|
||||
}
|
||||
|
||||
private processMultiLineDocumentationCommentRange(
|
||||
sourceFile: SourceFile, commentRange: CommentRange,
|
||||
sourceFile: SourceFile, commentRange: CommentRange,
|
||||
startLineAndChar: { line: number; character: number },
|
||||
endLineAndChar: { line: number; character: number },
|
||||
lines: string[]) {
|
||||
@ -686,94 +686,53 @@ module ts {
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
export class ClassificationTypeNames {
|
||||
public static comment = "comment";
|
||||
public static identifier = "identifier";
|
||||
public static keyword = "keyword";
|
||||
public static numericLiteral = "number";
|
||||
public static operator = "operator";
|
||||
public static stringLiteral = "string";
|
||||
public static whiteSpace = "whitespace";
|
||||
public static text = "text";
|
||||
|
||||
public static punctuation = "punctuation";
|
||||
|
||||
public static className = "class name";
|
||||
public static enumName = "enum name";
|
||||
public static interfaceName = "interface name";
|
||||
public static moduleName = "module name";
|
||||
public static typeParameterName = "type parameter name";
|
||||
export interface ClassifiedSpan {
|
||||
textSpan: TypeScript.TextSpan;
|
||||
classificationType: string; // ClassificationTypeNames
|
||||
}
|
||||
|
||||
export class ClassifiedSpan {
|
||||
constructor(public textSpan: TypeScript.TextSpan,
|
||||
public classificationType: string) {
|
||||
|
||||
}
|
||||
export interface NavigationBarItem {
|
||||
text: string;
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
spans: TypeScript.TextSpan[];
|
||||
childItems: NavigationBarItem[];
|
||||
indent: number;
|
||||
bolded: boolean;
|
||||
grayed: boolean;
|
||||
}
|
||||
|
||||
export class NavigationBarItem {
|
||||
constructor(public text: string,
|
||||
public kind: string,
|
||||
public kindModifiers: string,
|
||||
public spans: TypeScript.TextSpan[],
|
||||
public childItems: NavigationBarItem[] = null,
|
||||
public indent = 0,
|
||||
public bolded = false,
|
||||
public grayed = false) {
|
||||
}
|
||||
export interface TodoCommentDescriptor {
|
||||
text: string;
|
||||
priority: number;
|
||||
}
|
||||
|
||||
export class TodoCommentDescriptor {
|
||||
constructor(public text: string,
|
||||
public priority: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export class TodoComment {
|
||||
constructor(public descriptor: TodoCommentDescriptor,
|
||||
public message: string,
|
||||
public position: number) {
|
||||
}
|
||||
export interface TodoComment {
|
||||
descriptor: TodoCommentDescriptor;
|
||||
message: string;
|
||||
position: number;
|
||||
}
|
||||
|
||||
export class TextChange {
|
||||
constructor(public span: TypeScript.TextSpan, public newText: string) {
|
||||
}
|
||||
|
||||
static createInsert(pos: number, newText: string): TextChange {
|
||||
return new TextChange(new TypeScript.TextSpan(pos, 0), newText);
|
||||
}
|
||||
static createDelete(start: number, end: number): TextChange {
|
||||
return new TextChange(TypeScript.TextSpan.fromBounds(start, end), "");
|
||||
}
|
||||
static createReplace(start: number, end: number, newText: string): TextChange {
|
||||
return new TextChange(TypeScript.TextSpan.fromBounds(start, end), newText);
|
||||
}
|
||||
span: TypeScript.TextSpan;
|
||||
newText: string;
|
||||
}
|
||||
|
||||
export class ReferenceEntry {
|
||||
public fileName: string = "";
|
||||
public textSpan: TypeScript.TextSpan;
|
||||
public isWriteAccess: boolean = false;
|
||||
|
||||
constructor(fileName: string, textSpan: TypeScript.TextSpan, isWriteAccess: boolean) {
|
||||
this.fileName = fileName;
|
||||
this.textSpan = textSpan;
|
||||
this.isWriteAccess = isWriteAccess;
|
||||
}
|
||||
export interface ReferenceEntry {
|
||||
textSpan: TypeScript.TextSpan;
|
||||
fileName: string;
|
||||
isWriteAccess: boolean;
|
||||
}
|
||||
|
||||
export class NavigateToItem {
|
||||
constructor(public name: string,
|
||||
public kind: string,
|
||||
public kindModifiers: string,
|
||||
public matchKind: string,
|
||||
public fileName: string,
|
||||
public textSpan: TypeScript.TextSpan,
|
||||
public containerName: string,
|
||||
public containerKind: string) {
|
||||
}
|
||||
export interface NavigateToItem {
|
||||
name: string;
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
matchKind: string;
|
||||
fileName: string;
|
||||
textSpan: TypeScript.TextSpan;
|
||||
containerName: string;
|
||||
containerKind: string;
|
||||
}
|
||||
|
||||
export interface EditorOptions {
|
||||
@ -794,14 +753,13 @@ module ts {
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
||||
}
|
||||
|
||||
export class DefinitionInfo {
|
||||
constructor(public fileName: string,
|
||||
public textSpan: TypeScript.TextSpan,
|
||||
public kind: string,
|
||||
public name: string,
|
||||
public containerKind: string,
|
||||
public containerName: string) {
|
||||
}
|
||||
export interface DefinitionInfo {
|
||||
fileName: string;
|
||||
textSpan: TypeScript.TextSpan;
|
||||
kind: string;
|
||||
name: string;
|
||||
containerKind: string;
|
||||
containerName: string;
|
||||
}
|
||||
|
||||
export interface MemberName {
|
||||
@ -810,56 +768,37 @@ module ts {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export class QuickInfo {
|
||||
constructor(public kind: string,
|
||||
public kindModifiers: string,
|
||||
public textSpan: TypeScript.TextSpan,
|
||||
public displayParts: SymbolDisplayPart[],
|
||||
public documentation: SymbolDisplayPart[]) {
|
||||
}
|
||||
export interface QuickInfo {
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
textSpan: TypeScript.TextSpan;
|
||||
displayParts: SymbolDisplayPart[];
|
||||
documentation: SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
export class TypeInfo {
|
||||
constructor(
|
||||
public memberName: TypeScript.MemberName,
|
||||
public docComment: string,
|
||||
public fullSymbolName: string,
|
||||
public kind: string,
|
||||
public textSpan: TypeScript.TextSpan) {
|
||||
}
|
||||
export interface TypeInfo {
|
||||
memberName: TypeScript.MemberName;
|
||||
docComment: string;
|
||||
fullSymbolName: string;
|
||||
kind: string;
|
||||
textSpan: TypeScript.TextSpan;
|
||||
}
|
||||
|
||||
export class RenameInfo {
|
||||
constructor(public canRename: boolean,
|
||||
public localizedErrorMessage: string,
|
||||
public displayName: string,
|
||||
public fullDisplayName: string,
|
||||
public kind: string,
|
||||
public kindModifiers: string,
|
||||
public triggerSpan: TypeScript.TextSpan) {
|
||||
}
|
||||
|
||||
public static CreateError(localizedErrorMessage: string) {
|
||||
return new RenameInfo(/*canRename:*/ false, localizedErrorMessage,
|
||||
/*displayName:*/ null, /*fullDisplayName:*/ null,
|
||||
/*kind:*/ null, /*kindModifiers:*/ null, /*triggerSpan:*/ null);
|
||||
}
|
||||
|
||||
public static Create(displayName: string,
|
||||
fullDisplayName: string,
|
||||
kind: string,
|
||||
kindModifiers: string,
|
||||
triggerSpan: TypeScript.TextSpan) {
|
||||
return new RenameInfo(/*canRename:*/ true, /*localizedErrorMessage:*/ null, displayName, fullDisplayName, kind, kindModifiers, triggerSpan);
|
||||
}
|
||||
export interface RenameInfo {
|
||||
canRename: boolean;
|
||||
localizedErrorMessage: string;
|
||||
displayName: string;
|
||||
fullDisplayName: string;
|
||||
kind: string;
|
||||
kindModifiers: string;
|
||||
triggerSpan: TypeScript.TextSpan;
|
||||
}
|
||||
|
||||
export class SignatureHelpParameter {
|
||||
constructor(public name: string,
|
||||
public documentation: string,
|
||||
public display: string,
|
||||
public isOptional: boolean) {
|
||||
}
|
||||
export interface SignatureHelpParameter {
|
||||
name: string;
|
||||
documentation: string;
|
||||
display: string;
|
||||
isOptional: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -869,30 +808,27 @@ module ts {
|
||||
* an edit has happened, while signature help is still active, the host can ask important
|
||||
* questions like 'what parameter is the user currently contained within?'.
|
||||
*/
|
||||
export class SignatureHelpItem {
|
||||
constructor(public isVariadic: boolean,
|
||||
public prefix: string,
|
||||
public suffix: string,
|
||||
public separator: string,
|
||||
public parameters: SignatureHelpParameter[],
|
||||
public documentation: string) {
|
||||
}
|
||||
export interface SignatureHelpItem {
|
||||
isVariadic: boolean;
|
||||
prefix: string;
|
||||
suffix: string;
|
||||
separator: string;
|
||||
parameters: SignatureHelpParameter[];
|
||||
documentation: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a set of signature help items, and the preferred item that should be selected.
|
||||
*/
|
||||
export class SignatureHelpItems {
|
||||
constructor(public items: SignatureHelpItem[],
|
||||
public applicableSpan: TypeScript.TextSpan,
|
||||
public selectedItemIndex: number) {
|
||||
}
|
||||
export interface SignatureHelpItems {
|
||||
items: SignatureHelpItem[];
|
||||
applicableSpan: TypeScript.TextSpan;
|
||||
selectedItemIndex: number;
|
||||
}
|
||||
|
||||
export class SignatureHelpState {
|
||||
constructor(public argumentIndex: number,
|
||||
public argumentCount: number) {
|
||||
}
|
||||
export interface SignatureHelpState {
|
||||
argumentIndex: number;
|
||||
argumentCount: number;
|
||||
}
|
||||
|
||||
export interface CompletionInfo {
|
||||
@ -1064,6 +1000,25 @@ module ts {
|
||||
static staticModifier = "static";
|
||||
}
|
||||
|
||||
export class ClassificationTypeNames {
|
||||
public static comment = "comment";
|
||||
public static identifier = "identifier";
|
||||
public static keyword = "keyword";
|
||||
public static numericLiteral = "number";
|
||||
public static operator = "operator";
|
||||
public static stringLiteral = "string";
|
||||
public static whiteSpace = "whitespace";
|
||||
public static text = "text";
|
||||
|
||||
public static punctuation = "punctuation";
|
||||
|
||||
public static className = "class name";
|
||||
public static enumName = "enum name";
|
||||
public static interfaceName = "interface name";
|
||||
public static moduleName = "module name";
|
||||
public static typeParameterName = "type parameter name";
|
||||
}
|
||||
|
||||
enum MatchKind {
|
||||
none = 0,
|
||||
exact = 1,
|
||||
@ -1575,7 +1530,7 @@ module ts {
|
||||
isAnyFunction(node.parent) && (<FunctionDeclaration>node.parent).name === node;
|
||||
}
|
||||
|
||||
/// Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 }
|
||||
/** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */
|
||||
function isNameOfPropertyAssignment(node: Node): boolean {
|
||||
return (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.StringLiteral || node.kind === SyntaxKind.NumericLiteral) &&
|
||||
node.parent.kind === SyntaxKind.PropertyAssignment && (<PropertyDeclaration>node.parent).name === node;
|
||||
@ -1794,9 +1749,11 @@ module ts {
|
||||
fullTypeCheckChecker_doNotAccessDirectly = undefined;
|
||||
}
|
||||
|
||||
/// Clean up any semantic caches that are not needed.
|
||||
/// The host can call this method if it wants to jettison unused memory.
|
||||
/// We will just dump the typeChecker and recreate a new one. this should have the effect of destroying all the semantic caches.
|
||||
/**
|
||||
* Clean up any semantic caches that are not needed.
|
||||
* The host can call this method if it wants to jettison unused memory.
|
||||
* We will just dump the typeChecker and recreate a new one. this should have the effect of destroying all the semantic caches.
|
||||
*/
|
||||
function cleanupSemanticCache(): void {
|
||||
if (program) {
|
||||
typeInfoResolver = program.getTypeChecker(/*fullTypeCheckMode*/ false);
|
||||
@ -1820,8 +1777,10 @@ module ts {
|
||||
return program.getDiagnostics(getSourceFile(filename).getSourceFile());
|
||||
}
|
||||
|
||||
// getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors
|
||||
// If '-d' enabled, report both semantic and emitter errors
|
||||
/**
|
||||
* getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors
|
||||
* If '-d' enabled, report both semantic and emitter errors
|
||||
*/
|
||||
function getSemanticDiagnostics(filename: string) {
|
||||
synchronizeHostData();
|
||||
|
||||
@ -2461,12 +2420,13 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
return new QuickInfo(
|
||||
getSymbolKind(symbol),
|
||||
getSymbolModifiers(symbol),
|
||||
new TypeScript.TextSpan(node.getStart(), node.getWidth()),
|
||||
totalParts,
|
||||
documentationParts);
|
||||
return {
|
||||
kind: getSymbolKind(symbol),
|
||||
kindModifiers: getSymbolModifiers(symbol),
|
||||
textSpan: new TypeScript.TextSpan(node.getStart(), node.getWidth()),
|
||||
displayParts: totalParts,
|
||||
documentation: documentationParts
|
||||
};
|
||||
}
|
||||
|
||||
function getTypeAtPosition(fileName: string, position: number): TypeInfo {
|
||||
@ -2482,10 +2442,13 @@ module ts {
|
||||
var symbol = typeInfoResolver.getSymbolInfo(node);
|
||||
var type = symbol && typeInfoResolver.getTypeOfSymbol(symbol);
|
||||
if (type) {
|
||||
return new TypeInfo(
|
||||
new TypeScript.MemberNameString(typeInfoResolver.typeToString(type)),
|
||||
"", typeInfoResolver.symbolToString(symbol, getContainerNode(node)),
|
||||
getSymbolKind(symbol), TypeScript.TextSpan.fromBounds(node.pos, node.end));
|
||||
return {
|
||||
memberName: new TypeScript.MemberNameString(typeInfoResolver.typeToString(type)),
|
||||
docComment: "",
|
||||
fullSymbolName: typeInfoResolver.symbolToString(symbol, getContainerNode(node)),
|
||||
kind: getSymbolKind(symbol),
|
||||
textSpan: TypeScript.TextSpan.fromBounds(node.pos, node.end)
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@ -2494,13 +2457,14 @@ module ts {
|
||||
/// Goto definition
|
||||
function getDefinitionAtPosition(filename: string, position: number): DefinitionInfo[]{
|
||||
function getDefinitionInfo(node: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo {
|
||||
return new DefinitionInfo(
|
||||
node.getSourceFile().filename,
|
||||
TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd()),
|
||||
symbolKind,
|
||||
symbolName,
|
||||
undefined,
|
||||
containerName);
|
||||
return {
|
||||
fileName: node.getSourceFile().filename,
|
||||
textSpan: TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd()),
|
||||
kind: symbolKind,
|
||||
name: symbolName,
|
||||
containerKind: undefined,
|
||||
containerName: containerName
|
||||
};
|
||||
}
|
||||
|
||||
function tryAddSignature(signatureDeclarations: Declaration[], selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) {
|
||||
@ -2570,10 +2534,14 @@ module ts {
|
||||
if (comment) {
|
||||
var targetFilename = normalizePath(combinePaths(getDirectoryPath(filename), comment.filename));
|
||||
if (program.getSourceFile(targetFilename)) {
|
||||
return [new DefinitionInfo(
|
||||
targetFilename, TypeScript.TextSpan.fromBounds(0, 0),
|
||||
ScriptElementKind.scriptElement,
|
||||
comment.filename, undefined, undefined)];
|
||||
return [{
|
||||
fileName: targetFilename,
|
||||
textSpan: TypeScript.TextSpan.fromBounds(0, 0),
|
||||
kind: ScriptElementKind.scriptElement,
|
||||
name: comment.filename,
|
||||
containerName: undefined,
|
||||
containerKind: undefined
|
||||
}];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@ -2606,7 +2574,7 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
/// References and Occurances
|
||||
/// References and Occurrences
|
||||
function getOccurrencesAtPosition(filename: string, position: number): ReferenceEntry[] {
|
||||
synchronizeHostData();
|
||||
|
||||
@ -2726,7 +2694,11 @@ module ts {
|
||||
}
|
||||
|
||||
if (shouldHighlightNextKeyword) {
|
||||
result.push(new ReferenceEntry(filename, TypeScript.TextSpan.fromBounds(elseKeyword.getStart(), ifKeyword.end), /* isWriteAccess */ false));
|
||||
result.push({
|
||||
fileName: filename,
|
||||
textSpan: TypeScript.TextSpan.fromBounds(elseKeyword.getStart(), ifKeyword.end),
|
||||
isWriteAccess: false
|
||||
});
|
||||
i++; // skip the next keyword
|
||||
continue;
|
||||
}
|
||||
@ -3562,7 +3534,12 @@ module ts {
|
||||
start += 1;
|
||||
end -= 1;
|
||||
}
|
||||
return new ReferenceEntry(node.getSourceFile().filename, TypeScript.TextSpan.fromBounds(start, end), isWriteAccess(node));
|
||||
|
||||
return {
|
||||
fileName: node.getSourceFile().filename,
|
||||
textSpan: TypeScript.TextSpan.fromBounds(start, end),
|
||||
isWriteAccess: isWriteAccess(node)
|
||||
};
|
||||
}
|
||||
|
||||
/** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */
|
||||
@ -3731,9 +3708,9 @@ module ts {
|
||||
|
||||
// Reset writer back to undefined to make sure that we produce an error message if CompilerHost.writeFile method is called when we are not in getEmitOutput
|
||||
writer = undefined;
|
||||
return emitOutput;
|
||||
}
|
||||
|
||||
return emitOutput;
|
||||
}
|
||||
|
||||
// Signature help
|
||||
/**
|
||||
* This is a semantic operation.
|
||||
@ -3878,9 +3855,10 @@ module ts {
|
||||
if (symbol) {
|
||||
var type = classifySymbol(symbol);
|
||||
if (type) {
|
||||
result.push(new ClassifiedSpan(
|
||||
new TypeScript.TextSpan(node.getStart(), node.getWidth()),
|
||||
type));
|
||||
result.push({
|
||||
textSpan: new TypeScript.TextSpan(node.getStart(), node.getWidth()),
|
||||
classificationType: type
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3902,9 +3880,10 @@ module ts {
|
||||
|
||||
function classifyTrivia(trivia: TypeScript.ISyntaxTrivia) {
|
||||
if (trivia.isComment() && span.intersectsWith(trivia.fullStart(), trivia.fullWidth())) {
|
||||
result.push(new ClassifiedSpan(
|
||||
new TypeScript.TextSpan(trivia.fullStart(), trivia.fullWidth()),
|
||||
ClassificationTypeNames.comment));
|
||||
result.push({
|
||||
textSpan: new TypeScript.TextSpan(trivia.fullStart(), trivia.fullWidth()),
|
||||
classificationType: ClassificationTypeNames.comment
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -3922,9 +3901,10 @@ module ts {
|
||||
if (TypeScript.width(token) > 0) {
|
||||
var type = classifyTokenType(token);
|
||||
if (type) {
|
||||
result.push(new ClassifiedSpan(
|
||||
new TypeScript.TextSpan(TypeScript.start(token), TypeScript.width(token)),
|
||||
type));
|
||||
result.push({
|
||||
textSpan: new TypeScript.TextSpan(TypeScript.start(token), TypeScript.width(token)),
|
||||
classificationType: type
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -4227,7 +4207,11 @@ module ts {
|
||||
}
|
||||
|
||||
var message = matchArray[2];
|
||||
result.push(new TodoComment(descriptor, message, matchPosition));
|
||||
result.push({
|
||||
descriptor: descriptor,
|
||||
message: message,
|
||||
position: matchPosition
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -4314,7 +4298,7 @@ module ts {
|
||||
(char >= TypeScript.CharacterCodes._0 && char <= TypeScript.CharacterCodes._9);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getRenameInfo(fileName: string, position: number): RenameInfo {
|
||||
synchronizeHostData();
|
||||
@ -4332,14 +4316,38 @@ module ts {
|
||||
if (symbol && symbol.getDeclarations() && symbol.getDeclarations().length > 0) {
|
||||
var kind = getSymbolKind(symbol);
|
||||
if (kind) {
|
||||
return RenameInfo.Create(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind,
|
||||
return getRenameInfo(symbol.name, typeInfoResolver.getFullyQualifiedName(symbol), kind,
|
||||
getSymbolModifiers(symbol),
|
||||
new TypeScript.TextSpan(node.getStart(), node.getWidth()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return RenameInfo.CreateError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_this_element.key));
|
||||
return getRenameInfoError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_this_element.key));
|
||||
|
||||
function getRenameInfoError(localizedErrorMessage: string): RenameInfo {
|
||||
return {
|
||||
canRename: false,
|
||||
localizedErrorMessage: getLocaleSpecificMessage(Diagnostics.You_cannot_rename_this_element.key),
|
||||
displayName: undefined,
|
||||
fullDisplayName: undefined,
|
||||
kind: undefined,
|
||||
kindModifiers: undefined,
|
||||
triggerSpan: undefined
|
||||
};
|
||||
}
|
||||
|
||||
function getRenameInfo(displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, triggerSpan: TypeScript.TextSpan): RenameInfo {
|
||||
return {
|
||||
canRename: true,
|
||||
localizedErrorMessage: undefined,
|
||||
displayName: displayName,
|
||||
fullDisplayName: fullDisplayName,
|
||||
kind: kind,
|
||||
kindModifiers: kindModifiers,
|
||||
triggerSpan: triggerSpan
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -22,31 +22,29 @@ var debugObjectHost = (<any>this);
|
||||
|
||||
module ts {
|
||||
export interface ScriptSnapshotShim {
|
||||
// Get's a portion of the script snapshot specified by [start, end).
|
||||
/** Gets a portion of the script snapshot specified by [start, end). */
|
||||
getText(start: number, end: number): string;
|
||||
|
||||
// Get's the length of this script snapshot.
|
||||
/** Gets the length of this script snapshot. */
|
||||
getLength(): number;
|
||||
|
||||
// This call returns the JSON encoded array of the type:
|
||||
// number[]
|
||||
/** This call returns the JSON-encoded array of the type: number[] */
|
||||
getLineStartPositions(): string;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// { span: { start: number; length: number }; newLength: number }
|
||||
//
|
||||
// Or null value if there was no change.
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { span: { start: number; length: number }; newLength: number }
|
||||
*
|
||||
* Or undefined value if there was no change.
|
||||
*/
|
||||
getChangeRange(oldSnapshot: ScriptSnapshotShim): string;
|
||||
}
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// string[]
|
||||
/** Returns a JSON-encoded value of the type: string[] */
|
||||
getScriptFileNames(): string;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptIsOpen(fileName: string): boolean;
|
||||
@ -57,9 +55,7 @@ module ts {
|
||||
getDefaultLibFilename(): string;
|
||||
}
|
||||
|
||||
//
|
||||
// Public interface of of a language service instance shim.
|
||||
//
|
||||
/** Public interface of a language service instance shim. */
|
||||
export interface ShimFactory {
|
||||
registerShim(shim: Shim): void;
|
||||
unregisterShim(shim: Shim): void;
|
||||
@ -96,38 +92,54 @@ module ts {
|
||||
getSignatureHelpItems(fileName: string, position: number): string;
|
||||
getSignatureHelpCurrentArgumentState(fileName: string, position: number, applicableSpanStart: number): string;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// { canRename: boolean, localizedErrorMessage: string, displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, triggerSpan: { start; length } }
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { canRename: boolean, localizedErrorMessage: string, displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, triggerSpan: { start; length } }
|
||||
*/
|
||||
getRenameInfo(fileName: string, position: number): string;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// { fileName: string; textSpan: { start: number; length: number}; kind: string; name: string; containerKind: string; containerName: string }
|
||||
//
|
||||
// Or null value if no definition can be found.
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string; textSpan: { start: number; length: number}; kind: string; name: string; containerKind: string; containerName: string }
|
||||
*
|
||||
* Or undefined value if no definition can be found.
|
||||
*/
|
||||
getDefinitionAtPosition(fileName: string, position: number): string;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
|
||||
*/
|
||||
getReferencesAtPosition(fileName: string, position: number): string;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
|
||||
*/
|
||||
getOccurrencesAtPosition(fileName: string, position: number): string;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
|
||||
*/
|
||||
getImplementorsAtPosition(fileName: string, position: number): string;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = [];
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = [];
|
||||
*/
|
||||
getNavigateToItems(searchValue: string): string;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// { text: string; kind: string; kindModifiers: string; bolded: boolean; grayed: boolean; indent: number; spans: { start: number; length: number; }[]; childItems: <recursive use of this type>[] } [] = [];
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { text: string; kind: string; kindModifiers: string; bolded: boolean; grayed: boolean; indent: number; spans: { start: number; length: number; }[]; childItems: <recursive use of this type>[] } [] = [];
|
||||
*/
|
||||
getNavigationBarItems(fileName: string): string;
|
||||
|
||||
// Returns a JSON encoded value of the type:
|
||||
// { textSpan: { start: number, length: number }; hintSpan: { start: number, length: number }; bannerText: string; autoCollapse: boolean } [] = [];
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { textSpan: { start: number, length: number }; hintSpan: { start: number, length: number }; bannerText: string; autoCollapse: boolean } [] = [];
|
||||
*/
|
||||
getOutliningSpans(fileName: string): string;
|
||||
|
||||
getTodoComments(fileName: string, todoCommentDescriptors: string): string;
|
||||
@ -435,9 +447,12 @@ module ts {
|
||||
return forwardJSONCall(this.logger, actionDescription, action);
|
||||
}
|
||||
|
||||
// DISPOSE
|
||||
// Ensure (almost) deterministic release of internal Javascript resources when
|
||||
// some external native objects holds onto us (e.g. Com/Interop).
|
||||
/// DISPOSE
|
||||
|
||||
/**
|
||||
* Ensure (almost) deterministic release of internal Javascript resources when
|
||||
* some external native objects holds onto us (e.g. Com/Interop).
|
||||
*/
|
||||
public dispose(dummy: any): void {
|
||||
this.logger.log("dispose()");
|
||||
this.languageService.dispose();
|
||||
@ -454,8 +469,11 @@ module ts {
|
||||
super.dispose(dummy);
|
||||
}
|
||||
|
||||
// REFRESH
|
||||
// Update the list of scripts known to the compiler
|
||||
/// REFRESH
|
||||
|
||||
/**
|
||||
* Update the list of scripts known to the compiler
|
||||
*/
|
||||
public refresh(throwOnError: boolean): void {
|
||||
this.forwardJSONCall(
|
||||
"refresh(" + throwOnError + ")",
|
||||
@ -540,8 +558,11 @@ module ts {
|
||||
}
|
||||
|
||||
/// QUICKINFO
|
||||
/// Computes a string representation of the type at the requested position
|
||||
/// in the active file.
|
||||
|
||||
/**
|
||||
* Computes a string representation of the type at the requested position
|
||||
* in the active file.
|
||||
*/
|
||||
public getQuickInfoAtPosition(fileName: string, position: number): string {
|
||||
return this.forwardJSONCall(
|
||||
"getQuickInfoAtPosition('" + fileName + "', " + position + ")",
|
||||
@ -562,8 +583,11 @@ module ts {
|
||||
}
|
||||
|
||||
/// NAMEORDOTTEDNAMESPAN
|
||||
/// Computes span information of the name or dotted name at the requested position
|
||||
// in the active file.
|
||||
|
||||
/**
|
||||
* Computes span information of the name or dotted name at the requested position
|
||||
* in the active file.
|
||||
*/
|
||||
public getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string {
|
||||
return this.forwardJSONCall(
|
||||
"getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")",
|
||||
@ -573,8 +597,10 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
/// STATEMENTSPAN
|
||||
/// Computes span information of statement at the requested position in the active file.
|
||||
/**
|
||||
* STATEMENTSPAN
|
||||
* Computes span information of statement at the requested position in the active file.
|
||||
*/
|
||||
public getBreakpointStatementAtPosition(fileName: string, position: number): string {
|
||||
return this.forwardJSONCall(
|
||||
"getBreakpointStatementAtPosition('" + fileName + "', " + position + ")",
|
||||
@ -606,8 +632,11 @@ module ts {
|
||||
|
||||
|
||||
/// GOTO DEFINITION
|
||||
/// Computes the definition location and file for the symbol
|
||||
/// at the requested position.
|
||||
|
||||
/**
|
||||
* Computes the definition location and file for the symbol
|
||||
* at the requested position.
|
||||
*/
|
||||
public getDefinitionAtPosition(fileName: string, position: number): string {
|
||||
return this.forwardJSONCall(
|
||||
"getDefinitionAtPosition('" + fileName + "', " + position + ")",
|
||||
@ -645,9 +674,12 @@ module ts {
|
||||
}
|
||||
|
||||
/// GET REFERENCES
|
||||
/// Return references to a symbol at the requested position.
|
||||
/// References are separated by "\n".
|
||||
/// Each reference is a "fileindex min lim" sub-string.
|
||||
|
||||
/**
|
||||
* Return references to a symbol at the requested position.
|
||||
* References are separated by "\n".
|
||||
* Each reference is a "fileindex min lim" sub-string.
|
||||
*/
|
||||
public getReferencesAtPosition(fileName: string, position: number): string {
|
||||
return this.forwardJSONCall(
|
||||
"getReferencesAtPosition('" + fileName + "', " + position + ")",
|
||||
@ -675,9 +707,12 @@ module ts {
|
||||
|
||||
|
||||
/// COMPLETION LISTS
|
||||
/// Get a string based representation of the completions
|
||||
/// to provide at the given source position and providing a member completion
|
||||
/// list if requested.
|
||||
|
||||
/**
|
||||
* Get a string based representation of the completions
|
||||
* to provide at the given source position and providing a member completion
|
||||
* list if requested.
|
||||
*/
|
||||
public getCompletionsAtPosition(fileName: string, position: number, isMemberCompletion: boolean) {
|
||||
return this.forwardJSONCall(
|
||||
"getCompletionsAtPosition('" + fileName + "', " + position + ", " + isMemberCompletion + ")",
|
||||
@ -687,7 +722,7 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
/// Get a string based representation of a completion list entry details
|
||||
/** Get a string based representation of a completion list entry details */
|
||||
public getCompletionEntryDetails(fileName: string, position: number, entryName: string) {
|
||||
return this.forwardJSONCall(
|
||||
"getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")",
|
||||
@ -728,7 +763,8 @@ module ts {
|
||||
}
|
||||
|
||||
/// NAVIGATE TO
|
||||
/// Return a list of symbols that are interesting to navigate to
|
||||
|
||||
/** Return a list of symbols that are interesting to navigate to */
|
||||
public getNavigateToItems(searchValue: string): string {
|
||||
return this.forwardJSONCall(
|
||||
"getNavigateToItems('" + searchValue + "')",
|
||||
@ -807,9 +843,6 @@ module ts {
|
||||
return forwardJSONCall(this.logger, actionDescription, action);
|
||||
}
|
||||
|
||||
///
|
||||
/// getPreProcessedFileInfo
|
||||
///
|
||||
public getPreProcessedFileInfo(fileName: string, sourceText: TypeScript.IScriptSnapshot): string {
|
||||
return this.forwardJSONCall(
|
||||
"getPreProcessedFileInfo('" + fileName + "')",
|
||||
@ -819,9 +852,6 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
///
|
||||
/// getDefaultCompilationSettings
|
||||
///
|
||||
public getDefaultCompilationSettings(): string {
|
||||
return this.forwardJSONCall(
|
||||
"getDefaultCompilationSettings()",
|
||||
|
||||
@ -261,7 +261,7 @@ module ts.SignatureHelp {
|
||||
display += "?";
|
||||
}
|
||||
display += ": " + typeInfoResolver.typeToString(typeInfoResolver.getTypeOfSymbol(p), argumentListOrTypeArgumentList);
|
||||
return new SignatureHelpParameter(p.name, "", display, isOptional);
|
||||
return { name: p.name, documentation: "", display: display, isOptiona: isOptional };
|
||||
});
|
||||
var callTargetNode = (<CallExpression>argumentListOrTypeArgumentList.parent).func;
|
||||
var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTargetNode);
|
||||
@ -273,7 +273,14 @@ module ts.SignatureHelp {
|
||||
}
|
||||
prefix += "(";
|
||||
var suffix = "): " + typeInfoResolver.typeToString(candidateSignature.getReturnType(), argumentListOrTypeArgumentList);
|
||||
return new SignatureHelpItem(candidateSignature.hasRestParameter, prefix, suffix, ", ", parameterHelpItems, "");
|
||||
return {
|
||||
isVariadic: candidateSignature.hasRestParameter,
|
||||
prefix: prefix,
|
||||
suffix: suffix,
|
||||
separator: ", ",
|
||||
parameters: parameterHelpItems,
|
||||
documentation: ""
|
||||
};
|
||||
});
|
||||
var selectedItemIndex = candidates.indexOf(bestSignature);
|
||||
if (selectedItemIndex < 0) {
|
||||
@ -291,7 +298,11 @@ module ts.SignatureHelp {
|
||||
var applicableSpanStart = argumentListOrTypeArgumentList.getFullStart();
|
||||
var applicableSpanEnd = skipTrivia(sourceFile.text, argumentListOrTypeArgumentList.end, /*stopAfterLineBreak*/ false);
|
||||
var applicableSpan = new TypeScript.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
|
||||
return new SignatureHelpItems(items, applicableSpan, selectedItemIndex);
|
||||
return {
|
||||
items: items,
|
||||
applicableSpan: applicableSpan,
|
||||
selectedItemIndex: selectedItemIndex
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,7 +338,7 @@ module ts.SignatureHelp {
|
||||
var numberOfCommas = countWhere(argumentListOrTypeArgumentList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken);
|
||||
var argumentCount = numberOfCommas + 1;
|
||||
if (argumentCount <= 1) {
|
||||
return new SignatureHelpState(/*argumentIndex*/ 0, argumentCount);
|
||||
return { argumentIndex: 0, argumentCount: argumentCount };
|
||||
}
|
||||
|
||||
var indexOfNodeContainingPosition = findListItemIndexContainingPosition(argumentListOrTypeArgumentList, position);
|
||||
@ -338,12 +349,12 @@ module ts.SignatureHelp {
|
||||
// Alternatively, we could be in range of one of the arguments, in which case we need to divide
|
||||
// by 2 to exclude commas. Use bit shifting in order to take the floor of the division.
|
||||
var argumentIndex = indexOfNodeContainingPosition < 0 ? argumentCount - 1 : indexOfNodeContainingPosition >> 1;
|
||||
return new SignatureHelpState(argumentIndex, argumentCount);
|
||||
}
|
||||
|
||||
function getChildListThatStartsWithOpenerToken(parent: Node, openerToken: Node, sourceFile: SourceFile): Node {
|
||||
return { argumentIndex: argumentIndex, argumentCount: argumentCount };
|
||||
}
|
||||
|
||||
function getChildListThatStartsWithOpenerToken(parent: Node, openerToken: Node, sourceFile: SourceFile): Node {
|
||||
var children = parent.getChildren(sourceFile);
|
||||
var indexOfOpenerToken = children.indexOf(openerToken);
|
||||
return children[indexOfOpenerToken + 1];
|
||||
return children[indexOfOpenerToken + 1];
|
||||
}
|
||||
}
|
||||
@ -1,26 +1,32 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
// Represents an immutable snapshot of a script at a specified time. Once acquired, the
|
||||
// snapshot is observably immutable. i.e. the same calls with the same parameters will return
|
||||
// the same values.
|
||||
/**
|
||||
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
|
||||
* snapshot is observably immutable. i.e. the same calls with the same parameters will return
|
||||
* the same values.
|
||||
*/
|
||||
export interface IScriptSnapshot {
|
||||
// Get's a portion of the script snapshot specified by [start, end).
|
||||
/** Gets a portion of the script snapshot specified by [start, end). */
|
||||
getText(start: number, end: number): string;
|
||||
|
||||
// Get's the length of this script snapshot.
|
||||
/** Gets the length of this script snapshot. */
|
||||
getLength(): number;
|
||||
|
||||
// This call returns the array containing the start position of every line.
|
||||
// i.e."[0, 10, 55]". TODO: consider making this optional. The language service could
|
||||
// always determine this (albeit in a more expensive manner).
|
||||
/**
|
||||
* This call returns the array containing the start position of every line.
|
||||
* i.e."[0, 10, 55]". TODO: consider making this optional. The language service could
|
||||
* always determine this (albeit in a more expensive manner).
|
||||
*/
|
||||
getLineStartPositions(): number[];
|
||||
|
||||
// Gets the TextChangeRange that describe how the text changed between this text and
|
||||
// an older version. This informatoin is used by the incremental parser to determine
|
||||
// what sections of the script need to be reparsed. 'null' can be returned if the
|
||||
// change range cannot be determined. However, in that case, incremental parsing will
|
||||
// not happen and the entire document will be reparsed.
|
||||
/**
|
||||
* Gets the TextChangeRange that describe how the text changed between this text and
|
||||
* an older version. This information is used by the incremental parser to determine
|
||||
* what sections of the script need to be re-parsed. 'undefined' can be returned if the
|
||||
* change range cannot be determined. However, in that case, incremental parsing will
|
||||
* not happen and the entire document will be re - parsed.
|
||||
*/
|
||||
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user