Search in sources :

Example 56 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 57 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 58 with IndexNotReadyException

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

the class AntRenameHandler method getPsiElementsIn.

@Nullable
private static PsiElement[] getPsiElementsIn(final Editor editor, final PsiFile psiFile) {
    try {
        final PsiReference reference = TargetElementUtil.findReference(editor, editor.getCaretModel().getOffset());
        if (reference == null) {
            return null;
        }
        final Collection<PsiElement> candidates = TargetElementUtil.getInstance().getTargetCandidates(reference);
        return ContainerUtil.toArray(candidates, new PsiElement[candidates.size()]);
    } catch (IndexNotReadyException e) {
        return null;
    }
}
Also used : IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) PsiReference(com.intellij.psi.PsiReference) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 59 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 60 with IndexNotReadyException

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

the class AddExternalLibraryToDependenciesQuickFix method invoke.

@Override
public void invoke(@NotNull Project project, final Editor editor, PsiFile file) throws IncorrectOperationException {
    DependencyScope scope = suggestScopeByLocation(myCurrentModule, myReference.getElement());
    JavaProjectModelModificationService.getInstance(project).addDependency(myCurrentModule, myLibraryDescriptor, scope).done(aVoid -> new WriteAction() {

        protected void run(@NotNull final Result result) {
            try {
                importClass(myCurrentModule, editor, myReference, myQualifiedClassName);
            } catch (IndexNotReadyException e) {
                LOG.info(e);
            }
        }
    }.execute());
}
Also used : DependencyScope(com.intellij.openapi.roots.DependencyScope) WriteAction(com.intellij.openapi.application.WriteAction) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) NotNull(org.jetbrains.annotations.NotNull) Result(com.intellij.openapi.application.Result)

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