use of com.intellij.debugger.impl.DebuggerContextImpl in project smali by JesusFreke.
the class LazyValue method virtualMachine.
@Override
public VirtualMachine virtualMachine() {
if (evaluationContext != null) {
return ((VirtualMachineProxyImpl) evaluationContext.getDebugProcess().getVirtualMachineProxy()).getVirtualMachine();
} else {
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
final DebugProcessImpl process = debuggerContext.getDebugProcess();
if (process != null) {
return process.getVirtualMachineProxy().getVirtualMachine();
}
}
return null;
}
use of com.intellij.debugger.impl.DebuggerContextImpl in project intellij-community by JetBrains.
the class ValueHint method createInspectTree.
public static InspectDebuggerTree createInspectTree(final NodeDescriptorImpl descriptor, Project project) {
final InspectDebuggerTree tree = new InspectDebuggerTree(project);
final AnAction setValueAction = ActionManager.getInstance().getAction(DebuggerActions.SET_VALUE);
setValueAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0)), tree);
Disposer.register(tree, new Disposable() {
@Override
public void dispose() {
setValueAction.unregisterCustomShortcutSet(tree);
}
});
tree.setInspectDescriptor(descriptor);
DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(project).getContext();
tree.rebuild(context);
return tree;
}
use of com.intellij.debugger.impl.DebuggerContextImpl in project intellij-community by JetBrains.
the class DebuggerTreeCreatorImpl method createDescriptorByNode.
@Override
public void createDescriptorByNode(Object node, final ResultConsumer<Pair<NodeDescriptorImpl, String>> resultConsumer) {
if (node instanceof DebuggerTreeNodeImpl) {
final DebuggerTreeNodeImpl debuggerTreeNode = (DebuggerTreeNodeImpl) node;
final DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
context.getDebugProcess().getManagerThread().schedule(new DebuggerContextCommandImpl(context) {
@Override
public void threadAction() {
try {
final TextWithImports evaluationText = DebuggerTreeNodeExpression.createEvaluationText(debuggerTreeNode, context);
resultConsumer.onSuccess(Pair.create(debuggerTreeNode.getDescriptor(), evaluationText.getText()));
} catch (EvaluateException e) {
resultConsumer.onFailure(e);
}
}
});
}
}
use of com.intellij.debugger.impl.DebuggerContextImpl in project intellij-community by JetBrains.
the class BreakpointWithHighlighter method updateUI.
/**
* updates the state of breakpoint and all the related UI widgets etc
*/
@Override
public final void updateUI() {
if (!isVisible() || ApplicationManager.getApplication().isUnitTestMode()) {
return;
}
DebuggerInvocationUtil.swingInvokeLater(myProject, () -> {
if (!isValid()) {
return;
}
DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
DebugProcessImpl debugProcess = context.getDebugProcess();
if (debugProcess == null || !debugProcess.isAttached()) {
updateCaches(null);
updateGutter();
} else {
debugProcess.getManagerThread().invoke(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
ApplicationManager.getApplication().runReadAction(() -> {
if (!myProject.isDisposed()) {
updateCaches(debugProcess);
}
});
DebuggerInvocationUtil.swingInvokeLater(myProject, BreakpointWithHighlighter.this::updateGutter);
}
});
}
});
}
use of com.intellij.debugger.impl.DebuggerContextImpl in project intellij-community by JetBrains.
the class DefaultCodeFragmentFactory method createCodeFragment.
public JavaCodeFragment createCodeFragment(TextWithImports item, PsiElement context, final Project project) {
final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(project);
final String text = item.getText();
final JavaCodeFragment fragment;
if (CodeFragmentKind.EXPRESSION == item.getKind()) {
final String expressionText = StringUtil.endsWithChar(text, ';') ? text.substring(0, text.length() - 1) : text;
fragment = factory.createExpressionCodeFragment(expressionText, context, null, true);
} else /*if (CodeFragmentKind.CODE_BLOCK == item.getKind())*/
{
fragment = factory.createCodeBlockCodeFragment(text, context, true);
}
if (item.getImports().length() > 0) {
fragment.addImportsFromString(item.getImports());
}
fragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE);
//noinspection HardCodedStringLiteral
fragment.putUserData(KEY, "DebuggerComboBoxEditor.IS_DEBUGGER_EDITOR");
fragment.putCopyableUserData(JavaCompletionUtil.DYNAMIC_TYPE_EVALUATOR, (expression, parameters) -> {
if (!RuntimeTypeEvaluator.isSubtypeable(expression)) {
return null;
}
if (parameters.getInvocationCount() <= 1 && JavaCompletionUtil.mayHaveSideEffects(expression)) {
final CompletionService service = CompletionService.getCompletionService();
if (parameters.getInvocationCount() < 2) {
service.setAdvertisementText("Invoke completion once more to see runtime type variants");
}
return null;
}
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
DebuggerSession debuggerSession = debuggerContext.getDebuggerSession();
if (debuggerSession != null && debuggerContext.getSuspendContext() != null) {
final Semaphore semaphore = new Semaphore();
semaphore.down();
final AtomicReference<PsiType> nameRef = new AtomicReference<>();
final RuntimeTypeEvaluator worker = new RuntimeTypeEvaluator(null, expression, debuggerContext, ProgressManager.getInstance().getProgressIndicator()) {
@Override
protected void typeCalculationFinished(@Nullable PsiType type) {
nameRef.set(type);
semaphore.up();
}
};
debuggerSession.getProcess().getManagerThread().invoke(worker);
for (int i = 0; i < 50; i++) {
ProgressManager.checkCanceled();
if (semaphore.waitFor(20))
break;
}
return nameRef.get();
}
return null;
});
return fragment;
}
Aggregations