Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Commit fd8b2ea

Browse files
committed
upgrade groovy + gson
1 parent 92227dc commit fd8b2ea

File tree

16 files changed

+40
-28
lines changed

16 files changed

+40
-28
lines changed

ant/build.gant

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
*/
1717
import javax.xml.XMLConstants
1818

19-
import groovy.json.JsonSlurper
2019
import groovy.util.XmlSlurper
2120

21+
import com.google.gson.JsonParser
22+
2223
import org.apache.tools.ant.BuildException
2324
import org.apache.tools.ant.taskdefs.condition.Os
2425

@@ -254,11 +255,11 @@ target(name: 'deploy.eclipse'){
254255
instances = new File(binding.getVariable('user.home') + '/.eclim/.eclimd_instances')
255256
if (instances.exists()){
256257
eclipse = binding.getVariable('eclipse')
257-
parser = new JsonSlurper()
258258
instances.eachLine { line ->
259-
json = parser.parseText(line)
260-
port = json.port
261-
echo("# shutdown: ${json.workspace}:${json.port}")
259+
json = JsonParser.parseString(line)
260+
port = json.get('port').getAsInt()
261+
workspace = json.get('workspace').getAsString()
262+
echo("# shutdown: ${workspace}:${port}")
262263
eclim('-command shutdown',
263264
port=port, failonerror=false, dir=existing.toString() + '/bin')
264265
}
File renamed without changes.

ant/lib/gant/groovy-3.0.6.jar

7.58 MB
Binary file not shown.

ant/lib/gant/groovy-ant-3.0.6.jar

85.1 KB
Binary file not shown.

ant/lib/gant/groovy-json-3.0.6.jar

130 KB
Binary file not shown.

ant/lib/gant/groovy-xml-3.0.6.jar

286 KB
Binary file not shown.

ant/lib/groovy-all-2.2.0.jar

-6.25 MB
Binary file not shown.

build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126

127127
<taskdef name="gant" classname="org.codehaus.gant.ant.Gant">
128128
<classpath>
129-
<fileset dir="ant/lib" includes="*.jar"/>
129+
<fileset dir="ant/lib" includes="**/*.jar"/>
130130
<fileset dir="org.eclim" includes="lib/*.jar"/>
131131
</classpath>
132132
</taskdef>

doc/content/vim/java/import.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. Copyright (C) 2005 - 2012 Eric Van Dewoestine
1+
.. Copyright (C) 2005 - 2020 Eric Van Dewoestine
22
33
This program is free software: you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -55,7 +55,7 @@ Configuration
5555

5656
.. _org.eclim.java.import.exclude:
5757

58-
- **org.eclim.java.import.exclude** (Default: ["^com\.sun\..*", "^sunw\?\..*"]) -
58+
- **org.eclim.java.import.exclude** (Default: ["^com\.sun\..*", "^sunw?\..*"]) -
5959
List of patterns to exclude from import results.
6060

6161
.. _org.eclim.java.import.package_separation_level:

org.eclim.core/java/org/eclim/plugin/core/command/project/ProjectUpdateCommand.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
import java.io.File;
2020
import java.io.FileReader;
2121

22+
import java.nio.file.Files;
23+
import java.nio.file.Path;
24+
import java.nio.file.Paths;
25+
2226
import java.util.ArrayList;
2327
import java.util.List;
2428
import java.util.Map;
@@ -47,7 +51,7 @@
4751

4852
import com.google.gson.JsonElement;
4953
import com.google.gson.JsonObject;
50-
import com.google.gson.JsonStreamParser;
54+
import com.google.gson.JsonParser;
5155

5256
/**
5357
* Command to update a project.
@@ -102,13 +106,15 @@ private List<Error> updateSettings(IProject project, String settings)
102106
throws Exception
103107
{
104108
FileReader in = null;
105-
File file = new File(settings);
109+
Path file = Paths.get(settings);
106110
ArrayList<Error> errors = new ArrayList<Error>();
107111
try{
108-
in = new FileReader(file);
109-
JsonStreamParser parser = new JsonStreamParser(in);
110-
JsonObject obj = (JsonObject)parser.next();
112+
String content = Files.readString(file);
113+
// somewhere between gson 1.7.1 and 2.8.6 it became stupidily strict on
114+
// back slashes in values.
115+
content = content.replace("\\", "\\\\");
111116

117+
JsonObject obj = (JsonObject)JsonParser.parseString(content);
112118
Preferences preferences = getPreferences();
113119
for (Map.Entry<String, JsonElement> entry : obj.entrySet()){
114120
String name = entry.getKey();
@@ -122,7 +128,7 @@ private List<Error> updateSettings(IProject project, String settings)
122128
}finally{
123129
IOUtils.closeQuietly(in);
124130
try{
125-
file.delete();
131+
file.toFile().delete();
126132
}catch(Exception e){
127133
logger.warn("Error deleting project settings temp file: " + file, e);
128134
}

org.eclim.core/java/org/eclim/plugin/core/preference/Preferences.java

+13-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.osgi.service.prefs.BackingStoreException;
4141

4242
import com.google.gson.Gson;
43+
import com.google.gson.GsonBuilder;
4344

4445
import com.google.gson.reflect.TypeToken;
4546

@@ -67,6 +68,8 @@ public class Preferences
6768
private static final String NODE_NAME = "org.eclim";
6869
private static final String GLOBAL = "_global_";
6970

71+
private static Gson gson = new GsonBuilder().setLenient().create();
72+
7073
private static Preferences instance = new Preferences();
7174
private static Map<String, OptionHandler> optionHandlers =
7275
new HashMap<String, OptionHandler>();
@@ -328,7 +331,10 @@ public String[] getArrayValue(IProject project, String name)
328331
{
329332
String value = getValues(project).get(name);
330333
if (value != null && value.trim().length() != 0){
331-
return new Gson().fromJson(value, String[].class);
334+
// somewhere between gson 1.7.1 and 2.8.6 it became stupidily strict on
335+
// back slashes in values.
336+
value = value.replace("\\", "\\\\");
337+
return gson.fromJson(value, String[].class);
332338
}
333339
return ArrayUtils.EMPTY_STRING_ARRAY;
334340
}
@@ -356,7 +362,9 @@ public Set<String> getSetValue(IProject project, String name)
356362
{
357363
String value = getValues(project).get(name);
358364
if (value != null && value.trim().length() != 0){
359-
return (Set<String>)new Gson().fromJson(
365+
// more gson being overly strict on back slashes
366+
value = value.replace("\\", "\\\\");
367+
return (Set<String>)gson.fromJson(
360368
value, new TypeToken<Set<String>>(){}.getType());
361369
}
362370
return new HashSet<String>();
@@ -385,7 +393,9 @@ public Map<String, String> getMapValue(IProject project, String name)
385393
{
386394
String value = getValues(project).get(name);
387395
if (value != null && value.trim().length() != 0){
388-
return (Map<String, String>)new Gson().fromJson(
396+
// more gson being overly strict on back slashes
397+
value = value.replace("\\", "\\\\");
398+
return (Map<String, String>)gson.fromJson(
389399
value, new TypeToken<Map<String, String>>(){}.getType());
390400
}
391401
return new HashMap<String, String>();

org.eclim.core/test/junit/org/eclim/Eclim.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
import org.apache.commons.lang.StringUtils;
2727

28-
import org.apache.tools.ant.taskdefs.condition.Os;
29-
3028
import org.eclim.util.CommandExecutor;
3129
import org.eclim.util.IOUtils;
3230

@@ -52,8 +50,6 @@ public class Eclim
5250
private static final String PRETTY = "-pretty";
5351
private static final String COMMAND = "-command";
5452

55-
private static final JsonParser JSON_PARSER = new JsonParser();
56-
5753
private static String workspace;
5854

5955
/**
@@ -157,7 +153,7 @@ public static Object execute(String[] args, long timeout, boolean failOnError)
157153
result = "\"\"";
158154
}
159155
try{
160-
return toType(JSON_PARSER.parse(result));
156+
return toType(JsonParser.parseString(result));
161157
}catch(JsonSyntaxException jse){
162158
if(!failOnError){
163159
return result;

org.eclim.jdt/java/org/eclim/plugin/jdt/PluginResources.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void initialize(String name)
9191
"JDT org.eclim.java.logging.template logger.gst\n" +
9292
"JDT org.eclim.java.import.package_separation_level 1 (-1|\\d+)\n" +
9393
"JDT org.eclim.java.import.exclude " +
94-
"[\"^com\\.sun\\..*\",\"^sunw\\?\\..*\"] JSON[]\n" +
94+
"[\"^com\\.sun\\..*\",\"^sunw?\\..*\"] JSON[]\n" +
9595
"JDT org.eclim.java.format.strip_trialing_whitespace true (true|false)\n" +
9696
"JDT org.eclim.java.checkstyle.config\n" +
9797
"JDT org.eclim.java.checkstyle.properties\n" +
@@ -111,7 +111,7 @@ public void initialize(String name)
111111
);
112112
// Indentation settings found in DefaultCodeFormatterConstants
113113
PreferenceFactory.addOptions(NATURE,
114-
"JDT org.eclipse.jdt.core.compiler.source ^(1\\.[3-8]|9|10)$\n" +
114+
"JDT org.eclipse.jdt.core.compiler.source ^(1\\.[3-8]|9|1[0-5])$\n" +
115115
"JDT org.eclipse.jdt.ui.importorder [a-zA-Z0-9_.#;]+\n" +
116116
"JDT/Javadoc " + JavaUI.ID_PLUGIN + ".project_javadoc_location\n" +
117117
"JDT/CodeComplete " +

org.eclim.pydev/build_pydev.gant

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import groovy.json.JsonSlurper
1+
import com.google.gson.Gson
22

33
feature_pydev = 'org.python.pydev.feature'
44

@@ -8,9 +8,8 @@ target(name: 'org.eclim.pydev.test'){
88
port = getEclimdPort()
99
cmd = "${cmd} --nailgun-port ${port} -command"
1010

11-
parser = new JsonSlurper()
12-
interpreters = parser.parseText(
13-
"${cmd} python_list_interpreters".execute().text)
11+
result = "${cmd} python_list_interpreters".execute().text
12+
interpreters = new Gson().fromJson(result, List<Map<String, String>>.class)
1413

1514
if (!interpreters){
1615
python = 'which python'.execute().text

org.eclim/lib/gson-1.7.1.jar

-170 KB
Binary file not shown.

org.eclim/lib/gson-2.8.6.jar

235 KB
Binary file not shown.

0 commit comments

Comments
 (0)