fmgasparino / google-gin

Automatically exported from code.google.com/p/google-gin
Apache License 2.0
0 stars 0 forks source link

Support ParameterizedType Injection #101

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I want to use ParameterizedType injection. But google-gin erase type 
parameters. IMO ParameterizedType injection and Generator make simple 
programing model.

Example:

Get Person's validator from Gininjector.
-----------------------------
 Injector
-----------------------------
@GinModules(PersonModule.class)
public interface PersonsInjector extends Ginjector{
    // get the person's validator
    IValidator<Person> validator();
}
-----------------------------
I'd tried to implement ValidatorGenerator to active this code. But 
Generator erase type parameters from type name.

--------------------------
 validator.gwt.xml
--------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.3//EN" 
"http://google-web-toolkit.googlecode.com/svn/tags/2.0.3/distro-
source/core/src/gwt-module.dtd">
<module>
    <source path="client" />
    <generate-with class="validator.rebind.ValidatorGenerator">
        <when-type-assignable
    class="com.google.gwt.validation.client.interfaces.IValidator" />
    </generate-with>
</module>

--------------------------
ValidatorGenerator
--------------------------
public class ValidatorGenerator extends Generator {

    @Override
    public String generate(TreeLogger logger, GeneratorContext context,
            String typeName) throws UnableToCompleteException {

          // erased type parameters from type name.
          assert 
"com.google.gwt.validation.client.interfaces.IValidator".equals(typeName);
          .....
    }
}

-----------------------------

Linkage:
 http://code.google.com/p/google-web-toolkit/issues/detail?id=4897

Original issue reported on code.google.com by takeshi....@gmail.com on 1 May 2010 at 5:16

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've created a patch.

http://codereview.appspot.com/1049041/show

Original comment by takeshi....@gmail.com on 1 May 2010 at 6:45

GoogleCodeExporter commented 9 years ago
Adding type parameters (and other kinds of useful information) to GWT.create is 
an often requested feature for GWT and one that Gin could certainly take 
advantage of. No idea if/when this finds its way into GWT though so I'll mark 
it as wont fix until the original issue is resolved. Feel free to request 
reopening of this bug once a change has been made to GWT.

Original comment by aragos on 7 Jul 2010 at 3:32