Update stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-06-20 19:35:02 +02:00
Ursprung 75f88d65ac
Commit 96953bdec4
2 geänderte Dateien mit 10 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -111,7 +111,7 @@ public abstract class AbstractSWCommand<T> {
for (Method method : methods) { for (Method method : methods) {
Cached cached = method.getAnnotation(Cached.class); Cached cached = method.getAnnotation(Cached.class);
addMapper(Mapper.class, method, i -> i == 0, false, AbstractTypeMapper.class, (anno, typeMapper) -> { addMapper(Mapper.class, method, i -> i == 0, false, AbstractTypeMapper.class, (anno, typeMapper) -> {
addToCache(cached, typeMapper); TabCompletionCache.add(typeMapper, cached);
if (anno.local()) { if (anno.local()) {
localTypeMapper.putIfAbsent(anno.value(), (AbstractTypeMapper<T, ?>) typeMapper); localTypeMapper.putIfAbsent(anno.value(), (AbstractTypeMapper<T, ?>) typeMapper);
} else { } else {
@ -119,7 +119,7 @@ public abstract class AbstractSWCommand<T> {
} }
}); });
addMapper(ClassMapper.class, method, i -> i == 0, false, AbstractTypeMapper.class, (anno, typeMapper) -> { addMapper(ClassMapper.class, method, i -> i == 0, false, AbstractTypeMapper.class, (anno, typeMapper) -> {
addToCache(cached, typeMapper); TabCompletionCache.add(typeMapper, cached);
if (anno.local()) { if (anno.local()) {
localTypeMapper.putIfAbsent(anno.value().getTypeName(), (AbstractTypeMapper<T, ?>) typeMapper); localTypeMapper.putIfAbsent(anno.value().getTypeName(), (AbstractTypeMapper<T, ?>) typeMapper);
} else { } else {
@ -213,14 +213,6 @@ public abstract class AbstractSWCommand<T> {
initialized = true; initialized = true;
} }
private void addToCache(Cached cached, AbstractTypeMapper<?, ?> typeMapper) {
if (cached != null) {
TabCompletionCache.cached.add(typeMapper);
if (cached.global()) TabCompletionCache.global.add(typeMapper);
TabCompletionCache.cacheDuration.put(typeMapper, cached.timeUnit().toMillis(cached.cacheDuration()));
}
}
private <T extends Annotation> void add(Class<T> annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class<?> returnType, BiConsumer<T, Parameter[]> consumer) { private <T extends Annotation> void add(Class<T> annotation, Method method, IntPredicate parameterTester, boolean firstParameter, Class<?> returnType, BiConsumer<T, Parameter[]> consumer) {
T[] anno = SWCommandUtils.getAnnotation(method, annotation); T[] anno = SWCommandUtils.getAnnotation(method, annotation);
if (anno == null || anno.length == 0) return; if (anno == null || anno.length == 0) return;

Datei anzeigen

@ -15,6 +15,14 @@ public class TabCompletionCache {
Set<AbstractTypeMapper<?, ?>> global = new HashSet<>(); Set<AbstractTypeMapper<?, ?>> global = new HashSet<>();
Map<AbstractTypeMapper<?, ?>, Long> cacheDuration = new HashMap<>(); Map<AbstractTypeMapper<?, ?>, Long> cacheDuration = new HashMap<>();
void add(AbstractTypeMapper<?, ?> typeMapper, AbstractSWCommand.Cached cached) {
if (cached != null) {
TabCompletionCache.cached.add(typeMapper);
if (cached.global()) TabCompletionCache.global.add(typeMapper);
TabCompletionCache.cacheDuration.put(typeMapper, cached.timeUnit().toMillis(cached.cacheDuration()));
}
}
@EqualsAndHashCode @EqualsAndHashCode
@AllArgsConstructor @AllArgsConstructor
private static class Key { private static class Key {