Search in sources :

Example 21 with IndexNotReadyException

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));
        }
    }
}
Also used : ProcessingContext(com.intellij.util.ProcessingContext) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) ElementPattern(com.intellij.patterns.ElementPattern)

Example 22 with IndexNotReadyException

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;
    }
}
Also used : TreePath(javax.swing.tree.TreePath) ArrayList(java.util.ArrayList) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) PsiElement(com.intellij.psi.PsiElement) Location(com.intellij.execution.Location)

Example 23 with IndexNotReadyException

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("");
}
Also used : DebugProcess(com.intellij.debugger.engine.DebugProcess) DebugProcessImpl(com.intellij.debugger.engine.DebugProcessImpl) IntegerValue(com.sun.jdi.IntegerValue) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) DebuggerContextImpl(com.intellij.debugger.impl.DebuggerContextImpl) PsiAnnotation(com.intellij.psi.PsiAnnotation)

Example 24 with IndexNotReadyException

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();
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiClass(com.intellij.psi.PsiClass) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException)

Example 25 with IndexNotReadyException

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;
}
Also used : Project(com.intellij.openapi.project.Project) PsiClass(com.intellij.psi.PsiClass) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)70 Nullable (org.jetbrains.annotations.Nullable)14 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)12 PsiElement (com.intellij.psi.PsiElement)11 Project (com.intellij.openapi.project.Project)10 PsiFile (com.intellij.psi.PsiFile)10 TextRange (com.intellij.openapi.util.TextRange)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 NotNull (org.jetbrains.annotations.NotNull)8 Document (com.intellij.openapi.editor.Document)6 Editor (com.intellij.openapi.editor.Editor)6 LocalQuickFixAndIntentionActionOnPsiElement (com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement)5 Ref (com.intellij.openapi.util.Ref)4 LightweightHint (com.intellij.ui.LightweightHint)4 HighlightInfo (com.intellij.codeInsight.daemon.impl.HighlightInfo)3 Module (com.intellij.openapi.module.Module)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 StringUtil (com.intellij.openapi.util.text.StringUtil)3 PsiClass (com.intellij.psi.PsiClass)3 javax.swing (javax.swing)3