Skip to content

Commit de4de68

Browse files
authored
Merge pull request #352 from Systems-Modeling/ST6RI-531
ST6RI-531: Non-ASCII characters may not be parsed properly in Jupyter
2 parents 2098a7d + b14e16b commit de4de68

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

org.omg.sysml.jupyter.kernel/src/main/java/org/omg/sysml/jupyter/kernel/ISysML.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,17 @@ public class ISysML {
3535

3636
private static volatile SysMLKernel kernel;
3737

38+
public static void initialize() {
39+
kernel = new SysMLKernel();
40+
}
41+
3842
public static void main(String[] args) throws Exception {
3943
if (args.length < 1) {
4044
throw new IllegalArgumentException("Missing connection file argument");
4145
}
4246

47+
initialize();
48+
4349
Path connectionFile = Paths.get(args[0]);
4450

4551
if (!Files.isRegularFile(connectionFile))
@@ -52,8 +58,6 @@ public static void main(String[] args) throws Exception {
5258
KernelConnectionProperties connProps = KernelConnectionProperties.parse(contents);
5359
JupyterConnection connection = new JupyterConnection(connProps);
5460

55-
56-
kernel = new SysMLKernel();
5761
kernel.becomeHandlerForConnection(connection);
5862

5963
connection.connect();

org.omg.sysml.jupyter.kernel/src/main/java/org/omg/sysml/jupyter/kernel/SysMLKernel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public class SysMLKernel extends BaseKernel {
4545
private final Magics magics;
4646
private final MyMagicParser magicParser;
4747

48+
public Magics getMagics() {
49+
return magics;
50+
}
51+
4852
public SysMLKernel() {
4953
this.interactive = SysMLInteractive.getInstance();
5054
Optional<String> libraryPath = Optional.ofNullable(System.getenv(ISysML.LIBRARY_PATH_KEY));

org.omg.sysml/src/org/omg/sysml/util/SysMLUtil.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
* SysML 2 Pilot Implementation
3-
* Copyright (c) 2019, 2020 Model Driven Solutions, Inc.
3+
* Copyright (c) 2019-2022 Model Driven Solutions, Inc.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU Lesser General Public License as published by
@@ -38,6 +38,7 @@
3838
import org.eclipse.emf.ecore.util.EcoreUtil;
3939
import org.eclipse.xtext.resource.IResourceDescription.Manager;
4040
import org.eclipse.xtext.resource.IResourceServiceProvider;
41+
import org.eclipse.xtext.resource.XtextResource;
4142
import org.eclipse.xtext.resource.impl.ResourceDescriptionsData;
4243
import org.omg.sysml.lang.sysml.SysMLPackage;
4344

@@ -68,6 +69,7 @@ protected SysMLUtil() {
6869
protected SysMLUtil(ResourceDescriptionsData resourceDescriptionData) {
6970
SysMLPackage.eINSTANCE.getName();
7071
this.resourceSet = new ResourceSetImpl();
72+
this.resourceSet.getLoadOptions().put(XtextResource.OPTION_ENCODING, "UTF-8");
7173
this.index = resourceDescriptionData;
7274
ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(this.resourceSet, this.index);
7375
}
@@ -214,7 +216,7 @@ public void readAll(final File file, boolean isInput) {
214216
}
215217

216218
/**
217-
* If the given path identifies an file with an allowable extension, then read it.
219+
* If the given path identifies a file with an allowable extension, then read it.
218220
* If the given path is for a directory, then recursively read all the allowable files in it,
219221
* directly or indirectly.
220222
*

0 commit comments

Comments
 (0)