forked from redhat-developer/intellij-quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: mark @BuildStep-annotated methods as implicitly used
Signed-off-by: Fred Bricon <[email protected]>
- Loading branch information
Showing
3 changed files
with
58 additions
and
1 deletion.
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
56 changes: 56 additions & 0 deletions
56
.../com/redhat/devtools/intellij/quarkus/psi/internal/QuarkusBuildImplicitUsageProvider.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,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Red Hat Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
* which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package com.redhat.devtools.intellij.quarkus.psi.internal; | ||
|
||
import com.intellij.codeInsight.daemon.ImplicitUsageProvider; | ||
import com.intellij.psi.PsiElement; | ||
import com.intellij.psi.PsiMethod; | ||
import com.redhat.devtools.intellij.lsp4mp4ij.psi.core.jaxrs.JaxRsConstants; | ||
import com.redhat.devtools.intellij.lsp4mp4ij.psi.core.utils.AnnotationUtils; | ||
import com.redhat.devtools.intellij.lsp4mp4ij.psi.internal.restclient.MicroProfileRestClientConstants; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import static com.redhat.devtools.intellij.lsp4mp4ij.psi.core.utils.AnnotationUtils.hasAnyAnnotation; | ||
import static com.redhat.devtools.intellij.quarkus.QuarkusConstants.QUARKUS_DEPLOYMENT_BUILDSTEP_ANNOTATION; | ||
|
||
/** | ||
* Automatically declares as used, methods annotated with {@link io.quarkus.deployment.annotations.BuildStep} annotations, such as: | ||
* <p> | ||
* {@code | ||
* @BuildStep | ||
* AdditionalBeanBuildItem producePrettyTime() { | ||
* return new AdditionalBeanBuildItem(PrettyTimeProducer.class); | ||
* } | ||
* } | ||
* </p> | ||
*/ | ||
public class QuarkusBuildImplicitUsageProvider implements ImplicitUsageProvider { | ||
|
||
@Override | ||
public boolean isImplicitUsage(@NotNull PsiElement element) { | ||
return isImplicitRead(element) || isImplicitWrite(element); | ||
} | ||
|
||
@Override | ||
public boolean isImplicitRead(@NotNull PsiElement element) { | ||
return element instanceof PsiMethod && | ||
!((PsiMethod)element).isConstructor() && | ||
AnnotationUtils.hasAnyAnnotation(element, QUARKUS_DEPLOYMENT_BUILDSTEP_ANNOTATION); | ||
} | ||
|
||
@Override | ||
public boolean isImplicitWrite(@NotNull PsiElement element) { | ||
return false; | ||
} | ||
} |
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