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