FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add @Ignored annotation support by filiphr · Pull Request #258 · mapstruct/mapstruct-idea · GitHub

Add @Ignored annotation support - #258

Open
filiphr wants to merge 2 commits into
mainfrom
add-ignored-annotation-support
Open

Add @Ignored annotation support#258
filiphr wants to merge 2 commits into
mainfrom
add-ignored-annotation-support

Conversation

filiphr commented Mar 2, 2026

Copy link
Copy Markdown
Member

Summary

Closes #237, closes #238

Add support for the @Ignored annotation introduced in MapStruct 1.7:

  • Code completion for @Ignored(targets=...) with prefix support — correctly excludes targets already defined in other @Ignored and @Mapping annotations on the same method
  • Go-to-declaration and find usages for ignored target properties
  • UnmappedTargetPropertiesInspection considers @Ignored targets as mapped
  • TargetPropertyMappedMoreThanOnceInspection detects conflicts between @Mapping and @Ignored targeting the same property
  • Unknown target reference inspection for @Ignored targets

Also refactors MapstructTargetReference by extracting shared logic into BaseTargetReference, reused by both MapstructTargetReference and the new MapstructIgnoredTargetReference. Generalizes extractMappingAnnotationsFromMappings to extractRepeatableAnnotations for reuse with @IgnoredList.

Test plan

  • IgnoredTargetsCompletionTestCase — completion with/without prefix, multiple targets, multiple annotations, invalid prefix, combined with @Mapping
  • UnmappedTargetPropertiesWithIgnoredInspectionTest — unmapped properties inspection respects @Ignored
  • TargetPropertyMappedMoreThanOnceInspectionTest — detects @Mapping/@Ignored conflicts
  • MapstructReferenceInspectionTest — unknown target reference for @Ignored
  • MapstructCompletionTestCase — completion with @Ignored present on method
  • Full build passes (./gradlew build)

…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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 (with prefix), go-to-declaration/find-usages, and unknown-reference highlighting.
  • Update inspections to treat @Ignored targets as mapped and detect @Mapping/@Ignored conflicts.
  • Refactor target reference resolution into BaseTargetReference and 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.

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

Labels

None yet

Projects

None yet

2 participants


Back | FazBrowse Home | New Git URL