Skip to content

Commit

Permalink
Fix bug, remove unnecessary flag, fix hash comparison on Linux (#1734)
Browse files Browse the repository at this point in the history
* Undo changes

* Test fixes

* Increase timeout

* Remove double event listening

* Remove test

* Revert "Remove test"

This reverts commit e240c3f.

* Revert "Remove double event listening"

This reverts commit af573be.

* #1096 The if statement is automatically formatted incorrectly

* Merge fix

* Add more tests

* More tests

* Typo

* Test

* Also better handle multiline arguments

* Add a couple missing periods

[skip ci]

* Undo changes

* Test fixes

* Increase timeout

* Remove double event listening

* Remove test

* Revert "Remove test"

This reverts commit e240c3f.

* Revert "Remove double event listening"

This reverts commit af573be.

* Merge fix

* #1257 On type formatting errors for args and kwargs

* Handle f-strings

* Stop importing from test code

* #1308 Single line statements leading to an indentation on the next line

* #726 editing python after inline if statement invalid indent

* Undo change

* Move constant

* Harden LS startup error checks

* #1364 Intellisense doesn't work after specific const string

* Telemetry for the analysis enging

* PR feedback

* Fix typo

* Test baseline update

* Jedi 0.12

* Priority to goto_defition

* News

* Replace unzip

* Linux flavors + test

* Grammar check

* Grammar test

* Test baselines

* Add news

* Pin dependency

[skip ci]

* Specify markdown as preferable format

* Improve function argument detection

* Specify markdown

* Pythia setting

* Baseline updates

* Baseline update

* Improve startup

* Handle missing interpreter better

* Handle interpreter change

* Delete old file

* Fix LS startup time reporting

* Remove Async suffix from IFileSystem

* Remove Pythia

* Remove pre-packaged MSIL

* Exe name on Unix

* Plain linux

* Fix casing

* Fix message

* Update PTVS engine activation steps

* Type formatter eats space in from .

* fIX CASING

* Remove flag
  • Loading branch information
Mikhail Arkhipov authored May 23, 2018
1 parent 3877334 commit eee1529
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 31 deletions.
1 change: 0 additions & 1 deletion src/client/activation/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
maxDocumentationTextLength: 0
},
asyncStartup: true,
intelliCodeEnabled: settings.intelliCodeEnabled,
testEnvironment: isTestExecution()
}
};
Expand Down
24 changes: 0 additions & 24 deletions src/client/activation/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-analysis';
const downloadBaseFileName = 'Python-Analysis-VSCode';
const downloadVersion = '0.1.0';
const downloadFileExtension = '.nupkg';
const modelName = 'model-sequence.json.gz';

export class AnalysisEngineDownloader {
private readonly output: OutputChannel;
Expand Down Expand Up @@ -56,29 +55,6 @@ export class AnalysisEngineDownloader {
}
}

public async downloadIntelliCodeModel(context: ExtensionContext): Promise<void> {
const modelFolder = path.join(context.extensionPath, 'analysis', 'Pythia', 'model');
const localPath = path.join(modelFolder, modelName);
if (await this.fs.fileExists(localPath)) {
return;
}

let localTempFilePath = '';
try {
localTempFilePath = await this.downloadFile(downloadUriPrefix, modelName, 'Downloading IntelliCode Model File... ');
await this.fs.createDirectory(modelFolder);
await this.fs.copyFile(localTempFilePath, localPath);
} catch (err) {
this.output.appendLine('failed.');
this.output.appendLine(err);
throw new Error(err);
} finally {
if (localTempFilePath.length > 0) {
await this.fs.deleteFile(localTempFilePath);
}
}
}

private async downloadFile(location: string, fileName: string, title: string): Promise<string> {
const uri = `${location}/${fileName}`;
this.output.append(`Downloading ${uri}... `);
Expand Down
4 changes: 2 additions & 2 deletions src/client/activation/hashVerifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class HashVerifier {

readStream.pipe(hash);
await deferred.promise;
const actual = hash.read();
return expectedDigest === platformString ? true : actual === expectedDigest;
const actual = hash.read() as string;
return expectedDigest === platformString ? true : actual.toLowerCase() === expectedDigest.toLowerCase();
}
}
3 changes: 0 additions & 3 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const IS_WINDOWS = /^win/.test(process.platform);
// tslint:disable-next-line:completed-docs
export class PythonSettings extends EventEmitter implements IPythonSettings {
private static pythonSettings: Map<string, PythonSettings> = new Map<string, PythonSettings>();
public intelliCodeEnabled = true;
public downloadCodeAnalysis = true;
public jediEnabled = true;
public jediPath = '';
Expand Down Expand Up @@ -127,8 +126,6 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
this.jediPath = '';
}
this.jediMemoryLimit = pythonSettings.get<number>('jediMemoryLimit')!;
} else {
this.intelliCodeEnabled = systemVariables.resolveAny(pythonSettings.get<boolean>('intelliCodeEnabled', true))!;
}

// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion
Expand Down
1 change: 0 additions & 1 deletion src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export interface IPythonSettings {
readonly pythonPath: string;
readonly venvPath: string;
readonly venvFolders: string[];
readonly intelliCodeEnabled: boolean;
readonly downloadCodeAnalysis: boolean;
readonly jediEnabled: boolean;
readonly jediPath: string;
Expand Down
10 changes: 10 additions & 0 deletions src/client/formatters/lineFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export class LineFormatter {
private handleOperator(index: number): void {
const t = this.tokens.getItemAt(index);
const prev = index > 0 ? this.tokens.getItemAt(index - 1) : undefined;
const next = index < this.tokens.count - 1 ? this.tokens.getItemAt(index + 1) : undefined;

if (t.length === 1) {
const opCode = this.text.charCodeAt(t.start);
switch (opCode) {
Expand All @@ -107,6 +109,14 @@ export class LineFormatter {
}
break;
case Char.Period:
if (prev && this.isKeyword(prev, 'from')) {
this.builder.softAppendSpace();
}
this.builder.append(this.text[t.start]);
if (next && this.isKeyword(next, 'import')) {
this.builder.softAppendSpace();
}
return;
case Char.At:
case Char.ExclamationMark:
this.builder.append(this.text[t.start]);
Expand Down
9 changes: 9 additions & 0 deletions src/test/format/extension.lineFormatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ suite('Formatting - line formatter', () => {
test('Function returning tuple', () => {
testFormatLine('x,y=f(a)', 'x, y = f(a)');
});
test('from. import A', () => {
testFormatLine('from. import A', 'from . import A');
});
test('from .. import', () => {
testFormatLine('from ..import', 'from .. import');
});
test('from..x import', () => {
testFormatLine('from..x import', 'from ..x import');
});
test('Grammar file', () => {
const content = fs.readFileSync(grammarFile).toString('utf8');
const lines = content.splitLines({ trim: false, removeEmptyEntries: false });
Expand Down

0 comments on commit eee1529

Please sign in to comment.