Search in sources :

Example 6 with IndexNotReadyException

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

the class HighlightUsagesAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
    final Project project = e.getProject();
    if (editor == null || project == null)
        return;
    String commandName = getTemplatePresentation().getText();
    if (commandName == null)
        commandName = "";
    CommandProcessor.getInstance().executeCommand(project, () -> {
        PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
        try {
            HighlightUsagesHandler.invoke(project, editor, psiFile);
        } catch (IndexNotReadyException ex) {
            DumbService.getInstance(project).showDumbModeNotification(ActionsBundle.message("action.HighlightUsagesInFile.not.ready"));
        }
    }, commandName, null);
}
Also used : Project(com.intellij.openapi.project.Project) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor)

Example 7 with IndexNotReadyException

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

the class FrameworkDetectionManager method showSetupFrameworksDialog.

private void showSetupFrameworksDialog(Notification notification) {
    List<? extends DetectedFrameworkDescription> descriptions;
    try {
        descriptions = getValidDetectedFrameworks();
    } catch (IndexNotReadyException e) {
        DumbService.getInstance(myProject).showDumbModeNotification("Information about detected frameworks is not available until indices are built");
        return;
    }
    if (descriptions.isEmpty()) {
        Messages.showInfoMessage(myProject, "No frameworks are detected", "Framework Detection");
        return;
    }
    final ConfigureDetectedFrameworksDialog dialog = new ConfigureDetectedFrameworksDialog(myProject, descriptions);
    if (dialog.showAndGet()) {
        notification.expire();
        List<DetectedFrameworkDescription> selected = dialog.getSelectedFrameworks();
        FrameworkDetectionUtil.setupFrameworks(selected, new PlatformModifiableModelsProvider(), new DefaultModulesProvider(myProject));
        for (DetectedFrameworkDescription description : selected) {
            final int detectorId = FrameworkDetectorRegistry.getInstance().getDetectorId(description.getDetector());
            myDetectedFrameworksData.putExistentFrameworkFiles(detectorId, description.getRelatedFiles());
        }
    }
}
Also used : ConfigureDetectedFrameworksDialog(com.intellij.framework.detection.impl.ui.ConfigureDetectedFrameworksDialog) DefaultModulesProvider(com.intellij.openapi.roots.ui.configuration.DefaultModulesProvider) DetectedFrameworkDescription(com.intellij.framework.detection.DetectedFrameworkDescription) PlatformModifiableModelsProvider(com.intellij.openapi.roots.PlatformModifiableModelsProvider) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException)

Example 8 with IndexNotReadyException

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

the class TodoDirNode method getFileCount.

public int getFileCount(PsiDirectory directory) {
    Iterator<PsiFile> iterator = myBuilder.getFiles(directory);
    int count = 0;
    try {
        while (iterator.hasNext()) {
            PsiFile psiFile = iterator.next();
            if (getStructure().accept(psiFile)) {
                count++;
            }
        }
    } catch (IndexNotReadyException e) {
        return count;
    }
    return count;
}
Also used : IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) PsiFile(com.intellij.psi.PsiFile)

Example 9 with IndexNotReadyException

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

the class TodoFileNode method updateImpl.

@Override
protected void updateImpl(PresentationData data) {
    super.updateImpl(data);
    String newName;
    if (myBuilder.getTodoTreeStructure().isPackagesShown()) {
        newName = getValue().getName();
    } else {
        newName = mySingleFileMode ? getValue().getName() : getValue().getVirtualFile().getPresentableUrl();
    }
    int nameEndOffset = newName.length();
    int todoItemCount;
    try {
        todoItemCount = myBuilder.getTodoTreeStructure().getTodoItemCount(getValue());
    } catch (IndexNotReadyException e) {
        return;
    }
    if (mySingleFileMode) {
        if (todoItemCount == 0) {
            newName = IdeBundle.message("node.todo.no.items.found", newName);
        } else {
            newName = IdeBundle.message("node.todo.found.items", newName, todoItemCount);
        }
    } else {
        newName = IdeBundle.message("node.todo.items", newName, todoItemCount);
    }
    myHighlightedRegions.clear();
    TextAttributes textAttributes = new TextAttributes();
    textAttributes.setForegroundColor(myColor);
    myHighlightedRegions.add(new HighlightedRegion(0, nameEndOffset, textAttributes));
    EditorColorsScheme colorsScheme = UsageTreeColorsScheme.getInstance().getScheme();
    myHighlightedRegions.add(new HighlightedRegion(nameEndOffset, newName.length(), colorsScheme.getAttributes(UsageTreeColors.NUMBER_OF_USAGES)));
}
Also used : IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) TextAttributes(com.intellij.openapi.editor.markup.TextAttributes) HighlightedRegion(com.intellij.ui.HighlightedRegion) EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme)

Example 10 with IndexNotReadyException

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

the class TodoTreeBuilder method init.

/**
   * Initializes the builder. Subclasses should don't forget to call this method after constructor has
   * been invoked.
   */
public final void init() {
    TodoTreeStructure todoTreeStructure = createTreeStructure();
    setTreeStructure(todoTreeStructure);
    todoTreeStructure.setTreeBuilder(this);
    try {
        rebuildCache();
    } catch (IndexNotReadyException ignore) {
    }
    initRootNode();
    Object selectableElement = todoTreeStructure.getFirstSelectableElement();
    if (selectableElement != null) {
        buildNodeForElement(selectableElement);
        DefaultMutableTreeNode node = getNodeForElement(selectableElement);
        if (node != null) {
            getTree().getSelectionModel().setSelectionPath(new TreePath(node.getPath()));
        }
    }
    FileStatusManager.getInstance(myProject).addFileStatusListener(myFileStatusListener);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException)

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