1 11 package org.eclipse.jdt.internal.debug.ui.variables; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.model.IExpression; 15 import org.eclipse.debug.core.model.IValue; 16 import org.eclipse.debug.internal.ui.model.elements.ExpressionContentProvider; 17 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 18 import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; 19 import org.eclipse.jdt.debug.core.IJavaObject; 20 import org.eclipse.jdt.internal.debug.core.logicalstructures.JDIAllInstancesValue; 21 import org.eclipse.jdt.internal.debug.core.model.JDIDebugModelMessages; 22 import org.eclipse.jdt.internal.debug.core.model.JDIReferenceListValue; 23 import org.eclipse.jdt.internal.debug.core.model.JDIReferenceListVariable; 24 25 import com.ibm.icu.text.MessageFormat; 26 27 34 public class JavaExpressionContentProvider extends ExpressionContentProvider{ 35 36 39 protected Object [] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { 40 Object [] variables = getAllChildren(parent, context); 41 if (JavaVariableContentProvider.displayReferencesAsChild(parent)){ 42 IValue value = ((IExpression)parent).getValue(); 43 if (!(value instanceof JDIAllInstancesValue) && !(value instanceof JDIReferenceListValue)) { 44 Object [] moreVariables = new Object [variables.length+1]; 45 System.arraycopy(variables, 0, moreVariables, 1, variables.length); 46 moreVariables[0] = new JDIReferenceListVariable(MessageFormat.format(JDIDebugModelMessages.JDIReferenceListValue_6, new String []{value.getReferenceTypeName() + " " + value.getValueString()}),(IJavaObject)value); return getElements(moreVariables, index, length); 48 } 49 } 50 return getElements(variables, index, length); 51 } 52 53 56 protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { 57 int count = super.getChildCount(element, context, monitor); 58 if (JavaVariableContentProvider.displayReferencesAsChild(element)){ 59 IValue value = ((IExpression)element).getValue(); 60 if (!(value instanceof JDIAllInstancesValue) && !(value instanceof JDIReferenceListValue)) { 61 count++; 62 } 63 } 64 return count; 65 } 66 67 70 protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { 71 if (JavaVariableContentProvider.displayReferencesAsChild(element)){ 72 return true; 73 } 74 return super.hasChildren(element, context, monitor); 75 } 76 77 } 78 | Popular Tags |