Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
d1da48b
update to use latest api
DonJayamanne Oct 3, 2017
15d8d35
Merge branch 'master' into 1228Multiroot
DonJayamanne Oct 4, 2017
b305a72
config changes for multiroot workspace
DonJayamanne Oct 5, 2017
674da9e
linting support with multi roots
DonJayamanne Oct 5, 2017
a549fc6
multi root support for formatters
DonJayamanne Oct 6, 2017
657e20f
determine workspace root path
DonJayamanne Oct 6, 2017
d492b5a
revert change
DonJayamanne Oct 6, 2017
c0c70fb
support multiple configs per workspace folder
DonJayamanne Oct 6, 2017
86e36c1
modify formatters to use resource specific settings
DonJayamanne Oct 6, 2017
c5cd8a9
modified installer to pass resource for workspace resolution
DonJayamanne Oct 9, 2017
663b345
null test in installer
DonJayamanne Oct 9, 2017
bcca381
canges to config settings to support multiroot workspace
DonJayamanne Oct 9, 2017
e3279cb
changes to code refactoring to support workspace symbols
DonJayamanne Oct 9, 2017
965eae9
oops
DonJayamanne Oct 9, 2017
234ff78
modified to settings are resolved using document uri
DonJayamanne Oct 9, 2017
e15e627
merged 1228Multiroot
DonJayamanne Oct 9, 2017
da4e2ab
unit tests for multi root support
DonJayamanne Oct 11, 2017
b575dcc
fix unittests for multiroot
DonJayamanne Oct 11, 2017
7457c89
exclude files
DonJayamanne Oct 11, 2017
54741c1
add new line
DonJayamanne Oct 11, 2017
ef306b0
config changes for multiroot workspace
DonJayamanne Oct 5, 2017
af113a4
installer, config changes with unit tests
DonJayamanne Oct 11, 2017
23ab751
new lines and enabled multi root linter tests
DonJayamanne Oct 11, 2017
b4295ef
fix sys variables
DonJayamanne Oct 12, 2017
360e919
added unit test to resolve ${workspaceRoot} in settings.json
DonJayamanne Oct 12, 2017
52e93c5
#1228 workspace symbols with multiroot support
DonJayamanne Oct 12, 2017
c2ba665
fix test
DonJayamanne Oct 12, 2017
e0f57ce
added some data for workspace symbol tests
DonJayamanne Oct 12, 2017
9e79d26
data for unit tests
DonJayamanne Oct 12, 2017
bbf2403
fixed to add support for multit roots with unit tests
DonJayamanne Oct 12, 2017
57ce355
account for mutiroot files in sub directory
DonJayamanne Oct 12, 2017
f044e27
disable all but multiroot tests
DonJayamanne Oct 12, 2017
99bf348
fixed tests
DonJayamanne Oct 12, 2017
45ac933
fix tests
DonJayamanne Oct 12, 2017
a2ba087
merged
DonJayamanne Oct 12, 2017
5a9a750
Merge branch '1228MultiRootMaster' into 1228FixTravisAndConfigSettings
DonJayamanne Oct 12, 2017
a819096
test where failing
DonJayamanne Oct 12, 2017
672d625
properly determine root workspace
DonJayamanne Oct 12, 2017
48ace91
fix pytest unit test
DonJayamanne Oct 12, 2017
61d7b8c
delete files
DonJayamanne Oct 12, 2017
fd812b7
Merge branch '1228MultiRootMaster' into 1228FixTravisAndConfigSettings
DonJayamanne Oct 12, 2017
fc10a55
add awaiter
DonJayamanne Oct 12, 2017
9ab5e14
use a path that works on multiple os
DonJayamanne Oct 12, 2017
fc66c9a
fixes
DonJayamanne Oct 13, 2017
121ff0f
uncomment
DonJayamanne Oct 13, 2017
6c01e78
invert
DonJayamanne Oct 13, 2017
b1b2677
debug statements
DonJayamanne Oct 13, 2017
76e4139
use default workspace
DonJayamanne Oct 13, 2017
35fba77
reverted unwanted changes
DonJayamanne Oct 13, 2017
22f0301
oops
DonJayamanne Oct 13, 2017
b9eaeaf
test unittests only
DonJayamanne Oct 13, 2017
1dd4cb4
more logging
DonJayamanne Oct 13, 2017
26a8fdc
partial fixes to unit tests
DonJayamanne Oct 13, 2017
75a9e7b
run all tests
DonJayamanne Oct 13, 2017
85c1085
changes not to set paths for shebang tests
DonJayamanne Oct 13, 2017
83e82e1
remove comments
DonJayamanne Oct 13, 2017
5101eb5
update settings only if necessary
DonJayamanne Oct 13, 2017
50e875c
fix test
DonJayamanne Oct 13, 2017
223b6dc
include files for tests
DonJayamanne Oct 13, 2017
67ec41e
Fixed travis tests for multi root workspace symbols (#1306)
DonJayamanne Oct 13, 2017
3da7274
merged
DonJayamanne Oct 13, 2017
158d837
merged fixes
DonJayamanne Oct 13, 2017
ee0003c
Added brackets around print statements (for p3)
DonJayamanne Oct 13, 2017
7a07dad
merged latest changes
DonJayamanne Oct 13, 2017
f4274c0
use resource when getting settings
DonJayamanne Oct 13, 2017
005f3f1
merged latest changes
DonJayamanne Oct 13, 2017
35b4818
support multiroot in language services
DonJayamanne Oct 13, 2017
a16bb33
merge latest
DonJayamanne Oct 13, 2017
dcf60fb
merge latest
DonJayamanne Oct 14, 2017
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
18 changes: 10 additions & 8 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

import * as vscode from 'vscode';
import { JediFactory } from './languageServices/jediProxyFactory';
import { PythonCompletionItemProvider } from './providers/completionProvider';
import { PythonHoverProvider } from './providers/hoverProvider';
import { PythonDefinitionProvider } from './providers/definitionProvider';
Expand Down Expand Up @@ -68,7 +69,8 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(activateUpdateSparkLibraryProvider());
activateSimplePythonRefactorProvider(context, formatOutChannel);
context.subscriptions.push(activateFormatOnSaveProvider(PYTHON, formatOutChannel));
context.subscriptions.push(activateGoToObjectDefinitionProvider(context));
const jediFactory = new JediFactory(context.asAbsolutePath('.'));
context.subscriptions.push(...activateGoToObjectDefinitionProvider(jediFactory));

context.subscriptions.push(vscode.commands.registerCommand(Commands.Start_REPL, () => {
getPathFromPythonCommand(["-c", "import sys;print(sys.executable)"]).catch(() => {
Expand Down Expand Up @@ -99,19 +101,19 @@ export async function activate(context: vscode.ExtensionContext) {
]
});

context.subscriptions.push(jediFactory);
context.subscriptions.push(vscode.languages.registerRenameProvider(PYTHON, new PythonRenameProvider(formatOutChannel)));
const definitionProvider = new PythonDefinitionProvider(context);
const jediProx = definitionProvider.JediProxy;
const definitionProvider = new PythonDefinitionProvider(jediFactory);
context.subscriptions.push(vscode.languages.registerDefinitionProvider(PYTHON, definitionProvider));
context.subscriptions.push(vscode.languages.registerHoverProvider(PYTHON, new PythonHoverProvider(context, jediProx)));
context.subscriptions.push(vscode.languages.registerReferenceProvider(PYTHON, new PythonReferenceProvider(context, jediProx)));
context.subscriptions.push(vscode.languages.registerCompletionItemProvider(PYTHON, new PythonCompletionItemProvider(context, jediProx), '.'));
context.subscriptions.push(vscode.languages.registerHoverProvider(PYTHON, new PythonHoverProvider(jediFactory)));
context.subscriptions.push(vscode.languages.registerReferenceProvider(PYTHON, new PythonReferenceProvider(jediFactory)));
context.subscriptions.push(vscode.languages.registerCompletionItemProvider(PYTHON, new PythonCompletionItemProvider(jediFactory), '.'));
context.subscriptions.push(vscode.languages.registerCodeLensProvider(PYTHON, new ShebangCodeLensProvider()))

const symbolProvider = new PythonSymbolProvider(context, jediProx);
const symbolProvider = new PythonSymbolProvider(jediFactory);
context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(PYTHON, symbolProvider));
if (pythonSettings.devOptions.indexOf('DISABLE_SIGNATURE') === -1) {
context.subscriptions.push(vscode.languages.registerSignatureHelpProvider(PYTHON, new PythonSignatureProvider(context, jediProx), '(', ','));
context.subscriptions.push(vscode.languages.registerSignatureHelpProvider(PYTHON, new PythonSignatureProvider(jediFactory), '(', ','));
}
if (pythonSettings.formatting.provider !== 'none') {
const formatProvider = new PythonFormattingEditProvider(context, formatOutChannel);
Expand Down
7 changes: 4 additions & 3 deletions src/client/jedi/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use strict";

import { SocketClient } from './socketClient';
import { SocketServer } from '../common/comms/socketServer';
import * as child_process from 'child_process';
import * as path from 'path';
import * as vscode from 'vscode';
import { SocketClient } from './socketClient';
import { SocketServer } from '../common/comms/socketServer';
import { createDeferred, Deferred } from '../common/helpers';
import { PythonSettings } from '../common/configSettings';
import { EventEmitter } from 'events';
Expand Down Expand Up @@ -80,7 +80,8 @@ export class ClientAdapter extends EventEmitter {
this.startSocketServer().then(port => {
const def = createDeferred<any>();
const options = { env: newEnv, cwd: this.rootDir };
this.process = child_process.spawn(PythonSettings.getInstance().pythonPath, [pyFile, port.toString()], options);
const rootDirUri = this.rootDir ? vscode.Uri.file(this.rootDir) : undefined;
this.process = child_process.spawn(PythonSettings.getInstance(rootDirUri).pythonPath, [pyFile, port.toString()], options);
this.process.stdout.setEncoding('utf8');
this.process.stderr.setEncoding('utf8');

Expand Down
8 changes: 3 additions & 5 deletions src/client/jedi/parsers/CompletionParser.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { CompletionItem, SymbolKind, SnippetString } from 'vscode';
import * as proxy from '../../providers/jediProxy';
import { extractSignatureAndDocumentation } from '../../providers/jediHelpers';
import { PythonSettings } from '../../common/configSettings';

const pythonSettings = PythonSettings.getInstance();
import { CompletionItem, SymbolKind, SnippetString, Uri } from 'vscode';

export class CompletionParser {
public static parse(data: proxy.ICompletionResult): CompletionItem[] {
public static parse(data: proxy.ICompletionResult, resource: Uri): CompletionItem[] {
if (!data || data.items.length === 0) {
return [];
}
Expand All @@ -16,7 +14,7 @@ export class CompletionParser {
completionItem.kind = item.type;
completionItem.documentation = sigAndDocs[1].length === 0 ? item.description : sigAndDocs[1];
completionItem.detail = sigAndDocs[0].split(/\r?\n/).join('');
if (pythonSettings.autoComplete.addBrackets === true &&
if (PythonSettings.getInstance(resource).autoComplete.addBrackets === true &&
(item.kind === SymbolKind.Function || item.kind === SymbolKind.Method)) {
completionItem.insertText = new SnippetString(item.text).appendText("(").appendTabstop().appendText(")");
}
Expand Down
38 changes: 38 additions & 0 deletions src/client/languageServices/jediProxyFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Disposable, Uri, workspace } from 'vscode';
import { JediProxy, JediProxyHandler, ICommandResult } from '../providers/jediProxy';

export class JediFactory implements Disposable {
private disposables: Disposable[];
private jediProxyHandlers: Map<string, JediProxyHandler<ICommandResult>>;

constructor(private extensionRootPath: string) {
this.disposables = [];
this.jediProxyHandlers = new Map<string, JediProxyHandler<ICommandResult>>();
}

public dispose() {
this.disposables.forEach(disposable => disposable.dispose());
this.disposables = [];
}
public getJediProxyHandler<T extends ICommandResult>(resource: Uri): JediProxyHandler<T> {
const workspaceFolder = workspace.getWorkspaceFolder(resource);
let workspacePath = workspaceFolder ? workspaceFolder.uri.fsPath : undefined;
if (!workspacePath) {
if (Array.isArray(workspace.workspaceFolders) && workspace.workspaceFolders.length > 0) {
workspacePath = workspace.workspaceFolders[0].uri.fsPath;
}
else {
workspacePath = __dirname;
}
}

if (!this.jediProxyHandlers.has(workspacePath)) {
const jediProxy = new JediProxy(this.extensionRootPath, workspacePath);
const jediProxyHandler = new JediProxyHandler(jediProxy);
this.disposables.push(jediProxy, jediProxyHandler);
this.jediProxyHandlers.set(workspacePath, jediProxyHandler);
}
// tslint:disable-next-line:no-non-null-assertion
return this.jediProxyHandlers.get(workspacePath)! as JediProxyHandler<T>;
}
}
18 changes: 7 additions & 11 deletions src/client/providers/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,21 @@ import * as telemetryContracts from '../common/telemetryContracts';
import { extractSignatureAndDocumentation } from './jediHelpers';
import { EOL } from 'os';
import { PythonSettings } from '../common/configSettings';
import { SnippetString } from 'vscode';

const pythonSettings = PythonSettings.getInstance();
import { SnippetString, Uri } from 'vscode';
import { JediFactory } from '../languageServices/jediProxyFactory';

export class PythonCompletionItemProvider implements vscode.CompletionItemProvider {
private jediProxyHandler: proxy.JediProxyHandler<proxy.ICompletionResult>;

public constructor(context: vscode.ExtensionContext, jediProxy: proxy.JediProxy = null) {
this.jediProxyHandler = new proxy.JediProxyHandler(context, jediProxy);
}
private static parseData(data: proxy.ICompletionResult): vscode.CompletionItem[] {
public constructor(private jediFactory: JediFactory) { }
private static parseData(data: proxy.ICompletionResult, resource: Uri): vscode.CompletionItem[] {
if (data && data.items.length > 0) {
return data.items.map(item => {
const sigAndDocs = extractSignatureAndDocumentation(item);
let completionItem = new vscode.CompletionItem(item.text);
completionItem.kind = item.type;
completionItem.documentation = sigAndDocs[1].length === 0 ? item.description : sigAndDocs[1];
completionItem.detail = sigAndDocs[0].split(/\r?\n/).join('');
if (pythonSettings.autoComplete.addBrackets === true &&
if (PythonSettings.getInstance(resource).autoComplete.addBrackets === true &&
(item.kind === vscode.SymbolKind.Function || item.kind === vscode.SymbolKind.Method)) {
completionItem.insertText = new SnippetString(item.text).appendText("(").appendTabstop().appendText(")");
}
Expand Down Expand Up @@ -67,10 +63,10 @@ export class PythonCompletionItemProvider implements vscode.CompletionItemProvid
};

const timer = new telemetryHelper.Delays();
return this.jediProxyHandler.sendCommand(cmd, token).then(data => {
return this.jediFactory.getJediProxyHandler<proxy.ICompletionResult>(document.uri).sendCommand(cmd, token).then(data => {
timer.stop();
telemetryHelper.sendTelemetryEvent(telemetryContracts.IDE.Completion, {}, timer.toMeasures());
const completions = PythonCompletionItemProvider.parseData(data);
const completions = PythonCompletionItemProvider.parseData(data, document.uri);
return completions;
});
}
Expand Down
14 changes: 4 additions & 10 deletions src/client/providers/definitionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,11 @@

import * as vscode from 'vscode';
import * as proxy from './jediProxy';
import * as telemetryContracts from "../common/telemetryContracts";
import * as telemetryContracts from '../common/telemetryContracts';
import { JediFactory } from '../languageServices/jediProxyFactory';

export class PythonDefinitionProvider implements vscode.DefinitionProvider {
private jediProxyHandler: proxy.JediProxyHandler<proxy.IDefinitionResult>;
public get JediProxy(): proxy.JediProxy {
return this.jediProxyHandler.JediProxy;
}

public constructor(context: vscode.ExtensionContext) {
this.jediProxyHandler = new proxy.JediProxyHandler(context);
}
public constructor(private jediFactory: JediFactory) { }
private static parseData(data: proxy.IDefinitionResult, possibleWord: string): vscode.Definition {
if (data && Array.isArray(data.definitions) && data.definitions.length > 0) {
const definitions = data.definitions.filter(d => d.text === possibleWord);
Expand Down Expand Up @@ -46,7 +40,7 @@ export class PythonDefinitionProvider implements vscode.DefinitionProvider {
cmd.source = document.getText();
}
let possibleWord = document.getText(range);
return this.jediProxyHandler.sendCommand(cmd, token).then(data => {
return this.jediFactory.getJediProxyHandler<proxy.IDefinitionResult>(document.uri).sendCommand(cmd, token).then(data => {
return PythonDefinitionProvider.parseData(data, possibleWord);
});
}
Expand Down
9 changes: 3 additions & 6 deletions src/client/providers/hoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ import * as vscode from 'vscode';
import * as proxy from './jediProxy';
import { highlightCode } from './jediHelpers';
import { EOL } from 'os';
import { JediFactory } from '../languageServices/jediProxyFactory';

export class PythonHoverProvider implements vscode.HoverProvider {
private jediProxyHandler: proxy.JediProxyHandler<proxy.IHoverResult>;

public constructor(context: vscode.ExtensionContext, jediProxy: proxy.JediProxy = null) {
this.jediProxyHandler = new proxy.JediProxyHandler(context, jediProxy);
}
public constructor(private jediFactory: JediFactory) { }
private static parseData(data: proxy.IHoverResult, currentWord: string): vscode.Hover {
let results = [];
let capturedInfo: string[] = [];
Expand Down Expand Up @@ -96,7 +93,7 @@ export class PythonHoverProvider implements vscode.HoverProvider {
cmd.source = document.getText();
}

const data = await this.jediProxyHandler.sendCommand(cmd, token);
const data = await this.jediFactory.getJediProxyHandler<proxy.IHoverResult>(document.uri).sendCommand(cmd, token);
if (!data || !data.items.length) {
return;
}
Expand Down
Loading