Merge remote-tracking branch 'origin/release-2.0.5' into vladima/generate-protocol

This commit is contained in:
Vladimir Matveev 2016-10-12 10:02:53 -07:00
commit a1b94163f0
60 changed files with 2587 additions and 132 deletions

View File

@ -17,7 +17,6 @@ declare module "gulp-typescript" {
stripInternal?: boolean;
types?: string[];
}
interface CompileStream extends NodeJS.ReadWriteStream { } // Either gulp or gulp-typescript has some odd typings which don't reflect reality, making this required
}
import * as insert from "gulp-insert";
import * as sourcemaps from "gulp-sourcemaps";
@ -378,10 +377,10 @@ gulp.task(builtLocalCompiler, false, [servicesFile], () => {
return localCompilerProject.src()
.pipe(newer(builtLocalCompiler))
.pipe(sourcemaps.init())
.pipe(tsc(localCompilerProject))
.pipe(localCompilerProject())
.pipe(prependCopyright())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(builtLocalDirectory));
.pipe(gulp.dest("."));
});
gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
@ -389,7 +388,7 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
const {js, dts} = servicesProject.src()
.pipe(newer(servicesFile))
.pipe(sourcemaps.init())
.pipe(tsc(servicesProject));
.pipe(servicesProject());
const completedJs = js.pipe(prependCopyright())
.pipe(sourcemaps.write("."));
const completedDts = dts.pipe(prependCopyright(/*outputCopyright*/true))
@ -407,13 +406,13 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => {
file.path = nodeDefinitionsFile;
return content + "\r\nexport = ts;";
}))
.pipe(gulp.dest(builtLocalDirectory)),
.pipe(gulp.dest(".")),
completedDts.pipe(clone())
.pipe(insert.transform((content, file) => {
file.path = nodeStandaloneDefinitionsFile;
return content.replace(/declare (namespace|module) ts/g, 'declare module "typescript"');
}))
]).pipe(gulp.dest(builtLocalDirectory));
]).pipe(gulp.dest("."));
});
// cancellationToken.js
@ -423,7 +422,7 @@ gulp.task(cancellationTokenJs, false, [servicesFile], () => {
return cancellationTokenProject.src()
.pipe(newer(cancellationTokenJs))
.pipe(sourcemaps.init())
.pipe(tsc(cancellationTokenProject))
.pipe(cancellationTokenProject())
.pipe(prependCopyright())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(builtLocalDirectory));
@ -436,10 +435,10 @@ gulp.task(typingsInstallerJs, false, [servicesFile], () => {
return cancellationTokenProject.src()
.pipe(newer(typingsInstallerJs))
.pipe(sourcemaps.init())
.pipe(tsc(cancellationTokenProject))
.pipe(cancellationTokenProject())
.pipe(prependCopyright())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(builtLocalDirectory));
.pipe(gulp.dest("."));
});
const serverFile = path.join(builtLocalDirectory, "tsserver.js");
@ -449,10 +448,10 @@ gulp.task(serverFile, false, [servicesFile, typingsInstallerJs, cancellationToke
return serverProject.src()
.pipe(newer(serverFile))
.pipe(sourcemaps.init())
.pipe(tsc(serverProject))
.pipe(serverProject())
.pipe(prependCopyright())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(builtLocalDirectory));
.pipe(gulp.dest("."));
});
const tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js");
@ -463,14 +462,14 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => {
const {js, dts}: { js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream } = serverLibraryProject.src()
.pipe(sourcemaps.init())
.pipe(newer(tsserverLibraryFile))
.pipe(tsc(serverLibraryProject));
.pipe(serverLibraryProject());
return merge2([
js.pipe(prependCopyright())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(builtLocalDirectory)),
.pipe(gulp.dest(".")),
dts.pipe(prependCopyright())
.pipe(gulp.dest(builtLocalDirectory))
.pipe(gulp.dest("."))
]);
});
@ -542,9 +541,9 @@ gulp.task(run, false, [servicesFile], () => {
return testProject.src()
.pipe(newer(run))
.pipe(sourcemaps.init())
.pipe(tsc(testProject))
.pipe(testProject())
.pipe(sourcemaps.write(".", { includeContent: false, sourceRoot: "../../" }))
.pipe(gulp.dest(builtLocalDirectory));
.pipe(gulp.dest("."));
});
const internalTests = "internal/";
@ -723,16 +722,16 @@ declare module "convert-source-map" {
}
gulp.task("browserify", "Runs browserify on run.js to produce a file suitable for running tests in the browser", [servicesFile], (done) => {
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "built/local/bundle.js" }, /*useBuiltCompiler*/ true));
const testProject = tsc.createProject("src/harness/tsconfig.json", getCompilerSettings({ outFile: "../../built/local/bundle.js" }, /*useBuiltCompiler*/ true));
return testProject.src()
.pipe(newer("built/local/bundle.js"))
.pipe(sourcemaps.init())
.pipe(tsc(testProject))
.pipe(testProject())
.pipe(through2.obj((file, enc, next) => {
const originalMap = file.sourceMap;
const prebundledContent = file.contents.toString();
// Make paths absolute to help sorcery deal with all the terrible paths being thrown around
originalMap.sources = originalMap.sources.map(s => path.resolve("src", s));
originalMap.sources = originalMap.sources.map(s => path.resolve(s));
// intoStream (below) makes browserify think the input file is named this, so this is what it puts in the sourcemap
originalMap.file = "built/local/_stream_0.js";

View File

@ -2067,6 +2067,18 @@ namespace FourSlash {
}
}
public verifyNavigationTree(json: any) {
const tree = this.languageService.getNavigationTree(this.activeFile.fileName);
if (JSON.stringify(tree, replacer) !== JSON.stringify(json)) {
this.raiseError(`verifyNavigationTree failed - expected: ${stringify(json)}, got: ${stringify(tree, replacer)}`);
}
function replacer(key: string, value: any) {
// Don't check "spans", and omit falsy values.
return key === "spans" ? undefined : (value || undefined);
}
}
public printNavigationItems(searchValue: string) {
const items = this.languageService.getNavigateToItems(searchValue);
const length = items && items.length;
@ -3103,6 +3115,9 @@ namespace FourSlashInterface {
public navigationBar(json: any) {
this.state.verifyNavigationBar(json);
}
public navigationTree(json: any) {
this.state.verifyNavigationTree(json);
}
public navigationItemsListCount(count: number, searchValue: string, matchKind?: string) {
this.state.verifyNavigationItemsCount(count, searchValue, matchKind);

View File

@ -453,6 +453,10 @@ namespace Harness.LanguageService {
getNavigationBarItems(fileName: string): ts.NavigationBarItem[] {
return unwrapJSONCallResult(this.shim.getNavigationBarItems(fileName));
}
getNavigationTree(fileName: string): ts.NavigationTree {
return unwrapJSONCallResult(this.shim.getNavigationTree(fileName));
}
getOutliningSpans(fileName: string): ts.OutliningSpan[] {
return unwrapJSONCallResult(this.shim.getOutliningSpans(fileName));
}

View File

@ -5,7 +5,6 @@
"removeComments": true,
"preserveConstEnums": true,
"pretty": true,
"outDir": "../../../built/local",
"module": "commonjs",
"sourceMap": true,
"stripInternal": true,

View File

@ -460,7 +460,7 @@ namespace ts.server {
return this.lastRenameEntry.locations;
}
decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string, lineMap: number[]): NavigationBarItem[] {
private decodeNavigationBarItems(items: protocol.NavigationBarItem[], fileName: string, lineMap: number[]): NavigationBarItem[] {
if (!items) {
return [];
}
@ -469,10 +469,7 @@ namespace ts.server {
text: item.text,
kind: item.kind,
kindModifiers: item.kindModifiers || "",
spans: item.spans.map(span =>
createTextSpanFromBounds(
this.lineOffsetToPosition(fileName, span.start, lineMap),
this.lineOffsetToPosition(fileName, span.end, lineMap))),
spans: item.spans.map(span => this.decodeSpan(span, fileName, lineMap)),
childItems: this.decodeNavigationBarItems(item.childItems, fileName, lineMap),
indent: item.indent,
bolded: false,
@ -481,17 +478,37 @@ namespace ts.server {
}
getNavigationBarItems(fileName: string): NavigationBarItem[] {
const args: protocol.FileRequestArgs = {
file: fileName
};
const request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, args);
const request = this.processRequest<protocol.NavBarRequest>(CommandNames.NavBar, { file: fileName });
const response = this.processResponse<protocol.NavBarResponse>(request);
const lineMap = this.getLineMap(fileName);
return this.decodeNavigationBarItems(response.body, fileName, lineMap);
}
private decodeNavigationTree(tree: protocol.NavigationTree, fileName: string, lineMap: number[]): NavigationTree {
return {
text: tree.text,
kind: tree.kind,
kindModifiers: tree.kindModifiers,
spans: tree.spans.map(span => this.decodeSpan(span, fileName, lineMap)),
childItems: map(tree.childItems, item => this.decodeNavigationTree(item, fileName, lineMap))
};
}
getNavigationTree(fileName: string): NavigationTree {
const request = this.processRequest<protocol.NavTreeRequest>(CommandNames.NavTree, { file: fileName });
const response = this.processResponse<protocol.NavTreeResponse>(request);
const lineMap = this.getLineMap(fileName);
return this.decodeNavigationTree(response.body, fileName, lineMap);
}
private decodeSpan(span: protocol.TextSpan, fileName: string, lineMap: number[]) {
return createTextSpanFromBounds(
this.lineOffsetToPosition(fileName, span.start, lineMap),
this.lineOffsetToPosition(fileName, span.end, lineMap));
}
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan {
throw new Error("Not Implemented Yet.");
}

View File

@ -38,6 +38,8 @@ namespace ts.server.protocol {
export type Navto = "navto";
/* @internal */
export type NavtoFull = "navto-full";
export type NavTree = "navtree";
export type NavTreeFull = "navtree-full";
export type Occurrences = "occurrences";
export type DocumentHighlights = "documentHighlights";
/* @internal */
@ -74,6 +76,7 @@ namespace ts.server.protocol {
export type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full";
/* @internal */
export type Cleanup = "cleanup";
/* @internal */
export type OutliningSpans = "outliningSpans";
export type TodoComments = "todoComments";
export type Indentation = "indentation";
@ -211,7 +214,7 @@ namespace ts.server.protocol {
*/
export interface TodoCommentRequestArgs extends FileRequestArgs {
/**
* Array of target TodoCommentDescriptors that describes TODO comments to be found
* Array of target TodoCommentDescriptors that describes TODO comments to be found
*/
descriptors: TodoCommentDescriptor[];
}
@ -226,6 +229,7 @@ namespace ts.server.protocol {
/**
* Request to obtain outlining spans in file.
*/
/* @internal */
export interface OutliningSpansRequest extends FileRequest {
command: CommandTypes.OutliningSpans;
}
@ -233,6 +237,7 @@ namespace ts.server.protocol {
/**
* Response to OutliningSpansRequest request.
*/
/* @internal */
export interface OutliningSpansResponse extends Response {
body?: OutliningSpan[];
}
@ -376,7 +381,7 @@ namespace ts.server.protocol {
offset: number;
/**
* Position (can be specified instead of line/offset pair)
* Position (can be specified instead of line/offset pair)
*/
/* @internal */
position?: number;
@ -723,12 +728,12 @@ namespace ts.server.protocol {
/**
* Represents a file in external project.
* External project is project whose set of files, compilation options and open\close state
* External project is project whose set of files, compilation options and open\close state
* is maintained by the client (i.e. if all this data come from .csproj file in Visual Studio).
* External project will exist even if all files in it are closed and should be closed explicity.
* If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will
* If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will
* create configured project for every config file but will maintain a link that these projects were created
* as a result of opening external project so they should be removed once external project is closed.
* as a result of opening external project so they should be removed once external project is closed.
*/
export interface ExternalFile {
/**
@ -1121,7 +1126,7 @@ namespace ts.server.protocol {
}
/**
* Response for CompileOnSaveAffectedFileListRequest request;
* Response for CompileOnSaveAffectedFileListRequest request;
*/
export interface CompileOnSaveAffectedFileListResponse extends Response {
body: CompileOnSaveAffectedFileListSingleProject[];
@ -1877,6 +1882,14 @@ namespace ts.server.protocol {
command: CommandTypes.NavBar;
}
/**
* NavTree request; value of command field is "navtree".
* Return response giving the navigation tree of the requested file.
*/
export interface NavTreeRequest extends FileRequest {
command: CommandTypes.NavTree;
}
export interface NavigationBarItem {
/**
* The item's display text.
@ -1909,7 +1922,20 @@ namespace ts.server.protocol {
indent: number;
}
/** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */
export interface NavigationTree {
text: string;
kind: string;
kindModifiers: string;
spans: TextSpan[];
childItems?: NavigationTree[];
}
export interface NavBarResponse extends Response {
body?: NavigationBarItem[];
}
export interface NavTreeResponse extends Response {
body?: NavigationTree;
}
}

View File

@ -4,7 +4,7 @@ namespace ts.server {
export class ScriptInfo {
/**
* All projects that include this file
* All projects that include this file
*/
readonly containingProjects: Project[] = [];
private formatCodeSettings: ts.FormatCodeSettings;

View File

@ -96,6 +96,8 @@ namespace ts.server {
export const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync";
export const NavBar: protocol.CommandTypes.NavBar = "navbar";
export const NavBarFull: protocol.CommandTypes.NavBarFull = "navbar-full";
export const NavTree: protocol.CommandTypes.NavTree = "navtree";
export const NavTreeFull: protocol.CommandTypes.NavTreeFull = "navtree-full";
export const Navto: protocol.CommandTypes.Navto = "navto";
export const NavtoFull: protocol.CommandTypes.NavtoFull = "navto-full";
export const Occurrences: protocol.CommandTypes.Occurrences = "occurrences";
@ -525,7 +527,7 @@ namespace ts.server {
const scriptInfo = this.projectService.getScriptInfo(args.file);
projects = scriptInfo.containingProjects;
}
// ts.filter handles case when 'projects' is undefined
// ts.filter handles case when 'projects' is undefined
projects = filter(projects, p => p.languageServiceEnabled);
if (!projects || !projects.length) {
return Errors.ThrowNoProject();
@ -919,15 +921,8 @@ namespace ts.server {
return completions.entries.reduce((result: protocol.CompletionEntry[], entry: ts.CompletionEntry) => {
if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) {
const { name, kind, kindModifiers, sortText, replacementSpan } = entry;
let convertedSpan: protocol.TextSpan = undefined;
if (replacementSpan) {
convertedSpan = {
start: scriptInfo.positionToLineOffset(replacementSpan.start),
end: scriptInfo.positionToLineOffset(replacementSpan.start + replacementSpan.length)
};
}
const convertedSpan: protocol.TextSpan =
replacementSpan ? this.decorateSpan(replacementSpan, scriptInfo) : undefined;
result.push({ name, kind, kindModifiers, sortText, replacementSpan: convertedSpan });
}
return result;
@ -1065,38 +1060,54 @@ namespace ts.server {
this.projectService.closeClientFile(file);
}
private decorateNavigationBarItem(project: Project, fileName: NormalizedPath, items: ts.NavigationBarItem[]): protocol.NavigationBarItem[] {
if (!items) {
return undefined;
}
const scriptInfo = project.getScriptInfoForNormalizedPath(fileName);
return items.map(item => ({
private decorateNavigationBarItems(items: ts.NavigationBarItem[], scriptInfo: ScriptInfo): protocol.NavigationBarItem[] {
return map(items, item => ({
text: item.text,
kind: item.kind,
kindModifiers: item.kindModifiers,
spans: item.spans.map(span => ({
start: scriptInfo.positionToLineOffset(span.start),
end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span))
})),
childItems: this.decorateNavigationBarItem(project, fileName, item.childItems),
spans: item.spans.map(span => this.decorateSpan(span, scriptInfo)),
childItems: this.decorateNavigationBarItems(item.childItems, scriptInfo),
indent: item.indent
}));
}
private getNavigationBarItems(args: protocol.FileRequestArgs, simplifiedResult: boolean): protocol.NavigationBarItem[] | NavigationBarItem[] {
const { file, project } = this.getFileAndProject(args);
const items = project.getLanguageService().getNavigationBarItems(file);
if (!items) {
return undefined;
}
return simplifiedResult
? this.decorateNavigationBarItem(project, file, items)
const items = project.getLanguageService(/*ensureSynchronized*/ false).getNavigationBarItems(file);
return !items
? undefined
: simplifiedResult
? this.decorateNavigationBarItems(items, project.getScriptInfoForNormalizedPath(file))
: items;
}
private decorateNavigationTree(tree: ts.NavigationTree, scriptInfo: ScriptInfo): protocol.NavigationTree {
return {
text: tree.text,
kind: tree.kind,
kindModifiers: tree.kindModifiers,
spans: tree.spans.map(span => this.decorateSpan(span, scriptInfo)),
childItems: map(tree.childItems, item => this.decorateNavigationTree(item, scriptInfo))
};
}
private decorateSpan(span: TextSpan, scriptInfo: ScriptInfo): protocol.TextSpan {
return {
start: scriptInfo.positionToLineOffset(span.start),
end: scriptInfo.positionToLineOffset(ts.textSpanEnd(span))
};
}
private getNavigationTree(args: protocol.FileRequestArgs, simplifiedResult: boolean): protocol.NavigationTree | NavigationTree {
const { file, project } = this.getFileAndProject(args);
const tree = project.getLanguageService(/*ensureSynchronized*/ false).getNavigationTree(file);
return !tree
? undefined
: simplifiedResult
? this.decorateNavigationTree(tree, project.getScriptInfoForNormalizedPath(file))
: tree;
}
private getNavigateToItems(args: protocol.NavtoRequestArgs, simplifiedResult: boolean): protocol.NavtoItem[] | NavigateToItem[] {
const projects = this.getProjects(args);
@ -1183,19 +1194,11 @@ namespace ts.server {
const position = this.getPosition(args, scriptInfo);
const spans = project.getLanguageService(/*ensureSynchronized*/ false).getBraceMatchingAtPosition(file, position);
if (!spans) {
return undefined;
}
if (simplifiedResult) {
return spans.map(span => ({
start: scriptInfo.positionToLineOffset(span.start),
end: scriptInfo.positionToLineOffset(span.start + span.length)
}));
}
else {
return spans;
}
return !spans
? undefined
: simplifiedResult
? spans.map(span => this.decorateSpan(span, scriptInfo))
: spans;
}
getDiagnosticsForProject(delay: number, fileName: string) {
@ -1474,6 +1477,12 @@ namespace ts.server {
[CommandNames.NavBarFull]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getNavigationBarItems(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.NavTree]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getNavigationTree(request.arguments, /*simplifiedResult*/ true));
},
[CommandNames.NavTreeFull]: (request: protocol.FileRequest) => {
return this.requiredResponse(this.getNavigationTree(request.arguments, /*simplifiedResult*/ false));
},
[CommandNames.Occurrences]: (request: protocol.FileLocationRequest) => {
return this.requiredResponse(this.getOccurrences(request.arguments));
},

View File

@ -5,7 +5,7 @@
"removeComments": true,
"preserveConstEnums": true,
"pretty": true,
"out": "../../built/local/tsserver.js",
"outFile": "../../built/local/tsserver.js",
"sourceMap": true,
"stripInternal": true,
"types": [

View File

@ -3,7 +3,7 @@
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"out": "../../built/local/tsserverlibrary.js",
"outFile": "../../built/local/tsserverlibrary.js",
"sourceMap": true,
"stripInternal": true,
"declaration": true,

View File

@ -5,7 +5,7 @@
"removeComments": true,
"preserveConstEnums": true,
"pretty": true,
"out": "../../built/local/typingsInstaller.js",
"outFile": "../../../built/local/typingsInstaller.js",
"sourceMap": true,
"stripInternal": true,
"types": [

View File

@ -157,48 +157,49 @@ namespace ts.server {
}
};
}
function throwLanguageServiceIsDisabledError() {
function throwLanguageServiceIsDisabledError(): never {
throw new Error("LanguageService is disabled");
}
export const nullLanguageService: LanguageService = {
cleanupSemanticCache: (): any => throwLanguageServiceIsDisabledError(),
getSyntacticDiagnostics: (): any => throwLanguageServiceIsDisabledError(),
getSemanticDiagnostics: (): any => throwLanguageServiceIsDisabledError(),
getCompilerOptionsDiagnostics: (): any => throwLanguageServiceIsDisabledError(),
getSyntacticClassifications: (): any => throwLanguageServiceIsDisabledError(),
getEncodedSyntacticClassifications: (): any => throwLanguageServiceIsDisabledError(),
getSemanticClassifications: (): any => throwLanguageServiceIsDisabledError(),
getEncodedSemanticClassifications: (): any => throwLanguageServiceIsDisabledError(),
getCompletionsAtPosition: (): any => throwLanguageServiceIsDisabledError(),
findReferences: (): any => throwLanguageServiceIsDisabledError(),
getCompletionEntryDetails: (): any => throwLanguageServiceIsDisabledError(),
getQuickInfoAtPosition: (): any => throwLanguageServiceIsDisabledError(),
findRenameLocations: (): any => throwLanguageServiceIsDisabledError(),
getNameOrDottedNameSpan: (): any => throwLanguageServiceIsDisabledError(),
getBreakpointStatementAtPosition: (): any => throwLanguageServiceIsDisabledError(),
getBraceMatchingAtPosition: (): any => throwLanguageServiceIsDisabledError(),
getSignatureHelpItems: (): any => throwLanguageServiceIsDisabledError(),
getDefinitionAtPosition: (): any => throwLanguageServiceIsDisabledError(),
getRenameInfo: (): any => throwLanguageServiceIsDisabledError(),
getTypeDefinitionAtPosition: (): any => throwLanguageServiceIsDisabledError(),
getReferencesAtPosition: (): any => throwLanguageServiceIsDisabledError(),
getDocumentHighlights: (): any => throwLanguageServiceIsDisabledError(),
getOccurrencesAtPosition: (): any => throwLanguageServiceIsDisabledError(),
getNavigateToItems: (): any => throwLanguageServiceIsDisabledError(),
getNavigationBarItems: (): any => throwLanguageServiceIsDisabledError(),
getOutliningSpans: (): any => throwLanguageServiceIsDisabledError(),
getTodoComments: (): any => throwLanguageServiceIsDisabledError(),
getIndentationAtPosition: (): any => throwLanguageServiceIsDisabledError(),
getFormattingEditsForRange: (): any => throwLanguageServiceIsDisabledError(),
getFormattingEditsForDocument: (): any => throwLanguageServiceIsDisabledError(),
getFormattingEditsAfterKeystroke: (): any => throwLanguageServiceIsDisabledError(),
getDocCommentTemplateAtPosition: (): any => throwLanguageServiceIsDisabledError(),
isValidBraceCompletionAtPosition: (): any => throwLanguageServiceIsDisabledError(),
getEmitOutput: (): any => throwLanguageServiceIsDisabledError(),
getProgram: (): any => throwLanguageServiceIsDisabledError(),
getNonBoundSourceFile: (): any => throwLanguageServiceIsDisabledError(),
dispose: (): any => throwLanguageServiceIsDisabledError(),
cleanupSemanticCache: throwLanguageServiceIsDisabledError,
getSyntacticDiagnostics: throwLanguageServiceIsDisabledError,
getSemanticDiagnostics: throwLanguageServiceIsDisabledError,
getCompilerOptionsDiagnostics: throwLanguageServiceIsDisabledError,
getSyntacticClassifications: throwLanguageServiceIsDisabledError,
getEncodedSyntacticClassifications: throwLanguageServiceIsDisabledError,
getSemanticClassifications: throwLanguageServiceIsDisabledError,
getEncodedSemanticClassifications: throwLanguageServiceIsDisabledError,
getCompletionsAtPosition: throwLanguageServiceIsDisabledError,
findReferences: throwLanguageServiceIsDisabledError,
getCompletionEntryDetails: throwLanguageServiceIsDisabledError,
getQuickInfoAtPosition: throwLanguageServiceIsDisabledError,
findRenameLocations: throwLanguageServiceIsDisabledError,
getNameOrDottedNameSpan: throwLanguageServiceIsDisabledError,
getBreakpointStatementAtPosition: throwLanguageServiceIsDisabledError,
getBraceMatchingAtPosition: throwLanguageServiceIsDisabledError,
getSignatureHelpItems: throwLanguageServiceIsDisabledError,
getDefinitionAtPosition: throwLanguageServiceIsDisabledError,
getRenameInfo: throwLanguageServiceIsDisabledError,
getTypeDefinitionAtPosition: throwLanguageServiceIsDisabledError,
getReferencesAtPosition: throwLanguageServiceIsDisabledError,
getDocumentHighlights: throwLanguageServiceIsDisabledError,
getOccurrencesAtPosition: throwLanguageServiceIsDisabledError,
getNavigateToItems: throwLanguageServiceIsDisabledError,
getNavigationBarItems: throwLanguageServiceIsDisabledError,
getNavigationTree: throwLanguageServiceIsDisabledError,
getOutliningSpans: throwLanguageServiceIsDisabledError,
getTodoComments: throwLanguageServiceIsDisabledError,
getIndentationAtPosition: throwLanguageServiceIsDisabledError,
getFormattingEditsForRange: throwLanguageServiceIsDisabledError,
getFormattingEditsForDocument: throwLanguageServiceIsDisabledError,
getFormattingEditsAfterKeystroke: throwLanguageServiceIsDisabledError,
getDocCommentTemplateAtPosition: throwLanguageServiceIsDisabledError,
isValidBraceCompletionAtPosition: throwLanguageServiceIsDisabledError,
getEmitOutput: throwLanguageServiceIsDisabledError,
getProgram: throwLanguageServiceIsDisabledError,
getNonBoundSourceFile: throwLanguageServiceIsDisabledError,
dispose: throwLanguageServiceIsDisabledError,
};
export interface ServerLanguageServiceHost {
@ -245,7 +246,7 @@ namespace ts.server {
// another operation was already scheduled for this id - cancel it
this.host.clearTimeout(this.pendingTimeouts[operationId]);
}
// schedule new operation, pass arguments
// schedule new operation, pass arguments
this.pendingTimeouts[operationId] = this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb);
}

View File

@ -21,6 +21,13 @@ namespace ts.NavigationBar {
return result;
}
export function getNavigationTree(sourceFile: SourceFile): NavigationTree {
curSourceFile = sourceFile;
const result = convertToTree(rootNavigationBarNode(sourceFile));
curSourceFile = undefined;
return result;
}
// Keep sourceFile handy so we don't have to search for it every time we need to call `getText`.
let curSourceFile: SourceFile;
function nodeText(node: Node): string {
@ -503,6 +510,16 @@ namespace ts.NavigationBar {
// NavigationBarItem requires an array, but will not mutate it, so just give it this for performance.
const emptyChildItemArray: NavigationBarItem[] = [];
function convertToTree(n: NavigationBarNode): NavigationTree {
return {
text: getItemName(n.node),
kind: getNodeKind(n.node),
kindModifiers: getNodeModifiers(n.node),
spans: getSpans(n),
childItems: map(n.children, convertToTree)
};
}
function convertToTopLevelItem(n: NavigationBarNode): NavigationBarItem {
return {
text: getItemName(n.node),
@ -527,16 +544,16 @@ namespace ts.NavigationBar {
grayed: false
};
}
}
function getSpans(n: NavigationBarNode): TextSpan[] {
const spans = [getNodeSpan(n.node)];
if (n.additionalNodes) {
for (const node of n.additionalNodes) {
spans.push(getNodeSpan(node));
}
function getSpans(n: NavigationBarNode): TextSpan[] {
const spans = [getNodeSpan(n.node)];
if (n.additionalNodes) {
for (const node of n.additionalNodes) {
spans.push(getNodeSpan(node));
}
return spans;
}
return spans;
}
function getModuleName(moduleDeclaration: ModuleDeclaration): string {

View File

@ -1260,6 +1260,7 @@ namespace ts {
getNavigateToItems(searchValue: string, maxResultCount?: number, excludeDts?: boolean): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getNavigationTree(fileName: string): NavigationTree;
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
@ -1293,6 +1294,12 @@ namespace ts {
classificationType: string; // ClassificationTypeNames
}
/**
* Navigation bar interface designed for visual studio's dual-column layout.
* This does not form a proper tree.
* The navbar is returned as a list of top-level items, each of which has a list of child items.
* Child items always have an empty array for their `childItems`.
*/
export interface NavigationBarItem {
text: string;
kind: string;
@ -1304,6 +1311,26 @@ namespace ts {
grayed: boolean;
}
/**
* Node in a tree of nested declarations in a file.
* The top node is always a script or module node.
*/
export interface NavigationTree {
/** Name of the declaration, or a short description, e.g. "<class>". */
text: string;
/** A ScriptElementKind */
kind: string;
/** ScriptElementKindModifier separated by commas, e.g. "public,abstract" */
kindModifiers: string;
/**
* Spans of the nodes that generated this declaration.
* There will be more than one if this is the result of merging.
*/
spans: TextSpan[];
/** Present if non-empty */
childItems?: NavigationTree[];
}
export interface TodoCommentDescriptor {
text: string;
priority: number;
@ -7875,9 +7902,11 @@ namespace ts {
}
function getNavigationBarItems(fileName: string): NavigationBarItem[] {
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
return NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName));
}
return NavigationBar.getNavigationBarItems(sourceFile);
function getNavigationTree(fileName: string): NavigationTree {
return NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName));
}
function getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[] {
@ -8967,6 +8996,7 @@ namespace ts {
getRenameInfo,
findRenameLocations,
getNavigationBarItems,
getNavigationTree,
getOutliningSpans,
getTodoComments,
getBraceMatchingAtPosition,

View File

@ -218,6 +218,9 @@ namespace ts {
*/
getNavigationBarItems(fileName: string): string;
/** Returns a JSON-encoded value of the type ts.NavigationTree. */
getNavigationTree(fileName: string): string;
/**
* Returns a JSON-encoded value of the type:
* { textSpan: { start: number, length: number }; hintSpan: { start: number, length: number }; bannerText: string; autoCollapse: boolean } [] = [];
@ -937,6 +940,13 @@ namespace ts {
);
}
public getNavigationTree(fileName: string): string {
return this.forwardJSONCall(
`getNavigationTree('${fileName}')`,
() => this.languageService.getNavigationTree(fileName)
);
}
public getOutliningSpans(fileName: string): string {
return this.forwardJSONCall(
`getOutliningSpans('${fileName}')`,

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

@ -0,0 +1,814 @@
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 these methods to support completions for module specifiers.
* Without these methods, only completions for ambient modules will be provided.
*/
readDirectory?(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[];
readFile?(path: string, encoding?: string): string;
fileExists?(path: string): boolean;
/*
* LS host can optionally implement these methods to support automatic updating when new type libraries are installed
*/
getTypeRootsVersion?(): number;
/*
* 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 is also required for full import and type reference completions. Without it defined, certain
* completions will not be provided
*/
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;
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol;
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[];
getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[];
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, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getNavigationTree(fileName: string): NavigationTree;
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions | EditorSettings): number;
getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput;
getProgram(): Program;
/* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
/**
* @internal
* @deprecated Use ts.createSourceFile instead.
*/
getSourceFile(fileName: string): SourceFile;
dispose(): void;
}
export interface Classifications {
spans: number[];
endOfLineState: EndOfLineState;
}
export interface ClassifiedSpan {
textSpan: TextSpan;
classificationType: string; // ClassificationTypeNames
}
/**
* Navigation bar interface designed for visual studio's dual-column layout.
* This does not form a proper tree.
* The navbar is returned as a list of top-level items, each of which has a list of child items.
* Child items always have an empty array for their `childItems`.
*/
export interface NavigationBarItem {
text: string;
kind: string;
kindModifiers: string;
spans: TextSpan[];
childItems: NavigationBarItem[];
indent: number;
bolded: boolean;
grayed: boolean;
}
/**
* Node in a tree of nested declarations in a file.
* The top node is always a script or module node.
*/
export interface NavigationTree {
/** Name of the declaration, or a short description, e.g. "<class>". */
text: string;
/** A ScriptElementKind */
kind: string;
/** ScriptElementKindModifier separated by commas, e.g. "public,abstract" */
kindModifiers: string;
/**
* Spans of the nodes that generated this declaration.
* There will be more than one if this is the result of merging.
*/
spans: TextSpan[];
/** Present if non-empty */
childItems?: NavigationTree[];
}
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 ImplementationLocation {
textSpan: TextSpan;
fileName: string;
}
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 enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
}
/* @deprecated - consider using EditorSettings instead */
export interface EditorOptions {
BaseIndentSize?: number;
IndentSize: number;
TabSize: number;
NewLineCharacter: string;
ConvertTabsToSpaces: boolean;
IndentStyle: IndentStyle;
}
export interface EditorSettings {
baseIndentSize?: number;
indentSize: number;
tabSize: number;
newLineCharacter: string;
convertTabsToSpaces: boolean;
indentStyle: IndentStyle;
}
/* @deprecated - consider using FormatCodeSettings instead */
export interface FormatCodeOptions extends EditorOptions {
InsertSpaceAfterCommaDelimiter: boolean;
InsertSpaceAfterSemicolonInForStatements: boolean;
InsertSpaceBeforeAndAfterBinaryOperators: boolean;
InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
InsertSpaceAfterTypeAssertion?: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
}
export interface FormatCodeSettings extends EditorSettings {
insertSpaceAfterCommaDelimiter: boolean;
insertSpaceAfterSemicolonInForStatements: boolean;
insertSpaceBeforeAndAfterBinaryOperators: boolean;
insertSpaceAfterKeywordsInControlFlowStatements: boolean;
insertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: boolean;
insertSpaceAfterTypeAssertion?: boolean;
placeOpenBraceOnNewLineForFunctions: boolean;
placeOpenBraceOnNewLineForControlBlocks: boolean;
}
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 {
isGlobalCompletion: boolean;
isMemberCompletion: boolean;
/**
* true when the current location also allows for a new identifier
*/
isNewIdentifierLocation: boolean;
entries: CompletionEntry[];
}
export interface CompletionEntry {
name: string;
kind: string; // see ScriptElementKind
kindModifiers: string; // see ScriptElementKindModifier, comma separated
sortText: string;
/**
* An optional span that indicates the text to be replaced by this completion item. It will be
* set if the required span differs from the one generated by the default replacement behavior and should
* be used in that case
*/
replacementSpan?: TextSpan;
}
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;
}
// 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 const directory = "directory";
export const externalModuleName = "external module name";
}
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,
}
}

View File

@ -5,6 +5,32 @@
goTo.marker();
edit.deleteAtCaret('class Bar { }'.length);
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "Foo",
"kind": "enum",
"childItems": [
{
"text": "a",
"kind": "const"
},
{
"text": "b",
"kind": "const"
},
{
"text": "c",
"kind": "const"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -195,6 +195,7 @@ declare namespace FourSlashInterface {
noDocCommentTemplate(): void;
navigationBar(json: any): void;
navigationTree(json: any): void;
navigationItemsListCount(count: number, searchValue: string, matchKind?: string): void;
navigationItemsListContains(name: string, kind: string, searchValue: string, matchKind: string, fileName?: string, parentName?: string): void;
occurrencesAtPositionContains(range: Range, isWriteAccess?: boolean): void;

View File

@ -5,6 +5,27 @@
//// ["bar"]: string;
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "C",
"kind": "class",
"childItems": [
{
"text": "[\"bar\"]",
"kind": "property"
},
{
"text": "foo",
"kind": "property"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
@ -31,4 +52,4 @@ verify.navigationBar([
],
"indent": 1
}
])
]);

View File

@ -2,6 +2,17 @@
//// const c = 0;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "c",
"kind": "const"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -27,6 +27,83 @@
//// export var x = 3;
//// }
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "ABC",
"kind": "class",
"childItems": [
{
"text": "foo",
"kind": "method",
"kindModifiers": "public"
}
]
},
{
"text": "ABC",
"kind": "module",
"childItems": [
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
},
{
"text": "Windows",
"kind": "module",
"kindModifiers": "declare",
"childItems": [
{
"text": "Foundation",
"kind": "module",
"kindModifiers": "export,declare",
"childItems": [
{
"text": "A",
"kind": "var",
"kindModifiers": "export,declare"
},
{
"text": "B",
"kind": "var",
"kindModifiers": "export,declare"
},
{
"text": "Test",
"kind": "class",
"kindModifiers": "export,declare",
"childItems": [
{
"text": "wow",
"kind": "method",
"kindModifiers": "public,declare"
}
]
},
{
"text": "Test",
"kind": "module",
"kindModifiers": "export,declare",
"childItems": [
{
"text": "Boom",
"kind": "function",
"kindModifiers": "export,declare"
}
]
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -13,6 +13,17 @@
////export default function Func { }
goTo.file("a.ts");
verify.navigationTree({
"text": "\"a\"",
"kind": "module",
"childItems": [
{
"text": "default",
"kind": "class",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"a\"",
@ -34,6 +45,17 @@ verify.navigationBar([
]);
goTo.file("b.ts");
verify.navigationTree({
"text": "\"b\"",
"kind": "module",
"childItems": [
{
"text": "C",
"kind": "class",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"b\"",
@ -55,6 +77,17 @@ verify.navigationBar([
]);
goTo.file("c.ts");
verify.navigationTree({
"text": "\"c\"",
"kind": "module",
"childItems": [
{
"text": "default",
"kind": "function",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"c\"",
@ -76,6 +109,17 @@ verify.navigationBar([
]);
goTo.file("d.ts");
verify.navigationTree({
"text": "\"d\"",
"kind": "module",
"childItems": [
{
"text": "Func",
"kind": "function",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"d\"",

View File

@ -2,6 +2,17 @@
////let c = 0;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "c",
"kind": "let"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -26,6 +26,85 @@
//// (class { });
////})
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "<function>",
"kind": "function",
"childItems": [
{
"text": "nest",
"kind": "function",
"childItems": [
{
"text": "moreNest",
"kind": "function"
}
]
},
{
"text": "x",
"kind": "function",
"childItems": [
{
"text": "xx",
"kind": "function"
}
]
},
{
"text": "y",
"kind": "const",
"childItems": [
{
"text": "foo",
"kind": "function"
}
]
}
]
},
{
"text": "<function>",
"kind": "function",
"childItems": [
{
"text": "<function>",
"kind": "function"
},
{
"text": "z",
"kind": "function"
}
]
},
{
"text": "classes",
"kind": "function",
"childItems": [
{
"text": "<class>",
"kind": "class"
},
{
"text": "cls2",
"kind": "class"
},
{
"text": "cls3",
"kind": "class"
}
]
},
{
"text": "global.cls",
"kind": "class"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -3,6 +3,39 @@
////console.log(console.log(class Y {}, class X {}), console.log(class B {}, class A {}));
////console.log(class Cls { meth() {} });
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "A",
"kind": "class"
},
{
"text": "B",
"kind": "class"
},
{
"text": "Cls",
"kind": "class",
"childItems": [
{
"text": "meth",
"kind": "method"
}
]
},
{
"text": "X",
"kind": "class"
},
{
"text": "Y",
"kind": "class"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -8,6 +8,33 @@
//// }
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "X",
"kind": "class",
"childItems": [
{
"text": "x",
"kind": "getter"
},
{
"text": "x",
"kind": "setter",
"childItems": [
{
"text": "f",
"kind": "function"
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -4,6 +4,29 @@
////import c = require("m");
////import * as d from "m";
verify.navigationTree({
"text": "\"navigationBarImports\"",
"kind": "module",
"childItems": [
{
"text": "a",
"kind": "alias"
},
{
"text": "b",
"kind": "alias"
},
{
"text": "c",
"kind": "alias"
},
{
"text": "d",
"kind": "alias"
}
]
});
verify.navigationBar([
{
"text": "\"navigationBarImports\"",

View File

@ -6,6 +6,57 @@
////const bar1, [c, d]
////var {e, x: [f, g]} = {a:1, x:[]};
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "let"
},
{
"text": "b",
"kind": "let"
},
{
"text": "bar",
"kind": "var"
},
{
"text": "bar1",
"kind": "const"
},
{
"text": "c",
"kind": "const"
},
{
"text": "d",
"kind": "const"
},
{
"text": "e",
"kind": "var"
},
{
"text": "f",
"kind": "var"
},
{
"text": "foo",
"kind": "var"
},
{
"text": "foo1",
"kind": "let"
},
{
"text": "g",
"kind": "var"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -11,6 +11,41 @@
//// }
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "A",
"kind": "class",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
},
{
"text": "x",
"kind": "property"
}
]
},
{
"text": "B",
"kind": "class",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
},
{
"text": "x",
"kind": "property"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -5,6 +5,23 @@
//// }
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "Test",
"kind": "class",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -9,6 +9,26 @@
////
////export * from "a"; // no bindings here
verify.navigationTree({
"text": "\"navigationBarItemsExports\"",
"kind": "module",
"childItems": [
{
"text": "a",
"kind": "alias"
},
{
"text": "B",
"kind": "alias"
},
{
"text": "e",
"kind": "alias",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"navigationBarItemsExports\"",

View File

@ -14,6 +14,53 @@
//// var v = 10;
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "baz",
"kind": "function",
"childItems": [
{
"text": "v",
"kind": "var"
}
]
},
{
"text": "foo",
"kind": "function",
"childItems": [
{
"text": "bar",
"kind": "function",
"childItems": [
{
"text": "biz",
"kind": "function",
"childItems": [
{
"text": "z",
"kind": "var"
}
]
},
{
"text": "y",
"kind": "var"
}
]
},
{
"text": "x",
"kind": "var"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -4,6 +4,23 @@
//// function;
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "f",
"kind": "function",
"childItems": [
{
"text": "<function>",
"kind": "function"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -5,6 +5,27 @@
//// function;
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "<function>",
"kind": "function"
},
{
"text": "f",
"kind": "function",
"childItems": [
{
"text": "<function>",
"kind": "function"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -13,6 +13,44 @@
////
////import * as ns from "a";
verify.navigationTree({
"text": "\"navigationBarItemsImports\"",
"kind": "module",
"childItems": [
{
"text": "a",
"kind": "alias"
},
{
"text": "B",
"kind": "alias"
},
{
"text": "c",
"kind": "alias"
},
{
"text": "D",
"kind": "alias"
},
{
"text": "d1",
"kind": "alias"
},
{
"text": "d2",
"kind": "alias"
},
{
"text": "e",
"kind": "alias"
},
{
"text": "ns",
"kind": "alias"
}
]
});
verify.navigationBar([
{

View File

@ -18,6 +18,77 @@
//// emptyMethod() { } // Non child functions method should not be duplicated
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "Class",
"kind": "class",
"childItems": [
{
"text": "constructor",
"kind": "constructor",
"childItems": [
{
"text": "LocalEnumInConstructor",
"kind": "enum",
"childItems": [
{
"text": "LocalEnumMemberInConstructor",
"kind": "const"
}
]
},
{
"text": "LocalFunctionInConstructor",
"kind": "function"
},
{
"text": "LocalInterfaceInConstrcutor",
"kind": "interface"
}
]
},
{
"text": "emptyMethod",
"kind": "method"
},
{
"text": "method",
"kind": "method",
"childItems": [
{
"text": "LocalEnumInMethod",
"kind": "enum",
"childItems": [
{
"text": "LocalEnumMemberInMethod",
"kind": "const"
}
]
},
{
"text": "LocalFunctionInMethod",
"kind": "function",
"childItems": [
{
"text": "LocalFunctionInLocalFunctionInMethod",
"kind": "function"
}
]
},
{
"text": "LocalInterfaceInMethod",
"kind": "interface"
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -39,6 +39,114 @@
////var p: IPoint = new Shapes.Point(3, 4);
////var dist = p.getDist();
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "dist",
"kind": "var"
},
{
"text": "IPoint",
"kind": "interface",
"childItems": [
{
"text": "()",
"kind": "call"
},
{
"text": "new()",
"kind": "construct"
},
{
"text": "[]",
"kind": "index"
},
{
"text": "getDist",
"kind": "method"
},
{
"text": "prop",
"kind": "property"
}
]
},
{
"text": "p",
"kind": "var"
},
{
"text": "Shapes",
"kind": "module",
"childItems": [
{
"text": "Point",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
},
{
"text": "getDist",
"kind": "method"
},
{
"text": "getOrigin",
"kind": "method",
"kindModifiers": "private,static"
},
{
"text": "origin",
"kind": "property",
"kindModifiers": "static"
},
{
"text": "value",
"kind": "getter"
},
{
"text": "value",
"kind": "setter"
},
{
"text": "x",
"kind": "property",
"kindModifiers": "public"
},
{
"text": "y",
"kind": "property",
"kindModifiers": "public"
}
]
},
{
"text": "Values",
"kind": "enum",
"childItems": [
{
"text": "value1",
"kind": "const"
},
{
"text": "value2",
"kind": "const"
},
{
"text": "value3",
"kind": "const"
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -6,6 +6,22 @@ goTo.marker();
edit.insertLine("module A");
edit.insert("export class ");
verify.navigationTree({
"text": "\"navigationBarItemsItems2\"",
"kind": "module",
"childItems": [
{
"text": "<class>",
"kind": "class",
"kindModifiers": "export"
},
{
"text": "A",
"kind": "module"
}
]
});
// should not crash
verify.navigationBar([
{

View File

@ -4,6 +4,25 @@
//// public s: string;
////}
verify.navigationTree({
"text": "\"navigationBarItemsItemsExternalModules\"",
"kind": "module",
"childItems": [
{
"text": "Bar",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "s",
"kind": "property",
"kindModifiers": "public"
}
]
}
]
});
verify.navigationBar([
{
"text": "\"navigationBarItemsItemsExternalModules\"",

View File

@ -6,6 +6,30 @@
////}
////export var x: number;
verify.navigationTree({
"text": "\"file\"",
"kind": "module",
"childItems": [
{
"text": "Bar",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "s",
"kind": "property",
"kindModifiers": "public"
}
]
},
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"file\"",

View File

@ -6,6 +6,30 @@
////}
////export var x: number;
verify.navigationTree({
"text": "\"my fil\\\"e\"",
"kind": "module",
"childItems": [
{
"text": "Bar",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "s",
"kind": "property",
"kindModifiers": "public"
}
]
},
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"my fil\\\"e\"",

View File

@ -20,6 +20,23 @@
////}
goTo.marker("file1");
// nothing else should show up
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "Module1",
"kind": "module",
"childItems": [
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
@ -46,6 +63,23 @@ verify.navigationBar([
]);
goTo.marker("file2");
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "Module1.SubModule",
"kind": "module",
"childItems": [
{
"text": "y",
"kind": "var",
"kindModifiers": "export"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -3,6 +3,28 @@
//// foo() {}
////}
verify.navigationTree({
"text": "\"navigationBarItemsMissingName1\"",
"kind": "module",
"childItems": [
{
"text": "<function>",
"kind": "function",
"kindModifiers": "export"
},
{
"text": "C",
"kind": "class",
"childItems": [
{
"text": "foo",
"kind": "method"
}
]
}
]
});
verify.navigationBar([
{
"text": "\"navigationBarItemsMissingName1\"",

View File

@ -6,6 +6,23 @@
////}
// Anonymous classes are still included.
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "<class>",
"kind": "class",
"childItems": [
{
"text": "foo",
"kind": "method"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -27,6 +27,73 @@
//We have 8 module keywords, and 4 var keywords.
//The declarations of A.B.C.x do not get merged, so the 4 vars are independent.
//The two 'A' modules, however, do get merged, so in reality we have 7 modules.
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "'X2.Y2.Z2'",
"kind": "module",
"kindModifiers": "declare"
},
{
"text": "\"X.Y.Z\"",
"kind": "module",
"kindModifiers": "declare"
},
{
"text": "A",
"kind": "module",
"childItems": [
{
"text": "B",
"kind": "module",
"childItems": [
{
"text": "C",
"kind": "module",
"childItems": [
{
"text": "x",
"kind": "var",
"kindModifiers": "declare"
}
]
}
]
},
{
"text": "z",
"kind": "var",
"kindModifiers": "export"
}
]
},
{
"text": "A.B",
"kind": "module",
"childItems": [
{
"text": "y",
"kind": "var",
"kindModifiers": "export"
}
]
},
{
"text": "A.B.C",
"kind": "module",
"childItems": [
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -24,6 +24,56 @@
//// }
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "\"Multiline\\\nMadness\"",
"kind": "module",
"kindModifiers": "declare"
},
{
"text": "\"Multiline\\r\\nMadness\"",
"kind": "module",
"kindModifiers": "declare"
},
{
"text": "\"MultilineMadness\"",
"kind": "module",
"kindModifiers": "declare"
},
{
"text": "Bar",
"kind": "class",
"childItems": [
{
"text": "'a1\\\\\\r\\nb'",
"kind": "property"
},
{
"text": "'a2\\\n \\\n b'",
"kind": "method"
}
]
},
{
"text": "Foo",
"kind": "interface",
"childItems": [
{
"text": "\"a1\\\\\\r\\nb\"",
"kind": "property"
},
{
"text": "\"a2\\\n \\\n b\"",
"kind": "method"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -6,6 +6,43 @@
//// }
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "List",
"kind": "class",
"childItems": [
{
"text": "constructor",
"kind": "constructor",
"childItems": [
{
"text": "local",
"kind": "var"
}
]
},
{
"text": "a",
"kind": "property",
"kindModifiers": "public"
},
{
"text": "b",
"kind": "property",
"kindModifiers": "private"
},
{
"text": "c",
"kind": "property"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -6,6 +6,31 @@
//// get [Symbol.isConcatSpreadable]() { }
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "C",
"kind": "class",
"childItems": [
{
"text": "[Symbol.isConcatSpreadable]",
"kind": "getter"
},
{
"text": "[Symbol.isRegExp]",
"kind": "property"
},
{
"text": "[Symbol.iterator]",
"kind": "method"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -5,6 +5,27 @@
//// [Symbol.iterator](): string;
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "I",
"kind": "interface",
"childItems": [
{
"text": "[Symbol.isRegExp]",
"kind": "property"
},
{
"text": "[Symbol.iterator]",
"kind": "method"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -5,6 +5,17 @@
//// [Symbol.isRegExp] = 0
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "E",
"kind": "enum"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -2,6 +2,17 @@
////type T = number | string;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "T",
"kind": "type"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -5,6 +5,25 @@
/////** @typedef {(string|number)} */
////const x = 0;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "NumberLike",
"kind": "type"
},
{
"text": "x",
"kind": "const"
},
{
"text": "x",
"kind": "type"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -0,0 +1,30 @@
/// <reference path="fourslash.ts"/>
/////** Test */
////export const Test = {}
verify.navigationTree({
"text": "\"navigationBarJsDocCommentWithNoTags\"",
"kind": "module",
"childItems": [
{
"text": "Test",
"kind": "const",
"kindModifiers": "export"
}
]
});
verify.navigationBar([
{
"text": "\"navigationBarJsDocCommentWithNoTags\"",
"kind": "module",
"childItems": [
{
"text": "Test",
"kind": "const",
"kindModifiers": "export"
}
]
}
]);

View File

@ -11,6 +11,37 @@
//// function bar() {}
////}
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "module",
"childItems": [
{
"text": "bar",
"kind": "function"
},
{
"text": "foo",
"kind": "function"
}
]
},
{
"text": "b",
"kind": "module",
"childItems": [
{
"text": "foo",
"kind": "function"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
@ -60,6 +91,22 @@ verify.navigationBar([
////function a() {}
goTo.file("file2.ts");
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "function"
},
{
"text": "a",
"kind": "module"
}
]
});
verify.navigationBar([
{
"text": "<global>",
@ -101,6 +148,34 @@ verify.navigationBar([
////}
goTo.file("file3.ts");
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "module",
"childItems": [
{
"text": "A",
"kind": "interface",
"childItems": [
{
"text": "bar",
"kind": "property"
},
{
"text": "foo",
"kind": "property"
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",
@ -147,6 +222,36 @@ verify.navigationBar([
////module A.B { export var y; }
goTo.file("file4.ts");
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "A",
"kind": "module",
"childItems": [
{
"text": "x",
"kind": "var",
"kindModifiers": "export"
}
]
},
{
"text": "A.B",
"kind": "module",
"childItems": [
{
"text": "y",
"kind": "var",
"kindModifiers": "export"
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -1,4 +1,16 @@
////import *{} from 'foo';
verify.navigationTree({
"text": "\"navigationBarNamespaceImportWithNoName\"",
"kind": "module",
"childItems": [
{
"text": "<unknown>",
"kind": "alias"
}
]
});
verify.navigationBar([
{
"text": "\"navigationBarNamespaceImportWithNoName\"",

View File

@ -4,6 +4,25 @@
////let y = 1;
////const z = 2;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "x",
"kind": "var"
},
{
"text": "y",
"kind": "let"
},
{
"text": "z",
"kind": "const"
}
]
});
verify.navigationBar([
{
"text": "<global>",
@ -31,6 +50,26 @@ verify.navigationBar([
////const [c] = 0;
goTo.file("file2.ts");
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "a",
"kind": "var"
},
{
"text": "b",
"kind": "let"
},
{
"text": "c",
"kind": "const"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -10,6 +10,29 @@
//// /** @type {/*1*/NumberLike} */
//// var numberLike;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "numberLike",
"kind": "var"
},
{
"text": "NumberLike",
"kind": "type"
},
{
"text": "NumberLike2",
"kind": "var"
},
{
"text": "NumberLike2",
"kind": "type"
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -38,6 +38,114 @@
////var p: IPoint = new Shapes.Point(3, 4);
////var dist = p.getDist();
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "dist",
"kind": "var"
},
{
"text": "IPoint",
"kind": "interface",
"childItems": [
{
"text": "()",
"kind": "call"
},
{
"text": "new()",
"kind": "construct"
},
{
"text": "[]",
"kind": "index"
},
{
"text": "getDist",
"kind": "method"
},
{
"text": "prop",
"kind": "property"
}
]
},
{
"text": "p",
"kind": "var"
},
{
"text": "Shapes",
"kind": "module",
"childItems": [
{
"text": "Point",
"kind": "class",
"kindModifiers": "export",
"childItems": [
{
"text": "constructor",
"kind": "constructor"
},
{
"text": "getDist",
"kind": "method"
},
{
"text": "getOrigin",
"kind": "method",
"kindModifiers": "private,static"
},
{
"text": "origin",
"kind": "property",
"kindModifiers": "static"
},
{
"text": "value",
"kind": "getter"
},
{
"text": "value",
"kind": "setter"
},
{
"text": "x",
"kind": "property",
"kindModifiers": "public"
},
{
"text": "y",
"kind": "property",
"kindModifiers": "public"
}
]
},
{
"text": "Values",
"kind": "enum",
"childItems": [
{
"text": "value1",
"kind": "const"
},
{
"text": "value2",
"kind": "const"
},
{
"text": "value3",
"kind": "const"
}
]
}
]
}
]
});
verify.navigationBar([
{
"text": "<global>",

View File

@ -2,6 +2,17 @@
//// {| "itemName": "c", "kind": "const", "parentName": "" |}const c = 0;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "c",
"kind": "const"
}
]
})
verify.navigationBar([
{
"text": "<global>",

View File

@ -2,6 +2,17 @@
//// {| "itemName": "c", "kind": "const", "parentName": "" |}const c = 0;
verify.navigationTree({
"text": "<global>",
"kind": "script",
"childItems": [
{
"text": "c",
"kind": "const"
}
]
})
verify.navigationBar([
{
"text": "<global>",