generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
849 additions
and
698 deletions.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
32 changes: 6 additions & 26 deletions
32
src/main/java/com/cleanroommc/groovyscript/gameobjects/Completer.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 |
---|---|---|
@@ -1,41 +1,21 @@ | ||
package com.cleanroommc.groovyscript.gameobjects; | ||
|
||
import com.cleanroommc.groovyscript.server.Completions; | ||
import org.eclipse.lsp4j.CompletionItem; | ||
import org.eclipse.lsp4j.CompletionItemKind; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
@Deprecated | ||
@ApiStatus.ScheduledForRemoval(inVersion = "1.2.0") | ||
@FunctionalInterface | ||
public interface Completer { | ||
|
||
void complete(int paramIndex, Completions items); | ||
public interface Completer extends com.cleanroommc.groovyscript.mapper.Completer { | ||
|
||
static <V> Completer ofNamed(Supplier<Iterable<V>> values, Function<V, String> toString, int preferredParamIndex) { | ||
return ofValues(values, v -> { | ||
String s = toString.apply(v); | ||
if (s != null) { | ||
var item = new CompletionItem(toString.apply(v)); | ||
item.setKind(CompletionItemKind.Constant); | ||
return item; | ||
} | ||
return null; | ||
}, preferredParamIndex); | ||
return (Completer) com.cleanroommc.groovyscript.mapper.Completer.ofNamed(values, toString, preferredParamIndex); | ||
} | ||
|
||
static <V> Completer ofValues(Supplier<Iterable<V>> values, Function<V, CompletionItem> toCompletionItem, int preferredParamIndex) { | ||
return (paramIndex, items) -> { | ||
if (preferredParamIndex < 0 || preferredParamIndex == paramIndex) { | ||
items.addAll(values.get(), toCompletionItem); | ||
} | ||
}; | ||
} | ||
|
||
default Completer and(Completer other) { | ||
return (paramIndex, items) -> { | ||
complete(paramIndex, items); | ||
other.complete(paramIndex, items); | ||
}; | ||
return (Completer) com.cleanroommc.groovyscript.mapper.Completer.ofValues(values, toCompletionItem, preferredParamIndex); | ||
} | ||
} |
Oops, something went wrong.