Skip to content

Commit 6336925

Browse files
committed
Merge pull request #3047 from bryanforbes/fix-tsserver-config-parse
ProjectService passing incorrect object to parseConfigFile()
2 parents ee4a15c + 884ca4e commit 6336925

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

src/server/editorServices.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ module ts.server {
398398

399399
export class ProjectService {
400400
filenameToScriptInfo: ts.Map<ScriptInfo> = {};
401-
// open, non-configured root files
401+
// open, non-configured root files
402402
openFileRoots: ScriptInfo[] = [];
403403
// projects built from openFileRoots
404404
inferredProjects: Project[] = [];
@@ -421,7 +421,7 @@ module ts.server {
421421
hostInfo: "Unknown host"
422422
}
423423
}
424-
424+
425425
getFormatCodeOptions(file?: string) {
426426
if (file) {
427427
var info = this.filenameToScriptInfo[file];
@@ -448,7 +448,7 @@ module ts.server {
448448
}
449449
}
450450
}
451-
451+
452452
log(msg: string, type = "Err") {
453453
this.psLogger.msg(msg, type);
454454
}
@@ -457,17 +457,17 @@ module ts.server {
457457
if (args.file) {
458458
var info = this.filenameToScriptInfo[args.file];
459459
if (info) {
460-
info.setFormatOptions(args.formatOptions);
460+
info.setFormatOptions(args.formatOptions);
461461
this.log("Host configuration update for file " + args.file, "Info");
462462
}
463463
}
464464
else {
465465
if (args.hostInfo !== undefined) {
466466
this.hostConfiguration.hostInfo = args.hostInfo;
467-
this.log("Host information " + args.hostInfo, "Info");
467+
this.log("Host information " + args.hostInfo, "Info");
468468
}
469469
if (args.formatOptions) {
470-
mergeFormatOptions(this.hostConfiguration.formatCodeOptions, args.formatOptions);
470+
mergeFormatOptions(this.hostConfiguration.formatCodeOptions, args.formatOptions);
471471
this.log("Format host information updated", "Info");
472472
}
473473
}
@@ -487,7 +487,7 @@ module ts.server {
487487

488488
fileDeletedInFilesystem(info: ScriptInfo) {
489489
this.psLogger.info(info.fileName + " deleted");
490-
490+
491491
if (info.fileWatcher) {
492492
info.fileWatcher.close();
493493
info.fileWatcher = undefined;
@@ -537,7 +537,7 @@ module ts.server {
537537
}
538538
return false;
539539
}
540-
540+
541541
addOpenFile(info: ScriptInfo) {
542542
if (this.setConfiguredProjectRoot(info)) {
543543
this.openFileRootsConfigured.push(info);
@@ -561,7 +561,7 @@ module ts.server {
561561
copyListRemovingItem(r.defaultProject, this.inferredProjects);
562562
// put r in referenced open file list
563563
this.openFilesReferenced.push(r);
564-
// set default project of r to the new project
564+
// set default project of r to the new project
565565
r.defaultProject = info.defaultProject;
566566
}
567567
else {
@@ -694,7 +694,7 @@ module ts.server {
694694
this.openFilesReferenced = openFilesReferenced;
695695

696696
// Then, loop through all of the open files that are project roots.
697-
// For each root file, note the project that it roots. Then see if
697+
// For each root file, note the project that it roots. Then see if
698698
// any other projects newly reference the file. If zero projects
699699
// newly reference the file, keep it as a root. If one or more
700700
// projects newly references the file, remove its project from the
@@ -719,7 +719,7 @@ module ts.server {
719719

720720
// Finally, if we found any open, referenced files that are no longer
721721
// referenced by their default project, treat them as newly opened
722-
// by the editor.
722+
// by the editor.
723723
for (var i = 0, len = unattachedOpenFiles.length; i < len; i++) {
724724
this.addOpenFile(unattachedOpenFiles[i]);
725725
}
@@ -809,7 +809,7 @@ module ts.server {
809809
}
810810
else {
811811
this.log("Opened configuration file " + configFileName,"Info");
812-
this.configuredProjects.push(configResult.project);
812+
this.configuredProjects.push(configResult.project);
813813
}
814814
}
815815
var info = this.openFile(fileName, true);
@@ -901,22 +901,22 @@ module ts.server {
901901
}
902902
return false;
903903
}
904-
904+
905905
openConfigFile(configFilename: string, clientFileName?: string): ProjectOpenResult {
906906
configFilename = ts.normalizePath(configFilename);
907907
// file references will be relative to dirPath (or absolute)
908908
var dirPath = ts.getDirectoryPath(configFilename);
909-
var rawConfig = <ProjectOptions>ts.readConfigFile(configFilename);
910-
if (!rawConfig) {
911-
return { errorMsg: "tsconfig syntax error" };
909+
var rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.readConfigFile(configFilename);
910+
if (rawConfig.error) {
911+
return rawConfig.error;
912912
}
913913
else {
914-
var parsedCommandLine = ts.parseConfigFile(rawConfig, ts.sys, dirPath);
914+
var parsedCommandLine = ts.parseConfigFile(rawConfig.config, ts.sys, dirPath);
915915
if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) {
916916
return { errorMsg: "tsconfig option errors" };
917917
}
918918
else if (parsedCommandLine.fileNames) {
919-
var projectOptions: ProjectOptions = {
919+
var projectOptions: ProjectOptions = {
920920
files: parsedCommandLine.fileNames,
921921
compilerOptions: parsedCommandLine.options
922922
};
@@ -1040,7 +1040,7 @@ module ts.server {
10401040
startPath: LineCollection[];
10411041
endBranch: LineCollection[] = [];
10421042
branchNode: LineNode;
1043-
// path to current node
1043+
// path to current node
10441044
stack: LineNode[];
10451045
state = CharRangeSection.Entire;
10461046
lineCollectionAtBranch: LineCollection;
@@ -1242,7 +1242,7 @@ module ts.server {
12421242
}
12431243
}
12441244

1245-
// text change information
1245+
// text change information
12461246
class TextChange {
12471247
constructor(public pos: number, public deleteLen: number, public insertedText?: string) {
12481248
}
@@ -1290,7 +1290,7 @@ module ts.server {
12901290
if (cb)
12911291
cb();
12921292
}
1293-
1293+
12941294
// reload whole script, leaving no change history behind reload
12951295
reload(script: string) {
12961296
this.currentVersion++;
@@ -1300,7 +1300,7 @@ module ts.server {
13001300
snap.index = new LineIndex();
13011301
var lm = LineIndex.linesFromText(script);
13021302
snap.index.load(lm.lines);
1303-
// REVIEW: could use linked list
1303+
// REVIEW: could use linked list
13041304
for (var i = this.minVersion; i < this.currentVersion; i++) {
13051305
this.versions[i] = undefined;
13061306
}
@@ -1381,7 +1381,7 @@ module ts.server {
13811381
return this.index.root.charCount();
13821382
}
13831383

1384-
// this requires linear space so don't hold on to these
1384+
// this requires linear space so don't hold on to these
13851385
getLineStartPositions(): number[] {
13861386
var starts: number[] = [-1];
13871387
var count = 1;
@@ -1643,7 +1643,7 @@ module ts.server {
16431643
}
16441644

16451645
walk(rangeStart: number, rangeLength: number, walkFns: ILineIndexWalker) {
1646-
// assume (rangeStart < this.totalChars) && (rangeLength <= this.totalChars)
1646+
// assume (rangeStart < this.totalChars) && (rangeLength <= this.totalChars)
16471647
var childIndex = 0;
16481648
var child = this.children[0];
16491649
var childCharCount = child.charCount();
@@ -1729,7 +1729,7 @@ module ts.server {
17291729
line: lineNumber,
17301730
offset: charOffset
17311731
}
1732-
}
1732+
}
17331733
else if (childInfo.child.isLeaf()) {
17341734
return {
17351735
line: lineNumber,
@@ -1917,4 +1917,4 @@ module ts.server {
19171917
return 1;
19181918
}
19191919
}
1920-
}
1920+
}

src/services/shims.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// Copyright (c) Microsoft Corporation. All rights reserved.
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
@@ -83,7 +83,7 @@ module ts {
8383
export interface Shim {
8484
dispose(dummy: any): void;
8585
}
86-
86+
8787
export interface LanguageServiceShim extends Shim {
8888
languageService: LanguageService;
8989

@@ -145,7 +145,7 @@ module ts {
145145
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
146146
*/
147147
getReferencesAtPosition(fileName: string, position: number): string;
148-
148+
149149
/**
150150
* Returns a JSON-encoded value of the type:
151151
* { definition: <encoded>; references: <encoded>[] }[]
@@ -162,8 +162,8 @@ module ts {
162162
/**
163163
* Returns a JSON-encoded value of the type:
164164
* { fileName: string; highlights: { start: number; length: number, isDefinition: boolean }[] }[]
165-
*
166-
* @param fileToSearch A JSON encoded string[] containing the file names that should be
165+
*
166+
* @param fileToSearch A JSON encoded string[] containing the file names that should be
167167
* considered when searching.
168168
*/
169169
getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string;
@@ -244,7 +244,7 @@ module ts {
244244

245245
export class LanguageServiceShimHostAdapter implements LanguageServiceHost {
246246
private files: string[];
247-
247+
248248
constructor(private shimHost: LanguageServiceShimHost) {
249249
}
250250

@@ -255,7 +255,7 @@ module ts {
255255
public trace(s: string): void {
256256
this.shimHost.trace(s);
257257
}
258-
258+
259259
public error(s: string): void {
260260
this.shimHost.error(s);
261261
}
@@ -322,7 +322,7 @@ module ts {
322322
}
323323
}
324324
}
325-
325+
326326
export class CoreServicesShimHostAdapter implements ParseConfigHost {
327327

328328
constructor(private shimHost: CoreServicesShimHost) {
@@ -587,7 +587,7 @@ module ts {
587587

588588
/**
589589
* Computes the definition location and file for the symbol
590-
* at the requested position.
590+
* at the requested position.
591591
*/
592592
public getDefinitionAtPosition(fileName: string, position: number): string {
593593
return this.forwardJSONCall(
@@ -601,7 +601,7 @@ module ts {
601601

602602
/**
603603
* Computes the definition location of the type of the symbol
604-
* at the requested position.
604+
* at the requested position.
605605
*/
606606
public getTypeDefinitionAtPosition(fileName: string, position: number): string {
607607
return this.forwardJSONCall(
@@ -684,8 +684,8 @@ module ts {
684684
/// COMPLETION LISTS
685685

686686
/**
687-
* Get a string based representation of the completions
688-
* to provide at the given source position and providing a member completion
687+
* Get a string based representation of the completions
688+
* to provide at the given source position and providing a member completion
689689
* list if requested.
690690
*/
691691
public getCompletionsAtPosition(fileName: string, position: number) {
@@ -883,7 +883,7 @@ module ts {
883883
return {
884884
options: configFile.options,
885885
files: configFile.fileNames,
886-
errors: realizeDiagnostics(configFile.errors, '\r\n')
886+
errors: [realizeDiagnostics(configFile.errors, '\r\n')]
887887
};
888888
});
889889
}

0 commit comments

Comments
 (0)