Exemplo n.º 1
0
 @Override
 public String getName() {
   String name = myField.name();
   if (myField.isStatic()
       && !(myField.declaringType().name().equals(myParent.referenceType().name()))) {
     name = name + " (" + myField.declaringType().name() + ")";
   }
   return name;
 }
 @Override
 public Value calcValue(EvaluationContextImpl evaluationContext) throws EvaluateException {
   DebuggerManagerThreadImpl.assertIsManagerThread();
   try {
     return (myObject != null)
         ? myObject.getValue(myField)
         : myField.declaringType().getValue(myField);
   } catch (ObjectCollectedException ignored) {
     throw EvaluateExceptionUtil.OBJECT_WAS_COLLECTED;
   }
 }
 @Override
 public String calcValueName() {
   String res = super.calcValueName();
   if (Boolean.TRUE.equals(getUserData(SHOW_DECLARING_TYPE))) {
     return NodeRendererSettings.getInstance()
             .getClassRenderer()
             .renderTypeName(myField.declaringType().name())
         + "."
         + res;
   }
   return res;
 }
 @Override
 public PsiExpression getDescriptorEvaluation(DebuggerContext context) throws EvaluateException {
   PsiElementFactory elementFactory = JavaPsiFacade.getInstance(myProject).getElementFactory();
   String fieldName;
   if (isStatic()) {
     String typeName = myField.declaringType().name().replace('$', '.');
     typeName =
         DebuggerTreeNodeExpression.normalize(
             typeName, PositionUtil.getContextElement(context), myProject);
     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);
   }
 }