use of com.intellij.debugger.engine.evaluation.TextWithImportsImpl in project android by JetBrains.
the class ArrayMapRendererBase method buildChildren.
/** Builds a list of {@link DebuggerTreeNode}'s that are the children of this node. */
@Override
public void buildChildren(Value value, ChildrenBuilder builder, EvaluationContext evaluationContext) {
DebuggerManagerThreadImpl.assertIsManagerThread();
List<DebuggerTreeNode> children = new ArrayList<DebuggerTreeNode>();
NodeManagerImpl nodeManager = (NodeManagerImpl) builder.getNodeManager();
NodeDescriptorFactory descriptorFactory = builder.getDescriptorManager();
int size;
try {
size = getArrayMapSize(value, evaluationContext);
} catch (Exception e) {
size = 0;
}
for (int i = 0, n = Math.min(size, MAX_CHILDREN); i < n; i++) {
// For each entry, display the value at that entry. TODO: we need to show the key corresponding to this as well.
// We used to show the key and value by using the following expression:
// String expression = String.format("new Object[] {this.keyAt(%1$d), this.valueAt(%2$d)}", i, i);
// But it turns out that this throws "java.lang.ClassNotFoundException: [LObject;"
// Until we find an alternate scheme, just show the value.
String expression = String.format("this.valueAt(%1$d)", i);
UserExpressionData descriptorData = new UserExpressionData((ValueDescriptorImpl) builder.getParentDescriptor(), myFqn, String.format("value[%1$d]", i), new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, expression, "", StdFileTypes.JAVA));
UserExpressionDescriptor userExpressionDescriptor = descriptorFactory.getUserExpressionDescriptor(builder.getParentDescriptor(), descriptorData);
DebuggerTreeNode arrayMapItemNode = nodeManager.createNode(userExpressionDescriptor, evaluationContext);
children.add(arrayMapItemNode);
}
if (size > MAX_CHILDREN) {
children.add(nodeManager.createMessageNode(new MessageDescriptor(MORE_ELEMENTS, MessageDescriptor.SPECIAL)));
}
builder.setChildren(children);
}
use of com.intellij.debugger.engine.evaluation.TextWithImportsImpl in project smali by JesusFreke.
the class SmaliCodeFragmentFactoryTest method assertCompletionContains.
private void assertCompletionContains(String completionText, PsiElement context, String[] expectedItems, String[] disallowedItems) {
SmaliCodeFragmentFactory codeFragmentFactory = new SmaliCodeFragmentFactory();
JavaCodeFragment fragment = codeFragmentFactory.createCodeFragment(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, completionText), context, getProject());
Editor editor = createEditor(fragment.getVirtualFile());
editor.getCaretModel().moveToOffset(completionText.length());
new CodeCompletionHandlerBase(CompletionType.BASIC).invokeCompletion(getProject(), editor);
List<LookupElement> elements = LookupManager.getInstance(getProject()).getActiveLookup().getItems();
HashSet expectedSet = Sets.newHashSet(expectedItems);
HashSet disallowedSet = Sets.newHashSet(disallowedItems);
for (LookupElement element : elements) {
expectedSet.remove(element.toString());
Assert.assertFalse(disallowedSet.contains(element.toString()));
}
Assert.assertTrue(expectedSet.size() == 0);
}
use of com.intellij.debugger.engine.evaluation.TextWithImportsImpl in project android by JetBrains.
the class ArrayMapRendererBase method calcLabel.
@Override
public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener listener) throws EvaluateException {
if (!(descriptor.getValue() instanceof ObjectReference)) {
return DebuggerBundle.message("label.undefined");
}
ObjectReference ref = (ObjectReference) descriptor.getValue();
myLabelRenderer.setLabelExpression(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, "size()", "", StdFileTypes.JAVA));
return ValueDescriptorImpl.getIdLabel(ref) + ", size = " + myLabelRenderer.calcLabel(descriptor, evaluationContext, listener);
}
use of com.intellij.debugger.engine.evaluation.TextWithImportsImpl in project intellij-community by JetBrains.
the class DebuggerUtilsImpl method readTextWithImports.
@Override
public TextWithImports readTextWithImports(Element root, String name) {
String s = JDOMExternalizerUtil.readField(root, name);
if (s != null) {
return new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, s);
} else {
Element option = JDOMExternalizerUtil.getOption(root, name);
if (option != null) {
XExpressionState state = new XExpressionState();
XmlSerializer.deserializeInto(state, option);
return TextWithImportsImpl.fromXExpression(state.toXExpression());
}
}
return null;
}
use of com.intellij.debugger.engine.evaluation.TextWithImportsImpl in project intellij-community by JetBrains.
the class FilteredRequestorImpl method readExternal.
public void readExternal(Element parentNode) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, parentNode);
if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY)) {
// compatibility with older format
SUSPEND = false;
SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
}
String condition = JDOMExternalizerUtil.readField(parentNode, CONDITION_OPTION_NAME);
if (condition != null) {
setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
}
myClassFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(FILTER_OPTION_NAME));
myClassExclusionFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(EXCLUSION_FILTER_OPTION_NAME));
final ClassFilter[] instanceFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(INSTANCE_ID_OPTION_NAME));
final List<InstanceFilter> iFilters = new ArrayList<>(instanceFilters.length);
for (ClassFilter instanceFilter : instanceFilters) {
try {
iFilters.add(InstanceFilter.create(instanceFilter));
} catch (Exception ignored) {
}
}
myInstanceFilters = iFilters.isEmpty() ? InstanceFilter.EMPTY_ARRAY : iFilters.toArray(new InstanceFilter[iFilters.size()]);
}
Aggregations