Skip to content

Commit 6d00a3e

Browse files
authored
Add code gathering for single cell (#6803)
* Set up UI button * Add gather files * Set up sending messages from MainPanel to InteractiveWindow * Implement INotebookExecutionLogger interface * Cast vscodeLanguageClient.CompletionItem to any to fix build err * Add GatherExecution to ServiceRegistry * Correctly implement INotebookExecutionLogger * Make sure we get the same instance of GatherExecution * Works! * Fix bug in lexer * Use traceInfo and traceError instead of this.logger * Exclude functions which don't modify their args * Do not render gather button on edit cell * Add newline after each slice for readability * Ignore df.tail * Render gather button on all code cells * Parser TypeErrors on empty string * Open gathered code over origin file, another visible editor, or beside, never on top of, the interactive window * Update build script since settingregistry.d.ts for @jupyterlab/coreutils v3.0.0^ is different * Add traceInfo, rename executionLogger, add comment at top of gathered program * Bug fix, ensure that IPython get_ipython is imported * Fix bug where gathered code was opening on top of interactive window because Output:Tasks window shows up as visibleTextEditors[0] with viewColumn === undefined * Follow what's done in interactiveWindowCommandListener.viewDocument * Add function test * Get functional test passing * Wrap gatherCode function with public facing implementation * Add test for gather code button * Fix variable naming * Add functional test for code added from an editor * Allow users to edit default slicing rules via settings.json * Update test to pass in configService to gatherExecution * Fix naming convention * Don't parse code cells whose contents are just comments. Otherwise TypeError is thrown which pollutes the logs * Find uses in classes * Use the new MSR python-program-analysis npm package * Remove scripts for parser since we're using the npm package now * Bump @msrvida/python-program-analysis, remove unneeded dependencies * Postinstall script needs to look elsewhere for the settingregistry file * Use npm package for slicing functionality too * Restore strict mode * Remove unneeded code * Bump @msrvida/python-program/analysis version * Update to use Rich's new MockDocument constructor signature * Put gather single cell behind a feature flag * Update datascience dependencies * Remove extra comma * Move listening for gather feature flag change into GatherExecution * Fix breaking unit tests * Handle GatherCode message in a listener * Add reload button * Add news entry * Add to react helpers * Add more missing dom4 stuff * Fix failing functional test * Force version to be 0.1.0 * Use issue number
1 parent de7a909 commit 6d00a3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7809
-6819
lines changed

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"obj": true,
88
"bin": true,
99
"**/__pycache__": true,
10-
"node_modules": true,
1110
"**/.mypy_cache/**": true,
1211
"**/.ropeproject/**": true
1312
},

build/ci/postInstall.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33
'use strict';
4-
Object.defineProperty(exports, "__esModule", { value: true });
5-
const colors = require("colors/safe");
6-
const fs = require("fs");
7-
const path = require("path");
8-
const constants_1 = require("../constants");
4+
exports.__esModule = true;
5+
var colors = require("colors/safe");
6+
var fs = require("fs");
7+
var path = require("path");
8+
var constants_1 = require("../constants");
99
/**
1010
* In order to compile the extension in strict mode, one of the dependencies (@jupyterlab) has some files that
1111
* just won't compile in strict mode.
@@ -14,23 +14,29 @@ const constants_1 = require("../constants");
1414
* The solution is to modify the type definition file after `npm install`.
1515
*/
1616
function fixJupyterLabDTSFiles() {
17-
const relativePath = path.join('node_modules', '@jupyterlab', 'coreutils', 'lib', 'settingregistry.d.ts');
18-
const filePath = path.join(constants_1.ExtensionRootDir, relativePath);
17+
var relativePath = path.join('node_modules', '@jupyterlab', 'services', 'node_modules', '@jupyterlab', 'coreutils', 'lib', 'settingregistry.d.ts');
18+
var filePath = path.join(constants_1.ExtensionRootDir, relativePath);
1919
if (!fs.existsSync(filePath)) {
20-
throw new Error(`Type Definition file from JupyterLab not found '${filePath}' (pvsc post install script)`);
20+
throw new Error("Type Definition file from JupyterLab not found '" + filePath + "' (pvsc post install script)");
2121
}
22-
const fileContents = fs.readFileSync(filePath, { encoding: 'utf8' });
22+
var fileContents = fs.readFileSync(filePath, { encoding: 'utf8' });
2323
if (fileContents.indexOf('[key: string]: ISchema | undefined;') > 0) {
2424
// tslint:disable-next-line:no-console
25-
console.log(colors.blue(`${relativePath} file already updated (by Python VSC)`));
25+
console.log(colors.blue(relativePath + " file already updated (by Python VSC)"));
2626
return;
2727
}
28-
const replacedText = fileContents.replace('[key: string]: ISchema;', '[key: string]: ISchema | undefined;');
29-
if (fileContents === replacedText) {
30-
throw new Error('Fix for JupyterLabl file \'settingregistry.d.ts\' failed (pvsc post install script)');
28+
if (fileContents.indexOf('[key: string]: ISchema;') > 0) {
29+
var replacedText = fileContents.replace('[key: string]: ISchema;', '[key: string]: ISchema | undefined;');
30+
if (fileContents === replacedText) {
31+
throw new Error('Fix for JupyterLabl file \'settingregistry.d.ts\' failed (pvsc post install script)');
32+
}
33+
fs.writeFileSync(filePath, replacedText);
34+
// tslint:disable-next-line:no-console
35+
console.log(colors.green(relativePath + " file updated (by Python VSC)"));
36+
}
37+
else {
38+
// tslint:disable-next-line:no-console
39+
console.log(colors.red(relativePath + " file does not need updating."));
3140
}
32-
fs.writeFileSync(filePath, replacedText);
33-
// tslint:disable-next-line:no-console
34-
console.log(colors.green(`${relativePath} file updated (by Python VSC)`));
3541
}
3642
fixJupyterLabDTSFiles();

build/ci/postInstall.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { ExtensionRootDir } from '../constants';
1717
*/
1818
function fixJupyterLabDTSFiles() {
1919
const relativePath = path.join(
20+
'node_modules',
21+
'@jupyterlab',
22+
'services',
2023
'node_modules',
2124
'@jupyterlab',
2225
'coreutils',
@@ -36,13 +39,18 @@ function fixJupyterLabDTSFiles() {
3639
console.log(colors.blue(`${relativePath} file already updated (by Python VSC)`));
3740
return;
3841
}
39-
const replacedText = fileContents.replace('[key: string]: ISchema;', '[key: string]: ISchema | undefined;');
40-
if (fileContents === replacedText) {
41-
throw new Error('Fix for JupyterLabl file \'settingregistry.d.ts\' failed (pvsc post install script)');
42+
if (fileContents.indexOf('[key: string]: ISchema;') > 0) {
43+
const replacedText = fileContents.replace('[key: string]: ISchema;', '[key: string]: ISchema | undefined;');
44+
if (fileContents === replacedText) {
45+
throw new Error('Fix for JupyterLabl file \'settingregistry.d.ts\' failed (pvsc post install script)');
46+
}
47+
fs.writeFileSync(filePath, replacedText);
48+
// tslint:disable-next-line:no-console
49+
console.log(colors.green(`${relativePath} file updated (by Python VSC)`));
50+
} else {
51+
// tslint:disable-next-line:no-console
52+
console.log(colors.red(`${relativePath} file does not need updating.`));
4253
}
43-
fs.writeFileSync(filePath, replacedText);
44-
// tslint:disable-next-line:no-console
45-
console.log(colors.green(`${relativePath} file updated (by Python VSC)`));
4654
}
4755

4856
fixJupyterLabDTSFiles();

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ gulp.task('compile', done => {
7272
.on('error', () => (failed = true))
7373
.js.pipe(gulp.dest('out'))
7474
.on('finish', () => (failed ? done(new Error('TypeScript compilation errors')) : done()));
75-
});
75+
});
7676

7777
gulp.task('precommit', done => run({ exitOnError: true, mode: 'staged' }, done));
7878

news/1 Enhancements/6810.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add code gathering tools

0 commit comments

Comments
 (0)