Skip to content

Commit

Permalink
better display names
Browse files Browse the repository at this point in the history
  • Loading branch information
hduelme committed Dec 10, 2023
1 parent ecd27f0 commit b2e5916
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ private void inspectUnnecessaryWhitespaces(@NotNull ProblemsHolder problemsHolde
return;
}
if ( text.indexOf( "java(" ) > 1 ) {
problemsHolder.registerProblem( property, "Remove Whitespaces before " + property.getName(),
problemsHolder.registerProblem( property,
MapStructBundle.message( "inspection.java.expression.unnecessary.whitespace",
"before", property.getAttributeName() ),
ProblemHighlightType.WEAK_WARNING, new RemoveWhitespacesBefore(property) );
}
if ( text.lastIndexOf( ')' ) < text.length() - 2) {
problemsHolder.registerProblem( property, "Remove Whitespace after " + property.getName(),
problemsHolder.registerProblem( property,
MapStructBundle.message( "inspection.java.expression.unnecessary.whitespace",
"after", property.getAttributeName() ),
ProblemHighlightType.WEAK_WARNING, new RemoveWhitespacesAfter(property) );
}
}
Expand All @@ -65,7 +69,8 @@ private RemoveWhitespacesBefore(@NotNull PsiNameValuePair element) {

@Override
public @IntentionName @NotNull String getText() {
return MapStructBundle.message( "inspection.java.expression.unnecessary.whitespace", "before", name );
return MapStructBundle.message( "inspection.java.expression.remove.unnecessary.whitespace",
"before", name );
}

@Override
Expand All @@ -84,7 +89,7 @@ public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull

@Override
public @IntentionFamilyName @NotNull String getFamilyName() {
return MapStructBundle.message( "intention.java.expression.unnecessary.whitespace" );
return MapStructBundle.message( "intention.java.expression.remove.unnecessary.whitespace" );
}

@Override
Expand All @@ -111,7 +116,7 @@ private RemoveWhitespacesAfter(@NotNull PsiNameValuePair element) {

@Override
public @IntentionName @NotNull String getText() {
return MapStructBundle.message( "inspection.java.expression.unnecessary.whitespace", "after", name );
return MapStructBundle.message( "inspection.java.expression.remove.unnecessary.whitespace", "after", name );
}

@Override
Expand All @@ -130,7 +135,7 @@ public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull

@Override
public @IntentionFamilyName @NotNull String getFamilyName() {
return MapStructBundle.message( "intention.java.expression.unnecessary.whitespace" );
return MapStructBundle.message( "intention.java.expression.remove.unnecessary.whitespace" );
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@
enabledByDefault="true"
level="ERROR"
bundle="org.mapstruct.intellij.messages.MapStructBundle"
key="inspection.not.null.checkable.property.source.used.with.default.property"
key="inspection.not.null.checkable.property.source.used.with.default.property.title"
shortName="NotNullCheckableSourcePropertyUsedWithDefaultValue"
implementationClass="org.mapstruct.intellij.inspection.NotNullCheckableSourcePropertyUsedWithDefaultValueInspection"/>
<localInspection
language="JAVA"
enabledByDefault="true"
level="WARNING"
bundle="org.mapstruct.intellij.messages.MapStructBundle"
key="inspection.java.expression.unnecessary.whitespace"
key="inspection.java.expression.unnecessary.whitespace.title"
shortName="JavaExpressionUnnecessaryWhitespaces"
implementationClass="org.mapstruct.intellij.inspection.JavaExpressionUnnecessaryWhitespacesInspector"/>
</extensions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ inspection.no.source.property=No source property defined
inspection.more.than.one.source.property=More than one source property defined
inspection.more.than.one.default.source.property=More than one default source property defined
inspection.not.null.checkable.property.source.used.with.default.property={0} property used with {1}
inspection.java.expression.unnecessary.whitespace=Remove unnecessary whitespaces {0} {1}
inspection.not.null.checkable.property.source.used.with.default.property.title=Constant or expression source property used with a default source property
inspection.java.expression.unnecessary.whitespace=Unnecessary whitespaces {0} {1}
inspection.java.expression.remove.unnecessary.whitespace=Remove unnecessary whitespaces {0} {1}
inspection.java.expression.unnecessary.whitespace.title=Unnecessary whitespaces before or after Java expression
intention.add.ignore.all.unmapped.target.properties=Add ignore all unmapped target properties
intention.add.ignore.unmapped.target.property=Add ignore unmapped target property
intention.add.unmapped.target.property=Add unmapped target property
intention.no.source.property=Add one source property
intention.more.than.one.source.property=Only use one source property
intention.more.than.one.default.source.property=Only use one default source property
intention.not.null.checkable.property.source.used.with.default.property=Remove default properties
intention.java.expression.unnecessary.whitespace=Remove unnecessary whitespaces
intention.java.expression.remove.unnecessary.whitespace=Remove unnecessary whitespaces
plugin.settings.title=MapStruct
plugin.settings.quickFix.title=Quick fix properties
plugin.settings.quickFix.preferSourceBeforeTargetInMapping=Prefer source before target in @Mapping
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void setName(String name) {
@Mapper
interface SingleMappingMapper {

@Mapping(target = "name", source = "name", <weak_warning descr="Remove Whitespace after conditionExpression">conditionExpression = "java( !source.getName().length > 0 ) "</weak_warning>)
@Mapping(target = "lastName", source = "name", <weak_warning descr="Remove Whitespace after defaultExpression">defaultExpression = "java( \" \" ) "</weak_warning>)
@Mapping(target = "city", <weak_warning descr="Remove Whitespace after expression">expression = "java( \" \" ) "</weak_warning>)
@Mapping(target = "name", source = "name", <weak_warning descr="Unnecessary whitespaces after conditionExpression">conditionExpression = "java( !source.getName().length > 0 ) "</weak_warning>)
@Mapping(target = "lastName", source = "name", <weak_warning descr="Unnecessary whitespaces after defaultExpression">defaultExpression = "java( \" \" ) "</weak_warning>)
@Mapping(target = "city", <weak_warning descr="Unnecessary whitespaces after expression">expression = "java( \" \" ) "</weak_warning>)
Target map(Source source);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public void setName(String name) {
@Mapper
interface SingleMappingMapper {

@Mapping(target = "name", source = "name", <weak_warning descr="Remove Whitespaces before conditionExpression">conditionExpression = " java( !source.getName().length > 0 )"</weak_warning>)
@Mapping(target = "lastName", source = "name", <weak_warning descr="Remove Whitespaces before defaultExpression">defaultExpression = " java( \" \" )"</weak_warning>)
@Mapping(target = "city", <weak_warning descr="Remove Whitespaces before expression">expression = " java( \" \" )"</weak_warning>)
@Mapping(target = "name", source = "name", <weak_warning descr="Unnecessary whitespaces before conditionExpression">conditionExpression = " java( !source.getName().length > 0 )"</weak_warning>)
@Mapping(target = "lastName", source = "name", <weak_warning descr="Unnecessary whitespaces before defaultExpression">defaultExpression = " java( \" \" )"</weak_warning>)
@Mapping(target = "city", <weak_warning descr="Unnecessary whitespaces before expression">expression = " java( \" \" )"</weak_warning>)
Target map(Source source);
}

0 comments on commit b2e5916

Please sign in to comment.