Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Exception when opening a JavaScript project #6645

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just -> LibraryKind.findById?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's deprecated in favor if this one

);

@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());
}
}
Loading