Skip to content

Commit 324539f

Browse files
committed
fix: artifact' quickfix should be highlighted with different color
in case it has no issues at all , and has a recommendation Signed-off-by: Zvi Grinberg <[email protected]>
1 parent 5d856dd commit 324539f

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

src/main/java/org/jboss/tools/intellij/componentanalysis/CAAnnotator.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,18 @@ public void apply(@NotNull PsiFile file, Map<Dependency, Result> annotationResul
153153

154154
elements.forEach(e -> {
155155
if (e != null) {
156-
AnnotationBuilder builder = holder
157-
.newAnnotation(HighlightSeverity.ERROR, messageBuilder.toString())
158-
.tooltip(tooltipBuilder.toString())
159-
.range(e);
160-
161-
builder.withFix(new SAIntentionAction());
162-
163156
if (!quickfixes.isEmpty() && this.isQuickFixApplicable(e)) {
164-
quickfixes.forEach((source, report) ->
165-
builder.withFix(this.createQuickFix(e, source, report)));
157+
quickfixes.forEach((source, report) ->{
158+
AnnotationBuilder builder = holder
159+
.newAnnotation(getHighlightSeverity(report), messageBuilder.toString())
160+
.tooltip(tooltipBuilder.toString())
161+
.range(e);
162+
builder.withFix(new SAIntentionAction());
163+
builder.withFix(this.createQuickFix(e, source, report));
164+
builder.create();
165+
}
166+
);
166167
}
167-
168-
builder.create();
169168
}
170169
});
171170
}
@@ -174,6 +173,19 @@ public void apply(@NotNull PsiFile file, Map<Dependency, Result> annotationResul
174173
});
175174
}
176175

176+
@NotNull
177+
private static HighlightSeverity getHighlightSeverity(DependencyReport report) {
178+
if(CAIntentionAction.thereAreNoIssues(report) && CAIntentionAction.thereIsRecommendation(report))
179+
{
180+
return HighlightSeverity.WEAK_WARNING;
181+
}
182+
else
183+
{
184+
return HighlightSeverity.ERROR;
185+
}
186+
187+
}
188+
177189
abstract protected String getInspectionShortName();
178190

179191
abstract protected Map<Dependency, List<PsiElement>> getDependencies(PsiFile file);

src/main/java/org/jboss/tools/intellij/componentanalysis/CAIntentionAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ private static boolean thereIsTcRemediation(DependencyReport dependency) {
123123
}
124124
}
125125

126-
private static boolean thereIsRecommendation(DependencyReport dependency) {
126+
static boolean thereIsRecommendation(DependencyReport dependency) {
127127
return dependency.getRecommendation() != null && !dependency.getRecommendation().version().trim().equals("");
128128
}
129129

130-
private static boolean thereAreNoIssues(DependencyReport dependency) {
130+
static boolean thereAreNoIssues(DependencyReport dependency) {
131131
return dependency.getIssues() == null || dependency.getIssues().size() == 0;
132132
}
133133

0 commit comments

Comments
 (0)