Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita904eab

Browse files
authored
Merge pull requestHaehnchen#1744 from Haehnchen/feature/gson
SymfonyWebpackUtil: migrate from "org.json.simple" to "com.google.gson"
2 parents9291baa +55c7371 commita904eab

File tree

3 files changed

+33
-15
lines changed

3 files changed

+33
-15
lines changed

‎src/main/java/fr/adrienbrault/idea/symfony2plugin/templating/webpack/SymfonyWebpackUtil.java‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
packagefr.adrienbrault.idea.symfony2plugin.templating.webpack;
22

3+
importcom.google.gson.JsonElement;
4+
importcom.google.gson.JsonObject;
5+
importcom.google.gson.JsonParser;
6+
importcom.google.gson.JsonSyntaxException;
37
importcom.intellij.openapi.project.Project;
48
importcom.intellij.openapi.util.Pair;
59
importcom.intellij.openapi.util.io.StreamUtil;
@@ -9,9 +13,6 @@
913
importcom.intellij.psi.search.GlobalSearchScope;
1014
importfr.adrienbrault.idea.symfony2plugin.util.ProjectUtil;
1115
importorg.jetbrains.annotations.NotNull;
12-
importorg.json.simple.JSONObject;
13-
importorg.json.simple.parser.JSONParser;
14-
importorg.json.simple.parser.ParseException;
1516

1617
importjava.io.IOException;
1718
importjava.util.function.Consumer;
@@ -62,27 +63,29 @@ private static void visitEntryPointJson(@NotNull VirtualFile virtualFile, @NotNu
6263
return;
6364
}
6465

65-
Objectparse;
66+
JsonObjectjsonObject;
6667
try {
67-
JSONParserjsonParser =newJSONParser();
68-
parse =jsonParser.parse(s);
68+
jsonObject =newJsonParser().parse(s).getAsJsonObject();
69+
}catch (JsonSyntaxExceptione) {
70+
return;
71+
}
6972

70-
}catch (ParseExceptione) {
73+
if (jsonObject ==null) {
7174
return;
7275
}
7376

74-
if (!(parseinstanceofJSONObject)) {
77+
JsonElemententrypoints =jsonObject.get("entrypoints");
78+
if (entrypoints ==null) {
7579
return;
7680
}
7781

78-
Objectentrypoints = ((JSONObject)parse).get("entrypoints");
82+
JsonObjectasJsonObject =entrypoints.getAsJsonObject();
83+
if (asJsonObject ==null) {
84+
return;
85+
}
7986

80-
if (entrypointsinstanceofJSONObject) {
81-
for (Objecto : ((JSONObject)entrypoints).keySet()) {
82-
if (oinstanceofString) {
83-
consumer.accept(Pair.create(virtualFile, (String)o));
84-
}
85-
}
87+
for (Strings1 :asJsonObject.keySet()) {
88+
consumer.accept(Pair.create(virtualFile,s1));
8689
}
8790
}
8891

‎src/test/java/fr/adrienbrault/idea/symfony2plugin/tests/templating/webpack/SymfonyWebpackUtilTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public String getTestDataPath() {
2121
publicvoidtestVisitEntries() {
2222
myFixture.copyFileToProject("webpack.config.js");
2323
myFixture.copyFileToProject("entrypoints.json");
24+
myFixture.copyFileToProject("entrypoints_invalid.json");
2425

2526
Set<String>entries =newHashSet<>();
2627

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"entrypoints": {
3+
"entry_foobar": {
4+
"js": []
5+
},
6+
"entry_foobar_2": {
7+
"js": [];
8+
},
9+
"mainEntry": {
10+
"js": [],
11+
"css": [],
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp