use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.
the class RunConfigurationsComboBoxAction method update.
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
Project project = e.getData(CommonDataKeys.PROJECT);
if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())) {
presentation.setDescription(ExecutionBundle.message("choose.run.configuration.action.description"));
}
try {
if (project == null || project.isDisposed() || !project.isInitialized()) {
updatePresentation(null, null, null, presentation);
presentation.setEnabled(false);
} else {
updatePresentation(ExecutionTargetManager.getActiveTarget(project), RunManagerEx.getInstanceEx(project).getSelectedConfiguration(), project, presentation);
presentation.setEnabled(true);
}
} catch (IndexNotReadyException e1) {
presentation.setEnabled(false);
}
}
use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.
the class RunConfigurationsComboBoxAction method setConfigurationIcon.
private static void setConfigurationIcon(final Presentation presentation, final RunnerAndConfigurationSettings settings, final Project project) {
try {
Icon icon = RunManagerEx.getInstanceEx(project).getConfigurationIcon(settings);
ExecutionManagerImpl executionManager = ExecutionManagerImpl.getInstance(project);
List<RunContentDescriptor> runningDescriptors = executionManager.getRunningDescriptors(s -> s == settings);
if (runningDescriptors.size() == 1) {
icon = ExecutionUtil.getLiveIndicator(icon);
}
if (runningDescriptors.size() > 1) {
icon = IconUtil.addText(icon, String.valueOf(runningDescriptors.size()));
}
presentation.setIcon(icon);
} catch (IndexNotReadyException ignored) {
}
}
use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.
the class MethodBreakpoint method getMethodDescriptor.
//public boolean canMoveTo(final SourcePosition position) {
// return super.canMoveTo(position) && PositionUtil.getPsiElementAt(getProject(), PsiMethod.class, position) != null;
//}
/**
* finds FQ method's class name and method's signature
*/
@Nullable
private static MethodDescriptor getMethodDescriptor(@NotNull final Project project, @NotNull final PsiFile psiJavaFile, @NotNull final SourcePosition sourcePosition) {
final PsiDocumentManager docManager = PsiDocumentManager.getInstance(project);
final Document document = docManager.getDocument(psiJavaFile);
if (document == null) {
return null;
}
//final int endOffset = document.getLineEndOffset(sourcePosition);
//final MethodDescriptor descriptor = docManager.commitAndRunReadAction(new Computable<MethodDescriptor>() {
// conflicts with readAction on initial breakpoints creation
final MethodDescriptor descriptor = ApplicationManager.getApplication().runReadAction(new Computable<MethodDescriptor>() {
@Nullable
public MethodDescriptor compute() {
//PsiMethod method = DebuggerUtilsEx.findPsiMethod(psiJavaFile, endOffset);
PsiMethod method = PositionUtil.getPsiElementAt(project, PsiMethod.class, sourcePosition);
if (method == null) {
return null;
}
final int methodOffset = method.getTextOffset();
if (methodOffset < 0) {
return null;
}
if (document.getLineNumber(methodOffset) < sourcePosition.getLine()) {
return null;
}
final PsiIdentifier identifier = method.getNameIdentifier();
int methodNameOffset = identifier != null ? identifier.getTextOffset() : methodOffset;
final MethodDescriptor descriptor = new MethodDescriptor();
descriptor.methodName = JVMNameUtil.getJVMMethodName(method);
try {
descriptor.methodSignature = JVMNameUtil.getJVMSignature(method);
descriptor.isStatic = method.hasModifierProperty(PsiModifier.STATIC);
} catch (IndexNotReadyException ignored) {
return null;
}
descriptor.methodLine = document.getLineNumber(methodNameOffset);
return descriptor;
}
});
if (descriptor == null || descriptor.methodName == null || descriptor.methodSignature == null) {
return null;
}
return descriptor;
}
use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.
the class ClassPresentationProvider method getPresentation.
@Override
public ItemPresentation getPresentation(@NotNull final PsiClass psiClass) {
return new ColoredItemPresentation() {
@Override
public String getPresentableText() {
return ClassPresentationUtil.getNameForClass(psiClass, false);
}
@Override
public String getLocationString() {
PsiFile file = psiClass.getContainingFile();
if (file instanceof PsiClassOwner) {
PsiClassOwner classOwner = (PsiClassOwner) file;
String packageName = classOwner.getPackageName();
if (packageName.isEmpty())
return null;
return "(" + packageName + ")";
}
return null;
}
@Override
public TextAttributesKey getTextAttributesKey() {
try {
if (psiClass.isDeprecated()) {
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
}
} catch (IndexNotReadyException ignore) {
}
return null;
}
@Override
public Icon getIcon(boolean open) {
return psiClass.getIcon(Iconable.ICON_FLAG_VISIBILITY | Iconable.ICON_FLAG_READ_STATUS);
}
};
}
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);
}
Aggregations