Skip to content

Commit

Permalink
Fix serialisation of property values (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
jshiell committed Jun 5, 2022
1 parent b1f239f commit bb5a037
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# CheckStyle-IDEA Changelog

* **5.67.1** Fix: Improve serialisation from legacy formats (#574).
* **5.67.1** Fix: Fix serialisation of property values (#573).
* **5.67.0** New: Added Checkstyle 10.3.
* **5.67.0** Fix: Project paths should now remain relative where possible (#569).
* **5.67.0** Fix: Fix NPE in module configuration (#570).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,21 @@ static ProjectSettings create(@NotNull final PluginConfiguration currentPluginCo
projectSettings.activeLocationIds = new ArrayList<>(currentPluginConfig.getActiveLocationIds());

projectSettings.locations = currentPluginConfig.getLocations().stream()
.map(location -> new ConfigurationLocation(
location.getId(),
location.getType().name(),
location.getRawLocation(),
location.getDescription(),
location.getNamedScope().map(NamedScope::getScopeId).orElse("")
))
.collect(Collectors.toList());
.map(location -> new ConfigurationLocation(
location.getId(),
location.getType().name(),
location.getRawLocation(),
location.getDescription(),
location.getNamedScope().map(NamedScope::getScopeId).orElse(""),
location.getProperties()
))
.collect(Collectors.toList());

return projectSettings;
}

@SuppressWarnings("unused") // for serialisation
@SuppressWarnings("unused")
// for serialisation
ProjectSettings() {
}

Expand Down Expand Up @@ -168,20 +170,22 @@ private ConfigurationLocationFactory configurationLocationFactory(@NotNull final
}

@Nullable
private org.infernus.idea.checkstyle.model.ConfigurationLocation deserialiseLocation(@NotNull Project project,
@Nullable ProjectConfigurationState.ConfigurationLocation location) {
private org.infernus.idea.checkstyle.model.ConfigurationLocation deserialiseLocation(@NotNull final Project project,
@Nullable final ProjectConfigurationState.ConfigurationLocation location) {
if (location == null) {
return null;
}

try {
return configurationLocationFactory(project).create(
org.infernus.idea.checkstyle.model.ConfigurationLocation configurationLocation = configurationLocationFactory(project).create(
project,
location.id,
ConfigurationType.parse(location.type),
location.location,
Objects.requireNonNullElse(location.location, "").trim(),
location.description,
NamedScopeHelper.getScopeByIdWithDefaultFallback(project, location.scope));
configurationLocation.setProperties(Objects.requireNonNullElse(location.properties, new HashMap<>()));
return configurationLocation;
} catch (Exception e) {
LOG.error("Failed to deserialise " + location, e);
return null;
Expand All @@ -201,32 +205,42 @@ static class ConfigurationLocation {
private String description;
@Text
private String location;
@MapAnnotation
private Map<String, String> properties;

@SuppressWarnings("unused") // serialisation
public ConfigurationLocation() {
@SuppressWarnings("unused")
// serialisation
ConfigurationLocation() {
}

public ConfigurationLocation(String id,
String type,
String location,
String description,
String scope) {
ConfigurationLocation(final String id,
final String type,
final String location,
final String description,
final String scope,
final Map<String, String> properties) {
this.id = id;
this.type = type;
this.scope = scope;
this.description = description;
this.location = location;
if (properties != null && !properties.isEmpty()) {
this.properties = properties;
} else {
this.properties = null;
}
}

@Override
public String toString() {
return "ConfigurationLocation{" +
"id='" + id + '\'' +
", type='" + type + '\'' +
", scope='" + scope + '\'' +
", description='" + description + '\'' +
", location='" + location + '\'' +
'}';
return "ConfigurationLocation{"
+ "id='" + id + '\''
+ ", type='" + type + '\''
+ ", scope='" + scope + '\''
+ ", description='" + description + '\''
+ ", location='" + location + '\''
+ ", properties='" + properties + '\''
+ '}';
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<![CDATA[
<ul>
<li>5.67.1: Fix: Improve serialisation from legacy formats (#574).</li>
<li>5.67.1: Fix: Fix serialisation of property values (#573).</li>
<li>5.67.0: New: Added Checkstyle 10.3.</li>
<li>5.67.0: Fix: Project paths should now remain relative where possible (#569).</li>
<li>5.67.0: Fix: Fix NPE in module configuration (#570).</li>
Expand Down

0 comments on commit bb5a037

Please sign in to comment.