Skip to content

Commit

Permalink
combine 2 util classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker committed Aug 3, 2023
1 parent 80771c5 commit d679934
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 50 deletions.
16 changes: 16 additions & 0 deletions src/main/java/io/papermc/codebook/lvt/LvtUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import dev.denwav.hypo.asm.HypoAsmUtil;
import dev.denwav.hypo.model.data.types.JvmType;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.objectweb.asm.Type;
Expand Down Expand Up @@ -71,6 +72,21 @@ public static String findNextWord(final int start, final String str) {
return nextWord.toString();
}

public static @Nullable String tryMatchPrefix(final String methodName, final List<String> possiblePrefixes) {
// skip any exact match
if (possiblePrefixes.contains(methodName)) {
return null;
}
@Nullable String prefix = null;
for (final String possiblePrefix : possiblePrefixes) {
if (hasPrefix(methodName, possiblePrefix)) {
prefix = possiblePrefix;
break;
}
}
return prefix;
}

public static boolean isStringAllUppercase(final String input) {
for (int i = 0; i < input.length(); i++) {
final char ch = input.charAt(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
package io.papermc.codebook.lvt.suggestion;

import static io.papermc.codebook.lvt.LvtUtil.decapitalize;
import static io.papermc.codebook.lvt.suggestion.SuggestionUtil.tryMatchPrefix;
import static io.papermc.codebook.lvt.LvtUtil.tryMatchPrefix;

import io.papermc.codebook.lvt.suggestion.context.ContainerContext;
import io.papermc.codebook.lvt.suggestion.context.method.MethodCallContext;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

package io.papermc.codebook.lvt.suggestion;

import static io.papermc.codebook.lvt.suggestion.SuggestionUtil.tryMatchPrefix;
import static io.papermc.codebook.lvt.LvtUtil.tryMatchPrefix;

import dev.denwav.hypo.model.data.types.PrimitiveType;
import io.papermc.codebook.lvt.suggestion.context.ContainerContext;
Expand Down

0 comments on commit d679934

Please sign in to comment.