Skip to content

Commit

Permalink
fix: Exception when opening a JavaScript project (#6645)
Browse files Browse the repository at this point in the history
closes #6643
  • Loading branch information
tpasternak authored Aug 16, 2024
1 parent fcc25cd commit 5bf121b
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import com.intellij.openapi.roots.impl.libraries.LibraryEx;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryKind;
import com.intellij.openapi.roots.libraries.LibraryKindRegistry;
import com.intellij.util.LazyInitializer;

import java.util.function.Predicate;
import javax.annotation.Nullable;

Expand All @@ -29,20 +32,22 @@ class BlazeJavascriptLibrarySource extends LibrarySource.Adapter {

private BlazeJavascriptLibrarySource() {}

@Nullable static final LibraryKind JS_LIBRARY_KIND = LibraryKind.findById("javaScript");
static final LazyInitializer.LazyValue<LibraryKind> JS_LIBRARY_KIND = LazyInitializer.create(
() -> LibraryKindRegistry.getInstance().findKindById("javaScript")
);

@Nullable
@Override
public Predicate<Library> getGcRetentionFilter() {
if (JS_LIBRARY_KIND == null) {
if (JS_LIBRARY_KIND.get() == null) {
return null;
}
return BlazeJavascriptLibrarySource::isJavascriptLibrary;
}

static boolean isJavascriptLibrary(Library library) {
return JS_LIBRARY_KIND != null
return JS_LIBRARY_KIND.get() != null
&& library instanceof LibraryEx
&& JS_LIBRARY_KIND.equals(((LibraryEx) library).getKind());
&& JS_LIBRARY_KIND.get().equals(((LibraryEx) library).getKind());
}
}

0 comments on commit 5bf121b

Please sign in to comment.