Just use notImplemented

This commit is contained in:
Andy Hanson 2016-10-20 07:15:25 -07:00
parent 5e7e5421fa
commit ca970063a3
7 changed files with 26 additions and 31 deletions

View File

@ -872,16 +872,11 @@ namespace ts {
/** Does nothing. */
export function noop(): void {}
/** A function not intended to be implemented. */
/** Throws an error because a function is not implemented. */
export function notImplemented(): never {
throw new Error("Not implemented");
}
/** A function which isn't implemented, but should be eventually. */
export function notYetImplemented(): never {
throw new Error("TODO: Not yet implemented");
}
export function memoize<T>(callback: () => T): () => T {
let value: T;
return () => {

View File

@ -1668,7 +1668,7 @@ namespace Harness {
// This does not need to exist strictly speaking, but many tests will need to be updated if it's removed
export function compileString(_code: string, _unitName: string, _callback: (result: CompilerResult) => void) {
// NEWTODO: Re-implement 'compileString'
return ts.notYetImplemented();
return ts.notImplemented();
}
export interface GeneratedFile {

View File

@ -313,7 +313,7 @@ namespace Harness.LanguageService {
getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); }
readDirectory(_rootDir: string, _extension: string): string {
return ts.notYetImplemented();
return ts.notImplemented();
}
readDirectoryNames = ts.notImplemented;
readFileNames = ts.notImplemented;
@ -335,7 +335,7 @@ namespace Harness.LanguageService {
constructor(private shim: ts.ClassifierShim) {
}
getEncodedLexicalClassifications(_text: string, _lexState: ts.EndOfLineState, _classifyKeywordsInGenerics?: boolean): ts.Classifications {
return ts.notYetImplemented();
return ts.notImplemented();
}
getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult {
const result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split("\n");
@ -644,7 +644,7 @@ namespace Harness.LanguageService {
}
createDirectory(_directoryName: string): void {
return ts.notYetImplemented();
return ts.notImplemented();
}
getCurrentDirectory(): string {
@ -660,7 +660,7 @@ namespace Harness.LanguageService {
}
readDirectory(_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] {
return ts.notYetImplemented();
return ts.notImplemented();
}
watchFile(): ts.FileWatcher {

View File

@ -26,10 +26,10 @@ namespace ts {
return path in fileMap ? fileMap[path].content : undefined;
},
writeFile: (_path: string, _data: string, _writeByteOrderMark?: boolean) => {
return ts.notYetImplemented();
return ts.notImplemented();
},
resolvePath: (_path: string): string => {
return ts.notYetImplemented();
return ts.notImplemented();
},
fileExists: (path: string): boolean => {
return path in fileMap;
@ -47,7 +47,7 @@ namespace ts {
getDirectories: () => [],
getEnvironmentVariable: () => "",
readDirectory: (_path: string, _extension?: string[], _exclude?: string[], _include?: string[]): string[] => {
return ts.notYetImplemented();
return ts.notImplemented();
},
exit: noop,
watchFile: () => ({

View File

@ -111,7 +111,7 @@ namespace ts {
getDefaultLibFileName(): string {
return "lib.d.ts";
},
writeFile: notYetImplemented,
writeFile: notImplemented,
getCurrentDirectory(): string {
return "";
},

View File

@ -521,8 +521,8 @@ namespace ts.projectSystem {
readonly resolvePath = (s: string) => s;
readonly getExecutingFilePath = () => this.executingFilePath;
readonly getCurrentDirectory = () => this.currentDirectory;
readonly exit = notYetImplemented;
readonly getEnvironmentVariable = notYetImplemented;
readonly exit = notImplemented;
readonly getEnvironmentVariable = notImplemented;
}
export function makeSessionRequest<T>(command: string, args: T) {

View File

@ -242,7 +242,7 @@ namespace ts.server {
}
getCompletionEntrySymbol(_fileName: string, _position: number, _entryName: string): Symbol {
return notYetImplemented();
return notImplemented();
}
getNavigateToItems(searchValue: string): NavigateToItem[] {
@ -415,7 +415,7 @@ namespace ts.server {
}
getEmitOutput(_fileName: string): EmitOutput {
return notYetImplemented();
return notImplemented();
}
getSyntacticDiagnostics(fileName: string): Diagnostic[] {
@ -457,7 +457,7 @@ namespace ts.server {
}
getCompilerOptionsDiagnostics(): Diagnostic[] {
return notYetImplemented();
return notImplemented();
}
getRenameInfo(fileName: string, position: number, findInStrings?: boolean, findInComments?: boolean): RenameInfo {
@ -562,11 +562,11 @@ namespace ts.server {
}
getNameOrDottedNameSpan(_fileName: string, _startPos: number, _endPos: number): TextSpan {
return notYetImplemented();
return notImplemented();
}
getBreakpointStatementAtPosition(_fileName: string, _position: number): TextSpan {
return notYetImplemented();
return notImplemented();
}
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
@ -656,19 +656,19 @@ namespace ts.server {
}
getOutliningSpans(_fileName: string): OutliningSpan[] {
return notYetImplemented();
return notImplemented();
}
getTodoComments(_fileName: string, _descriptors: TodoCommentDescriptor[]): TodoComment[] {
return notYetImplemented();
return notImplemented();
}
getDocCommentTemplateAtPosition(_fileName: string, _position: number): TextInsertion {
return notYetImplemented();
return notImplemented();
}
isValidBraceCompletionAtPosition(_fileName: string, _position: number, _openingBrace: number): boolean {
return notYetImplemented();
return notImplemented();
}
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] {
@ -735,23 +735,23 @@ namespace ts.server {
}
getIndentationAtPosition(_fileName: string, _position: number, _options: EditorOptions): number {
return notYetImplemented();
return notImplemented();
}
getSyntacticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] {
return notYetImplemented();
return notImplemented();
}
getSemanticClassifications(_fileName: string, _span: TextSpan): ClassifiedSpan[] {
return notYetImplemented();
return notImplemented();
}
getEncodedSyntacticClassifications(_fileName: string, _span: TextSpan): Classifications {
return notYetImplemented();
return notImplemented();
}
getEncodedSemanticClassifications(_fileName: string, _span: TextSpan): Classifications {
return notYetImplemented();
return notImplemented();
}
getProgram(): Program {