Skip to content

Add generics support - #273

Open
maybetm wants to merge 1 commit into
mapstruct:mainfrom
maybetm:add_generics_support
Open

maybetm wants to merge 1 commit into
mapstruct:mainfrom
maybetm:add_generics_support

Conversation

@maybetm

@maybetm maybetm commented Jul 19, 2026

Copy link
Copy Markdown

Hi! ☺️ I noticed that the MapStruct IDEA plugin didn't support generics properly in some cases.
This PR adds support for generic types. I'd appreciate it if you could review and merge these changes!

Before

image

After

image

@maybetm maybetm changed the title add generics support Add generics support Jul 19, 2026

@hduelme hduelme left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maybetm, good catch! I left a few comments for you. Could you also add tests covering the other branches?

@maybetm
maybetm force-pushed the add_generics_support branch from 19196bd to 30b3520 Compare August 4, 2026 10:23
Comment thread build.gradle
@maybetm
maybetm requested a review from hduelme August 4, 2026 10:42
@maybetm
maybetm force-pushed the add_generics_support branch from 30b3520 to d781aa0 Compare August 4, 2026 10:51
@maybetm
maybetm force-pushed the add_generics_support branch from d781aa0 to f9e342b Compare August 4, 2026 11:02
@hduelme

hduelme commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

@maybetm sorry for the late response. I saw that you fixed my previous findings.
The only thing still open is the change insrc/test/java/org/mapstruct/intellij/MapstructBaseCompletionTestCase.java. I’m still not sure whether this change is needed. Could you provide some more information about your environment and why the change is required?

I’ll re-review your PR soon.

Comment on lines +150 to +159
PsiType contextType = Optional.ofNullable( getPrevious() )
.map( MapstructBaseReference::resolvedType )
.or( () -> Optional.ofNullable( this.getMappingMethod() )
.map( MapstructUtil::getSourceParameters )
.filter( params -> params.length == 1 )
.map( psiParameters -> psiParameters[0] )
.map( SourceUtils::getParameterType )
)
.orElse( null );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this only supported for one source parameter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants