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);
}
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());
}
}
}
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;
}
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)));
}
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);
}
Aggregations