Monday, November 10, 2014

Generators in GWT 2.6.0.

Hello,
Tests generators in GWT 2.6.0.

public class rttiGenerator extends Generator {

@Override
public String generate(TreeLogger logger, GeneratorContext context,
String typeName) throws UnableToCompleteException {
JClassType classType;
try {
classType = context.getTypeOracle().getType(typeName);
SourceWriter src = getSourceWriter(classType, context, logger);
src.println();
src.commit(logger);
return typeName + "Generated";
} catch (NotFoundException e) {
e.printStackTrace();
}
return null;
}

public SourceWriter getSourceWriter(JClassType classType,
GeneratorContext context, TreeLogger logger) {
String packageName = classType.getPackage().getName();
String simpleName = classType.getSimpleSourceName() + "Generated";
ClassSourceFileComposerFactory composer = new
ClassSourceFileComposerFactory(
packageName, simpleName);
composer.addImport("com.google.gwt.user.client.ui.*");
composer.setSuperclass("Button");
PrintWriter printWriter = context.tryCreate(logger, packageName,
simpleName);
if (printWriter == null) {
return null;
} else {
SourceWriter sw = composer.createSourceWriter(context,
printWriter);
return sw;
}
}
}


RttiClassGWT.gwt.xml:

<module>
<inherits name='com.google.gwt.user.User'/>

<generate-with class="pl.cba.lukaszbaczek.rttiClassGWT.rttiGenerator">
<when-type-assignable
class="com.google.gwt.user.client.ui.IsWidget" />
</generate-with>

<source path="rttiClassGWT"/>
<source path="client"/>
</module>

Compiling module org.yournamehere.Main
Validating units:
[ERROR] Errors in
'jar:file:/C:/Users/Łukasz/Documents/NetBeansProjects/RttiClassGWT/dist/RttiClassGWT.jar!/pl/cba/lukaszbaczek/rttiClassGWT/rttiGenerator.java'
[ERROR] Line 22: No source code is available for type
com.google.gwt.core.ext.Generator; did you forget to inherit a required
module?
[ERROR] Line 25: No source code is available for type
com.google.gwt.core.ext.TreeLogger; did you forget to inherit a required
module?
[ERROR] Line 25: No source code is available for type
com.google.gwt.core.ext.GeneratorContext; did you forget to inherit a
required module?
[ERROR] Line 25: No source code is available for type
com.google.gwt.core.ext.UnableToCompleteException; did you forget to
inherit a required module?
[ERROR] Line 26: No source code is available for type
com.google.gwt.core.ext.typeinfo.JClassType; did you forget to inherit a
required module?
[ERROR] Line 29: No source code is available for type
com.google.gwt.user.rebind.SourceWriter; did you forget to inherit a
required module?
[ERROR] Line 33: No source code is available for type
com.google.gwt.core.ext.typeinfo.NotFoundException; did you forget to
inherit a required module?
[ERROR] Line 43: No source code is available for type
com.google.gwt.user.rebind.ClassSourceFileComposerFactory; did you
forget to inherit a required module?
[ERROR] Line 47: No source code is available for type
java.io.PrintWriter; did you forget to inherit a required module?
[ERROR] Aborting compile due to errors in some input files
C:\Users\Łukasz\Documents\NetBeansProjects\xxx\nbproject\build-gwt.xml:331:
The following error occurred while executing this line:
C:\Users\Łukasz\Documents\NetBeansProjects\xxx\nbproject\build-gwt.xml:480:
Java returned: 1
BUILD FAILED (total time: 18 seconds)

RG
Łukasz

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment