Skip to content

TEST. Ignore this PR. #53881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ interface ProjectNavigateToItems {
}

function createDocumentSpanSet(): Set<DocumentSpan> {
return createSet(({textSpan}) => textSpan.start + 100003 * textSpan.length, documentSpansEqual);
return createSet(({ textSpan }) => textSpan.start + 100003 * textSpan.length, documentSpansEqual);
}

function getRenameLocationsWorker(
Expand Down Expand Up @@ -2237,6 +2237,11 @@ export class Session<TMessage = string> implements EventSender {
}

private getCompletions(args: protocol.CompletionsRequestArgs, kind: protocol.CommandTypes.CompletionInfo | protocol.CommandTypes.Completions | protocol.CommandTypes.CompletionsFull): WithMetadata<readonly protocol.CompletionEntry[]> | protocol.CompletionInfo | CompletionInfo | undefined {
// Should always return true.
if (kind === "completionInfo" || kind === "completions" || kind === "completions-full") {
throw new Error('Test error message.');
}

const { file, project } = this.getFileAndProject(args);
const scriptInfo = this.projectService.getScriptInfoForNormalizedPath(file)!;
const position = this.getPosition(args, scriptInfo);
Expand Down Expand Up @@ -2515,6 +2520,20 @@ export class Session<TMessage = string> implements EventSender {
}

private getNavigateToItems(args: protocol.NavtoRequestArgs, simplifiedResult: boolean): readonly protocol.NavtoItem[] | readonly NavigateToItem[] {

function getRandomInt(max: number) {
return Math.floor(Math.random() * max);
}

const random = getRandomInt(2);

if (random == 0) {
throw new Error('This is error 0');
}
else if (random == 1) {
throw new Error('This is error 1');
}

const full = this.getFullNavigateToItems(args);
return !simplifiedResult ?
flatMap(full, ({ navigateToItems }) => navigateToItems) :
Expand Down Expand Up @@ -2769,7 +2788,7 @@ export class Session<TMessage = string> implements EventSender {
try {
codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, this.getFormatOptions(file), this.getPreferences(file));
}
catch(e) {
catch (e) {
const ls = project.getLanguageService();
const existingDiagCodes = [
...ls.getSyntacticDiagnostics(file),
Expand Down Expand Up @@ -3734,5 +3753,5 @@ function isCompletionEntryData(data: any): data is CompletionEntryData {
&& typeof data.exportName === "string"
&& (data.fileName === undefined || typeof data.fileName === "string")
&& (data.ambientModuleName === undefined || typeof data.ambientModuleName === "string"
&& (data.isPackageJsonImport === undefined || typeof data.isPackageJsonImport === "boolean"));
&& (data.isPackageJsonImport === undefined || typeof data.isPackageJsonImport === "boolean"));
}