-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest only missing constants for ValueMapping source
- Loading branch information
Showing
5 changed files
with
219 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
38 changes: 38 additions & 0 deletions
38
src/main/java/org/mapstruct/intellij/util/ValueMappingUtils.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright MapStruct Authors. | ||
* | ||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package org.mapstruct.intellij.util; | ||
|
||
import java.util.Objects; | ||
import java.util.stream.Stream; | ||
|
||
import com.intellij.codeInsight.AnnotationUtil; | ||
import com.intellij.psi.PsiMethod; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static org.mapstruct.intellij.util.MapstructAnnotationUtils.findAllDefinedValueMappingAnnotations; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
public class ValueMappingUtils { | ||
|
||
private ValueMappingUtils() { | ||
} | ||
|
||
/** | ||
* Find all defined {@link org.mapstruct.ValueMapping#source()} for the given method | ||
* | ||
* @param method that needs to be checked | ||
* | ||
* @return see description | ||
*/ | ||
public static Stream<String> findAllDefinedValueMappingSources(@NotNull PsiMethod method) { | ||
return findAllDefinedValueMappingAnnotations( method ) | ||
.map( psiAnnotation -> AnnotationUtil.getDeclaredStringAttributeValue( psiAnnotation, "source" ) ) | ||
.filter( Objects::nonNull ) | ||
.filter( s -> !s.isEmpty() ); | ||
} | ||
} |
This file contains 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