private void resolveValuesFromThisVariable()

in com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/InlineValuesRequestHandler.java [182:249]


    private void resolveValuesFromThisVariable(ObjectReference thisObj, InlineVariable[] unresolvedVariables, Variable[] result,
        boolean isSyntheticLambdaFrame) {
        if (thisObj == null) {
            return;
        }

        int unresolved = 0;
        for (Variable item : result) {
            if (item == null) {
                unresolved++;
            }
        }

        try {
            ReferenceType type = thisObj.referenceType();
            String typeName = type.name();
            ObjectReference enclosingInstance = null;
            for (Field field : type.allFields()) {
                String fieldName = field.name();
                boolean isSyntheticField = field.isSynthetic();
                Value fieldValue = null;
                for (int i = 0; i < unresolvedVariables.length; i++) {
                    if (result[i] != null) {
                        continue;
                    }

                    InlineVariable inlineVariable = unresolvedVariables[i];
                    boolean isInlineFieldVariable = (inlineVariable.declaringClass != null);
                    boolean isMatch = false;
                    if (isSyntheticLambdaFrame) {
                        isMatch = !isInlineFieldVariable && Objects.equals(fieldName, inlineVariable.expression);
                    } else {
                        boolean isMatchedField = isInlineFieldVariable
                            && Objects.equals(fieldName, inlineVariable.expression)
                            && Objects.equals(typeName, inlineVariable.declaringClass);
                        boolean isMatchedCapturedVariable = !isInlineFieldVariable
                            && isSyntheticField
                            && isCapturedLocalVariable(fieldName, inlineVariable.expression);
                        isMatch = isMatchedField || isMatchedCapturedVariable;

                        if (!isMatch && isSyntheticField && enclosingInstance == null && isCapturedThisVariable(fieldName)) {
                            Value value = thisObj.getValue(field);
                            if (value instanceof ObjectReference) {
                                enclosingInstance = (ObjectReference) value;
                                break;
                            }
                        }
                    }

                    if (isMatch) {
                        fieldValue = fieldValue == null ? thisObj.getValue(field) : fieldValue;
                        result[i] = new Variable(inlineVariable.expression, fieldValue);
                        unresolved--;
                    }
                }

                if (unresolved <= 0) {
                    break;
                }
            }

            if (unresolved > 0 && enclosingInstance != null) {
                resolveValuesFromThisVariable(enclosingInstance, unresolvedVariables, result, isSyntheticLambdaFrame);
            }
        } catch (Exception ex) {
            // do nothing
        }
    }