Esempio n. 1
0
  @Override
  public PsiElement getChildValueExpression(DebuggerTreeNode node, DebuggerContext context)
      throws EvaluateException {
    FieldDescriptor fieldDescriptor = (FieldDescriptor) node.getDescriptor();

    PsiElementFactory elementFactory =
        JavaPsiFacade.getInstance(node.getProject()).getElementFactory();
    try {
      return elementFactory.createExpressionFromText(
          "this." + fieldDescriptor.getField().name(),
          DebuggerUtils.findClass(
              fieldDescriptor.getObject().referenceType().name(),
              context.getProject(),
              context.getDebugProcess().getSearchScope()));
    } catch (IncorrectOperationException e) {
      throw new EvaluateException(
          DebuggerBundle.message("error.invalid.field.name", fieldDescriptor.getField().name()),
          null);
    }
  }
 @Override
 public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
   PsiElementFactory elementFactory =
       JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
   try {
     return elementFactory.createExpressionFromText(
         getName(), PositionUtil.getContextElement(context));
   } catch (IncorrectOperationException e) {
     throw new EvaluateException(
         DebuggerBundle.message("error.invalid.local.variable.name", getName()), e);
   }
 }
 @Override
 public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
   PsiElementFactory elementFactory =
       JavaPsiFacade.getInstance(context.getProject()).getElementFactory();
   String fieldName;
   if (isStatic()) {
     String typeName = myField.declaringType().name().replace('$', '.');
     typeName =
         DebuggerTreeNodeExpression.normalize(
             typeName, PositionUtil.getContextElement(context), context.getProject());
     fieldName = typeName + "." + getName();
   } else {
     //noinspection HardCodedStringLiteral
     fieldName =
         isOuterLocalVariableValue()
             ? StringUtil.trimStart(getName(), OUTER_LOCAL_VAR_FIELD_PREFIX)
             : "this." + getName();
   }
   try {
     return elementFactory.createExpressionFromText(fieldName, null);
   } catch (IncorrectOperationException e) {
     throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", getName()), e);
   }
 }