Skip to content

Commit

Permalink
Merge pull request #591 from dingyi222666/hotfix-issue-588
Browse files Browse the repository at this point in the history
Fix #588
  • Loading branch information
Rosemoe committed May 17, 2024
2 parents ab61ec9 + e4714e6 commit 43e1706
Show file tree
Hide file tree
Showing 7 changed files with 545 additions and 539 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.eclipse.tm4e.languageconfiguration.internal.model.LanguageConfiguration;

import java.io.Reader;
import java.util.Objects;

import io.github.rosemoe.sora.lang.EmptyLanguage;
import io.github.rosemoe.sora.lang.analysis.AnalyzeManager;
Expand All @@ -51,7 +50,6 @@
import io.github.rosemoe.sora.text.CharPosition;
import io.github.rosemoe.sora.text.ContentReference;
import io.github.rosemoe.sora.util.MyCharacter;
import io.github.rosemoe.sora.widget.SymbolPairMatch;

public class TextMateLanguage extends EmptyLanguage {

Expand Down Expand Up @@ -237,7 +235,10 @@ public void updateLanguage(GrammarDefinition grammarDefinition) {
@NonNull
@Override
public AnalyzeManager getAnalyzeManager() {
return Objects.requireNonNullElse(textMateAnalyzer, EmptyAnalyzeManager.INSTANCE);
if (textMateAnalyzer == null) {
return EmptyAnalyzeManager.INSTANCE;
}
return textMateAnalyzer;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ IToken[] getResult(final StateStack stack, final int lineLength) {
this._tokens.getLast().setStartIndex(0);
}

return this._tokens.toArray(IToken[]::new);
return this._tokens.toArray(new IToken[0]);
}

int[] getBinaryResult(final StateStack stack, final int lineLength) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ private static CompilePatternsResult _compilePatterns(@Nullable final Collection
}
}

return new CompilePatternsResult(r.toArray(RuleId[]::new), patterns.size() != r.size());
return new CompilePatternsResult(r.toArray(new RuleId[0]), patterns.size() != r.size());
}

private RuleFactory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.eclipse.jdt.annotation.Nullable;

Expand Down Expand Up @@ -110,7 +111,9 @@ public static String toStringWithIndex(final List<?> list) {
* @return a new list without null elements
*/
public static <T> List<T> noNulls(final @Nullable List<T> coll) {
return coll == null || coll.isEmpty() ? Collections.emptyList() : coll.stream().filter(Objects::nonNull).toList();
return coll == null || coll.isEmpty() ? Collections.emptyList() : coll.stream()
.filter(t -> t != null)
.collect(Collectors.toList());
}

private MoreCollections() {
Expand Down
Loading

0 comments on commit 43e1706

Please sign in to comment.