@Override public TypeUsageNode getFieldType(String fieldName, boolean staticContext) { for (Property property : getAllProperties(symbolResolver())) { if (property.getName().equals(fieldName)) { return property.getTypeUsage(); } } throw new IllegalArgumentException(fieldName); }
private void initializeMethodsByName(SymbolResolver resolver) { methodsByName = new HashMap<>(); // TODO methods inherited by Object // TODO if we implement inheritance also other methods inherited from classes or interfaces for (Property property : getDirectProperties(resolver)) { { String descriptor = "()" + property.getTypeUsage().jvmType().getDescriptor(); JvmMethodDefinition jvmMethodDefinition = new JvmMethodDefinition( getInternalName(), property.getterName(resolver), descriptor, false, false); InternalMethodDefinition getter = new InternalMethodDefinition( property.getterName(resolver), Collections.emptyList(), property.getTypeUsage(), jvmMethodDefinition); registerMethod(getter); } { String descriptor = "(" + property.getTypeUsage().jvmType().getDescriptor() + ")V"; JvmMethodDefinition jvmMethodDefinition = new JvmMethodDefinition( getInternalName(), property.setterName(), descriptor, false, false); FormalParameterNode param = new FormalParameterNode(property.getTypeUsage().copy(), property.getName()); param.setParent(this); InternalMethodDefinition setter = new InternalMethodDefinition( property.setterName(), ImmutableList.of(param), new VoidTypeUsageNode(), jvmMethodDefinition); registerMethod(setter); } } }