Skip to content

Commit

Permalink
@ConfigProperty for java.util.Duration with defaultValue flagged as fix:
Browse files Browse the repository at this point in the history
error

Fixes #1207

Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Aug 12, 2024
1 parent 869ead4 commit 2a285f9
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
import org.eclipse.lsp4mp.commons.utils.AntPathMatcher;

import java.text.MessageFormat;
import java.time.Duration;
import java.util.List;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static com.redhat.devtools.intellij.lsp4mp4ij.psi.core.MicroProfileConfigConstants.*;
import static com.redhat.devtools.intellij.lsp4mp4ij.psi.core.utils.AnnotationUtils.getAnnotationMemberValueExpression;
Expand Down Expand Up @@ -274,7 +276,24 @@ private static boolean isAssignable(String typeFqn, String value, Module javaPro
return PsiTypeUtils.findType(javaProject, value) != null;
case "java.lang.String":
return true;
case "java.time.Duration":
try {
Duration.parse(value);
return true;
}
catch(Exception e) {
return false;
}
default:
PsiClass type = PsiTypeUtils.findType(javaProject, typeFqn);
if (type != null) {
if (type.isEnum()) {
return Stream.of(type.getFields())
.anyMatch(e -> e.getName().equals(value));


}
}
return false;
}
} catch (NumberFormatException e) {
Expand Down

0 comments on commit 2a285f9

Please sign in to comment.