Merge branch 'master' into mergeMaster_09/01

This commit is contained in:
Kanchalai Tanglertsampan
2016-09-06 11:26:21 -07:00
108 changed files with 6659 additions and 1508 deletions

View File

@@ -128,6 +128,7 @@ var servicesSources = [
"services.ts",
"shims.ts",
"signatureHelp.ts",
"types.ts",
"utilities.ts",
"formatting/formatting.ts",
"formatting/formattingContext.ts",

View File

@@ -143,6 +143,7 @@ namespace ts {
const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
const resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true);
@@ -12264,10 +12265,10 @@ namespace ts {
// or that a different candidatesOutArray was passed in. Therefore, we need to redo the work
// to correctly fill the candidatesOutArray.
const cached = links.resolvedSignature;
if (cached && cached !== anySignature && !candidatesOutArray) {
if (cached && cached !== resolvingSignature && !candidatesOutArray) {
return cached;
}
links.resolvedSignature = anySignature;
links.resolvedSignature = resolvingSignature;
const result = resolveSignature(node, candidatesOutArray);
// If signature resolution originated in control flow type analysis (for example to compute the
// assigned type in a flow assignment) we don't cache the result as it may be based on temporary
@@ -12279,7 +12280,7 @@ namespace ts {
function getResolvedOrAnySignature(node: CallLikeExpression) {
// If we're already in the process of resolving the given signature, don't resolve again as
// that could cause infinite recursion. Instead, return anySignature.
return getNodeLinks(node).resolvedSignature === anySignature ? anySignature : getResolvedSignature(node);
return getNodeLinks(node).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(node);
}
function getInferredClassType(symbol: Symbol) {

View File

@@ -750,6 +750,36 @@ namespace ts {
return result;
}
/**
* Adds the value to an array of values associated with the key, and returns the array.
* Creates the array if it does not already exist.
*/
export function multiMapAdd<V>(map: Map<V[]>, key: string, value: V): V[] {
const values = map[key];
if (values) {
values.push(value);
return values;
}
else {
return map[key] = [value];
}
}
/**
* Removes a value from an array of values associated with the key.
* Does not preserve the order of those values.
* Does nothing if `key` is not in `map`, or `value` is not in `map[key]`.
*/
export function multiMapRemove<V>(map: Map<V[]>, key: string, value: V): void {
const values = map[key];
if (values) {
unorderedRemoveItem(values, value);
if (!values.length) {
delete map[key];
}
}
}
/**
* Tests whether a value is an array.
*/

View File

@@ -8,8 +8,6 @@ namespace ts {
const emptyArray: any[] = [];
const defaultTypeRoots = ["node_modules/@types"];
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string {
while (true) {
const fileName = combinePaths(searchPath, "tsconfig.json");
@@ -168,7 +166,7 @@ namespace ts {
const typeReferenceExtensions = [".d.ts"];
function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) {
function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost): string[] | undefined {
if (options.typeRoots) {
return options.typeRoots;
}
@@ -181,12 +179,38 @@ namespace ts {
currentDirectory = host.getCurrentDirectory();
}
if (!currentDirectory) {
return undefined;
}
return map(defaultTypeRoots, d => combinePaths(currentDirectory, d));
return currentDirectory && getDefaultTypeRoots(currentDirectory, host);
}
/**
* Returns the path to every node_modules/@types directory from some ancestor directory.
* Returns undefined if there are none.
*/
function getDefaultTypeRoots(currentDirectory: string, host: ModuleResolutionHost): string[] | undefined {
if (!host.directoryExists) {
return [combinePaths(currentDirectory, nodeModulesAtTypes)];
// And if it doesn't exist, tough.
}
let typeRoots: string[];
while (true) {
const atTypes = combinePaths(currentDirectory, nodeModulesAtTypes);
if (host.directoryExists(atTypes)) {
(typeRoots || (typeRoots = [])).push(atTypes);
}
const parent = getDirectoryPath(currentDirectory);
if (parent === currentDirectory) {
break;
}
currentDirectory = parent;
}
return typeRoots;
}
const nodeModulesAtTypes = combinePaths("node_modules", "@types");
/**
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups

View File

@@ -273,7 +273,7 @@ namespace ts {
}
function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void {
(fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback);
multiMapAdd(fileWatcherCallbacks, filePath, callback);
}
function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile {
@@ -289,13 +289,7 @@ namespace ts {
}
function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) {
const callbacks = fileWatcherCallbacks[filePath];
if (callbacks) {
unorderedRemoveItem(callbacks, callback);
if (callbacks.length === 0) {
delete fileWatcherCallbacks[filePath];
}
}
multiMapRemove(fileWatcherCallbacks, filePath, callback);
}
function fileEventHandler(eventName: string, relativeFileName: string, baseDirPath: string) {

View File

@@ -525,6 +525,67 @@ namespace FourSlash {
}
}
public verifyGoToDefinitionIs(endMarker: string | string[]) {
this.verifyGoToDefinitionWorker(endMarker instanceof Array ? endMarker : [endMarker]);
}
public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) {
if (endMarkerNames) {
this.verifyGoToDefinitionPlain(arg0, endMarkerNames);
}
else if (arg0 instanceof Array) {
const pairs: [string | string[], string | string[]][] = arg0;
for (const [start, end] of pairs) {
this.verifyGoToDefinitionPlain(start, end);
}
}
else {
const obj: { [startMarkerName: string]: string | string[] } = arg0;
for (const startMarkerName in obj) {
if (ts.hasProperty(obj, startMarkerName)) {
this.verifyGoToDefinitionPlain(startMarkerName, obj[startMarkerName]);
}
}
}
}
private verifyGoToDefinitionPlain(startMarkerNames: string | string[], endMarkerNames: string | string[]) {
if (startMarkerNames instanceof Array) {
for (const start of startMarkerNames) {
this.verifyGoToDefinitionSingle(start, endMarkerNames);
}
}
else {
this.verifyGoToDefinitionSingle(startMarkerNames, endMarkerNames);
}
}
public verifyGoToDefinitionForMarkers(markerNames: string[]) {
for (const markerName of markerNames) {
this.verifyGoToDefinitionSingle(`${markerName}Reference`, `${markerName}Definition`);
}
}
private verifyGoToDefinitionSingle(startMarkerName: string, endMarkerNames: string | string[]) {
this.goToMarker(startMarkerName);
this.verifyGoToDefinitionWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames]);
}
private verifyGoToDefinitionWorker(endMarkers: string[]) {
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) || [];
if (endMarkers.length !== definitions.length) {
this.raiseError(`goToDefinitions failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`);
}
for (let i = 0; i < endMarkers.length; i++) {
const marker = this.getMarkerByName(endMarkers[i]), definition = definitions[i];
if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) {
this.raiseError(`goToDefinition failed for definition ${i}: expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`);
}
}
}
public verifyGetEmitOutputForCurrentFile(expected: string): void {
const emit = this.languageService.getEmitOutput(this.activeFile.fileName);
if (emit.outputFiles.length !== 1) {
@@ -1561,21 +1622,6 @@ namespace FourSlash {
this.goToPosition(len);
}
public goToDefinition(definitionIndex: number) {
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
if (!definitions || !definitions.length) {
this.raiseError("goToDefinition failed - expected to find at least one definition location but got 0");
}
if (definitionIndex >= definitions.length) {
this.raiseError(`goToDefinition failed - definitionIndex value (${definitionIndex}) exceeds definition list size (${definitions.length})`);
}
const definition = definitions[definitionIndex];
this.openFile(definition.fileName);
this.currentCaretPosition = definition.textSpan.start;
}
public goToTypeDefinition(definitionIndex: number) {
const definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
if (!definitions || !definitions.length) {
@@ -1591,28 +1637,6 @@ namespace FourSlash {
this.currentCaretPosition = definition.textSpan.start;
}
public verifyDefinitionLocationExists(negative: boolean) {
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
const foundDefinitions = definitions && definitions.length;
if (foundDefinitions && negative) {
this.raiseError(`goToDefinition - expected to 0 definition locations but got ${definitions.length}`);
}
else if (!foundDefinitions && !negative) {
this.raiseError("goToDefinition - expected to find at least one definition location but got 0");
}
}
public verifyDefinitionsCount(negative: boolean, expectedCount: number) {
const assertFn = negative ? assert.notEqual : assert.equal;
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
const actualCount = definitions && definitions.length || 0;
assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Definitions Count"));
}
public verifyTypeDefinitionsCount(negative: boolean, expectedCount: number) {
const assertFn = negative ? assert.notEqual : assert.equal;
@@ -1622,18 +1646,12 @@ namespace FourSlash {
assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Type definitions Count"));
}
public verifyDefinitionsName(negative: boolean, expectedName: string, expectedContainerName: string) {
public verifyGoToDefinitionName(expectedName: string, expectedContainerName: string) {
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
const actualDefinitionName = definitions && definitions.length ? definitions[0].name : "";
const actualDefinitionContainerName = definitions && definitions.length ? definitions[0].containerName : "";
if (negative) {
assert.notEqual(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
assert.notEqual(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name"));
}
else {
assert.equal(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
assert.equal(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name"));
}
assert.equal(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
assert.equal(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name"));
}
public getMarkers(): Marker[] {
@@ -1641,6 +1659,10 @@ namespace FourSlash {
return this.testData.markers.slice(0);
}
public getMarkerNames(): string[] {
return Object.keys(this.testData.markerPositions);
}
public getRanges(): Range[] {
return this.testData.ranges;
}
@@ -1649,8 +1671,7 @@ namespace FourSlash {
const result = ts.createMap<Range[]>();
for (const range of this.getRanges()) {
const text = this.rangeText(range);
const ranges = result[text] || (result[text] = []);
ranges.push(range);
ts.multiMapAdd(result, text, range);
}
return result;
}
@@ -2743,6 +2764,10 @@ namespace FourSlashInterface {
return this.state.getMarkers();
}
public markerNames(): string[] {
return this.state.getMarkerNames();
}
public marker(name?: string): FourSlash.Marker {
return this.state.getMarkerByName(name);
}
@@ -2778,10 +2803,6 @@ namespace FourSlashInterface {
this.state.goToEOF();
}
public definition(definitionIndex = 0) {
this.state.goToDefinition(definitionIndex);
}
public type(definitionIndex = 0) {
this.state.goToTypeDefinition(definitionIndex);
}
@@ -2886,22 +2907,10 @@ namespace FourSlashInterface {
this.state.verifyQuickInfoExists(this.negative);
}
public definitionCountIs(expectedCount: number) {
this.state.verifyDefinitionsCount(this.negative, expectedCount);
}
public typeDefinitionCountIs(expectedCount: number) {
this.state.verifyTypeDefinitionsCount(this.negative, expectedCount);
}
public definitionLocationExists() {
this.state.verifyDefinitionLocationExists(this.negative);
}
public verifyDefinitionsName(name: string, containerName: string) {
this.state.verifyDefinitionsName(this.negative, name, containerName);
}
public isValidBraceCompletionAtPosition(openingBrace: string) {
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
}
@@ -2945,6 +2954,25 @@ namespace FourSlashInterface {
this.state.verifyCurrentFileContent(text);
}
public goToDefinitionIs(endMarkers: string | string[]) {
this.state.verifyGoToDefinitionIs(endMarkers);
}
public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[]): void;
public goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void;
public goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
public goToDefinition(arg0: any, endMarkerName?: string | string[]) {
this.state.verifyGoToDefinition(arg0, endMarkerName);
}
public goToDefinitionForMarkers(...markerNames: string[]) {
this.state.verifyGoToDefinitionForMarkers(markerNames);
}
public goToDefinitionName(name: string, containerName: string) {
this.state.verifyGoToDefinitionName(name, containerName);
}
public verifyGetEmitOutputForCurrentFile(expected: string): void {
this.state.verifyGetEmitOutputForCurrentFile(expected);
}

View File

@@ -198,18 +198,12 @@ namespace ts {
watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher {
const path = this.toPath(directoryName);
const callbacks = this.watchedDirectories[path] || (this.watchedDirectories[path] = []);
const cbWithRecursive = { cb: callback, recursive };
callbacks.push(cbWithRecursive);
multiMapAdd(this.watchedDirectories, path, cbWithRecursive);
return {
referenceCount: 0,
directoryName,
close: () => {
unorderedRemoveItem(callbacks, cbWithRecursive);
if (!callbacks.length) {
delete this.watchedDirectories[path];
}
}
close: () => multiMapRemove(this.watchedDirectories, path, cbWithRecursive)
};
}
@@ -235,16 +229,8 @@ namespace ts {
watchFile(fileName: string, callback: FileWatcherCallback) {
const path = this.toPath(fileName);
const callbacks = this.watchedFiles[path] || (this.watchedFiles[path] = []);
callbacks.push(callback);
return {
close: () => {
unorderedRemoveItem(callbacks, callback);
if (!callbacks.length) {
delete this.watchedFiles[path];
}
}
};
multiMapAdd(this.watchedFiles, path, callback);
return { close: () => multiMapRemove(this.watchedFiles, path, callback) };
}
// TOOD: record and invoke callbacks to simulate timer events

View File

@@ -7,6 +7,7 @@
/// <reference path='navigationBar.ts' />
/// <reference path='patternMatcher.ts' />
/// <reference path='signatureHelp.ts' />
/// <reference path='types.ts' />
/// <reference path='utilities.ts' />
/// <reference path='jsTyping.ts' />
/// <reference path='formatting\formatting.ts' />
@@ -16,123 +17,6 @@ namespace ts {
/** The version of the language service API */
export const servicesVersion = "0.5";
export interface Node {
getSourceFile(): SourceFile;
getChildCount(sourceFile?: SourceFile): number;
getChildAt(index: number, sourceFile?: SourceFile): Node;
getChildren(sourceFile?: SourceFile): Node[];
getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
getFullStart(): number;
getEnd(): number;
getWidth(sourceFile?: SourceFile): number;
getFullWidth(): number;
getLeadingTriviaWidth(sourceFile?: SourceFile): number;
getFullText(sourceFile?: SourceFile): string;
getText(sourceFile?: SourceFile): string;
getFirstToken(sourceFile?: SourceFile): Node;
getLastToken(sourceFile?: SourceFile): Node;
}
export interface Symbol {
getFlags(): SymbolFlags;
getName(): string;
getDeclarations(): Declaration[];
getDocumentationComment(): SymbolDisplayPart[];
}
export interface Type {
getFlags(): TypeFlags;
getSymbol(): Symbol;
getProperties(): Symbol[];
getProperty(propertyName: string): Symbol;
getApparentProperties(): Symbol[];
getCallSignatures(): Signature[];
getConstructSignatures(): Signature[];
getStringIndexType(): Type;
getNumberIndexType(): Type;
getBaseTypes(): ObjectType[];
getNonNullableType(): Type;
}
export interface Signature {
getDeclaration(): SignatureDeclaration;
getTypeParameters(): Type[];
getParameters(): Symbol[];
getReturnType(): Type;
getDocumentationComment(): SymbolDisplayPart[];
}
export interface SourceFile {
/* @internal */ version: string;
/* @internal */ scriptSnapshot: IScriptSnapshot;
/* @internal */ nameTable: Map<number>;
/* @internal */ getNamedDeclarations(): Map<Declaration[]>;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
/**
* 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 {
/** Gets a portion of the script snapshot specified by [start, end). */
getText(start: number, end: number): string;
/** Gets the length of this script snapshot. */
getLength(): number;
/**
* 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 | undefined;
/** Releases all resources held by this script snapshot */
dispose?(): void;
}
export namespace ScriptSnapshot {
class StringScriptSnapshot implements IScriptSnapshot {
constructor(private text: string) {
}
public getText(start: number, end: number): string {
return this.text.substring(start, end);
}
public getLength(): number {
return this.text.length;
}
public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
// Text-based snapshots do not support incremental parsing. Return undefined
// to signal that to the caller.
return undefined;
}
}
export function fromString(text: string): IScriptSnapshot {
return new StringScriptSnapshot(text);
}
}
export interface PreProcessedFileInfo {
referencedFiles: FileReference[];
typeReferenceDirectives: FileReference[];
importedFiles: FileReference[];
ambientExternalModules: string[];
isLibFile: boolean;
}
const scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
const emptyArray: any[] = [];
@@ -996,8 +880,7 @@ namespace ts {
function addDeclaration(declaration: Declaration) {
const name = getDeclarationName(declaration);
if (name) {
const declarations = getDeclarations(name);
declarations.push(declaration);
multiMapAdd(result, name, declaration);
}
}
@@ -1146,694 +1029,6 @@ namespace ts {
}
}
export interface HostCancellationToken {
isCancellationRequested(): boolean;
}
//
// Public interface of the host of a language service instance.
//
export interface LanguageServiceHost {
getCompilationSettings(): CompilerOptions;
getNewLine?(): string;
getProjectVersion?(): string;
getScriptFileNames(): string[];
getScriptKind?(fileName: string): ScriptKind;
getScriptVersion(fileName: string): string;
getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
getLocalizedDiagnosticMessages?(): any;
getCancellationToken?(): HostCancellationToken;
getCurrentDirectory(): string;
getDefaultLibFileName(options: CompilerOptions): string;
log?(s: string): void;
trace?(s: string): void;
error?(s: string): void;
useCaseSensitiveFileNames?(): boolean;
/*
* LS host can optionally implement this method if it wants to be completely in charge of module name resolution.
* if implementation is omitted then language service will use built-in module resolution logic and get answers to
* host specific questions using 'getScriptSnapshot'.
*/
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
directoryExists?(directoryName: string): boolean;
getDirectories?(directoryName: string): string[];
}
//
// Public services of a language service instance associated
// with a language service host instance
//
export interface LanguageService {
cleanupSemanticCache(): void;
getSyntacticDiagnostics(fileName: string): Diagnostic[];
getSemanticDiagnostics(fileName: string): Diagnostic[];
// TODO: Rename this to getProgramDiagnostics to better indicate that these are any
// diagnostics present for the program level, and not just 'options' diagnostics.
getCompilerOptionsDiagnostics(): Diagnostic[];
/**
* @deprecated Use getEncodedSyntacticClassifications instead.
*/
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
/**
* @deprecated Use getEncodedSemanticClassifications instead.
*/
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
// Encoded as triples of [start, length, ClassificationType].
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan;
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan;
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems;
getRenameInfo(fileName: string, position: number): RenameInfo;
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
findReferences(fileName: string, position: number): ReferencedSymbol[];
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];
/** @deprecated */
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number;
getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[];
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
getEmitOutput(fileName: string): EmitOutput;
getProgram(): Program;
/* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
dispose(): void;
}
export interface Classifications {
spans: number[];
endOfLineState: EndOfLineState;
}
export interface ClassifiedSpan {
textSpan: TextSpan;
classificationType: string; // ClassificationTypeNames
}
export interface NavigationBarItem {
text: string;
kind: string;
kindModifiers: string;
spans: TextSpan[];
childItems: NavigationBarItem[];
indent: number;
bolded: boolean;
grayed: boolean;
}
export interface TodoCommentDescriptor {
text: string;
priority: number;
}
export interface TodoComment {
descriptor: TodoCommentDescriptor;
message: string;
position: number;
}
export class TextChange {
span: TextSpan;
newText: string;
}
export interface TextInsertion {
newText: string;
/** The position in newText the caret should point to after the insertion. */
caretOffset: number;
}
export interface RenameLocation {
textSpan: TextSpan;
fileName: string;
}
export interface ReferenceEntry {
textSpan: TextSpan;
fileName: string;
isWriteAccess: boolean;
isDefinition: boolean;
}
export interface DocumentHighlights {
fileName: string;
highlightSpans: HighlightSpan[];
}
export namespace HighlightSpanKind {
export const none = "none";
export const definition = "definition";
export const reference = "reference";
export const writtenReference = "writtenReference";
}
export interface HighlightSpan {
fileName?: string;
textSpan: TextSpan;
kind: string;
}
export interface NavigateToItem {
name: string;
kind: string;
kindModifiers: string;
matchKind: string;
isCaseSensitive: boolean;
fileName: string;
textSpan: TextSpan;
containerName: string;
containerKind: string;
}
export interface EditorOptions {
BaseIndentSize?: number;
IndentSize: number;
TabSize: number;
NewLineCharacter: string;
ConvertTabsToSpaces: boolean;
IndentStyle: IndentStyle;
}
export enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
}
export interface FormatCodeOptions extends EditorOptions {
InsertSpaceAfterCommaDelimiter: boolean;
InsertSpaceAfterSemicolonInForStatements: boolean;
InsertSpaceBeforeAndAfterBinaryOperators: boolean;
InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string | undefined;
}
export interface DefinitionInfo {
fileName: string;
textSpan: TextSpan;
kind: string;
name: string;
containerKind: string;
containerName: string;
}
export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo {
displayParts: SymbolDisplayPart[];
}
export interface ReferencedSymbol {
definition: ReferencedSymbolDefinitionInfo;
references: ReferenceEntry[];
}
export enum SymbolDisplayPartKind {
aliasName,
className,
enumName,
fieldName,
interfaceName,
keyword,
lineBreak,
numericLiteral,
stringLiteral,
localName,
methodName,
moduleName,
operator,
parameterName,
propertyName,
punctuation,
space,
text,
typeParameterName,
enumMemberName,
functionName,
regularExpressionLiteral,
}
export interface SymbolDisplayPart {
text: string;
kind: string;
}
export interface QuickInfo {
kind: string;
kindModifiers: string;
textSpan: TextSpan;
displayParts: SymbolDisplayPart[];
documentation: SymbolDisplayPart[];
}
export interface RenameInfo {
canRename: boolean;
localizedErrorMessage: string;
displayName: string;
fullDisplayName: string;
kind: string;
kindModifiers: string;
triggerSpan: TextSpan;
}
export interface SignatureHelpParameter {
name: string;
documentation: SymbolDisplayPart[];
displayParts: SymbolDisplayPart[];
isOptional: boolean;
}
/**
* Represents a single signature to show in signature help.
* The id is used for subsequent calls into the language service to ask questions about the
* signature help item in the context of any documents that have been updated. i.e. after
* 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 interface SignatureHelpItem {
isVariadic: boolean;
prefixDisplayParts: SymbolDisplayPart[];
suffixDisplayParts: SymbolDisplayPart[];
separatorDisplayParts: SymbolDisplayPart[];
parameters: SignatureHelpParameter[];
documentation: SymbolDisplayPart[];
}
/**
* Represents a set of signature help items, and the preferred item that should be selected.
*/
export interface SignatureHelpItems {
items: SignatureHelpItem[];
applicableSpan: TextSpan;
selectedItemIndex: number;
argumentIndex: number;
argumentCount: number;
}
export interface CompletionInfo {
isMemberCompletion: boolean;
isNewIdentifierLocation: boolean; // true when the current location also allows for a new identifier
entries: CompletionEntry[];
}
export interface CompletionEntry {
name: string;
kind: string; // see ScriptElementKind
kindModifiers: string; // see ScriptElementKindModifier, comma separated
sortText: string;
}
export interface CompletionEntryDetails {
name: string;
kind: string; // see ScriptElementKind
kindModifiers: string; // see ScriptElementKindModifier, comma separated
displayParts: SymbolDisplayPart[];
documentation: SymbolDisplayPart[];
}
export interface OutliningSpan {
/** The span of the document to actually collapse. */
textSpan: TextSpan;
/** The span of the document to display when the user hovers over the collapsed span. */
hintSpan: TextSpan;
/** The text to display in the editor for the collapsed region. */
bannerText: string;
/**
* Whether or not this region should be automatically collapsed when
* the 'Collapse to Definitions' command is invoked.
*/
autoCollapse: boolean;
}
export interface EmitOutput {
outputFiles: OutputFile[];
emitSkipped: boolean;
}
export const enum OutputFileType {
JavaScript,
SourceMap,
Declaration
}
export interface OutputFile {
name: string;
writeByteOrderMark: boolean;
text: string;
}
export const enum EndOfLineState {
None,
InMultiLineCommentTrivia,
InSingleQuoteStringLiteral,
InDoubleQuoteStringLiteral,
InTemplateHeadOrNoSubstitutionTemplate,
InTemplateMiddleOrTail,
InTemplateSubstitutionPosition,
}
export enum TokenClass {
Punctuation,
Keyword,
Operator,
Comment,
Whitespace,
Identifier,
NumberLiteral,
StringLiteral,
RegExpLiteral,
}
export interface ClassificationResult {
finalLexState: EndOfLineState;
entries: ClassificationInfo[];
}
export interface ClassificationInfo {
length: number;
classification: TokenClass;
}
export interface Classifier {
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
* @deprecated Use getLexicalClassifications instead.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications;
}
/**
* The document registry represents a store of SourceFile objects that can be shared between
* multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
* of files in the context.
* SourceFile objects account for most of the memory usage by the language service. Sharing
* the same DocumentRegistry instance between different instances of LanguageService allow
* for more efficient memory utilization since all projects will share at least the library
* file (lib.d.ts).
*
* A more advanced use of the document registry is to serialize sourceFile objects to disk
* and re-hydrate them when needed.
*
* To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
* to all subsequent createLanguageService calls.
*/
export interface DocumentRegistry {
/**
* Request a stored SourceFile with a given fileName and compilationSettings.
* The first call to acquire will call createLanguageServiceSourceFile to generate
* the SourceFile if was not found in the registry.
*
* @param fileName The name of the file requested
* @param compilationSettings Some compilation settings like target affects the
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
* multiple copies of the same file for different compilation settings.
* @parm scriptSnapshot Text of the file. Only used if the file was not found
* in the registry and a new one was created.
* @parm version Current version of the file. Only used if the file was not found
* in the registry and a new one was created.
*/
acquireDocument(
fileName: string,
compilationSettings: CompilerOptions,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
acquireDocumentWithKey(
fileName: string,
path: Path,
compilationSettings: CompilerOptions,
key: DocumentRegistryBucketKey,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
/**
* Request an updated version of an already existing SourceFile with a given fileName
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
* to get an updated SourceFile.
*
* @param fileName The name of the file requested
* @param compilationSettings Some compilation settings like target affects the
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
* multiple copies of the same file for different compilation settings.
* @param scriptSnapshot Text of the file.
* @param version Current version of the file.
*/
updateDocument(
fileName: string,
compilationSettings: CompilerOptions,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
updateDocumentWithKey(
fileName: string,
path: Path,
compilationSettings: CompilerOptions,
key: DocumentRegistryBucketKey,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
/**
* Informs the DocumentRegistry that a file is not needed any longer.
*
* Note: It is not allowed to call release on a SourceFile that was not acquired from
* this registry originally.
*
* @param fileName The name of the file to be released
* @param compilationSettings The compilation settings used to acquire the file
*/
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
reportStats(): string;
}
export type DocumentRegistryBucketKey = string & { __bucketKey: any };
// TODO: move these to enums
export namespace ScriptElementKind {
export const unknown = "";
export const warning = "warning";
/** predefined type (void) or keyword (class) */
export const keyword = "keyword";
/** top level script node */
export const scriptElement = "script";
/** module foo {} */
export const moduleElement = "module";
/** class X {} */
export const classElement = "class";
/** var x = class X {} */
export const localClassElement = "local class";
/** interface Y {} */
export const interfaceElement = "interface";
/** type T = ... */
export const typeElement = "type";
/** enum E */
export const enumElement = "enum";
// TODO: GH#9983
export const enumMemberElement = "const";
/**
* Inside module and script only
* const v = ..
*/
export const variableElement = "var";
/** Inside function */
export const localVariableElement = "local var";
/**
* Inside module and script only
* function f() { }
*/
export const functionElement = "function";
/** Inside function */
export const localFunctionElement = "local function";
/** class X { [public|private]* foo() {} } */
export const memberFunctionElement = "method";
/** class X { [public|private]* [get|set] foo:number; } */
export const memberGetAccessorElement = "getter";
export const memberSetAccessorElement = "setter";
/**
* class X { [public|private]* foo:number; }
* interface Y { foo:number; }
*/
export const memberVariableElement = "property";
/** class X { constructor() { } } */
export const constructorImplementationElement = "constructor";
/** interface Y { ():number; } */
export const callSignatureElement = "call";
/** interface Y { []:number; } */
export const indexSignatureElement = "index";
/** interface Y { new():Y; } */
export const constructSignatureElement = "construct";
/** function foo(*Y*: string) */
export const parameterElement = "parameter";
export const typeParameterElement = "type parameter";
export const primitiveType = "primitive type";
export const label = "label";
export const alias = "alias";
export const constElement = "const";
export const letElement = "let";
}
export namespace ScriptElementKindModifier {
export const none = "";
export const publicMemberModifier = "public";
export const privateMemberModifier = "private";
export const protectedMemberModifier = "protected";
export const exportedModifier = "export";
export const ambientModifier = "declare";
export const staticModifier = "static";
export const abstractModifier = "abstract";
}
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";
public static typeAliasName = "type alias name";
public static parameterName = "parameter name";
public static docCommentTagName = "doc comment tag name";
public static jsxOpenTagName = "jsx open tag name";
public static jsxCloseTagName = "jsx close tag name";
public static jsxSelfClosingTagName = "jsx self closing tag name";
public static jsxAttribute = "jsx attribute";
public static jsxText = "jsx text";
public static jsxAttributeStringLiteralValue = "jsx attribute string literal value";
}
export const enum ClassificationType {
comment = 1,
identifier = 2,
keyword = 3,
numericLiteral = 4,
operator = 5,
stringLiteral = 6,
regularExpressionLiteral = 7,
whiteSpace = 8,
text = 9,
punctuation = 10,
className = 11,
enumName = 12,
interfaceName = 13,
moduleName = 14,
typeParameterName = 15,
typeAliasName = 16,
parameterName = 17,
docCommentTagName = 18,
jsxOpenTagName = 19,
jsxCloseTagName = 20,
jsxSelfClosingTagName = 21,
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24,
}
/// Language Service
// Information about a specific host file.

View File

@@ -48,6 +48,7 @@
"services.ts",
"shims.ts",
"signatureHelp.ts",
"types.ts",
"utilities.ts",
"jsTyping.ts",
"formatting/formatting.ts",

806
src/services/types.ts Normal file
View File

@@ -0,0 +1,806 @@
namespace ts {
export interface Node {
getSourceFile(): SourceFile;
getChildCount(sourceFile?: SourceFile): number;
getChildAt(index: number, sourceFile?: SourceFile): Node;
getChildren(sourceFile?: SourceFile): Node[];
getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
getFullStart(): number;
getEnd(): number;
getWidth(sourceFile?: SourceFile): number;
getFullWidth(): number;
getLeadingTriviaWidth(sourceFile?: SourceFile): number;
getFullText(sourceFile?: SourceFile): string;
getText(sourceFile?: SourceFile): string;
getFirstToken(sourceFile?: SourceFile): Node;
getLastToken(sourceFile?: SourceFile): Node;
}
export interface Symbol {
getFlags(): SymbolFlags;
getName(): string;
getDeclarations(): Declaration[];
getDocumentationComment(): SymbolDisplayPart[];
}
export interface Type {
getFlags(): TypeFlags;
getSymbol(): Symbol;
getProperties(): Symbol[];
getProperty(propertyName: string): Symbol;
getApparentProperties(): Symbol[];
getCallSignatures(): Signature[];
getConstructSignatures(): Signature[];
getStringIndexType(): Type;
getNumberIndexType(): Type;
getBaseTypes(): ObjectType[];
getNonNullableType(): Type;
}
export interface Signature {
getDeclaration(): SignatureDeclaration;
getTypeParameters(): Type[];
getParameters(): Symbol[];
getReturnType(): Type;
getDocumentationComment(): SymbolDisplayPart[];
}
export interface SourceFile {
/* @internal */ version: string;
/* @internal */ scriptSnapshot: IScriptSnapshot;
/* @internal */ nameTable: Map<number>;
/* @internal */ getNamedDeclarations(): Map<Declaration[]>;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
/**
* 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 {
/** Gets a portion of the script snapshot specified by [start, end). */
getText(start: number, end: number): string;
/** Gets the length of this script snapshot. */
getLength(): number;
/**
* 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 | undefined;
/** Releases all resources held by this script snapshot */
dispose?(): void;
}
export namespace ScriptSnapshot {
class StringScriptSnapshot implements IScriptSnapshot {
constructor(private text: string) {
}
public getText(start: number, end: number): string {
return this.text.substring(start, end);
}
public getLength(): number {
return this.text.length;
}
public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
// Text-based snapshots do not support incremental parsing. Return undefined
// to signal that to the caller.
return undefined;
}
}
export function fromString(text: string): IScriptSnapshot {
return new StringScriptSnapshot(text);
}
}
export interface PreProcessedFileInfo {
referencedFiles: FileReference[];
typeReferenceDirectives: FileReference[];
importedFiles: FileReference[];
ambientExternalModules: string[];
isLibFile: boolean;
}
export interface HostCancellationToken {
isCancellationRequested(): boolean;
}
//
// Public interface of the host of a language service instance.
//
export interface LanguageServiceHost {
getCompilationSettings(): CompilerOptions;
getNewLine?(): string;
getProjectVersion?(): string;
getScriptFileNames(): string[];
getScriptKind?(fileName: string): ScriptKind;
getScriptVersion(fileName: string): string;
getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
getLocalizedDiagnosticMessages?(): any;
getCancellationToken?(): HostCancellationToken;
getCurrentDirectory(): string;
getDefaultLibFileName(options: CompilerOptions): string;
log?(s: string): void;
trace?(s: string): void;
error?(s: string): void;
useCaseSensitiveFileNames?(): boolean;
/*
* LS host can optionally implement this method if it wants to be completely in charge of module name resolution.
* if implementation is omitted then language service will use built-in module resolution logic and get answers to
* host specific questions using 'getScriptSnapshot'.
*/
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
directoryExists?(directoryName: string): boolean;
getDirectories?(directoryName: string): string[];
}
//
// Public services of a language service instance associated
// with a language service host instance
//
export interface LanguageService {
cleanupSemanticCache(): void;
getSyntacticDiagnostics(fileName: string): Diagnostic[];
getSemanticDiagnostics(fileName: string): Diagnostic[];
// TODO: Rename this to getProgramDiagnostics to better indicate that these are any
// diagnostics present for the program level, and not just 'options' diagnostics.
getCompilerOptionsDiagnostics(): Diagnostic[];
/**
* @deprecated Use getEncodedSyntacticClassifications instead.
*/
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
/**
* @deprecated Use getEncodedSemanticClassifications instead.
*/
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
// Encoded as triples of [start, length, ClassificationType].
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan;
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan;
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems;
getRenameInfo(fileName: string, position: number): RenameInfo;
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
findReferences(fileName: string, position: number): ReferencedSymbol[];
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];
/** @deprecated */
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number;
getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[];
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
getEmitOutput(fileName: string): EmitOutput;
getProgram(): Program;
/* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
dispose(): void;
}
export interface Classifications {
spans: number[];
endOfLineState: EndOfLineState;
}
export interface ClassifiedSpan {
textSpan: TextSpan;
classificationType: string; // ClassificationTypeNames
}
export interface NavigationBarItem {
text: string;
kind: string;
kindModifiers: string;
spans: TextSpan[];
childItems: NavigationBarItem[];
indent: number;
bolded: boolean;
grayed: boolean;
}
export interface TodoCommentDescriptor {
text: string;
priority: number;
}
export interface TodoComment {
descriptor: TodoCommentDescriptor;
message: string;
position: number;
}
export class TextChange {
span: TextSpan;
newText: string;
}
export interface TextInsertion {
newText: string;
/** The position in newText the caret should point to after the insertion. */
caretOffset: number;
}
export interface RenameLocation {
textSpan: TextSpan;
fileName: string;
}
export interface ReferenceEntry {
textSpan: TextSpan;
fileName: string;
isWriteAccess: boolean;
isDefinition: boolean;
}
export interface DocumentHighlights {
fileName: string;
highlightSpans: HighlightSpan[];
}
export namespace HighlightSpanKind {
export const none = "none";
export const definition = "definition";
export const reference = "reference";
export const writtenReference = "writtenReference";
}
export interface HighlightSpan {
fileName?: string;
textSpan: TextSpan;
kind: string;
}
export interface NavigateToItem {
name: string;
kind: string;
kindModifiers: string;
matchKind: string;
isCaseSensitive: boolean;
fileName: string;
textSpan: TextSpan;
containerName: string;
containerKind: string;
}
export interface EditorOptions {
BaseIndentSize?: number;
IndentSize: number;
TabSize: number;
NewLineCharacter: string;
ConvertTabsToSpaces: boolean;
IndentStyle: IndentStyle;
}
export enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
}
export interface FormatCodeOptions extends EditorOptions {
InsertSpaceAfterCommaDelimiter: boolean;
InsertSpaceAfterSemicolonInForStatements: boolean;
InsertSpaceBeforeAndAfterBinaryOperators: boolean;
InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string | undefined;
}
export interface DefinitionInfo {
fileName: string;
textSpan: TextSpan;
kind: string;
name: string;
containerKind: string;
containerName: string;
}
export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo {
displayParts: SymbolDisplayPart[];
}
export interface ReferencedSymbol {
definition: ReferencedSymbolDefinitionInfo;
references: ReferenceEntry[];
}
export enum SymbolDisplayPartKind {
aliasName,
className,
enumName,
fieldName,
interfaceName,
keyword,
lineBreak,
numericLiteral,
stringLiteral,
localName,
methodName,
moduleName,
operator,
parameterName,
propertyName,
punctuation,
space,
text,
typeParameterName,
enumMemberName,
functionName,
regularExpressionLiteral,
}
export interface SymbolDisplayPart {
text: string;
kind: string;
}
export interface QuickInfo {
kind: string;
kindModifiers: string;
textSpan: TextSpan;
displayParts: SymbolDisplayPart[];
documentation: SymbolDisplayPart[];
}
export interface RenameInfo {
canRename: boolean;
localizedErrorMessage: string;
displayName: string;
fullDisplayName: string;
kind: string;
kindModifiers: string;
triggerSpan: TextSpan;
}
export interface SignatureHelpParameter {
name: string;
documentation: SymbolDisplayPart[];
displayParts: SymbolDisplayPart[];
isOptional: boolean;
}
/**
* Represents a single signature to show in signature help.
* The id is used for subsequent calls into the language service to ask questions about the
* signature help item in the context of any documents that have been updated. i.e. after
* 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 interface SignatureHelpItem {
isVariadic: boolean;
prefixDisplayParts: SymbolDisplayPart[];
suffixDisplayParts: SymbolDisplayPart[];
separatorDisplayParts: SymbolDisplayPart[];
parameters: SignatureHelpParameter[];
documentation: SymbolDisplayPart[];
}
/**
* Represents a set of signature help items, and the preferred item that should be selected.
*/
export interface SignatureHelpItems {
items: SignatureHelpItem[];
applicableSpan: TextSpan;
selectedItemIndex: number;
argumentIndex: number;
argumentCount: number;
}
export interface CompletionInfo {
isMemberCompletion: boolean;
isNewIdentifierLocation: boolean; // true when the current location also allows for a new identifier
entries: CompletionEntry[];
}
export interface CompletionEntry {
name: string;
kind: string; // see ScriptElementKind
kindModifiers: string; // see ScriptElementKindModifier, comma separated
sortText: string;
}
export interface CompletionEntryDetails {
name: string;
kind: string; // see ScriptElementKind
kindModifiers: string; // see ScriptElementKindModifier, comma separated
displayParts: SymbolDisplayPart[];
documentation: SymbolDisplayPart[];
}
export interface OutliningSpan {
/** The span of the document to actually collapse. */
textSpan: TextSpan;
/** The span of the document to display when the user hovers over the collapsed span. */
hintSpan: TextSpan;
/** The text to display in the editor for the collapsed region. */
bannerText: string;
/**
* Whether or not this region should be automatically collapsed when
* the 'Collapse to Definitions' command is invoked.
*/
autoCollapse: boolean;
}
export interface EmitOutput {
outputFiles: OutputFile[];
emitSkipped: boolean;
}
export const enum OutputFileType {
JavaScript,
SourceMap,
Declaration
}
export interface OutputFile {
name: string;
writeByteOrderMark: boolean;
text: string;
}
export const enum EndOfLineState {
None,
InMultiLineCommentTrivia,
InSingleQuoteStringLiteral,
InDoubleQuoteStringLiteral,
InTemplateHeadOrNoSubstitutionTemplate,
InTemplateMiddleOrTail,
InTemplateSubstitutionPosition,
}
export enum TokenClass {
Punctuation,
Keyword,
Operator,
Comment,
Whitespace,
Identifier,
NumberLiteral,
StringLiteral,
RegExpLiteral,
}
export interface ClassificationResult {
finalLexState: EndOfLineState;
entries: ClassificationInfo[];
}
export interface ClassificationInfo {
length: number;
classification: TokenClass;
}
export interface Classifier {
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
* @deprecated Use getLexicalClassifications instead.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications;
}
/**
* The document registry represents a store of SourceFile objects that can be shared between
* multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
* of files in the context.
* SourceFile objects account for most of the memory usage by the language service. Sharing
* the same DocumentRegistry instance between different instances of LanguageService allow
* for more efficient memory utilization since all projects will share at least the library
* file (lib.d.ts).
*
* A more advanced use of the document registry is to serialize sourceFile objects to disk
* and re-hydrate them when needed.
*
* To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
* to all subsequent createLanguageService calls.
*/
export interface DocumentRegistry {
/**
* Request a stored SourceFile with a given fileName and compilationSettings.
* The first call to acquire will call createLanguageServiceSourceFile to generate
* the SourceFile if was not found in the registry.
*
* @param fileName The name of the file requested
* @param compilationSettings Some compilation settings like target affects the
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
* multiple copies of the same file for different compilation settings.
* @parm scriptSnapshot Text of the file. Only used if the file was not found
* in the registry and a new one was created.
* @parm version Current version of the file. Only used if the file was not found
* in the registry and a new one was created.
*/
acquireDocument(
fileName: string,
compilationSettings: CompilerOptions,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
acquireDocumentWithKey(
fileName: string,
path: Path,
compilationSettings: CompilerOptions,
key: DocumentRegistryBucketKey,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
/**
* Request an updated version of an already existing SourceFile with a given fileName
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
* to get an updated SourceFile.
*
* @param fileName The name of the file requested
* @param compilationSettings Some compilation settings like target affects the
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
* multiple copies of the same file for different compilation settings.
* @param scriptSnapshot Text of the file.
* @param version Current version of the file.
*/
updateDocument(
fileName: string,
compilationSettings: CompilerOptions,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
updateDocumentWithKey(
fileName: string,
path: Path,
compilationSettings: CompilerOptions,
key: DocumentRegistryBucketKey,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
/**
* Informs the DocumentRegistry that a file is not needed any longer.
*
* Note: It is not allowed to call release on a SourceFile that was not acquired from
* this registry originally.
*
* @param fileName The name of the file to be released
* @param compilationSettings The compilation settings used to acquire the file
*/
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
reportStats(): string;
}
export type DocumentRegistryBucketKey = string & { __bucketKey: any };
// TODO: move these to enums
export namespace ScriptElementKind {
export const unknown = "";
export const warning = "warning";
/** predefined type (void) or keyword (class) */
export const keyword = "keyword";
/** top level script node */
export const scriptElement = "script";
/** module foo {} */
export const moduleElement = "module";
/** class X {} */
export const classElement = "class";
/** var x = class X {} */
export const localClassElement = "local class";
/** interface Y {} */
export const interfaceElement = "interface";
/** type T = ... */
export const typeElement = "type";
/** enum E */
export const enumElement = "enum";
// TODO: GH#9983
export const enumMemberElement = "const";
/**
* Inside module and script only
* const v = ..
*/
export const variableElement = "var";
/** Inside function */
export const localVariableElement = "local var";
/**
* Inside module and script only
* function f() { }
*/
export const functionElement = "function";
/** Inside function */
export const localFunctionElement = "local function";
/** class X { [public|private]* foo() {} } */
export const memberFunctionElement = "method";
/** class X { [public|private]* [get|set] foo:number; } */
export const memberGetAccessorElement = "getter";
export const memberSetAccessorElement = "setter";
/**
* class X { [public|private]* foo:number; }
* interface Y { foo:number; }
*/
export const memberVariableElement = "property";
/** class X { constructor() { } } */
export const constructorImplementationElement = "constructor";
/** interface Y { ():number; } */
export const callSignatureElement = "call";
/** interface Y { []:number; } */
export const indexSignatureElement = "index";
/** interface Y { new():Y; } */
export const constructSignatureElement = "construct";
/** function foo(*Y*: string) */
export const parameterElement = "parameter";
export const typeParameterElement = "type parameter";
export const primitiveType = "primitive type";
export const label = "label";
export const alias = "alias";
export const constElement = "const";
export const letElement = "let";
}
export namespace ScriptElementKindModifier {
export const none = "";
export const publicMemberModifier = "public";
export const privateMemberModifier = "private";
export const protectedMemberModifier = "protected";
export const exportedModifier = "export";
export const ambientModifier = "declare";
export const staticModifier = "static";
export const abstractModifier = "abstract";
}
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";
public static typeAliasName = "type alias name";
public static parameterName = "parameter name";
public static docCommentTagName = "doc comment tag name";
public static jsxOpenTagName = "jsx open tag name";
public static jsxCloseTagName = "jsx close tag name";
public static jsxSelfClosingTagName = "jsx self closing tag name";
public static jsxAttribute = "jsx attribute";
public static jsxText = "jsx text";
public static jsxAttributeStringLiteralValue = "jsx attribute string literal value";
}
export const enum ClassificationType {
comment = 1,
identifier = 2,
keyword = 3,
numericLiteral = 4,
operator = 5,
stringLiteral = 6,
regularExpressionLiteral = 7,
whiteSpace = 8,
text = 9,
punctuation = 10,
className = 11,
enumName = 12,
interfaceName = 13,
moduleName = 14,
typeParameterName = 15,
typeAliasName = 16,
parameterName = 17,
docCommentTagName = 18,
jsxOpenTagName = 19,
jsxCloseTagName = 20,
jsxSelfClosingTagName = 21,
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24,
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/a/b'",
"File '/a/b/node_modules/jquery.ts' does not exist.",
"File '/a/b/node_modules/jquery.d.ts' does not exist.",

View File

@@ -1,8 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/a/b'",
"File '/a/b/node_modules/jquery.ts' does not exist.",
"File '/a/b/node_modules/jquery.d.ts' does not exist.",

View File

@@ -1,8 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/src/node_modules/@types'. ========",
"Resolving with primary search path '/src/node_modules/@types'",
"File '/src/node_modules/@types/jquery/package.json' does not exist.",
"File '/src/node_modules/@types/jquery/index.d.ts' does not exist.",
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/src'",
"File '/src/node_modules/jquery.ts' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",

View File

@@ -1,8 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/src'",
"File '/src/node_modules/jquery.ts' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",

View File

@@ -0,0 +1,31 @@
//// [tests/cases/compiler/typeRootsFromMultipleNodeModulesDirectories.ts] ////
//// [index.d.ts]
declare module "xyz" {
export const x: number;
}
//// [index.d.ts]
declare module "pdq" {
export const y: number;
}
//// [index.d.ts]
declare module "abc" {
export const z: number;
}
//// [a.ts]
import { x } from "xyz";
import { y } from "pdq";
import { z } from "abc";
x + y + z;
//// [a.js]
"use strict";
var xyz_1 = require("xyz");
var pdq_1 = require("pdq");
var abc_1 = require("abc");
xyz_1.x + pdq_1.y + abc_1.z;

View File

@@ -0,0 +1,34 @@
=== /foo/bar/a.ts ===
import { x } from "xyz";
>x : Symbol(x, Decl(a.ts, 0, 8))
import { y } from "pdq";
>y : Symbol(y, Decl(a.ts, 1, 8))
import { z } from "abc";
>z : Symbol(z, Decl(a.ts, 2, 8))
x + y + z;
>x : Symbol(x, Decl(a.ts, 0, 8))
>y : Symbol(y, Decl(a.ts, 1, 8))
>z : Symbol(z, Decl(a.ts, 2, 8))
=== /node_modules/@types/dopey/index.d.ts ===
declare module "xyz" {
export const x: number;
>x : Symbol(x, Decl(index.d.ts, 2, 16))
}
=== /foo/node_modules/@types/grumpy/index.d.ts ===
declare module "pdq" {
export const y: number;
>y : Symbol(y, Decl(index.d.ts, 1, 16))
}
=== /foo/node_modules/@types/sneezy/index.d.ts ===
declare module "abc" {
export const z: number;
>z : Symbol(z, Decl(index.d.ts, 1, 16))
}

View File

@@ -0,0 +1,157 @@
[
"======== Resolving module 'xyz' from '/foo/bar/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'xyz' from 'node_modules' folder.",
"File '/foo/bar/node_modules/xyz.ts' does not exist.",
"File '/foo/bar/node_modules/xyz.tsx' does not exist.",
"File '/foo/bar/node_modules/xyz.d.ts' does not exist.",
"File '/foo/bar/node_modules/xyz/package.json' does not exist.",
"File '/foo/bar/node_modules/xyz/index.ts' does not exist.",
"File '/foo/bar/node_modules/xyz/index.tsx' does not exist.",
"File '/foo/bar/node_modules/xyz/index.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/xyz.ts' does not exist.",
"File '/foo/bar/node_modules/@types/xyz.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/xyz.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/xyz/package.json' does not exist.",
"File '/foo/bar/node_modules/@types/xyz/index.ts' does not exist.",
"File '/foo/bar/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/xyz/index.d.ts' does not exist.",
"File '/foo/node_modules/xyz.ts' does not exist.",
"File '/foo/node_modules/xyz.tsx' does not exist.",
"File '/foo/node_modules/xyz.d.ts' does not exist.",
"File '/foo/node_modules/xyz/package.json' does not exist.",
"File '/foo/node_modules/xyz/index.ts' does not exist.",
"File '/foo/node_modules/xyz/index.tsx' does not exist.",
"File '/foo/node_modules/xyz/index.d.ts' does not exist.",
"File '/foo/node_modules/@types/xyz.ts' does not exist.",
"File '/foo/node_modules/@types/xyz.tsx' does not exist.",
"File '/foo/node_modules/@types/xyz.d.ts' does not exist.",
"File '/foo/node_modules/@types/xyz/package.json' does not exist.",
"File '/foo/node_modules/@types/xyz/index.ts' does not exist.",
"File '/foo/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/foo/node_modules/@types/xyz/index.d.ts' does not exist.",
"File '/node_modules/xyz.ts' does not exist.",
"File '/node_modules/xyz.tsx' does not exist.",
"File '/node_modules/xyz.d.ts' does not exist.",
"File '/node_modules/xyz/package.json' does not exist.",
"File '/node_modules/xyz/index.ts' does not exist.",
"File '/node_modules/xyz/index.tsx' does not exist.",
"File '/node_modules/xyz/index.d.ts' does not exist.",
"File '/node_modules/@types/xyz.ts' does not exist.",
"File '/node_modules/@types/xyz.tsx' does not exist.",
"File '/node_modules/@types/xyz.d.ts' does not exist.",
"File '/node_modules/@types/xyz/package.json' does not exist.",
"File '/node_modules/@types/xyz/index.ts' does not exist.",
"File '/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/node_modules/@types/xyz/index.d.ts' does not exist.",
"======== Module name 'xyz' was not resolved. ========",
"======== Resolving module 'pdq' from '/foo/bar/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'pdq' from 'node_modules' folder.",
"File '/foo/bar/node_modules/pdq.ts' does not exist.",
"File '/foo/bar/node_modules/pdq.tsx' does not exist.",
"File '/foo/bar/node_modules/pdq.d.ts' does not exist.",
"File '/foo/bar/node_modules/pdq/package.json' does not exist.",
"File '/foo/bar/node_modules/pdq/index.ts' does not exist.",
"File '/foo/bar/node_modules/pdq/index.tsx' does not exist.",
"File '/foo/bar/node_modules/pdq/index.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/pdq.ts' does not exist.",
"File '/foo/bar/node_modules/@types/pdq.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/pdq.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/pdq/package.json' does not exist.",
"File '/foo/bar/node_modules/@types/pdq/index.ts' does not exist.",
"File '/foo/bar/node_modules/@types/pdq/index.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/pdq/index.d.ts' does not exist.",
"File '/foo/node_modules/pdq.ts' does not exist.",
"File '/foo/node_modules/pdq.tsx' does not exist.",
"File '/foo/node_modules/pdq.d.ts' does not exist.",
"File '/foo/node_modules/pdq/package.json' does not exist.",
"File '/foo/node_modules/pdq/index.ts' does not exist.",
"File '/foo/node_modules/pdq/index.tsx' does not exist.",
"File '/foo/node_modules/pdq/index.d.ts' does not exist.",
"File '/foo/node_modules/@types/pdq.ts' does not exist.",
"File '/foo/node_modules/@types/pdq.tsx' does not exist.",
"File '/foo/node_modules/@types/pdq.d.ts' does not exist.",
"File '/foo/node_modules/@types/pdq/package.json' does not exist.",
"File '/foo/node_modules/@types/pdq/index.ts' does not exist.",
"File '/foo/node_modules/@types/pdq/index.tsx' does not exist.",
"File '/foo/node_modules/@types/pdq/index.d.ts' does not exist.",
"File '/node_modules/pdq.ts' does not exist.",
"File '/node_modules/pdq.tsx' does not exist.",
"File '/node_modules/pdq.d.ts' does not exist.",
"File '/node_modules/pdq/package.json' does not exist.",
"File '/node_modules/pdq/index.ts' does not exist.",
"File '/node_modules/pdq/index.tsx' does not exist.",
"File '/node_modules/pdq/index.d.ts' does not exist.",
"File '/node_modules/@types/pdq.ts' does not exist.",
"File '/node_modules/@types/pdq.tsx' does not exist.",
"File '/node_modules/@types/pdq.d.ts' does not exist.",
"File '/node_modules/@types/pdq/package.json' does not exist.",
"File '/node_modules/@types/pdq/index.ts' does not exist.",
"File '/node_modules/@types/pdq/index.tsx' does not exist.",
"File '/node_modules/@types/pdq/index.d.ts' does not exist.",
"======== Module name 'pdq' was not resolved. ========",
"======== Resolving module 'abc' from '/foo/bar/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'abc' from 'node_modules' folder.",
"File '/foo/bar/node_modules/abc.ts' does not exist.",
"File '/foo/bar/node_modules/abc.tsx' does not exist.",
"File '/foo/bar/node_modules/abc.d.ts' does not exist.",
"File '/foo/bar/node_modules/abc/package.json' does not exist.",
"File '/foo/bar/node_modules/abc/index.ts' does not exist.",
"File '/foo/bar/node_modules/abc/index.tsx' does not exist.",
"File '/foo/bar/node_modules/abc/index.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/abc.ts' does not exist.",
"File '/foo/bar/node_modules/@types/abc.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/abc.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/abc/package.json' does not exist.",
"File '/foo/bar/node_modules/@types/abc/index.ts' does not exist.",
"File '/foo/bar/node_modules/@types/abc/index.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/abc/index.d.ts' does not exist.",
"File '/foo/node_modules/abc.ts' does not exist.",
"File '/foo/node_modules/abc.tsx' does not exist.",
"File '/foo/node_modules/abc.d.ts' does not exist.",
"File '/foo/node_modules/abc/package.json' does not exist.",
"File '/foo/node_modules/abc/index.ts' does not exist.",
"File '/foo/node_modules/abc/index.tsx' does not exist.",
"File '/foo/node_modules/abc/index.d.ts' does not exist.",
"File '/foo/node_modules/@types/abc.ts' does not exist.",
"File '/foo/node_modules/@types/abc.tsx' does not exist.",
"File '/foo/node_modules/@types/abc.d.ts' does not exist.",
"File '/foo/node_modules/@types/abc/package.json' does not exist.",
"File '/foo/node_modules/@types/abc/index.ts' does not exist.",
"File '/foo/node_modules/@types/abc/index.tsx' does not exist.",
"File '/foo/node_modules/@types/abc/index.d.ts' does not exist.",
"File '/node_modules/abc.ts' does not exist.",
"File '/node_modules/abc.tsx' does not exist.",
"File '/node_modules/abc.d.ts' does not exist.",
"File '/node_modules/abc/package.json' does not exist.",
"File '/node_modules/abc/index.ts' does not exist.",
"File '/node_modules/abc/index.tsx' does not exist.",
"File '/node_modules/abc/index.d.ts' does not exist.",
"File '/node_modules/@types/abc.ts' does not exist.",
"File '/node_modules/@types/abc.tsx' does not exist.",
"File '/node_modules/@types/abc.d.ts' does not exist.",
"File '/node_modules/@types/abc/package.json' does not exist.",
"File '/node_modules/@types/abc/index.ts' does not exist.",
"File '/node_modules/@types/abc/index.tsx' does not exist.",
"File '/node_modules/@types/abc/index.d.ts' does not exist.",
"======== Module name 'abc' was not resolved. ========",
"======== Resolving type reference directive 'grumpy', containing file '/src/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========",
"Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'",
"File '/foo/node_modules/@types/grumpy/package.json' does not exist.",
"File '/foo/node_modules/@types/grumpy/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'grumpy' was successfully resolved to '/foo/node_modules/@types/grumpy/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'sneezy', containing file '/src/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========",
"Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'",
"File '/foo/node_modules/@types/sneezy/package.json' does not exist.",
"File '/foo/node_modules/@types/sneezy/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'sneezy' was successfully resolved to '/foo/node_modules/@types/sneezy/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'dopey', containing file '/src/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========",
"Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'",
"File '/foo/node_modules/@types/dopey/package.json' does not exist.",
"File '/foo/node_modules/@types/dopey/index.d.ts' does not exist.",
"File '/node_modules/@types/dopey/package.json' does not exist.",
"File '/node_modules/@types/dopey/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'dopey' was successfully resolved to '/node_modules/@types/dopey/index.d.ts', primary: true. ========"
]

View File

@@ -0,0 +1,36 @@
=== /foo/bar/a.ts ===
import { x } from "xyz";
>x : number
import { y } from "pdq";
>y : number
import { z } from "abc";
>z : number
x + y + z;
>x + y + z : number
>x + y : number
>x : number
>y : number
>z : number
=== /node_modules/@types/dopey/index.d.ts ===
declare module "xyz" {
export const x: number;
>x : number
}
=== /foo/node_modules/@types/grumpy/index.d.ts ===
declare module "pdq" {
export const y: number;
>y : number
}
=== /foo/node_modules/@types/sneezy/index.d.ts ===
declare module "abc" {
export const z: number;
>z : number
}

View File

@@ -0,0 +1,17 @@
//// [tests/cases/compiler/typeRootsFromNodeModulesInParentDirectory.ts] ////
//// [index.d.ts]
declare module "xyz" {
export const x: number;
}
//// [a.ts]
import { x } from "xyz";
x;
//// [a.js]
"use strict";
var xyz_1 = require("xyz");
xyz_1.x;

View File

@@ -0,0 +1,14 @@
=== /src/a.ts ===
import { x } from "xyz";
>x : Symbol(x, Decl(a.ts, 0, 8))
x;
>x : Symbol(x, Decl(a.ts, 0, 8))
=== /node_modules/@types/foo/index.d.ts ===
declare module "xyz" {
export const x: number;
>x : Symbol(x, Decl(index.d.ts, 2, 16))
}

View File

@@ -0,0 +1,39 @@
[
"======== Resolving module 'xyz' from '/src/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'xyz' from 'node_modules' folder.",
"File '/src/node_modules/xyz.ts' does not exist.",
"File '/src/node_modules/xyz.tsx' does not exist.",
"File '/src/node_modules/xyz.d.ts' does not exist.",
"File '/src/node_modules/xyz/package.json' does not exist.",
"File '/src/node_modules/xyz/index.ts' does not exist.",
"File '/src/node_modules/xyz/index.tsx' does not exist.",
"File '/src/node_modules/xyz/index.d.ts' does not exist.",
"File '/src/node_modules/@types/xyz.ts' does not exist.",
"File '/src/node_modules/@types/xyz.tsx' does not exist.",
"File '/src/node_modules/@types/xyz.d.ts' does not exist.",
"File '/src/node_modules/@types/xyz/package.json' does not exist.",
"File '/src/node_modules/@types/xyz/index.ts' does not exist.",
"File '/src/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/src/node_modules/@types/xyz/index.d.ts' does not exist.",
"File '/node_modules/xyz.ts' does not exist.",
"File '/node_modules/xyz.tsx' does not exist.",
"File '/node_modules/xyz.d.ts' does not exist.",
"File '/node_modules/xyz/package.json' does not exist.",
"File '/node_modules/xyz/index.ts' does not exist.",
"File '/node_modules/xyz/index.tsx' does not exist.",
"File '/node_modules/xyz/index.d.ts' does not exist.",
"File '/node_modules/@types/xyz.ts' does not exist.",
"File '/node_modules/@types/xyz.tsx' does not exist.",
"File '/node_modules/@types/xyz.d.ts' does not exist.",
"File '/node_modules/@types/xyz/package.json' does not exist.",
"File '/node_modules/@types/xyz/index.ts' does not exist.",
"File '/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/node_modules/@types/xyz/index.d.ts' does not exist.",
"======== Module name 'xyz' was not resolved. ========",
"======== Resolving type reference directive 'foo', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/foo/package.json' does not exist.",
"File '/node_modules/@types/foo/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/@types/foo/index.d.ts', primary: true. ========"
]

View File

@@ -0,0 +1,14 @@
=== /src/a.ts ===
import { x } from "xyz";
>x : number
x;
>x : number
=== /node_modules/@types/foo/index.d.ts ===
declare module "xyz" {
export const x: number;
>x : number
}

View File

@@ -0,0 +1,27 @@
// @noImplicitReferences: true
// @traceResolution: true
// @currentDirectory: /src
// @Filename: /node_modules/@types/dopey/index.d.ts
declare module "xyz" {
export const x: number;
}
// @Filename: /foo/node_modules/@types/grumpy/index.d.ts
declare module "pdq" {
export const y: number;
}
// @Filename: /foo/node_modules/@types/sneezy/index.d.ts
declare module "abc" {
export const z: number;
}
// @Filename: /foo/bar/a.ts
import { x } from "xyz";
import { y } from "pdq";
import { z } from "abc";
x + y + z;
// @Filename: /foo/bar/tsconfig.json
{}

View File

@@ -0,0 +1,15 @@
// @noImplicitReferences: true
// @traceResolution: true
// @currentDirectory: /src
// @Filename: /node_modules/@types/foo/index.d.ts
declare module "xyz" {
export const x: number;
}
// @Filename: /src/a.ts
import { x } from "xyz";
x;
// @Filename: /src/tsconfig.json
{}

File diff suppressed because one or more lines are too long

View File

@@ -12,28 +12,25 @@
goTo.marker("useFoo");
verify.quickInfoIs("import foo");
goTo.definition();
verify.caretAtMarker("importFoo");
goTo.definition();
verify.caretAtMarker("module");
verify.goToDefinition({
useFoo: "importFoo",
importFoo: "module"
});
goTo.marker("useBar");
verify.quickInfoIs("import bar");
goTo.definition();
verify.caretAtMarker("module");
verify.goToDefinition("useBar", "module");
goTo.marker("useBaz");
verify.quickInfoIs("import baz");
goTo.definition();
verify.caretAtMarker("importBaz");
goTo.marker("idBaz");
goTo.definition();
verify.caretAtMarker("module");
verify.goToDefinition({
useBaz: "importBaz",
idBaz: "module"
});
goTo.marker("useBang");
verify.quickInfoIs("import bang = require(\"jquery\")");
goTo.definition();
verify.caretAtMarker("importBang");
goTo.marker("idBang");
goTo.definition();
verify.caretAtMarker("module");
verify.goToDefinition({
useBang: "importBang",
idBang: "module"
});

View File

@@ -7,6 +7,4 @@
// @Filename: a.ts
//// /*2*/export class Foo {}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

View File

@@ -8,4 +8,4 @@
////var enumMember = e./*1*/thirdMember;
goTo.marker("1");
verify.verifyDefinitionsName("thirdMember", "e");
verify.goToDefinitionName("thirdMember", "e");

View File

@@ -99,6 +99,7 @@ declare namespace FourSlashInterface {
}
class test_ {
markers(): Marker[];
markerNames(): string[];
marker(name?: string): Marker;
ranges(): Range[];
rangesByText(): { [text: string]: Range[] };
@@ -108,7 +109,6 @@ declare namespace FourSlashInterface {
marker(name?: string): void;
bof(): void;
eof(): void;
definition(definitionIndex?: number): void;
type(definitionIndex?: number): void;
position(position: number, fileIndex?: number): any;
position(position: number, fileName?: string): any;
@@ -132,10 +132,7 @@ declare namespace FourSlashInterface {
errorExistsBeforeMarker(markerName?: string): void;
quickInfoIs(expectedText?: string, expectedDocumentation?: string): void;
quickInfoExists(): void;
definitionCountIs(expectedCount: number): void;
typeDefinitionCountIs(expectedCount: number): void;
definitionLocationExists(): void;
verifyDefinitionsName(name: string, containerName: string): void;
isValidBraceCompletionAtPosition(openingBrace?: string): void;
}
class verify extends verifyNegatable {
@@ -152,6 +149,21 @@ declare namespace FourSlashInterface {
eval(expr: string, value: any): void;
currentLineContentIs(text: string): void;
currentFileContentIs(text: string): void;
/** Verifies that goToDefinition at the current position would take you to `endMarker`. */
goToDefinitionIs(endMarkers: string | string[]): void;
goToDefinitionName(name: string, containerName: string): void;
/**
* `verify.goToDefinition("a", "b");` verifies that go-to-definition at marker "a" takes you to marker "b".
* `verify.goToDefinition(["a", "aa"], "b");` verifies that markers "a" and "aa" have the same definition "b".
* `verify.goToDefinition("a", ["b", "bb"]);` verifies that "a" has multiple definitions available.
*/
goToDefinition(startMarkerNames: string | string[], endMarkerNames: string | string[]): void;
/** Performs `goToDefinition` for each pair. */
goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void;
/** Performs `goToDefinition` on each key and value. */
goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
/** Verifies goToDefinition for each `${markerName}Reference` -> `${markerName}Definition` */
goToDefinitionForMarkers(...markerNames: string[]): void;
verifyGetEmitOutputForCurrentFile(expected: string): void;
verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void;
referencesCountIs(count: number): void;

View File

@@ -13,10 +13,7 @@
//// @/*useDecSymbol*/dec [s]() {}
////}
goTo.marker("useDecString");
goTo.definition();
verify.caretAtMarker("defDecString");
goTo.marker("useDecSymbol");
goTo.definition();
verify.caretAtMarker("defDecSymbol");
verify.goToDefinition({
useDecString: "defDecString",
useDecSymbol: "defDecSymbol"
});

View File

@@ -1,17 +1,14 @@
/// <reference path="fourslash.ts" />
//@Filename: a.ts
////var x: number;
////var /*def1*/x: number;
//@Filename: b.ts
////var x: number;
////var /*def2*/x: number;
//@Filename: c.ts
/////// <reference path="a.ts" />
/////// <reference path="b.ts" />
/////**/x++;
/////*use*/x++;
goTo.file("c.ts");
goTo.marker();
verify.definitionCountIs(2);
verify.goToDefinition("use", ["def1", "def2"]);

View File

@@ -23,20 +23,7 @@
//// x;
////}
goTo.marker('alias1Type');
goTo.definition();
verify.caretAtMarker('alias1Definition');
goTo.marker('alias2Type');
goTo.definition();
verify.caretAtMarker('alias2Definition');
goTo.marker('alias1Value');
goTo.definition();
verify.caretAtMarker('alias1Definition');
goTo.marker('alias2Value');
goTo.definition();
verify.caretAtMarker('alias2Definition');
verify.goToDefinition([
[["alias1Type", "alias1Value"], "alias1Definition"],
[["alias2Type", "alias2Value"], "alias2Definition"]
]);

View File

@@ -14,16 +14,4 @@
////ambientClass./*staticMethodReference*/method();
////ambientClassVariable./*instanceMethodReference*/method();
var markerList = [
"ambientVariable",
"ambientFunction",
"constructor",
"staticMethod",
"instanceMethod",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("ambientVariable", "ambientFunction", "constructor", "staticMethod", "instanceMethod");

View File

@@ -8,10 +8,4 @@
////o./*reference1*/myObjectMethod();
////o["/*reference2*/myObjectMethod"]();
goTo.marker("reference1");
goTo.definition();
verify.caretAtMarker("definition");
goTo.marker("reference2");
goTo.definition();
verify.caretAtMarker("definition");
verify.goToDefinition(["reference1", "reference2"], "definition");

View File

@@ -5,7 +5,6 @@
////var b: /*boolean*/boolean;
////var v: /*void*/void;
test.markers().forEach((m, i, a) => {
goTo.position(m.position, m.fileName);
verify.not.definitionLocationExists();
});
for (const marker of test.markerNames()) {
verify.goToDefinition(marker, []);
}

View File

@@ -6,7 +6,6 @@
////var t = /*true*/true;
////var f = /*false*/false;
test.markers().forEach((m, i, a) => {
goTo.position(m.position, m.fileName);
verify.not.definitionLocationExists();
});
for (const marker of test.markerNames()) {
verify.goToDefinition(marker, []);
}

View File

@@ -6,6 +6,4 @@
//// }
////}
goTo.marker("usage");
goTo.definition();
verify.caretAtMarker("definition");
verify.goToDefinition("usage", "definition");

View File

@@ -11,6 +11,4 @@
////
////var x = new /*usage*/Foo();
goTo.marker("usage");
goTo.definition();
verify.caretAtMarker("definition");
verify.goToDefinition("usage", "definition");

View File

@@ -9,14 +9,8 @@
////var constructorOverload = new /*constructorOverloadReference1*/ConstructorOverload();
////var constructorOverload = new /*constructorOverloadReference2*/ConstructorOverload("foo");
goTo.marker('constructorOverloadReference1');
goTo.definition();
verify.caretAtMarker('constructorOverload1');
goTo.marker('constructorOverloadReference2');
goTo.definition();
verify.caretAtMarker('constructorOverload2');
goTo.marker('constructorOverload1');
goTo.definition();
verify.caretAtMarker('constructorDefinition');
verify.goToDefinition({
constructorOverloadReference1: "constructorOverload1",
constructorOverloadReference2: "constructorOverload2",
constructorOverload1: "constructorDefinition"
});

View File

@@ -16,11 +16,7 @@
//// return target => target;
////}
goTo.marker('decoratorUse');
goTo.definition();
verify.caretAtMarker('decoratorDefinition');
goTo.marker('decoratorFactoryUse');
goTo.definition();
verify.caretAtMarker('decoratorFactoryDefinition');
verify.goToDefinition({
decoratorUse: "decoratorDefinition",
decoratorFactoryUse: "decoratorFactoryDefinition"
});

View File

@@ -14,16 +14,4 @@
////class fooCls implements /*remoteInterfaceReference*/remoteInterface { }
////var fooVar = /*remoteModuleReference*/remoteModule.foo;
var markerList = [
"remoteVariable",
"remoteFunction",
"remoteClass",
"remoteInterface",
"remoteModule",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("remoteVariable", "remoteFunction", "remoteClass", "remoteInterface", "remoteModule");

View File

@@ -21,16 +21,4 @@
////class rem2fooCls implements /*remoteInterfaceReference*/rem2Int { }
////var rem2fooVar = /*remoteModuleReference*/rem2Mod.foo;
var markerList = [
"remoteVariable",
"remoteFunction",
"remoteClass",
"remoteInterface",
"remoteModule",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("remoteVariable", "remoteFunction", "remoteClass", "remoteInterface", "remoteModule")

View File

@@ -7,6 +7,4 @@
// @Filename: a.ts
//// /*2*/export class Foo {}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

View File

@@ -8,6 +8,4 @@
/////*2*/class Foo {}
////export var x = 0;
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

View File

@@ -9,6 +9,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

View File

@@ -3,5 +3,4 @@
// @Filename: b.ts
////import n = require('unknown/*1*/');
goTo.marker('1');
verify.not.definitionLocationExists();
verify.goToDefinition("1", []);

View File

@@ -5,6 +5,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

View File

@@ -8,6 +8,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

View File

@@ -8,6 +8,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

View File

@@ -8,6 +8,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

View File

@@ -8,6 +8,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

View File

@@ -8,18 +8,9 @@
/////*functionOverloadReference2*/functionOverload("123");
/////*brokenOverload*/functionOverload({});
goTo.marker('functionOverloadReference1');
goTo.definition();
verify.caretAtMarker('functionOverload1');
goTo.marker('functionOverloadReference2');
goTo.definition();
verify.caretAtMarker('functionOverload2');
goTo.marker('brokenOverload');
goTo.definition();
verify.caretAtMarker('functionOverload1');
goTo.marker('functionOverload');
goTo.definition();
verify.caretAtMarker('functionOverloadDefinition');
verify.goToDefinition({
functionOverloadReference1: "functionOverload1",
functionOverloadReference2: "functionOverload2",
brokenOverload: "functionOverload1",
functionOverload: "functionOverloadDefinition"
});

View File

@@ -11,10 +11,7 @@
//// constructor() { }
////}
goTo.marker('staticFunctionOverload');
goTo.definition();
verify.caretAtMarker('staticFunctionOverloadDefinition');
goTo.marker('functionOverload');
goTo.definition();
verify.caretAtMarker('functionOverloadDefinition');
verify.goToDefinition({
staticFunctionOverload: "staticFunctionOverloadDefinition",
functionOverload: "functionOverloadDefinition"
});

View File

@@ -4,6 +4,4 @@
////}
////var implicitConstructor = new /*constructorReference*/ImplicitConstructor();
goTo.marker('constructorReference');
goTo.definition();
verify.caretAtMarker('constructorDefinition');
verify.goToDefinitionForMarkers("constructor");

View File

@@ -14,8 +14,5 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");

View File

@@ -14,8 +14,4 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");

View File

@@ -27,12 +27,4 @@
//// x;
////}
goTo.file("e.ts");
goTo.marker('classReference');
goTo.definition();
verify.caretAtMarker('classDefinition');
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition(["classReference", "classAliasDefinition"], "classDefinition");

View File

@@ -14,8 +14,4 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");

View File

@@ -14,8 +14,4 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");

View File

@@ -14,8 +14,4 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('moduleAliasDefinition');
goTo.definition();
verify.caretAtMarker('moduleDefinition');
verify.goToDefinition("moduleAliasDefinition", "moduleDefinition");

View File

@@ -10,8 +10,4 @@
////}
////export default Class;
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");

View File

@@ -19,35 +19,9 @@
//// }
////}
goTo.marker("interfaceReference");
goTo.definition();
verify.caretAtMarker("interfaceDefinition");
goTo.marker("interfaceReferenceInList");
goTo.definition();
verify.caretAtMarker("interfaceDefinition");
goTo.marker("interfaceReferenceInConstructor");
goTo.definition();
verify.caretAtMarker("interfaceDefinition");
goTo.marker("classReference");
goTo.definition();
verify.caretAtMarker("classDefinition");
goTo.marker("classReferenceInInitializer");
goTo.definition();
verify.caretAtMarker("classDefinition");
goTo.marker("enumReference");
goTo.definition();
verify.caretAtMarker("enumDefinition");
goTo.marker("enumReferenceInInitializer");
goTo.definition();
verify.caretAtMarker("enumDefinition");
goTo.marker("selfReference");
goTo.definition();
verify.caretAtMarker("selfDefinition");
verify.goToDefinition([
[["interfaceReference", "interfaceReferenceInList", "interfaceReferenceInConstructor"], "interfaceDefinition"],
[["classReference", "classReferenceInInitializer"], "classDefinition"],
[["enumReference", "enumReferenceInInitializer"], "enumDefinition"],
["selfReference", "selfDefinition"]
]);

View File

@@ -6,11 +6,4 @@
////
////var x = new Fo/*fooReference*/o<Ba/*barReference*/r>();
goTo.marker("barReference");
goTo.definition();
verify.caretAtMarker("barDefinition");
goTo.marker("fooReference");
goTo.definition();
verify.caretAtMarker("fooDefinition");
verify.goToDefinitionForMarkers("bar", "foo");

View File

@@ -11,6 +11,4 @@
//// }
////}
goTo.marker('interfaceReference');
goTo.definition();
verify.caretAtMarker('interfaceDefinition');
verify.goToDefinitionForMarkers("interface");

View File

@@ -9,19 +9,11 @@
//// }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('label1Definition');
goTo.marker('2');
goTo.definition();
verify.caretAtMarker('label2Definition');
// labels accross function bounderies
goTo.marker('3');
goTo.definition();
verify.caretAtMarker('label1Definition');
// undefined label
goTo.marker('4');
verify.not.definitionLocationExists();
verify.goToDefinition({
1: "label1Definition",
2: "label2Definition",
// labels accross function boundaries
3: "label1Definition",
// undefined label
4: []
});

View File

@@ -18,27 +18,11 @@
////methodOverload./*instanceMethodReference1*/method();
////methodOverload./*instanceMethodReference2*/method("456");
goTo.marker('staticMethodReference1');
goTo.definition();
verify.caretAtMarker('staticMethodOverload1');
goTo.marker('staticMethodReference2');
goTo.definition();
verify.caretAtMarker('staticMethodOverload2');
goTo.marker('instanceMethodReference1');
goTo.definition();
verify.caretAtMarker('instanceMethodOverload1');
goTo.marker('instanceMethodReference2');
goTo.definition();
verify.caretAtMarker('instanceMethodOverload2');
goTo.marker('staticMethodOverload1Name');
goTo.definition();
verify.caretAtMarker('staticMethodDefinition');
goTo.marker('instanceMethodOverload1Name');
goTo.definition();
verify.caretAtMarker('instanceMethodDefinition');
verify.goToDefinition({
staticMethodReference1: "staticMethodOverload1",
staticMethodReference2: "staticMethodOverload2",
instanceMethodReference1: "instanceMethodOverload1",
instanceMethodReference2: "instanceMethodOverload2",
staticMethodOverload1Name: "staticMethodDefinition",
instanceMethodOverload1Name: "instanceMethodDefinition"
});

View File

@@ -1,51 +1,34 @@
/// <reference path='fourslash.ts' />
// @Filename: a.ts
/////*interfaceDefintion1*/interface IFoo {
/////*interfaceDefinition1*/interface IFoo {
//// instance1: number;
////}
// @Filename: b.ts
/////*interfaceDefintion2*/interface IFoo {
/////*interfaceDefinition2*/interface IFoo {
//// instance2: number;
////}
////
/////*interfaceDefintion3*/interface IFoo {
/////*interfaceDefinition3*/interface IFoo {
//// instance3: number;
////}
////
////var ifoo: IFo/*interfaceReference*/o;
goTo.marker('interfaceReference');
goTo.definition(0);
verify.caretAtMarker('interfaceDefintion1');
goTo.marker('interfaceReference');
goTo.definition(1);
verify.caretAtMarker('interfaceDefintion2');
goTo.marker('interfaceReference');
goTo.definition(2);
verify.caretAtMarker('interfaceDefintion3');
verify.goToDefinition("interfaceReference", ["interfaceDefinition1", "interfaceDefinition2", "interfaceDefinition3"]);
// @Filename: c.ts
/////*moduleDefintion1*/module Module {
/////*moduleDefinition1*/module Module {
//// export class c1 { }
////}
// @Filename: d.ts
/////*moduleDefintion2*/module Module {
/////*moduleDefinition2*/module Module {
//// export class c2 { }
////}
// @Filename: e.ts
////Modul/*moduleReference*/e;
goTo.marker('moduleReference');
goTo.definition(0);
verify.caretAtMarker('moduleDefintion1');
goTo.marker('moduleReference');
goTo.definition(1);
verify.caretAtMarker('moduleDefintion2');
verify.goToDefinition("moduleReference", ["moduleDefinition1", "moduleDefinition2"]);

View File

@@ -8,7 +8,4 @@
////var foo: I;
////var { /*use*/property1: prop1 } = foo;
goTo.marker("use");
verify.definitionLocationExists();
goTo.definition();
verify.caretAtMarker("def");
verify.goToDefinition("use", "def");

View File

@@ -14,16 +14,4 @@
////o./*methodReference*/method;
////o./*es6StyleMethodReference*/es6StyleMethod;
var markerList = [
"value",
"getter",
"setter",
"method",
"es6StyleMethod",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("value", "getter", "setter", "method", "es6StyleMethod");

View File

@@ -11,6 +11,4 @@
////}
////A.B./*2*/f("");
goTo.marker("2");
goTo.definition();
verify.caretAtMarker("1");
verify.goToDefinition("2", "1");

View File

@@ -9,13 +9,11 @@
// @Filename: goToDefinitionPartialImplementation_2.ts
////module A {
//// export interface IA {
//// /*Part2Definition*/export interface IA {
//// x: number;
//// }
////
//// var x: /*Part2Use*/IA;
////}
goTo.marker('Part2Use');
goTo.definition();
verify.caretAtMarker('Part1Definition');
verify.goToDefinition("Part2Use", ["Part1Definition", "Part2Definition"]);

View File

@@ -2,7 +2,4 @@
////var x: st/*primitive*/ring;
goTo.marker("primitive");
verify.not.definitionLocationExists();
verify.goToDefinition("primitive", []);

View File

@@ -13,16 +13,4 @@
////class fooCls implements /*localInterfaceReference*/localInterface { }
////var fooVar = /*localModuleReference*/localModule.foo;
var markerList = [
"localVariable",
"localFunction",
"localClass",
"localInterface",
"localModule",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("localVariable", "localFunction", "localClass", "localInterface", "localModule");

View File

@@ -6,6 +6,4 @@
//// /*shadowVariableReference*/shadowVariable = 1;
////}
goTo.marker('shadowVariableReference');
goTo.definition();
verify.caretAtMarker('shadowVariableDefinition');
verify.goToDefinitionForMarkers("shadowVariable");

View File

@@ -5,6 +5,4 @@
//// /*shadowVariableReference*/shdVar = 1;
////}
goTo.marker('shadowVariableReference');
goTo.definition();
verify.caretAtMarker('shadowVariableDefinition');
verify.goToDefinitionForMarkers("shadowVariable");

View File

@@ -7,19 +7,9 @@
//// obj./*valueReference1*/name;
//// obj./*valueReference2*/id;
goTo.marker("valueDefinition1");
goTo.definition();
verify.caretAtMarker("valueDeclaration1");
goTo.marker("valueDefinition2");
goTo.definition(0);
verify.caretAtMarker("valueDeclaration2");
goTo.definition(1);
verify.caretAtMarker("valueDeclaration3");
goTo.marker("valueReference1");
goTo.definition();
verify.caretAtMarker("valueDefinition1");
goTo.marker("valueReference2");
goTo.definition();
verify.caretAtMarker("valueDefinition2");
verify.goToDefinition({
valueDefinition1: "valueDeclaration1",
valueDefinition2: ["valueDeclaration2", "valueDeclaration3"],
valueReference1: "valueDefinition1",
valueReference2: "valueDefinition2"
});

View File

@@ -4,5 +4,4 @@
//// f/*1*/oo
////}
goTo.marker("1");
verify.not.definitionLocationExists();
verify.goToDefinition("1", []);

View File

@@ -7,10 +7,7 @@
//// /*letProp*/y
////}
goTo.marker("varProp");
goTo.definition();
verify.caretAtMarker("varDef");
goTo.marker("letProp");
goTo.definition();
verify.caretAtMarker("letDef");
verify.goToDefinition({
varProp: "varDef",
letProp: "letDef"
});

View File

@@ -7,10 +7,4 @@
//// var n = new /*1*/c();
//// var n = new c/*3*/();
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
goTo.marker('3');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition(["1", "3"], "2");

View File

@@ -16,9 +16,7 @@
// @Filename: b.ts
/////*fileB*/
goTo.marker("unknownFile");
verify.not.definitionLocationExists();
goTo.marker("knownFile");
goTo.definition();
verify.caretAtMarker('fileB');
verify.goToDefinition({
unknownFile: [],
knownFile: "fileB"
});

View File

@@ -7,10 +7,7 @@
/////*useFNumber*/f`${0}`;
/////*useFBool*/f`${false}`;
goTo.marker("useFNumber");
goTo.definition();
verify.caretAtMarker("defFNumber");
goTo.marker("useFBool");
goTo.definition();
verify.caretAtMarker("defFBool");
verify.goToDefinition({
useFNumber: "defFNumber",
useFBool: "defFBool"
});

View File

@@ -1,6 +1,5 @@
/// <reference path='fourslash.ts'/>
// @noLib: true
////function f(/*fnDecl*/this: number) {
//// return /*fnUse*/this;
////}
@@ -9,12 +8,8 @@
//// get self(/*getterDecl*/this: number) { return /*getterUse*/this; }
////}
function verifyDefinition(a, b) {
goTo.marker(a);
goTo.definition();
verify.caretAtMarker(b);
}
verifyDefinition("fnUse", "fnDecl");
verifyDefinition("clsUse", "cls");
verifyDefinition("getterUse", "getterDecl");
verify.goToDefinition({
"fnUse": "fnDecl",
"clsUse": "cls",
"getterUse": "getterDecl"
});

View File

@@ -5,12 +5,7 @@
//// return typeof parameter === "string";
//// }
goTo.marker('parameterName');
goTo.definition();
verify.caretAtMarker('parameterDeclaration');
goTo.marker('typeReference');
goTo.definition();
verify.caretAtMarker('classDeclaration');
verify.goToDefinition({
parameterName: "parameterDeclaration",
typeReference: "classDeclaration"
});

View File

@@ -8,6 +8,4 @@
//// /// <reference types="lib/*1*/"/>
//// $.x;
goTo.marker("1");
goTo.definition();
verify.caretAtMarker("0");
verify.goToDefinition("1", "0");

View File

@@ -5,7 +5,6 @@
////var x = {}; x.some/*undefinedProperty*/Property;
////var a: any; a.some/*unkownProperty*/Property;
test.markers().forEach((m, i, a) => {
goTo.position(m.position, m.fileName);
verify.not.definitionLocationExists();
});
for (const marker of test.markerNames()) {
verify.goToDefinition(marker, []);
}

View File

@@ -15,12 +15,4 @@
////x./*propertyReference*/commonProperty;
////x./*3*/commonFunction;
goTo.marker("propertyReference");
verify.definitionCountIs(2);
goTo.definition(0);
verify.caretAtMarker("propertyDefinition1");
goTo.marker("propertyReference");
goTo.definition(1);
verify.caretAtMarker("propertyDefinition2");
verify.goToDefinition("propertyReference", ["propertyDefinition1", "propertyDefinition2"]);

View File

@@ -16,11 +16,4 @@
////
////x.common./*propertyReference*/a;
goTo.marker("propertyReference");
verify.definitionCountIs(2);
goTo.definition(0);
verify.caretAtMarker("propertyDefinition2");
goTo.marker("propertyReference");
goTo.definition(1);
verify.caretAtMarker("propertyDefinition1");
verify.goToDefinition("propertyReference", ["propertyDefinition2", "propertyDefinition1"]);

View File

@@ -9,7 +9,4 @@
////
////var x = (strings || numbers)./*usage*/specialPop()
goTo.marker("usage");
verify.definitionCountIs(1);
goTo.definition();
verify.caretAtMarker("definition");
verify.goToDefinition("usage", "definition");

View File

@@ -18,15 +18,4 @@
////
////var x = (snapcrackle || magnitude || art)./*usage*/pop;
goTo.marker("usage");
verify.definitionCountIs(3);
goTo.definition(0);
verify.caretAtMarker("def1");
goTo.marker("usage");
goTo.definition(1);
verify.caretAtMarker("def2");
goTo.marker("usage");
goTo.definition(2);
verify.caretAtMarker("def3");
verify.goToDefinition("usage", ["def1", "def2", "def3"]);

View File

@@ -19,15 +19,11 @@
//// }
////}
// Super in call position goes to constructor.
goTo.marker("super");
goTo.definition();
verify.caretAtMarker("ctr");
// Super in any other position goes to the superclass.
goTo.marker("superExpression");
goTo.definition();
verify.caretAtMarker("B");
goTo.marker("superBroken");
verify.definitionCountIs(0);
verify.goToDefinition({
// Super in call position goes to constructor.
super: "ctr",
// Super in any other position goes to the superclass.
superExpression: "B",
superBroken: []
});

View File

@@ -7,7 +7,5 @@
//// /*3*/import n = require('a');
//// var x = new /*1*/n.Foo();
goTo.marker('1');
goTo.definition();
// Won't-fixed: Should go to '2' instead
verify.caretAtMarker('3');
verify.goToDefinition("1", "3");

View File

@@ -6,6 +6,5 @@
goTo.marker();
verify.quickInfoIs("");
verify.verifyDefinitionsName("", "");
verify.typeDefinitionCountIs(0);
verify.goToDefinitionIs([]);
verify.referencesAre([]);

View File

@@ -15,10 +15,7 @@
//// x.alpha/*src1*/;
//// x.beta/*src2*/;
goTo.marker('src1');
goTo.definition();
verify.caretAtMarker('dst1');
goTo.marker('src2');
goTo.definition();
verify.caretAtMarker('dst2');
verify.goToDefinition({
src1: "dst1",
src2: "dst2"
});

View File

@@ -17,9 +17,7 @@
//// var [|/*dst*/nn|]: {name?: string; size?: number};
//// var x = <MyClass {...[|n/*src*/n|]}></MyClass>;
goTo.marker('src');
goTo.definition();
verify.caretAtMarker('dst');
verify.goToDefinition("src", "dst");
goTo.marker('src');
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);

View File

@@ -14,7 +14,6 @@ verify.quickInfoIs("var __proto__: M.__proto__", "");
goTo.marker('3');
verify.completionListContains("__proto__", "var __proto__: M.__proto__", "");
edit.insert("__proto__");
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinitionIs("2");
goTo.marker('4');
verify.quickInfoIs("var fun: (__proto__: any) => boolean", "");

View File

@@ -21,6 +21,4 @@ verify.occurrencesAtPositionContains(def);
verify.occurrencesAtPositionContains(imp);
verify.occurrencesAtPositionContains(mem);
goTo.definition();
verify.caretAtMarker('def');
verify.goToDefinitionIs("def");

View File

@@ -26,13 +26,11 @@ verify.navigationItemsListContains("foo", "const", "foo", "exact");
goTo.marker("foo_value");
verify.quickInfoIs("const foo: number");
goTo.definition();
verify.caretAtMarker("foo_value_declaration");
verify.goToDefinitionIs("foo_value_declaration");
goTo.marker("foo_type");
verify.quickInfoIs("import foo = require(\"foo_module\")");
goTo.definition();
verify.caretAtMarker("foo_type_declaration");
verify.goToDefinitionIs("foo_type_declaration");
// Above tested for global const and imported interface. Now test with global interface and imported const.
@@ -58,10 +56,8 @@ verify.navigationItemsListContains("bar", "interface", "bar", "exact");
goTo.marker("bar_value");
verify.quickInfoIs("import bar = require(\"bar_module\")");
goTo.definition();
verify.caretAtMarker("bar_value_declaration");
verify.goToDefinitionIs("bar_value_declaration");
goTo.marker("bar_type");
verify.quickInfoIs("interface bar");
goTo.definition();
verify.caretAtMarker("bar_type_declaration");
verify.goToDefinitionIs("bar_type_declaration");

View File

@@ -7,6 +7,4 @@
// @Filename: a.ts
//// /*2*/export class Foo {}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");

Some files were not shown because too many files have changed in this diff Show More