use of com.intellij.openapi.project.IndexNotReadyException in project go-lang-idea-plugin by go-lang-plugin-org.
the class DlvStackFrame method getEvaluator.
@Nullable
@Override
public XDebuggerEvaluator getEvaluator() {
return new XDebuggerEvaluator() {
@Override
public void evaluate(@NotNull String expression, @NotNull XEvaluationCallback callback, @Nullable XSourcePosition expressionPosition) {
myProcessor.send(new DlvRequest.EvalSymbol(expression, myId)).done(variable -> callback.evaluated(createXValue(variable, AllIcons.Debugger.Watch))).rejected(throwable -> callback.errorOccurred(throwable.getMessage()));
}
@Nullable
private PsiElement findElementAt(@Nullable PsiFile file, int offset) {
return file != null ? file.findElementAt(offset) : null;
}
@Nullable
@Override
public TextRange getExpressionRangeAtOffset(@NotNull Project project, @NotNull Document document, int offset, boolean sideEffectsAllowed) {
Ref<TextRange> currentRange = Ref.create(null);
PsiDocumentManager.getInstance(project).commitAndRunReadAction(() -> {
try {
PsiElement elementAtCursor = findElementAt(PsiDocumentManager.getInstance(project).getPsiFile(document), offset);
GoTypeOwner e = PsiTreeUtil.getParentOfType(elementAtCursor, GoExpression.class, GoVarDefinition.class, GoConstDefinition.class, GoParamDefinition.class);
if (e != null) {
currentRange.set(e.getTextRange());
}
} catch (IndexNotReadyException ignored) {
}
});
return currentRange.get();
}
};
}
use of com.intellij.openapi.project.IndexNotReadyException in project smali by JesusFreke.
the class SmaliFieldElementType method createStub.
@Override
public SmaliFieldStub createStub(@NotNull SmaliField psi, StubElement parentStub) {
try {
String fieldSmaliTypeName;
SmaliTypeElement typeElement = psi.getTypeElement();
if (typeElement != null) {
fieldSmaliTypeName = typeElement.getSmaliName();
} else {
fieldSmaliTypeName = "Ljava/lang/Object;";
}
return new SmaliFieldStub(parentStub, psi.getName(), fieldSmaliTypeName);
} catch (IndexNotReadyException ex) {
System.out.println(psi.getName());
throw ex;
}
}
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());
}
use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.
the class TemplateState method focusCurrentExpression.
private void focusCurrentExpression() {
if (isFinished() || isDisposed()) {
return;
}
PsiDocumentManager.getInstance(myProject).commitDocument(myDocument);
final int currentSegmentNumber = getCurrentSegmentNumber();
lockSegmentAtTheSameOffsetIfAny();
if (currentSegmentNumber < 0)
return;
final int start = mySegments.getSegmentStart(currentSegmentNumber);
final int end = mySegments.getSegmentEnd(currentSegmentNumber);
if (end >= 0) {
myEditor.getCaretModel().moveToOffset(end);
myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
myEditor.getSelectionModel().removeSelection();
myEditor.getSelectionModel().setSelection(start, end);
}
DumbService.getInstance(myProject).withAlternativeResolveEnabled(() -> {
Expression expressionNode = getCurrentExpression();
List<TemplateExpressionLookupElement> lookupItems = getCurrentExpressionLookupItems();
final PsiFile psiFile = getPsiFile();
if (!lookupItems.isEmpty()) {
if (((TemplateManagerImpl) TemplateManager.getInstance(myProject)).shouldSkipInTests()) {
insertSingleItem(lookupItems);
} else {
for (LookupElement lookupItem : lookupItems) {
assert lookupItem != null : expressionNode;
}
AsyncEditorLoader.performWhenLoaded(myEditor, () -> runLookup(lookupItems, expressionNode.getAdvertisingText()));
}
} else {
try {
Result result = expressionNode.calculateResult(getCurrentExpressionContext());
if (result != null) {
result.handleFocused(psiFile, myDocument, mySegments.getSegmentStart(currentSegmentNumber), mySegments.getSegmentEnd(currentSegmentNumber));
}
} catch (IndexNotReadyException ignore) {
}
}
});
focusCurrentHighlighter(true);
}
use of com.intellij.openapi.project.IndexNotReadyException in project intellij-community by JetBrains.
the class TodoPackageNode method update.
@Override
protected void update(PresentationData data) {
super.update(data);
final PackageElement packageElement = getValue();
try {
if (packageElement == null || !packageElement.getPackage().isValid()) {
setValue(null);
return;
}
int fileCount = getFileCount(packageElement);
if (fileCount == 0) {
setValue(null);
return;
}
PsiPackage aPackage = packageElement.getPackage();
String newName;
if (getStructure().areFlattenPackages()) {
newName = aPackage.getQualifiedName();
} else {
newName = myPresentationName != null ? myPresentationName : "";
}
int nameEndOffset = newName.length();
int todoItemCount = getTodoItemCount(packageElement);
newName = IdeBundle.message("node.todo.group", newName, todoItemCount, fileCount);
myHighlightedRegions.clear();
TextAttributes textAttributes = new TextAttributes();
Color newColor = null;
if (CopyPasteManager.getInstance().isCutElement(packageElement)) {
newColor = CopyPasteManager.CUT_COLOR;
}
textAttributes.setForegroundColor(newColor);
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)));
data.setPresentableText(newName);
} catch (IndexNotReadyException e) {
LOG.info(e);
data.setPresentableText("N/A");
}
}
Aggregations