Skip to content

Commit

Permalink
Update SuggestionsProcessor.java
Browse files Browse the repository at this point in the history
Now the injector can be asynchronous and adding at once - simultaneously
  • Loading branch information
aratakileo committed Sep 3, 2023
1 parent 6489369 commit 24df8cc
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,23 @@ public boolean process() {
final var asyncInjectorsBuffer = new ArrayList<AsyncInjector>();

for (final var injector: injectors) {
var isActiveInjector = false;
var isValidInjector = false;

if (injector instanceof SuggestionsInjector suggestionsInjector) {
isValidInjector = true;

final var suggestions = suggestionsInjector.getSuggestions(currentExpression);

if (suggestions == null || suggestions.isEmpty()) continue;
if (suggestions != null && !suggestions.isEmpty()) {
suggestionsInjectorsBuffer.put(suggestionsInjector, suggestions);
isActiveInjector = true;
}
}

if (injector instanceof AsyncInjector asyncInjector) {
isValidInjector = true;

suggestionsInjectorsBuffer.put(suggestionsInjector, suggestions);
} else if (injector instanceof AsyncInjector asyncInjector) {
final var willApplySuggestions = asyncInjector.initAsyncApplier(
currentExpression,
suggestionList -> {
Expand All @@ -85,15 +95,20 @@ public boolean process() {
}
);

if (!willApplySuggestions) continue;
if (willApplySuggestions) {
asyncInjectorsBuffer.add(asyncInjector);
isActiveInjector = true;
}
}

asyncInjectorsBuffer.add(asyncInjector);
} else {
if (!isValidInjector) {
LOGGER.error("Invalid Injector! (" + injector + ")");

continue;
}

if (!isActiveInjector) continue;

if (injector.getStartOffset() == 0) {
minOffset = 0;
continue;
Expand Down

0 comments on commit 24df8cc

Please sign in to comment.