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: Apply @Nullable annotation to spoon.support.util #5537

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/util/RtHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package spoon.support.util;

import org.jspecify.annotations.Nullable;
import spoon.reflect.code.CtExpression;
import spoon.reflect.code.CtInvocation;
import spoon.reflect.code.CtLiteral;
Expand Down Expand Up @@ -179,7 +180,7 @@ public static Collection<CtExecutableReference<?>> getAllExecutables(Class<?> cl
* @param numParams
* @return the found method or null
*/
public static Method getMethod(Class<?> clazz, String methodName, int numParams) {
public static @Nullable Method getMethod(Class<?> clazz, String methodName, int numParams) {
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (!method.isSynthetic() && method.getName().equals(methodName)) {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/spoon/support/util/internal/ElementNameMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.jspecify.annotations.Nullable;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.path.CtRole;
import spoon.support.modelobs.FineModelChangeListener;
Expand Down Expand Up @@ -91,7 +92,7 @@ protected ElementNameMap() {
* if the element is actually replaced.
*/
@Override
public T put(String key, T e) {
public @Nullable T put(String key, T e) {
if (e == null) {
return null;
}
Expand All @@ -107,12 +108,12 @@ public T put(String key, T e) {
return valueOrNull(map.put(key, wrapper));
}

private T valueOrNull(InsertOrderWrapper<T> wrapper) {
private @Nullable T valueOrNull(InsertOrderWrapper<T> wrapper) {
return wrapper != null ? wrapper.value : null;
}

@Override
public T remove(Object key) {
public @Nullable T remove(Object key) {
T removed = valueOrNull(map.remove(key));

if (removed == null) {
Expand Down Expand Up @@ -165,7 +166,7 @@ public boolean containsKey(Object key) {
}

@Override
public T get(Object key) {
public @Nullable T get(Object key) {
InsertOrderWrapper<T> wrapper = map.get(key);
if (wrapper == null) {
return null;
Expand Down