Skip to content

Commit 6badd0a

Browse files
committed
Support Lombok
1 parent 451f63e commit 6badd0a

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ intellij {
3535
pluginName = 'MapStruct-Intellij-Plugin'
3636
// The properties plugin is needed because Kotlin uses it
3737
// and for some reason plugins does not transitively pull itx
38-
plugins = ['java', 'Kotlin', 'properties']
38+
plugins = ['java', 'Kotlin', 'properties', 'lombok']
3939
}
4040

4141
// Simple function to load change-notes.html and description.html into valid text for plugin.xml

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.intellij.psi.PsiType;
2222
import com.intellij.psi.PsiVariable;
2323
import com.intellij.psi.util.PsiUtil;
24+
import de.plushnikov.intellij.plugin.psi.LombokLightMethodBuilder;
2425
import org.jetbrains.annotations.NotNull;
2526
import org.jetbrains.annotations.Nullable;
2627
import org.mapstruct.intellij.util.MapStructVersion;
@@ -86,6 +87,12 @@ builderSupportPresent && isBuilderEnabled( getMappingMethod() )
8687
if ( constructor != null && constructor.hasParameters() ) {
8788
for ( PsiParameter parameter : constructor.getParameterList().getParameters() ) {
8889
if ( value.equals( parameter.getName() ) ) {
90+
if ( constructor instanceof LombokLightMethodBuilder ) {
91+
PsiField field = psiClass.findFieldByName( value, true );
92+
if ( field != null ) {
93+
return field;
94+
}
95+
}
8996
return parameter;
9097
}
9198
}

src/main/java/org/mapstruct/intellij/util/TargetUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ public static PsiMethod resolveMappingConstructor(@NotNull PsiClass psiClass) {
223223
List<PsiMethod> accessibleConstructors = new ArrayList<>(constructors.length);
224224

225225
for ( PsiMethod constructor : constructors ) {
226-
if ( constructor.hasModifier( JvmModifier.PRIVATE ) ) {
227-
// private constructors are ignored
226+
if ( constructor.hasModifier( JvmModifier.PRIVATE ) || constructor.hasModifier( JvmModifier.PROTECTED ) ) {
227+
// private and protected constructors are ignored
228228
continue;
229229
}
230230
if ( !constructor.hasParameters() ) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!--
2+
3+
Copyright MapStruct Authors.
4+
5+
Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
-->
8+
<idea-plugin>
9+
</idea-plugin>

src/main/resources/META-INF/plugin.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
3030
on how to target different products -->
3131
<depends>com.intellij.modules.java</depends>
32-
<depends optional="true" config-file="withKotlin.xml">org.jetbrains.kotlin</depends>
32+
<depends optional="true" config-file="org.mapstruct.intellij-withKotlin.xml">org.jetbrains.kotlin</depends>
33+
<depends optional="true" config-file="org.mapstruct.intellij-withLombok.xml">Lombook Plugin</depends>
3334

3435
<extensions defaultExtensionNs="com.intellij">
3536
<!-- Add your extensions here -->

0 commit comments

Comments
 (0)