1 11 package org.eclipse.debug.internal.ui.model.elements; 12 13 import java.util.LinkedHashSet ; 14 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.debug.core.model.IErrorReportingExpression; 17 import org.eclipse.debug.core.model.IExpression; 18 import org.eclipse.debug.core.model.IValue; 19 import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; 20 import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate; 21 22 25 public class ExpressionContentProvider extends VariableContentProvider { 26 27 protected Object [] getAllChildren(Object parent, IPresentationContext context) throws CoreException { 28 if (parent instanceof IErrorReportingExpression) { 29 IErrorReportingExpression expression = (IErrorReportingExpression) parent; 30 if (expression.hasErrors()) { 31 String [] messages = expression.getErrorMessages(); 32 LinkedHashSet set = new LinkedHashSet (messages.length); 33 for (int i = 0; i < messages.length; i++) { 34 set.add(messages[i]); 35 } 36 return set.toArray(); 37 } 38 } 39 if (parent instanceof IExpression) { 40 IExpression expression = (IExpression) parent; 41 IValue value = expression.getValue(); 42 if (value != null) { 43 return getValueChildren(expression, value, context); 44 } 45 } 46 return EMPTY; 47 } 48 49 protected boolean hasChildren(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { 50 if (element instanceof IErrorReportingExpression) { 51 IErrorReportingExpression expression = (IErrorReportingExpression) element; 52 if (expression.hasErrors()) { 53 return true; 54 } 55 } 56 IValue value = ((IExpression)element).getValue(); 57 if (value == null) { 58 return false; 59 } 60 return value.hasVariables(); 61 } 62 } 63 | Popular Tags |