Skip to content

Commit f82fc92

Browse files
authored
#151 Rework inheritance and support auto inheritance
1 parent 5168fba commit f82fc92

File tree

33 files changed

+1365
-273
lines changed

33 files changed

+1365
-273
lines changed

src/main/java/org/mapstruct/intellij/codeinsight/references/MapstructTargetReference.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import static org.mapstruct.intellij.util.TargetUtils.isBuilderEnabled;
4242
import static org.mapstruct.intellij.util.TargetUtils.publicWriteAccessors;
4343
import static org.mapstruct.intellij.util.TargetUtils.resolveBuilderOrSelfClass;
44+
import static org.mapstruct.intellij.util.TypeUtils.firstParameterPsiType;
4445

4546
/**
4647
* Reference for {@link org.mapstruct.Mapping#target()}.
@@ -227,19 +228,4 @@ else if ( psiMember instanceof PsiVariable ) {
227228
}
228229

229230
}
230-
231-
/**
232-
* Util function for extracting the type of the first parameter of a method.
233-
*
234-
* @param psiMethod the method to extract the parameter from
235-
*
236-
* @return the type of the first parameter of the method
237-
*/
238-
private static PsiType firstParameterPsiType(PsiMethod psiMethod) {
239-
PsiParameter[] psiParameters = psiMethod.getParameterList().getParameters();
240-
if ( psiParameters.length == 0) {
241-
return null;
242-
}
243-
return psiParameters[0].getType();
244-
}
245231
}

src/main/java/org/mapstruct/intellij/inspection/UnmappedTargetPropertiesInspection.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
import static com.intellij.codeInsight.AnnotationUtil.findAnnotation;
4343
import static com.intellij.codeInsight.AnnotationUtil.getBooleanAttributeValue;
44+
import static org.mapstruct.intellij.inspection.inheritance.InheritConfigurationUtils.findInheritedTargetProperties;
4445
import static org.mapstruct.intellij.util.MapstructAnnotationUtils.addMappingAnnotation;
4546
import static org.mapstruct.intellij.util.MapstructAnnotationUtils.getUnmappedTargetPolicy;
4647
import static org.mapstruct.intellij.util.MapstructUtil.isInheritInverseConfiguration;
@@ -50,7 +51,6 @@
5051
import static org.mapstruct.intellij.util.TargetUtils.findAllDefinedMappingTargets;
5152
import static org.mapstruct.intellij.util.TargetUtils.findAllSourcePropertiesForCurrentTarget;
5253
import static org.mapstruct.intellij.util.TargetUtils.findAllTargetProperties;
53-
import static org.mapstruct.intellij.util.TargetUtils.findInheritedTargetProperties;
5454
import static org.mapstruct.intellij.util.TargetUtils.getRelevantType;
5555

5656
/**
@@ -78,6 +78,10 @@ private MyJavaElementVisitor(ProblemsHolder holder, MapStructVersion mapStructVe
7878
public void visitMethod(PsiMethod method) {
7979
super.visitMethod( method );
8080

81+
if ( !MapstructUtil.isMapper( method.getContainingClass() ) ) {
82+
return;
83+
}
84+
8185
PsiType targetType = getTargetType( method );
8286
if ( targetType == null ) {
8387
return;
@@ -86,12 +90,12 @@ public void visitMethod(PsiMethod method) {
8690
if ( isBeanMappingIgnoreByDefault( method ) ) {
8791
return;
8892
}
93+
8994
ReportingPolicy reportingPolicy = getUnmappedTargetPolicy( method );
9095
if (reportingPolicy == ReportingPolicy.IGNORE) {
9196
return;
9297
}
9398

94-
9599
Set<String> allTargetProperties = findAllTargetProperties( targetType, mapStructVersion, method );
96100

97101
// find and remove all defined mapping targets
@@ -204,6 +208,7 @@ private static PsiType getTargetType(PsiMethod method) {
204208
}
205209
return getRelevantType( method );
206210
}
211+
207212
}
208213

209214
private static class UnmappedTargetPropertyFix extends LocalQuickFixOnPsiElement {

0 commit comments

Comments
 (0)