Open
Conversation
…s, and inspections Add support for the `@Ignored` annotation introduced in MapStruct 1.7. This includes: - Code completion for `@Ignored(targets=...)` with `prefix` support - Go-to-declaration and find usages for ignored target properties - UnmappedTargetPropertiesInspection considers `@Ignored` targets - TargetPropertyMappedMoreThanOnceInspection detects conflicts between `@Mapping` and `@Ignored` targeting the same property - Unknown target reference inspection for `@Ignored` targets Completion correctly excludes targets already defined in other `@Ignored` and `@Mapping` annotations on the same method, including prefix-scoped targets.
There was a problem hiding this comment.
Pull request overview
Adds IntelliJ plugin support for MapStruct 1.7’s new @Ignored annotation, integrating it into completion, references, and inspections while refactoring shared target-reference logic.
Changes:
- Implement
@Ignored(targets=...)completion (withprefix), go-to-declaration/find-usages, and unknown-reference highlighting. - Update inspections to treat
@Ignoredtargets as mapped and detect@Mapping/@Ignoredconflicts. - Refactor target reference resolution into
BaseTargetReferenceand generalize repeatable-annotation extraction for reuse with@IgnoredList.
Reviewed changes
Copilot reviewed 38 out of 39 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| testData/mapping/CarMapperReturnTargetCarDtoWithIgnored.java | New completion fixture covering @Ignored interaction with @Mapping. |
| testData/inspection/UnmappedTargetPropertiesWithIgnored.java | New inspection fixture verifying unmapped-target logic respects @Ignored (incl. prefix). |
| testData/inspection/UnknownIgnoredTargetReference.java | New reference-highlighting fixture for unknown @Ignored targets/prefix/nesting. |
| testData/inspection/TargetPropertyMappedMoreThanOnceWithIgnored.java | New fixture for detecting @Mapping/@Ignored and @Ignored/@Ignored conflicts. |
| testData/completion/ignored/IgnoredTargetsWithPrefixMultipleTargets.java | Completion fixture for prefix + multiple targets. |
| testData/completion/ignored/IgnoredTargetsWithPrefixAndMapping.java | Completion fixture ensuring @Mapping targets are excluded from @Ignored suggestions. |
| testData/completion/ignored/IgnoredTargetsWithPrefix.java | Completion fixture for prefix without pre-filled targets. |
| testData/completion/ignored/IgnoredTargetsWithMapping.java | Completion fixture ensuring @Ignored excludes @Mapping(ignore=true) targets. |
| testData/completion/ignored/IgnoredTargetsWithInvalidPrefix.java | Completion fixture expecting no suggestions when prefix is invalid. |
| testData/completion/ignored/IgnoredTargetsSingleNoArray.java | Completion fixture for targets = "..." (non-array form). |
| testData/completion/ignored/IgnoredTargetsReferenceUnknownTarget.java | Reference fixture verifying unresolved target references. |
| testData/completion/ignored/IgnoredTargetsReferenceTargetWithPrefix.java | Reference fixture verifying resolution with prefix. |
| testData/completion/ignored/IgnoredTargetsReferenceTarget.java | Reference fixture verifying direct target resolution. |
| testData/completion/ignored/IgnoredTargetsReferenceNestedTarget.java | Reference fixture verifying nested target resolution. |
| testData/completion/ignored/IgnoredTargetsNoPrefix.java | Baseline completion fixture for @Ignored without prefix. |
| testData/completion/ignored/IgnoredTargetsMultipleTargets.java | Completion fixture excluding already-listed targets in the same annotation. |
| testData/completion/ignored/IgnoredTargetsMultipleAnnotations.java | Completion fixture excluding targets across multiple @Ignored annotations. |
| src/test/java/org/mapstruct/intellij/inspection/UnmappedTargetPropertiesWithIgnoredInspectionTest.java | New automated test for unmapped-target inspection behavior with @Ignored. |
| src/test/java/org/mapstruct/intellij/inspection/TargetPropertyMappedMoreThanOnceInspectionTest.java | Adds a test entry point for the new @Ignored conflict fixture. |
| src/test/java/org/mapstruct/intellij/inspection/MapstructReferenceInspectionTest.java | Adds reference-inspection test coverage for unknown @Ignored targets. |
| src/test/java/org/mapstruct/intellij/completion/IgnoredTargetsCompletionTestCase.java | New completion + reference tests dedicated to @Ignored. |
| src/test/java/org/mapstruct/intellij/MapstructCompletionTestCase.java | Extends existing completion suite to account for @Ignored on mapping methods. |
| src/main/java/org/mapstruct/intellij/util/TargetUtils.java | Adds utilities for collecting ignored targets (incl. @IgnoredList + prefix). |
| src/main/java/org/mapstruct/intellij/util/MapstructUtil.java | Adds FQNs for @Ignored/@IgnoredList and detects MapStruct 1.7 via class presence. |
| src/main/java/org/mapstruct/intellij/util/MapstructKotlinElementUtils.java | Adds Kotlin PSI element pattern for @Ignored parameters. |
| src/main/java/org/mapstruct/intellij/util/MapstructElementUtils.java | Adds Java PSI element pattern for @Ignored parameters. |
| src/main/java/org/mapstruct/intellij/util/MapstructAnnotationUtils.java | Generalizes repeatable-annotation extraction for reuse beyond @Mappings. |
| src/main/java/org/mapstruct/intellij/util/MapStructVersion.java | Adds V1_7_O version constant. |
| src/main/java/org/mapstruct/intellij/inspection/UnmappedTargetPropertiesInspection.java | Removes @Ignored targets from unmapped-target warnings. |
| src/main/java/org/mapstruct/intellij/inspection/TargetPropertyMappedMoreThanOnceInspection.java | Treats @Ignored targets as mapping targets for conflict detection. |
| src/main/java/org/mapstruct/intellij/codeinsight/references/MapstructTargetReference.java | Refactors target reference to reuse shared logic from BaseTargetReference. |
| src/main/java/org/mapstruct/intellij/codeinsight/references/MapstructReferenceContributor.java | Registers reference providers for @Ignored(prefix=...) and @Ignored(targets=...). |
| src/main/java/org/mapstruct/intellij/codeinsight/references/MapstructKotlinReferenceContributor.java | Registers Kotlin reference providers for @Ignored(prefix=...) and @Ignored(targets=...). |
| src/main/java/org/mapstruct/intellij/codeinsight/references/MapstructIgnoredTargetReference.java | New reference implementation for @Ignored#targets with prefix-aware type resolution. |
| src/main/java/org/mapstruct/intellij/codeinsight/references/BaseTargetReference.java | New shared base class for target references (resolve + variants + type logic). |
| description.html | Updates plugin description to mention @Ignored completion/references/inspections. |
| change-notes.html | Adds release notes entry documenting @Ignored support. |
| build.gradle | Bumps MapStruct dependency to 1.7 beta and updates jar rename logic; updates AssertJ. |
| README.md | Documents @Ignored support in feature list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/org/mapstruct/intellij/util/MapstructKotlinElementUtils.java
Outdated
Show resolved
Hide resolved
The Kotlin element pattern for @ignored used `insideAnnotationParam` which only matches standalone annotations. Changed to use `insideRepeatableAnnotationParam` with `IGNORED_LIST_ANNOTATION_FQN` so references and completion work when @ignored is nested inside @IgnoredList. Also fixed `insideRepeatableAnnotationParam` in `KotlinElementPattern` to use `withAncestor(2, ...)` instead of `withParent(...)` to support array parameters like `targets = ["..."]` where a collection literal sits between the string and the value argument. Added tests for @IgnoredList in both Java and Kotlin: - Completion with @IgnoredList container (Java and Kotlin) - Standalone @ignored completion in Kotlin - TargetPropertyMappedMoreThanOnce inspection with @IgnoredList
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #237, closes #238
Add support for the
@Ignoredannotation introduced in MapStruct 1.7:@Ignored(targets=...)withprefixsupport — correctly excludes targets already defined in other@Ignoredand@Mappingannotations on the same method@Ignoredtargets as mapped@Mappingand@Ignoredtargeting the same property@IgnoredtargetsAlso refactors
MapstructTargetReferenceby extracting shared logic intoBaseTargetReference, reused by bothMapstructTargetReferenceand the newMapstructIgnoredTargetReference. GeneralizesextractMappingAnnotationsFromMappingstoextractRepeatableAnnotationsfor reuse with@IgnoredList.Test plan
IgnoredTargetsCompletionTestCase— completion with/without prefix, multiple targets, multiple annotations, invalid prefix, combined with@MappingUnmappedTargetPropertiesWithIgnoredInspectionTest— unmapped properties inspection respects@IgnoredTargetPropertyMappedMoreThanOnceInspectionTest— detects@Mapping/@IgnoredconflictsMapstructReferenceInspectionTest— unknown target reference for@IgnoredMapstructCompletionTestCase— completion with@Ignoredpresent on method./gradlew build)