use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.
the class NamedObjectProviderBinding method addMatchingProviders.
static void addMatchingProviders(@NotNull PsiElement position, @Nullable final List<ProviderInfo<ElementPattern>> providerList, @NotNull Collection<ProviderInfo<ProcessingContext>> output, @NotNull PsiReferenceService.Hints hints) {
if (providerList == null)
return;
//noinspection ForLoopReplaceableByForEach
for (int i = 0; i < providerList.size(); i++) {
ProviderInfo<ElementPattern> info = providerList.get(i);
if (hints != PsiReferenceService.Hints.NO_HINTS && !info.provider.acceptsHints(position, hints)) {
continue;
}
final ProcessingContext context = new ProcessingContext();
if (hints != PsiReferenceService.Hints.NO_HINTS) {
context.put(PsiReferenceService.HINTS, hints);
}
boolean suitable = false;
try {
suitable = info.processingContext.accepts(position, context);
} catch (IndexNotReadyException ignored) {
}
if (suitable) {
output.add(new ProviderInfo<>(info.provider, context, info.priority));
}
}
}
use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.
the class TestTreeView method getData.
public Object getData(final String dataId) {
if (PlatformDataKeys.COPY_PROVIDER.is(dataId)) {
return this;
}
if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
TreePath[] paths = getSelectionPaths();
if (paths != null && paths.length > 1) {
final List<PsiElement> els = new ArrayList<>(paths.length);
for (TreePath path : paths) {
if (isPathSelected(path.getParentPath()))
continue;
AbstractTestProxy test = getSelectedTest(path);
if (test != null) {
final PsiElement psiElement = (PsiElement) TestsUIUtil.getData(test, CommonDataKeys.PSI_ELEMENT.getName(), myModel);
if (psiElement != null) {
els.add(psiElement);
}
}
}
return els.isEmpty() ? null : els.toArray(new PsiElement[els.size()]);
}
}
if (Location.DATA_KEYS.is(dataId)) {
TreePath[] paths = getSelectionPaths();
if (paths != null && paths.length > 1) {
final List<Location<?>> locations = new ArrayList<>(paths.length);
for (TreePath path : paths) {
if (isPathSelected(path.getParentPath()))
continue;
AbstractTestProxy test = getSelectedTest(path);
if (test != null) {
final Location<?> location = (Location<?>) TestsUIUtil.getData(test, Location.DATA_KEY.getName(), myModel);
if (location != null) {
locations.add(location);
}
}
}
return locations.isEmpty() ? null : locations.toArray(new Location[locations.size()]);
}
}
if (MODEL_DATA_KEY.is(dataId)) {
return myModel;
}
final TreePath selectionPath = getSelectionPath();
if (selectionPath == null)
return null;
final AbstractTestProxy testProxy = getSelectedTest(selectionPath);
if (testProxy == null)
return null;
try {
return TestsUIUtil.getData(testProxy, dataId, myModel);
} catch (IndexNotReadyException ignore) {
return null;
}
}
use of com.intellij.openapi.project.IndexNotReadyException in project android by JetBrains.
the class ResolveTypedIntegerCommand method action.
@Override
public void action() {
// TODO: see if it is possible to cache this evaluation
// if (myIsEvaluated) return;
DebugProcess debugProcess = myEvaluationContext.getDebugProcess();
if (!(debugProcess instanceof DebugProcessImpl)) {
return;
}
final DebuggerContextImpl debuggerContext = ((DebugProcessImpl) debugProcess).getDebuggerContext();
PsiAnnotation annotation = ApplicationManager.getApplication().runReadAction(new Computable<PsiAnnotation>() {
@Override
public PsiAnnotation compute() {
try {
return getAnnotation(debuggerContext);
} catch (IndexNotReadyException e) {
return null;
}
}
});
if (annotation != null) {
ResourceIdResolver resolver = ServiceManager.getService(myEvaluationContext.getProject(), ResourceIdResolver.class);
DynamicResourceIdResolver resolver1 = new DynamicResourceIdResolver(myEvaluationContext, resolver);
myResult = AnnotationsRenderer.render(resolver1, annotation, ((IntegerValue) myValue).value());
}
evaluationResult("");
}
use of com.intellij.openapi.project.IndexNotReadyException in project android by JetBrains.
the class ChooseClassDialog method findInheritors.
public static Collection<PsiClass> findInheritors(Module module, String name, boolean includeAll) {
PsiClass base = findClass(module, name);
if (base != null) {
GlobalSearchScope scope = includeAll ? GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, false) : GlobalSearchScope.moduleScope(module);
Collection<PsiClass> classes;
try {
classes = ClassInheritorsSearch.search(base, scope, true).findAll();
} catch (IndexNotReadyException e) {
classes = Collections.emptyList();
}
return classes;
}
return Collections.emptyList();
}
use of com.intellij.openapi.project.IndexNotReadyException in project android by JetBrains.
the class ChooseClassDialog method findClass.
@Nullable
public static PsiClass findClass(Module module, @Nullable String name) {
if (name == null) {
return null;
}
Project project = module.getProject();
PsiClass aClass;
try {
aClass = JavaPsiFacade.getInstance(project).findClass(name, GlobalSearchScope.allScope(project));
} catch (IndexNotReadyException e) {
aClass = null;
}
return aClass;
}
Aggregations