Skip to content

Commit

Permalink
previously added assert was using wrong path (__dirname rather than _…
Browse files Browse the repository at this point in the history
…_dirname/..)

fixed the assert and added comments indicating what is supposed to point what.
  • Loading branch information
heejaechang committed Feb 11, 2020
1 parent b1e0ff8 commit bdcd372
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 0 additions & 2 deletions server/src/languageServerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {

import { AnalyzerService } from './analyzer/service';
import { CommandLineOptions } from './common/commandLineOptions';
import * as debug from './common/debug'
import { Diagnostic as AnalyzerDiagnostic, DiagnosticCategory } from './common/diagnostic';
import './common/extensions';
import { combinePaths, convertPathToUri, convertUriToPath, normalizePath } from './common/pathUtils';
Expand Down Expand Up @@ -61,7 +60,6 @@ export abstract class LanguageServerBase {
// virtual file system to be used. initialized to real file system by default. but can't be overritten
this.fs = createFromRealFileSystem(this.connection.console);
// Stash the base directory into a global variable.
debug.assertDefined(rootDirectory);
(global as any).__rootDirectory = rootDirectory;
this.connection.console.log(`Server root directory: ${ rootDirectory }`);

Expand Down
14 changes: 12 additions & 2 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ class Server extends LanguageServerBase {
private _controller: CommandController;

constructor() {
debug.assert(fs.existsSync(path.join(__dirname, 'typeshed-fallback')), 'Unable to locate typeshed fallback folder.');
super('Pyright', getDirectoryPath(__dirname));
// pyright has "typeshed-fallback" under "client" and __dirname points to "client/server"
// make sure root directory point to "client", one level up from "client/server" where we can discover
// "typeshed-fallback" folder. in release, root is "extension" instead of "client" but
// folder structure is same (extension/server).
//
// root directory will be used for 2 different purposes.
// 1. to find "typeshed-fallback" folder.
// 2. to set "cwd" to run python to find search path.
const rootDirectory = getDirectoryPath(__dirname);
debug.assert(fs.existsSync(path.join(rootDirectory, 'typeshed-fallback')), `Unable to locate typeshed fallback folder at '${ rootDirectory }'`);
super('Pyright', rootDirectory);

this._controller = new CommandController(this);
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/tests/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { TestWalker } from '../analyzer/testWalker';
import { cloneDiagnosticSettings, ConfigOptions, ExecutionEnvironment } from '../common/configOptions';
import { Diagnostic, DiagnosticCategory } from '../common/diagnostic';
import { DiagnosticSink, TextRangeDiagnosticSink } from '../common/diagnosticSink';
import { ParseOptions, Parser, ParseResults } from '../parser/parser';
import { createFromRealFileSystem } from '../common/vfs';
import { ParseOptions, Parser, ParseResults } from '../parser/parser';

// This is a bit gross, but it's necessary to allow the fallback typeshed
// directory to be located when running within the jest environment. This
Expand Down

0 comments on commit bdcd372

Please sign in to comment.