|
|
95bc988 |
From 5adbd31eb97262e3d9bf0b3df71a4f248ade1d3d Mon Sep 17 00:00:00 2001
|
|
|
95bc988 |
From: Fabio Zadrozny <fabiofz@gmail.com>
|
|
|
95bc988 |
Date: Thu, 23 Jan 2020 10:05:30 -0300
|
|
|
95bc988 |
Subject: [PATCH] Update yaml to snakeyaml-engine.
|
|
|
95bc988 |
|
|
|
95bc988 |
---
|
|
|
95bc988 |
.../revisited/modules/AbstractModule.java | 3 +-
|
|
|
95bc988 |
.../pydev/debug/model/PyBreakpoint.java | 5 ++--
|
|
|
95bc988 |
.../pydev/debug/model/PyRunToLineTarget.java | 3 +-
|
|
|
95bc988 |
.../pydev/debug/model/PySetNextTarget.java | 6 ++--
|
|
|
95bc988 |
.../org.python.pydev.shared_core/.classpath | 2 +-
|
|
|
95bc988 |
.../META-INF/MANIFEST.MF | 4 +--
|
|
|
95bc988 |
.../build.properties | 9 +++---
|
|
|
95bc988 |
.../libs/README.txt | 10 ++++++-
|
|
|
95bc988 |
.../libs/snakeyaml-1.11.jar | Bin 270552 -> 0 bytes
|
|
|
95bc988 |
...snakeyaml-engine-2.1-20200105.160423-4.jar | Bin 0 -> 259565 bytes
|
|
|
95bc988 |
.../preferences/ScopedPreferences.java | 11 +++-----
|
|
|
95bc988 |
.../pydev/shared_core/yaml/YamlWrapper.java | 26 ++++++++++++++++--
|
|
|
95bc988 |
12 files changed, 53 insertions(+), 26 deletions(-)
|
|
|
95bc988 |
delete mode 100644 plugins/org.python.pydev.shared_core/libs/snakeyaml-1.11.jar
|
|
|
95bc988 |
create mode 100644 plugins/org.python.pydev.shared_core/libs/snakeyaml-engine-2.1-20200105.160423-4.jar
|
|
|
95bc988 |
|
|
|
95bc988 |
diff --git a/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PyBreakpoint.java b/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PyBreakpoint.java
|
|
|
95bc988 |
index ef32f96d4..1e1eee973 100644
|
|
|
95bc988 |
--- a/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PyBreakpoint.java
|
|
|
95bc988 |
+++ b/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PyBreakpoint.java
|
|
|
95bc988 |
@@ -137,7 +137,8 @@ private IPythonNature getPythonNature() {
|
|
|
95bc988 |
try {
|
|
|
95bc988 |
String externalPath = (String) marker.getAttribute(PyBreakpoint.PY_BREAK_EXTERNAL_PATH_ID);
|
|
|
95bc988 |
if (externalPath != null) {
|
|
|
95bc988 |
- Tuple<IPythonNature, String> infoForFile = InterpreterManagersAPI.getInfoForFile(new File(externalPath));
|
|
|
95bc988 |
+ Tuple<IPythonNature, String> infoForFile = InterpreterManagersAPI
|
|
|
95bc988 |
+ .getInfoForFile(new File(externalPath));
|
|
|
95bc988 |
if (infoForFile != null) {
|
|
|
95bc988 |
nature = infoForFile.o1;
|
|
|
95bc988 |
}
|
|
|
95bc988 |
@@ -272,7 +273,7 @@ public String getFunctionName() {
|
|
|
95bc988 |
//the ast manager is actually restored (so, modName is None, and we have little alternative
|
|
|
95bc988 |
//but making a parse to get the function name)
|
|
|
95bc988 |
IDocument doc = getDocument();
|
|
|
95bc988 |
- sourceModule = AbstractModule.createModuleFromDoc("", null, doc, nature, true);
|
|
|
95bc988 |
+ sourceModule = AbstractModule.createModuleFromDoc("", file, doc, nature, true);
|
|
|
95bc988 |
}
|
|
|
95bc988 |
|
|
|
95bc988 |
int lineToUse = getLineNumber() - 1;
|
|
|
95bc988 |
diff --git a/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PyRunToLineTarget.java b/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PyRunToLineTarget.java
|
|
|
95bc988 |
index 326f29acb..8b0ac59af 100644
|
|
|
95bc988 |
--- a/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PyRunToLineTarget.java
|
|
|
95bc988 |
+++ b/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PyRunToLineTarget.java
|
|
|
95bc988 |
@@ -26,7 +26,6 @@
|
|
|
95bc988 |
import org.python.pydev.parser.visitors.NodeUtils;
|
|
|
95bc988 |
import org.python.pydev.shared_core.string.FullRepIterable;
|
|
|
95bc988 |
|
|
|
95bc988 |
-
|
|
|
95bc988 |
public class PyRunToLineTarget implements IRunToLineTarget {
|
|
|
95bc988 |
|
|
|
95bc988 |
@Override
|
|
|
95bc988 |
@@ -71,7 +70,7 @@ public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume
|
|
|
95bc988 |
}
|
|
|
95bc988 |
|
|
|
95bc988 |
try {
|
|
|
95bc988 |
- sourceModule = (SourceModule) AbstractModule.createModuleFromDoc("", null, doc, nature, true);
|
|
|
95bc988 |
+ sourceModule = AbstractModule.createModuleFromDoc("", pyEdit.getEditorFile(), doc, nature, true);
|
|
|
95bc988 |
} catch (MisconfigurationException e) {
|
|
|
95bc988 |
Log.log(e);
|
|
|
95bc988 |
return;
|
|
|
95bc988 |
diff --git a/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PySetNextTarget.java b/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PySetNextTarget.java
|
|
|
95bc988 |
index 8ea27494f..36e2a6923 100644
|
|
|
95bc988 |
--- a/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PySetNextTarget.java
|
|
|
95bc988 |
+++ b/plugins/org.python.pydev.debug/src/org/python/pydev/debug/model/PySetNextTarget.java
|
|
|
95bc988 |
@@ -26,7 +26,6 @@
|
|
|
95bc988 |
import org.python.pydev.parser.visitors.NodeUtils;
|
|
|
95bc988 |
import org.python.pydev.shared_core.string.FullRepIterable;
|
|
|
95bc988 |
|
|
|
95bc988 |
-
|
|
|
95bc988 |
/**
|
|
|
95bc988 |
* @author Hussain Bohra
|
|
|
95bc988 |
*/
|
|
|
95bc988 |
@@ -38,7 +37,8 @@ public boolean canSetNextToLine(IWorkbenchPart part, ISelection selection, ISusp
|
|
|
95bc988 |
}
|
|
|
95bc988 |
|
|
|
95bc988 |
@Override
|
|
|
95bc988 |
- public boolean setNextToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException {
|
|
|
95bc988 |
+ public boolean setNextToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target)
|
|
|
95bc988 |
+ throws CoreException {
|
|
|
95bc988 |
// System.out.println("Run to line:"+target);
|
|
|
95bc988 |
PyStackFrame stack = null;
|
|
|
95bc988 |
if (target instanceof PyStackFrame) {
|
|
|
95bc988 |
@@ -74,7 +74,7 @@ public boolean setNextToLine(IWorkbenchPart part, ISelection selection, ISuspend
|
|
|
95bc988 |
}
|
|
|
95bc988 |
|
|
|
95bc988 |
try {
|
|
|
95bc988 |
- sourceModule = (SourceModule) AbstractModule.createModuleFromDoc("", null, doc, nature, true);
|
|
|
95bc988 |
+ sourceModule = AbstractModule.createModuleFromDoc("", pyEdit.getEditorFile(), doc, nature, true);
|
|
|
95bc988 |
} catch (MisconfigurationException e) {
|
|
|
95bc988 |
Log.log(e);
|
|
|
95bc988 |
return false;
|
|
|
95bc988 |
diff --git a/plugins/org.python.pydev.shared_core/.classpath b/plugins/org.python.pydev.shared_core/.classpath
|
|
|
95bc988 |
index f8225c656..1cdb88323 100644
|
|
|
95bc988 |
--- a/plugins/org.python.pydev.shared_core/.classpath
|
|
|
95bc988 |
+++ b/plugins/org.python.pydev.shared_core/.classpath
|
|
|
95bc988 |
@@ -2,7 +2,7 @@
|
|
|
95bc988 |
<classpath>
|
|
|
95bc988 |
<classpathentry kind="src" path="src"/>
|
|
|
95bc988 |
<classpathentry kind="src" path="tests"/>
|
|
|
95bc988 |
- <classpathentry exported="true" kind="lib" path="libs/snakeyaml-1.11.jar"/>
|
|
|
95bc988 |
+ <classpathentry exported="true" kind="lib" path="libs/snakeyaml-engine-2.1-20200105.160423-4.jar"/>
|
|
|
95bc988 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
|
|
95bc988 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
|
|
95bc988 |
<classpathentry kind="lib" path="libs/lucene-analyzers-common-6.1.0.jar"/>
|
|
|
95bc988 |
diff --git a/plugins/org.python.pydev.shared_core/META-INF/MANIFEST.MF b/plugins/org.python.pydev.shared_core/META-INF/MANIFEST.MF
|
|
|
95bc988 |
index 3c1f8b4df..6baa9c2b2 100644
|
|
|
95bc988 |
--- a/plugins/org.python.pydev.shared_core/META-INF/MANIFEST.MF
|
|
|
95bc988 |
+++ b/plugins/org.python.pydev.shared_core/META-INF/MANIFEST.MF
|
|
|
95bc988 |
@@ -4,9 +4,9 @@ Bundle-Name: Shared Core Plug-in
|
|
|
95bc988 |
Bundle-SymbolicName: org.python.pydev.shared_core;singleton:=true
|
|
|
84d4f24 |
Bundle-Version: 7.7.0.qualifier
|
|
|
95bc988 |
Bundle-ClassPath: shared_core.jar,
|
|
|
95bc988 |
- libs/snakeyaml-1.11.jar,
|
|
|
95bc988 |
libs/lucene-analyzers-common-6.1.0.jar,
|
|
|
95bc988 |
- libs/lucene-core-6.1.0.jar
|
|
|
95bc988 |
+ libs/lucene-core-6.1.0.jar,
|
|
|
95bc988 |
+ libs/snakeyaml-engine-2.1-20200105.160423-4.jar
|
|
|
95bc988 |
Bundle-Activator: org.python.pydev.shared_core.SharedCorePlugin
|
|
|
95bc988 |
Eclipse-BundleShape: dir
|
|
|
95bc988 |
Require-Bundle: org.eclipse.core.runtime,
|
|
|
95bc988 |
diff --git a/plugins/org.python.pydev.shared_core/build.properties b/plugins/org.python.pydev.shared_core/build.properties
|
|
|
95bc988 |
index 8af3a0600..3a551ee8c 100644
|
|
|
95bc988 |
--- a/plugins/org.python.pydev.shared_core/build.properties
|
|
|
95bc988 |
+++ b/plugins/org.python.pydev.shared_core/build.properties
|
|
|
95bc988 |
@@ -2,11 +2,10 @@ bin.includes = shared_core.jar,\
|
|
|
95bc988 |
META-INF/,\
|
|
|
95bc988 |
LICENSE.txt,\
|
|
|
95bc988 |
libs/,\
|
|
|
95bc988 |
- libs/lucene-analyzers-common-6.1.0.jar,\
|
|
|
95bc988 |
- libs/lucene-core-6.1.0.jar
|
|
|
95bc988 |
+ libs/snakeyaml-engine-2.1-20200105.160423-4.jar
|
|
|
95bc988 |
jars.compile.order = shared_core.jar
|
|
|
95bc988 |
source.shared_core.jar = src/
|
|
|
95bc988 |
output.shared_core.jar = bin/
|
|
|
95bc988 |
-jars.extra.classpath = libs/snakeyaml-1.11.jar,\
|
|
|
95bc988 |
- libs/lucene-core-6.1.0.jar,\
|
|
|
95bc988 |
- libs/lucene-analyzers-common-6.1.0.jar
|
|
|
95bc988 |
+jars.extra.classpath = libs/lucene-core-6.1.0.jar,\
|
|
|
95bc988 |
+ libs/lucene-analyzers-common-6.1.0.jar,\
|
|
|
95bc988 |
+ libs/snakeyaml-engine-2.1-20200105.160423-4.jar
|
|
|
95bc988 |
diff --git a/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/preferences/ScopedPreferences.java b/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/preferences/ScopedPreferences.java
|
|
|
95bc988 |
index 125a6f2eb..c6aa9c86a 100644
|
|
|
95bc988 |
--- a/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/preferences/ScopedPreferences.java
|
|
|
95bc988 |
+++ b/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/preferences/ScopedPreferences.java
|
|
|
95bc988 |
@@ -41,7 +41,7 @@
|
|
|
95bc988 |
import org.python.pydev.shared_core.string.StringUtils;
|
|
|
95bc988 |
import org.python.pydev.shared_core.structure.OrderedSet;
|
|
|
95bc988 |
import org.python.pydev.shared_core.structure.Tuple;
|
|
|
95bc988 |
-import org.yaml.snakeyaml.Yaml;
|
|
|
95bc988 |
+import org.python.pydev.shared_core.yaml.YamlWrapper;
|
|
|
95bc988 |
|
|
|
95bc988 |
public final class ScopedPreferences implements IScopedPreferences {
|
|
|
95bc988 |
|
|
|
95bc988 |
@@ -272,8 +272,7 @@ public String saveToProjectSettings(Map<String, Object> saveData, IProject... pr
|
|
|
95bc988 |
|
|
|
95bc988 |
private void dumpSaveDataToFile(Map<String, Object> saveData, IFile yamlFile, boolean exists) throws IOException,
|
|
|
95bc988 |
CoreException {
|
|
|
95bc988 |
- Yaml yaml = new Yaml();
|
|
|
95bc988 |
- String dumpAsMap = yaml.dumpAsMap(saveData);
|
|
|
95bc988 |
+ String dumpAsMap = YamlWrapper.dumpAsMap(saveData);
|
|
|
95bc988 |
if (!exists) {
|
|
|
95bc988 |
// Create empty (so that we can set the charset properly later on).
|
|
|
95bc988 |
yamlFile.create(new ByteArrayInputStream("".getBytes()), true, new NullProgressMonitor());
|
|
|
95bc988 |
@@ -284,8 +283,7 @@ private void dumpSaveDataToFile(Map<String, Object> saveData, IFile yamlFile, bo
|
|
|
95bc988 |
}
|
|
|
95bc988 |
|
|
|
95bc988 |
private void dumpSaveDataToFile(Map<String, Object> saveData, File yamlFile) throws IOException {
|
|
|
95bc988 |
- Yaml yaml = new Yaml();
|
|
|
95bc988 |
- String dumpAsMap = yaml.dumpAsMap(saveData);
|
|
|
95bc988 |
+ String dumpAsMap = YamlWrapper.dumpAsMap(saveData);
|
|
|
95bc988 |
FileUtils.writeStrToFile(dumpAsMap, yamlFile);
|
|
|
95bc988 |
// Don't use the code below because we want to dump as a map to have a better layout for the file.
|
|
|
95bc988 |
//
|
|
|
95bc988 |
@@ -541,8 +539,7 @@ public Object call() {
|
|
|
95bc988 |
if (yamlContents.trim().length() == 0) {
|
|
|
95bc988 |
return new HashMap<String, Object>();
|
|
|
95bc988 |
}
|
|
|
95bc988 |
- Yaml yaml = new Yaml();
|
|
|
95bc988 |
- Object load = yaml.load(yamlContents);
|
|
|
95bc988 |
+ Object load = YamlWrapper.load(yamlContents);
|
|
|
95bc988 |
if (!(load instanceof Map)) {
|
|
|
95bc988 |
if (load == null) {
|
|
|
95bc988 |
throw new Exception("Expected top-level element to be a map. Found: null");
|
|
|
95bc988 |
diff --git a/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/yaml/YamlWrapper.java b/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/yaml/YamlWrapper.java
|
|
|
95bc988 |
index 452675f10..844de9550 100644
|
|
|
95bc988 |
--- a/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/yaml/YamlWrapper.java
|
|
|
95bc988 |
+++ b/plugins/org.python.pydev.shared_core/src/org/python/pydev/shared_core/yaml/YamlWrapper.java
|
|
|
95bc988 |
@@ -2,12 +2,34 @@
|
|
|
95bc988 |
|
|
|
95bc988 |
import java.util.Map;
|
|
|
95bc988 |
|
|
|
95bc988 |
-import org.yaml.snakeyaml.Yaml;
|
|
|
95bc988 |
+import org.snakeyaml.engine.v2.api.Dump;
|
|
|
95bc988 |
+import org.snakeyaml.engine.v2.api.DumpSettings;
|
|
|
95bc988 |
+import org.snakeyaml.engine.v2.api.Load;
|
|
|
95bc988 |
+import org.snakeyaml.engine.v2.api.LoadSettings;
|
|
|
95bc988 |
+import org.snakeyaml.engine.v2.api.LoadSettingsBuilder;
|
|
|
95bc988 |
+import org.snakeyaml.engine.v2.common.FlowStyle;
|
|
|
95bc988 |
|
|
|
95bc988 |
public class YamlWrapper {
|
|
|
95bc988 |
|
|
|
95bc988 |
public static String dumpAsMap(@SuppressWarnings("rawtypes") Map map) {
|
|
|
95bc988 |
- return new Yaml().dumpAsMap(map);
|
|
|
95bc988 |
+ Dump dump = new Dump(
|
|
|
95bc988 |
+ DumpSettings.builder()
|
|
|
95bc988 |
+ .setBestLineBreak("\n")
|
|
|
95bc988 |
+ .setMultiLineFlow(true)
|
|
|
95bc988 |
+ .setIndent(2)
|
|
|
95bc988 |
+ .setDefaultFlowStyle(FlowStyle.BLOCK)
|
|
|
95bc988 |
+ .build());
|
|
|
95bc988 |
+ String output = dump.dumpToString(map);
|
|
|
95bc988 |
+ return output;
|
|
|
95bc988 |
+ }
|
|
|
95bc988 |
+
|
|
|
95bc988 |
+ public static Object load(String yamlContents) {
|
|
|
95bc988 |
+ LoadSettingsBuilder builder = LoadSettings.builder();
|
|
|
95bc988 |
+ LoadSettings settings = builder
|
|
|
95bc988 |
+ .setMaxAliasesForCollections(10)
|
|
|
95bc988 |
+ .build();
|
|
|
95bc988 |
+ Load load = new Load(settings);
|
|
|
95bc988 |
+ return load.loadFromString(yamlContents);
|
|
|
95bc988 |
}
|
|
|
95bc988 |
|
|
|
95bc988 |
}
|