mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-24 04:30:53 -06:00
Fix to test harness and addressing CR comments
This commit is contained in:
parent
a71fa457bd
commit
2aa8f05e64
@ -536,7 +536,7 @@ namespace ts {
|
||||
|
||||
export function parseSourceFile(fileName: string, _sourceText: string, languageVersion: ScriptTarget, _syntaxCursor: IncrementalParser.SyntaxCursor, setParentNodes?: boolean, scriptKind?: ScriptKind): SourceFile {
|
||||
|
||||
const isJavaScriptFile = hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0 || scriptKind == ScriptKind.Js;
|
||||
const isJavaScriptFile = hasJavaScriptFileExtension(fileName) || _sourceText.lastIndexOf("// @language=javascript", 0) === 0 || scriptKind == ScriptKind.JS;
|
||||
|
||||
initializeState(fileName, _sourceText, languageVersion, isJavaScriptFile, _syntaxCursor);
|
||||
|
||||
|
||||
@ -2462,10 +2462,10 @@ namespace ts {
|
||||
|
||||
export const enum ScriptKind {
|
||||
Unknown = 0,
|
||||
Js = 1,
|
||||
Jsx = 2,
|
||||
Ts = 3,
|
||||
Tsx = 4
|
||||
JS = 1,
|
||||
JSX = 2,
|
||||
TS = 3,
|
||||
TSX = 4
|
||||
}
|
||||
|
||||
export const enum ScriptTarget {
|
||||
|
||||
@ -183,7 +183,7 @@ namespace Harness.LanguageService {
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? new ScriptSnapshot(script) : undefined;
|
||||
}
|
||||
getScriptKind(fileName: string): ScriptKind { return ScriptKind.Unknown; }
|
||||
getScriptKind(fileName: string): ts.ScriptKind { return ts.ScriptKind.Unknown; }
|
||||
getScriptVersion(fileName: string): string {
|
||||
const script = this.getScriptInfo(fileName);
|
||||
return script ? script.version.toString() : undefined;
|
||||
@ -254,7 +254,7 @@ namespace Harness.LanguageService {
|
||||
const nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName);
|
||||
return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot);
|
||||
}
|
||||
getScriptKind(fileName: string): ScriptKind { return this.nativeHost.getScriptKind(fileName); }
|
||||
getScriptKind(fileName: string): ts.ScriptKind { return this.nativeHost.getScriptKind(fileName); }
|
||||
getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); }
|
||||
getLocalizedDiagnosticMessages(): string { return JSON.stringify({}); }
|
||||
|
||||
|
||||
@ -1019,7 +1019,7 @@ namespace ts {
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
getScriptFileNames(): string[];
|
||||
getScriptKind(fileName: string): ScriptKind;
|
||||
getScriptKind?(fileName: string): ScriptKind;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): IScriptSnapshot;
|
||||
getLocalizedDiagnosticMessages?(): any;
|
||||
@ -1750,7 +1750,7 @@ namespace ts {
|
||||
|
||||
private createEntry(fileName: string, path: Path) {
|
||||
let entry: HostFileInformation;
|
||||
const scriptKind = this.host.getScriptKind(fileName);
|
||||
const scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : ScriptKind.Unknown;
|
||||
const scriptSnapshot = this.host.getScriptSnapshot(fileName);
|
||||
if (scriptSnapshot) {
|
||||
entry = {
|
||||
@ -1823,7 +1823,7 @@ namespace ts {
|
||||
throw new Error("Could not find file: '" + fileName + "'.");
|
||||
}
|
||||
|
||||
const scriptKind = this.host.getScriptKind(fileName);
|
||||
const scriptKind = this.host.getScriptKind ? this.host.getScriptKind(fileName) : ScriptKind.Unknown;
|
||||
const version = this.host.getScriptVersion(fileName);
|
||||
let sourceFile: SourceFile;
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ namespace ts {
|
||||
|
||||
/** Returns a JSON-encoded value of the type: string[] */
|
||||
getScriptFileNames(): string;
|
||||
getScriptKind(fileName: string): ScriptKind;
|
||||
getScriptKind?(fileName: string): ScriptKind;
|
||||
getScriptVersion(fileName: string): string;
|
||||
getScriptSnapshot(fileName: string): ScriptSnapshotShim;
|
||||
getLocalizedDiagnosticMessages(): string;
|
||||
@ -350,7 +350,8 @@ namespace ts {
|
||||
public getScriptKind(fileName: string): ScriptKind {
|
||||
try {
|
||||
return this.shimHost.getScriptKind(fileName);
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
return ScriptKind.Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user