Skip to content

Commit c8f7cfa

Browse files
committed
Added RA to the library provider
1 parent 1ef2a78 commit c8f7cfa

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

plugin/backend/src/main/java/com/perl5/lang/perl/idea/configuration/settings/sdk/PerlLibraryProvider.kt

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,20 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
package com.perl5.lang.perl.idea.configuration.settings.sdk
1617

17-
package com.perl5.lang.perl.idea.configuration.settings.sdk;
18+
import com.intellij.openapi.application.ReadAction
19+
import com.intellij.openapi.project.Project
20+
import com.intellij.openapi.roots.AdditionalLibraryRootsProvider
21+
import com.intellij.openapi.roots.SyntheticLibrary
22+
import com.intellij.openapi.vfs.VirtualFile
23+
import com.perl5.lang.perl.idea.project.PerlProjectManager
24+
import com.perl5.lang.perl.util.PerlRunUtil
1825

19-
import com.intellij.openapi.project.Project;
20-
import com.intellij.openapi.roots.AdditionalLibraryRootsProvider;
21-
import com.intellij.openapi.roots.SyntheticLibrary;
22-
import com.intellij.openapi.vfs.VirtualFile;
23-
import com.perl5.lang.perl.idea.project.PerlProjectManager;
24-
import com.perl5.lang.perl.util.PerlRunUtil;
25-
import org.jetbrains.annotations.NotNull;
26+
class PerlLibraryProvider : AdditionalLibraryRootsProvider() {
27+
override fun getAdditionalProjectLibraries(project: Project): MutableCollection<SyntheticLibrary?> =
28+
PerlProjectManager.getInstance(project).projectLibraries
2629

27-
import java.util.ArrayList;
28-
import java.util.Collection;
29-
30-
public class PerlLibraryProvider extends AdditionalLibraryRootsProvider {
31-
32-
@Override
33-
public @NotNull Collection<SyntheticLibrary> getAdditionalProjectLibraries(@NotNull Project project) {
34-
return PerlProjectManager.getInstance(project).getProjectLibraries();
35-
}
36-
37-
@Override
38-
public @NotNull Collection<VirtualFile> getRootsToWatch(@NotNull Project project) {
39-
ArrayList<VirtualFile> libraryAndBinaryRoots = new ArrayList<>(PerlProjectManager.getInstance(project).getAllLibraryRoots());
40-
PerlRunUtil.getBinDirectories(project).forEach(libraryAndBinaryRoots::add);
41-
return libraryAndBinaryRoots;
42-
}
30+
override fun getRootsToWatch(project: Project): List<VirtualFile> =
31+
PerlProjectManager.getInstance(project).allLibraryRoots + ReadAction.compute<List<VirtualFile>, Throwable> { PerlRunUtil.getBinDirectories(project).toList() }
4332
}

0 commit comments

Comments
 (0)