/* (non-Javadoc)
   * @see org.eclipse.jface.text.ITextHoverExtension2#getHoverInfo2(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
   */
  public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
    IJavaScriptStackFrame frame = getFrame();
    if (frame != null) {
      IDocument document = textViewer.getDocument();
      if (document != null) {
        try {
          String variableName = document.get(hoverRegion.getOffset(), hoverRegion.getLength());
          IVariable var = findLocalVariable(frame, variableName);
          if (var != null) {
            return var;
          }

          // might be in 'this'
          var = frame.getThisObject();
          try {
            IValue val = var == null ? null : var.getValue();
            if (val != null) {
              IVariable[] vars = val.getVariables();
              for (int i = 0; i < vars.length; i++) {
                if (vars[i].getName().equals(variableName)) {
                  return vars[i];
                }
              }
            }
          } catch (DebugException de) {
            return null;
          }

        } catch (BadLocationException e) {
          return null;
        }
      }
    }
    return null;
  }
 public Object[] getChildren(Object obj) {
   try {
     Object[] variables = null;
     if (obj != null
         && obj instanceof IJavaObject
         && "org.drools.reteoo.ReteooStatefulSession"
             .equals(((IJavaObject) obj).getReferenceTypeName())) {
       variables = getAgendaElements((IJavaObject) obj);
     } else if (obj instanceof IVariable) {
       if (view.isShowLogicalStructure()) {
         IValue value = getLogicalValue(((IVariable) obj).getValue(), new ArrayList());
         variables = value.getVariables();
       }
       if (variables == null) {
         variables = ((IVariable) obj).getValue().getVariables();
       }
     }
     if (variables == null) {
       return new Object[0];
     } else {
       cache(obj, variables);
       return variables;
     }
   } catch (DebugException e) {
     DroolsEclipsePlugin.log(e);
     return new Object[0];
   }
 }
    private void addVariable(IVariable var, NesCVariableNameParser varPars, TreeParent parent) {
      try {
        IValue val = var.getValue();
        String cVarName = var.getName();
        String name = varPars.getVariableName(cVarName);
        TreeNode node = parent.hasChild(name);
        if (val.hasVariables()) {
          // var consists of multiple inner variables... (like for example a struct)
          if (node == null) {
            node = new TreeParent(name);
            node.setData(var);
            parent.addChild(node);
          }
          for (IVariable innerVar : val.getVariables()) {
            addVariable(innerVar, varPars, (TreeParent) node);
          }
        } else {
          if (node == null) {
            node = new TreeParent(name); // Leaf
            node.setData(var);
            parent.addChild(node);
          }
        }

      } catch (DebugException e) {
        TinyOSDebugPlugin.getDefault().log("Exception while adding variable to tree.", e);
      }
    }
 public void testEvalAnonymousClassVariable2() throws Throwable {
   try {
     init(30, 1);
     IValue value = eval("latch");
     String typeName = value.getReferenceTypeName();
     assertEquals("T_T_this_e : wrong type : ", "java.util.concurrent.CountDownLatch", typeName);
   } finally {
     end();
   }
 }
  public void testEvalAnonymousClassVariable1() throws Throwable {
    try {
      init(17, 2);
      IValue value = eval("innerClassField");
      String typeName = value.getReferenceTypeName();
      assertEquals("T_T_this_e : wrong type : ", "int", typeName);
      int intValue = ((IJavaPrimitiveValue) value).getIntValue();
      assertEquals("T_T_this_e : wrong result : ", 0, intValue);

    } finally {
      end();
    }
  }
 /**
  * @see
  *     org.eclipse.debug.ui.IDebugModelPresentation#computeDetail(org.eclipse.debug.core.model.IValue,
  *     org.eclipse.debug.ui.IValueDetailListener)
  */
 public void computeDetail(IValue value, IValueDetailListener listener) {
   try {
     listener.detailComputed(value, value.getValueString());
   } catch (DebugException e) {
     e.printStackTrace();
   }
 }
  public void testEvalNestedTypeTest_T_T_d() throws Throwable {
    try {
      init();
      IValue value = eval(T_T + dInt);
      String typeName = value.getReferenceTypeName();
      assertEquals("T_T_d : wrong type : ", "int", typeName);
      int intValue = ((IJavaPrimitiveValue) value).getIntValue();
      assertEquals("T_T_d : wrong result : ", dIntValue_0, intValue);

      value = eval(T_T + dString);
      typeName = value.getReferenceTypeName();
      assertEquals("T_T_d : wrong type : ", "java.lang.String", typeName);
      String stringValue = ((JDIObjectValue) value).getValueString();
      assertEquals("T_T_d : wrong result : ", dStringValue_0, stringValue);
    } finally {
      end();
    }
  }
 public void computeDetail(IValue value, IValueDetailListener listener) {
   String detail = "";
   try {
     if (value instanceof IDescentValue) {
       detail = ((IDescentValue) value).getDetail();
     } else {
       detail = value.getValueString();
     }
   } catch (DebugException e) {
   }
   listener.detailComputed(value, detail);
 }
Example #9
0
 /**
  * Returns children for the given value, creating array partitions if required
  *
  * @param parent expression or variable containing the given value
  * @param value the value to retrieve children for
  * @param context the context in which children have been requested
  * @return children for the given value, creating array partitions if required
  * @throws CoreException
  */
 protected Object[] getValueChildren(
     IDebugElement parent, IValue value, IPresentationContext context) throws CoreException {
   if (value == null) {
     return EMPTY;
   }
   IValue logicalValue = getLogicalValue(value, context);
   if (logicalValue instanceof IIndexedValue) {
     IIndexedValue indexedValue = (IIndexedValue) logicalValue;
     int partitionSize = computeParitionSize(indexedValue);
     if (partitionSize > 1) {
       int offset = indexedValue.getInitialOffset();
       int length = indexedValue.getSize();
       int numPartitions = length / partitionSize;
       int remainder = length % partitionSize;
       if (remainder > 0) {
         numPartitions++;
       }
       IVariable[] partitions = new IVariable[numPartitions];
       for (int i = 0; i < (numPartitions - 1); i++) {
         partitions[i] = new IndexedVariablePartition(parent, indexedValue, offset, partitionSize);
         offset = offset + partitionSize;
       }
       if (remainder == 0) {
         remainder = partitionSize;
       }
       partitions[numPartitions - 1] =
           new IndexedVariablePartition(parent, indexedValue, offset, remainder);
       return partitions;
     }
   }
   if (logicalValue == null) {
     // safeguard against an structure type returning null
     logicalValue = value;
   }
   return logicalValue.getVariables();
 }
Example #10
0
 /*
  * @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
  */
 public String getReferenceTypeName() throws DebugException {
   return value.getReferenceTypeName();
 }
Example #11
0
 /*
  * (non-Javadoc)
  * @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
  */
 public boolean verifyValue(IValue xvalue) throws DebugException {
   return verifyValue(xvalue.getValueString());
 }
Example #12
0
 /*
  * (non-Javadoc)
  * @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
  */
 public void setValue(IValue xvalue) throws DebugException {
   // assume never called unless supportsValueModification is true
   setValue(xvalue.getValueString());
 }
Example #13
0
 public boolean hasValueChanged() throws DebugException {
   if (fName.equals("FATAL_ERROR")
       && fType.equals("table")
       && fValue.getValueString().startsWith("A Fatal")) return true;
   return false;
 }