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