Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import error when exploring tables in pipelines that call segments #1074

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion packages/safe-ds-lang/src/language/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ export { locationToString, positionToString, rangeToString } from '../helpers/lo
// Messages
export * as messages from './runtime/messages.js';

// Constants
// Commands
export * as commands from './communication/commands.js';

// RPC
export * as rpc from './communication/rpc.js';

// Generation
export { CODEGEN_PREFIX } from './generation/safe-ds-python-generator.js';

// Dependencies
export const dependencies = {
'safe-ds-runner': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { TextDocument } from 'vscode-languageserver-textdocument';
const services = (await createSafeDsServices(NodeFileSystem)).SafeDs;
const documentBuilder = services.shared.workspace.DocumentBuilder;
const langiumDocuments = services.shared.workspace.LangiumDocuments;
const langiumDocumentFactory = services.shared.workspace.LangiumDocumentFactory;
const nameProvider = services.references.NameProvider;
const renameProvider = services.lsp.RenameProvider!;

Expand Down Expand Up @@ -258,11 +257,9 @@ describe('SafeDsRenameProvider', async () => {
}

// Add documents to workspace
const documents = descriptions.map((description) => {
const document = langiumDocumentFactory.fromString(description.originalContent, URI.parse(description.uri));
langiumDocuments.addDocument(document);
return document;
});
const documents = descriptions.map((description) =>
langiumDocuments.createDocument(URI.parse(description.uri), description.originalContent),
);
await documentBuilder.build(documents);

// Get the element to rename
Expand Down
17 changes: 11 additions & 6 deletions packages/safe-ds-vscode/src/extension/eda/apis/runnerApi.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Base64Image, Column, Profiling, ProfilingDetailStatistical, Table } from '@safe-ds/eda/types/state.js';
import { ast, messages, SafeDsServices } from '@safe-ds/lang';
import { AstNode, LangiumDocument } from 'langium';
import { ast, CODEGEN_PREFIX, messages, SafeDsServices } from '@safe-ds/lang';
import { LangiumDocument } from 'langium';
import * as vscode from 'vscode';
import crypto from 'crypto';
import { getPipelineDocument } from '../../mainClient.ts';
import { CODEGEN_PREFIX } from '../../../../../safe-ds-lang/src/language/generation/safe-ds-python-generator.ts';
import { safeDsLogger } from '../../helpers/logging.js';

export class RunnerApi {
services: SafeDsServices;
pipelinePath: vscode.Uri;
pipelineName: string;
pipelineNode: ast.SdsPipeline;
baseDocument: LangiumDocument<AstNode> | undefined;
baseDocument: LangiumDocument | undefined;
placeholderCounter = 0;

constructor(
Expand Down Expand Up @@ -52,12 +51,18 @@ export class RunnerApi {
const afterPipelineEnd = documentText.substring(endOfPipeline - 1);
const newDocumentText = beforePipelineEnd + addedLines + afterPipelineEnd;

const newDoc = this.services.shared.workspace.LangiumDocumentFactory.fromString(
newDocumentText,
this.services.shared.workspace.LangiumDocuments.deleteDocument(this.pipelinePath);
const newDoc = this.services.shared.workspace.LangiumDocuments.createDocument(
this.pipelinePath,
newDocumentText,
);
await this.services.shared.workspace.DocumentBuilder.build([newDoc]);

await this.services.runtime.Runner.executePipeline(pipelineExecutionId, newDoc, this.pipelineName);

this.services.shared.workspace.LangiumDocuments.deleteDocument(this.pipelinePath);
this.services.shared.workspace.LangiumDocuments.addDocument(this.baseDocument);

const runtimeCallback = (message: messages.RuntimeProgressMessage) => {
if (message.id !== pipelineExecutionId) {
return;
Expand Down