Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: adopt jspecify to spoon.support.compiler #5422

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/spoon/support/compiler/SpoonPom.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.maven.shared.invoker.MavenInvocationException;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.jspecify.annotations.Nullable;
import org.slf4j.Logger;
import spoon.Launcher;
import spoon.MavenLauncher;
Expand Down Expand Up @@ -332,7 +333,7 @@ private String extractVariable(String value) {
* @param key the key of the property
* @return the property value if key exists or null
*/
private String getProperty(String key) {
private @Nullable String getProperty(String key) {
if ("project.version".equals(key) || "pom.version".equals(key) || "version".equals(key)) {
if (model.getVersion() != null) {
return model.getVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.slf4j.LoggerFactory;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.jspecify.annotations.Nullable;

import spoon.SpoonException;
import spoon.reflect.code.CtAbstractSwitch;
import spoon.reflect.code.CtBinaryOperator;
Expand Down Expand Up @@ -572,7 +574,7 @@ public void scan(CtElement element) {
* @param e
* @return body of element or null if this element has no body
*/
static CtElement getBody(CtElement e) {
static @Nullable CtElement getBody(CtElement e) {
if (e instanceof CtBodyHolder) {
return ((CtBodyHolder) e).getBody();
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/spoon/support/compiler/jdt/ParentExiter.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
import org.jspecify.annotations.Nullable;

import spoon.SpoonException;
import spoon.reflect.code.BinaryOperatorKind;
Expand Down Expand Up @@ -1041,7 +1042,7 @@ public void visitCtTry(CtTry tryBlock) {
* @param tryBlock
* @return last CtCatch of `tryBlock` or null
*/
private CtCatch getLastCatcher(CtTry tryBlock) {
private @Nullable CtCatch getLastCatcher(CtTry tryBlock) {
List<CtCatch> catchers = tryBlock.getCatchers();
int nrCatchers = catchers.size();
if (nrCatchers > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ <T> CtTypeReference<T> getQualifiedTypeReference(char[][] tokens, TypeBinding re
* @param expectedName Name expected in imports.
* @return CtReference which can be a CtTypeReference, a CtPackageReference or null.
*/
CtReference getDeclaringReferenceFromImports(char[] expectedName) {
@Nullable CtReference getDeclaringReferenceFromImports(char[] expectedName) {
CompilationUnitDeclaration cuDeclaration = this.jdtTreeBuilder.getContextBuilder().compilationunitdeclaration;
if (cuDeclaration == null) {
return null;
Expand Down Expand Up @@ -887,7 +887,7 @@ <T> CtTypeReference<T> getTypeReference(TypeBinding binding, boolean resolveGene
* @return a type reference or null if the binding has no closest match
*/
@SuppressWarnings("ReturnOfNull")
private CtTypeReference<?> getTypeReferenceFromUnresolvedReferenceBinding(UnresolvedReferenceBinding binding) {
private @Nullable CtTypeReference<?> getTypeReferenceFromUnresolvedReferenceBinding(UnresolvedReferenceBinding binding) {
TypeBinding closestMatch = binding.closestMatch();
if (closestMatch != null) {
CtTypeReference<?> ref = this.jdtTreeBuilder.getFactory().Core().createTypeReference();
Expand Down