Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ public void setName(String name) {

public void setInterpreterFactory(InterpreterFactory factory) {
this.factory = factory;
synchronized (paragraphs) {
for (Paragraph p : paragraphs) {
p.setInterpreterFactory(factory);
}
}
}

public JobListenerFactory getJobListenerFactory() {
Expand Down Expand Up @@ -447,7 +452,6 @@ public void runAll() {
authenticationInfo.setUser(cronExecutingUser);
p.setAuthenticationInfo(authenticationInfo);

p.setInterpreterFactory(factory);
p.setListener(jobListenerFactory.getParagraphJobListener(this));
Interpreter intp = factory.getInterpreter(getId(), p.getRequiredReplName());

Expand All @@ -463,7 +467,6 @@ public void runAll() {
*/
public void run(String paragraphId) {
Paragraph p = getParagraph(paragraphId);
p.setInterpreterFactory(factory);
p.setListener(jobListenerFactory.getParagraphJobListener(this));
String requiredReplName = p.getRequiredReplName();
Interpreter intp = factory.getInterpreter(getId(), requiredReplName);
Expand Down Expand Up @@ -501,7 +504,6 @@ public boolean isTerminated() {

public List<InterpreterCompletion> completion(String paragraphId, String buffer, int cursor) {
Paragraph p = getParagraph(paragraphId);
p.setInterpreterFactory(factory);
p.setListener(jobListenerFactory.getParagraphJobListener(this));
List completion = p.completion(buffer, cursor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ public void testSelectingReplImplementation() throws IOException {
assertEquals("repl2: hello world", p2.getResult().message());
}

@Test
public void testReloadAndSetInterpreter() throws IOException {
// given a notebook
File srcDir = new File("src/test/resources/2A94M5J1Z");
File destDir = new File(notebookDir.getAbsolutePath() + "/2A94M5J1Z");
FileUtils.copyDirectory(srcDir, destDir);

// when load
notebook.reloadAllNotes(null);
assertEquals(1, notebook.getAllNotes().size());

// then interpreter factory should be injected into all the paragraphs
Note note = notebook.getAllNotes().get(0);
assertNull(note.getParagraphs().get(0).getRepl(null));
}

@Test
public void testReloadAllNotes() throws IOException {
File srcDir = new File("src/test/resources/2A94M5J1Z");
Expand Down