Skip to content

Commit

Permalink
fix: null analysis error "Null type mismatch"
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Mar 28, 2024
1 parent a13a348 commit 7c502d0
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public Reader getReader() throws IOException {
* as a fallback try to lookup a matching grammar via the fileType property inside the TextMate grammar file.
* this can be expensive as it results in potentially loading/parsing all registered grammar files
*/
return Stream //
final var result = Stream //
.concat(userDefinitions.stream(), pluginDefinitions.stream())
.map(definition -> {
final var grammarForScope = getGrammarForScope(definition.getScope());
Expand All @@ -242,8 +242,11 @@ public Reader getReader() throws IOException {
: null;
})
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
.findFirst();

// workaround for "Null type mismatch: required '@NonNull IGrammar' but the provided value is null" when using:
// return result.orElse(null);
return result.isPresent() ? result.get() : null;
}

@Override
Expand All @@ -255,7 +258,6 @@ public Reader getReader() throws IOException {
.toArray(IGrammarDefinition[]::new);
}


/**
* @param scopeName an unqualified (sources.batchfile) or qualified (sources.batchfile@plugin) scope name
*/
Expand Down

0 comments on commit 7c502d0

Please sign in to comment.