Skip to content
Open
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 @@ -27,6 +27,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Properties;
Expand All @@ -50,6 +51,7 @@
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;
import org.openide.util.lookup.ServiceProvider;

/**
Expand All @@ -59,6 +61,8 @@
@ServiceProvider(service=ClassPathProvider.class, position=9999)
public class ClassPathProviderImpl implements ClassPathProvider {

private static final RequestProcessor WORKER = new RequestProcessor(ClassPathProviderImpl.class.getName(), 1, false, false);

@Override
public ClassPath findClassPath(FileObject file, String type) {
TestRootDescription rootDesc = TestRootDescription.findRootDescriptionFor(file);
Expand Down Expand Up @@ -264,6 +268,19 @@ private String packageClause(String fileContent) {
private void initializeUsagesQuery(FileObject root) {
try {
ClassLoader cl = JavaSource.class.getClassLoader();

Class<?> repositoryUpdaterClass = Class.forName("org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater", false, cl);
Field workerField = repositoryUpdaterClass.getDeclaredField("WORKER");

workerField.setAccessible(true);

RequestProcessor repositoryUpdaterWorker = (RequestProcessor) workerField.get(null);

if (repositoryUpdaterWorker.isRequestProcessorThread()) {
WORKER.post(() -> initializeUsagesQuery(root));
return ;
}

Class<?> transactionContextClass = Class.forName("org.netbeans.modules.java.source.indexing.TransactionContext", false, cl);
Class<?> serviceClass = Class.forName("org.netbeans.modules.java.source.indexing.TransactionContext$Service", false, cl);
Method beginTrans = transactionContextClass.getDeclaredMethod("beginTrans");
Expand Down
Loading