Skip to content

Commit

Permalink
check for rope before creating temp file (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-mitrofanov-v authored Oct 19, 2023
1 parent 0d88f8f commit 4a5381a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/features/refactor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,15 @@ function validateDocumentForRefactor(doc: Document): Promise<void> {
}

export async function extractVariable(root: string, document: TextDocument, range: Range, outputChannel: OutputChannel): Promise<any> {
const doc = workspace.getDocument(document.uri);
const tempFile = await getTempFileWithDocumentContents(document);

const pythonToolsExecutionService = new PythonExecutionService();
const rope = await pythonToolsExecutionService.isModuleInstalled('rope');
if (!rope) {
window.showWarningMessage(`Module rope not installed`);
return;
}

const doc = workspace.getDocument(document.uri);
const tempFile = await getTempFileWithDocumentContents(document);
const workspaceFolder = workspace.getWorkspaceFolder(doc.uri);
const workspaceRoot = workspaceFolder ? Uri.parse(workspaceFolder.uri).fsPath : workspace.cwd;

Expand All @@ -232,16 +231,15 @@ export async function extractVariable(root: string, document: TextDocument, rang
}

export async function extractMethod(root: string, document: TextDocument, range: Range, outputChannel: OutputChannel): Promise<any> {
const doc = workspace.getDocument(document.uri);
const tempFile = await getTempFileWithDocumentContents(document);

const pythonToolsExecutionService = new PythonExecutionService();
const rope = await pythonToolsExecutionService.isModuleInstalled('rope');
if (!rope) {
window.showWarningMessage(`Module rope not installed`);
return;
}

const doc = workspace.getDocument(document.uri);
const tempFile = await getTempFileWithDocumentContents(document);
const workspaceFolder = workspace.getWorkspaceFolder(doc.uri);
const workspaceRoot = workspaceFolder ? Uri.parse(workspaceFolder.uri).fsPath : workspace.cwd;

Expand All @@ -258,16 +256,15 @@ export async function extractMethod(root: string, document: TextDocument, range:
}

export async function addImport(root: string, document: TextDocument, name: string, parent: boolean, outputChannel: OutputChannel): Promise<void> {
const doc = workspace.getDocument(document.uri);
const tempFile = await getTempFileWithDocumentContents(document);

const pythonToolsExecutionService = new PythonExecutionService();
const rope = await pythonToolsExecutionService.isModuleInstalled('rope');
if (!rope) {
window.showWarningMessage(`Module rope not installed`);
return;
}

const doc = workspace.getDocument(document.uri);
const tempFile = await getTempFileWithDocumentContents(document);
let parentModule = '';
if (parent) parentModule = await window.requestInput('Module:');

Expand Down

0 comments on commit 4a5381a

Please sign in to comment.