Search in sources :

Example 66 with IndexNotReadyException

use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.

the class AbstractPsiBasedNode method update.

// Should be called in atomic action
@Override
public void update(final PresentationData data) {
    ApplicationManager.getApplication().runReadAction(() -> {
        if (!validate()) {
            return;
        }
        final PsiElement value = extractPsiFromValue();
        LOG.assertTrue(value.isValid());
        int flags = getIconableFlags();
        try {
            Icon icon = value.getIcon(flags);
            data.setIcon(icon);
        } catch (IndexNotReadyException ignored) {
        }
        data.setPresentableText(myName);
        try {
            if (isDeprecated()) {
                data.setAttributesKey(CodeInsightColors.DEPRECATED_ATTRIBUTES);
            }
        } catch (IndexNotReadyException ignored) {
        }
        updateImpl(data);
        data.setIcon(patchIcon(myProject, data.getIcon(true), getVirtualFile()));
        for (ProjectViewNodeDecorator decorator : Extensions.getExtensions(ProjectViewNodeDecorator.EP_NAME, myProject)) {
            try {
                decorator.decorate(this, data);
            } catch (IndexNotReadyException ignored) {
            }
        }
    });
}
Also used : ProjectViewNodeDecorator(com.intellij.ide.projectView.ProjectViewNodeDecorator) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) RowIcon(com.intellij.ui.RowIcon) LayeredIcon(com.intellij.ui.LayeredIcon) PsiElement(com.intellij.psi.PsiElement)

Example 67 with IndexNotReadyException

use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.

the class GantPositionManagerHelper method getExtraScriptIfNotFound.

@Override
public PsiFile getExtraScriptIfNotFound(@NotNull ReferenceType refType, @NotNull final String runtimeName, @NotNull final Project project, @NotNull GlobalSearchScope scope) {
    try {
        final String fileName = StringUtil.getShortName(runtimeName);
        PsiFile[] files = FilenameIndex.getFilesByName(project, fileName + "." + GantScriptType.DEFAULT_EXTENSION, scope);
        if (files.length == 0)
            files = FilenameIndex.getFilesByName(project, fileName + "." + GantScriptType.DEFAULT_EXTENSION, GlobalSearchScope.allScope(project));
        if (files.length == 1)
            return files[0];
        if (files.length == 0) {
            files = FilenameIndex.getFilesByName(project, fileName + ".groovy", scope);
            if (files.length == 0)
                files = FilenameIndex.getFilesByName(project, fileName + "." + GantScriptType.DEFAULT_EXTENSION, GlobalSearchScope.allScope(project));
            PsiFile candidate = null;
            for (PsiFile file : files) {
                if (GroovyScriptUtil.isSpecificScriptFile(file, GantScriptType.INSTANCE)) {
                    if (candidate != null)
                        return null;
                    candidate = file;
                }
            }
            return candidate;
        }
    } catch (ProcessCanceledException | IndexNotReadyException ignored) {
    }
    return null;
}
Also used : IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) PsiFile(com.intellij.psi.PsiFile) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 68 with IndexNotReadyException

use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.

the class GroovyPositionManager method getPsiFileByLocation.

@Nullable
private PsiFile getPsiFileByLocation(@NotNull final Project project, @Nullable final Location location) {
    if (location == null)
        return null;
    final ReferenceType refType = location.declaringType();
    if (refType == null)
        return null;
    final String originalQName = refType.name().replace('/', '.');
    int dollar = originalQName.indexOf('$');
    String runtimeName = dollar >= 0 ? originalQName.substring(0, dollar) : originalQName;
    String qName = getOriginalQualifiedName(refType, runtimeName);
    GlobalSearchScope searchScope = myDebugProcess.getSearchScope();
    GroovyShortNamesCache cache = GroovyShortNamesCache.getGroovyShortNamesCache(project);
    try {
        List<PsiClass> classes = cache.getClassesByFQName(qName, searchScope, true);
        if (classes.isEmpty()) {
            classes = cache.getClassesByFQName(qName, searchScope, false);
        }
        if (classes.isEmpty()) {
            classes = cache.getClassesByFQName(qName, GlobalSearchScope.projectScope(project), false);
        }
        if (classes.isEmpty()) {
            classes = cache.getClassesByFQName(qName, addModuleContent(searchScope), false);
        }
        if (classes.isEmpty())
            return null;
        classes.sort(PsiClassUtil.createScopeComparator(searchScope));
        PsiClass clazz = classes.get(0);
        if (clazz != null)
            return clazz.getContainingFile();
    } catch (ProcessCanceledException | IndexNotReadyException e) {
        return null;
    }
    return getExtraScriptIfNotFound(project, refType, runtimeName, searchScope);
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiClass(com.intellij.psi.PsiClass) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) ReferenceType(com.sun.jdi.ReferenceType) GroovyShortNamesCache(org.jetbrains.plugins.groovy.lang.stubs.GroovyShortNamesCache) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) Nullable(org.jetbrains.annotations.Nullable)

Example 69 with IndexNotReadyException

use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.

the class UseDistributionWithSourcesNotificationProvider method createNotificationPanel.

@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    try {
        if (GradleConstants.DEFAULT_SCRIPT_NAME.equals(file.getName()) || GradleConstants.SETTINGS_FILE_NAME.equals(file.getName())) {
            final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
            if (module == null)
                return null;
            final String rootProjectPath = getRootProjectPath(module);
            if (rootProjectPath == null)
                return null;
            final GradleProjectSettings settings = GradleSettings.getInstance(module.getProject()).getLinkedProjectSettings(rootProjectPath);
            if (settings == null || settings.getDistributionType() != DistributionType.DEFAULT_WRAPPED)
                return null;
            if (settings.isDisableWrapperSourceDistributionNotification())
                return null;
            if (!showUseDistributionWithSourcesTip(rootProjectPath))
                return null;
            final EditorNotificationPanel panel = new EditorNotificationPanel();
            panel.setText(GradleBundle.message("gradle.notifications.use.distribution.with.sources"));
            panel.createActionLabel(GradleBundle.message("gradle.notifications.hide.tip"), () -> {
                settings.setDisableWrapperSourceDistributionNotification(true);
                EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
            });
            panel.createActionLabel(GradleBundle.message("gradle.notifications.apply.suggestion"), () -> {
                updateDefaultWrapperConfiguration(rootProjectPath);
                EditorNotifications.getInstance(module.getProject()).updateAllNotifications();
                ExternalSystemUtil.refreshProject(module.getProject(), GradleConstants.SYSTEM_ID, settings.getExternalProjectPath(), false, ProgressExecutionMode.START_IN_FOREGROUND_ASYNC);
            });
            return panel;
        }
    } catch (ProcessCanceledException | IndexNotReadyException ignored) {
    }
    return null;
}
Also used : GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) Module(com.intellij.openapi.module.Module) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 70 with IndexNotReadyException

use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.

the class PyDefinitionsAnnotator method visitPyFunction.

@Override
public void visitPyFunction(PyFunction node) {
    ASTNode name_node = node.getNameNode();
    if (name_node != null) {
        Annotation ann = getHolder().createInfoAnnotation(name_node, null);
        final String name = node.getName();
        LanguageLevel languageLevel = LanguageLevel.forElement(node);
        if (PyNames.UnderscoredAttributes.contains(name) || PyNames.getBuiltinMethods(languageLevel).containsKey(name)) {
            PyClass cls = node.getContainingClass();
            if (PyNames.NEW.equals(name)) {
                boolean new_style_class = false;
                try {
                    if (cls != null)
                        new_style_class = cls.isNewStyleClass(null);
                } catch (IndexNotReadyException ignored) {
                }
                if (new_style_class) {
                    ann.setTextAttributes(PyHighlighter.PY_PREDEFINED_DEFINITION);
                }
            } else {
                ann.setTextAttributes(PyHighlighter.PY_PREDEFINED_DEFINITION);
            }
        } else
            ann.setTextAttributes(PyHighlighter.PY_FUNC_DEFINITION);
    }
}
Also used : ASTNode(com.intellij.lang.ASTNode) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) Annotation(com.intellij.lang.annotation.Annotation)

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