DefaultResolver is the class that'll actually resolve how to show some variable.
| 62 | # DefaultResolver |
| 63 | # ======================================================================================================================= |
| 64 | class DefaultResolver: |
| 65 | """ |
| 66 | DefaultResolver is the class that'll actually resolve how to show some variable. |
| 67 | """ |
| 68 | |
| 69 | def resolve(self, var, attribute): |
| 70 | return getattr(var, attribute) |
| 71 | |
| 72 | def get_contents_debug_adapter_protocol(self, obj, fmt=None): |
| 73 | if MethodWrapperType: |
| 74 | dct, used___dict__ = self._get_py_dictionary(obj) |
| 75 | else: |
| 76 | dct = self._get_jy_dictionary(obj)[0] |
| 77 | |
| 78 | lst = sorted(dct.items(), key=lambda tup: sorted_attributes_key(tup[0])) |
| 79 | if used___dict__: |
| 80 | eval_name = ".__dict__[%s]" |
| 81 | else: |
| 82 | eval_name = ".%s" |
| 83 | |
| 84 | ret = [] |
| 85 | for attr_name, attr_value in lst: |
| 86 | entry = (attr_name, attr_value, eval_name % attr_name) |
| 87 | ret.append(entry) |
| 88 | |
| 89 | return ret |
| 90 | |
| 91 | def get_dictionary(self, var, names=None, used___dict__=False): |
| 92 | if MethodWrapperType: |
| 93 | return self._get_py_dictionary(var, names, used___dict__=used___dict__)[0] |
| 94 | else: |
| 95 | return self._get_jy_dictionary(var)[0] |
| 96 | |
| 97 | def _get_jy_dictionary(self, obj): |
| 98 | ret = {} |
| 99 | found = java.util.HashMap() |
| 100 | |
| 101 | original = obj |
| 102 | if hasattr_checked(obj, "__class__") and obj.__class__ == java.lang.Class: |
| 103 | # get info about superclasses |
| 104 | classes = [] |
| 105 | classes.append(obj) |
| 106 | c = obj.getSuperclass() |
| 107 | while c != None: |
| 108 | classes.append(c) |
| 109 | c = c.getSuperclass() |
| 110 | |
| 111 | # get info about interfaces |
| 112 | interfs = [] |
| 113 | for obj in classes: |
| 114 | interfs.extend(obj.getInterfaces()) |
| 115 | classes.extend(interfs) |
| 116 | |
| 117 | # now is the time when we actually get info on the declared methods and fields |
| 118 | for obj in classes: |
| 119 | declaredMethods = obj.getDeclaredMethods() |
| 120 | declaredFields = obj.getDeclaredFields() |
| 121 | for i in range(len(declaredMethods)): |
no outgoing calls