本文整理匯總了Java中com.google.gwt.core.ext.GeneratorContext.getTypeOracle方法的典型用法代碼示例。如果您正苦於以下問題:Java GeneratorContext.getTypeOracle方法的具體用法?Java GeneratorContext.getTypeOracle怎麽用?Java GeneratorContext.getTypeOracle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.core.ext.GeneratorContext
的用法示例。
在下文中一共展示了GeneratorContext.getTypeOracle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTestCases
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
public static List<TestCase> getTestCases(TreeLogger logger, GeneratorContext context)
throws UnableToCompleteException {
if (DEBUG) logger = logger.branch(TreeLogger.WARN, "Getting test cases", null, null);
TypeOracle oracle = context.getTypeOracle();
JClassType jsTestCaseClass = oracle.findType(JsTestCase.class.getName());
List<TestCase> testCases = new ArrayList<TestCase>();
for (JClassType classType : oracle.getTypes()) {
if (classType.equals(jsTestCaseClass) || !classType.isAssignableTo(jsTestCaseClass)) {
continue;
}
if (classType.getEnclosingType() != null) {
if (DEBUG) logger.log(TreeLogger.WARN, "Skipping nested class: " +
classType.getEnclosingType().getName() + "." + classType.getName());
continue;
}
if (DEBUG) logger.log(TreeLogger.WARN, "Found class: " + classType.getName());
testCases.add(new TestCase(classType, findTests(logger, context, classType)));
}
return testCases;
}
示例2: getAllInstantiableClassesByThisfactory
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
/**
* Filter all classes visible to GWT client side and return only those deemed instantiable
* through the factory class we are generating (that is EntityInputFactoryImpl).
* <p>
* Allowing all classes to be instantiable would potentially generate too huge class method
* perhaps even too huge to compile. There must be some sub-selection. Classes can be filtered
* based on marker interface, or class annotation see {@link JClassType#getAnnotation(Class)},
* or some regex matching based on package or class name.
*
* @param context
* @return Filter all classes visible to GWT client side and return only those deemed
* instantiable
*/
private List<JClassType> getAllInstantiableClassesByThisfactory(GeneratorContext context) {
TypeOracle oracle = context.getTypeOracle();
JClassType markerInterface1 = oracle.findType(IEntityInput.class.getName());
JClassType markerInterface2 = oracle.findType(Entity.class.getName());
List<JClassType> allInstantiableClasses = new LinkedList<JClassType>();
for (JClassType classType : oracle.getTypes()) {
if (!classType.equals(markerInterface1) && classType.isAssignableTo(markerInterface1)) {
allInstantiableClasses.add(classType);
}
else if (!classType.equals(markerInterface2) && classType.isAssignableTo(markerInterface2)) {
allInstantiableClasses.add(classType);
}
}
return allInstantiableClasses;
}
示例3: generate
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
@Override
public String generate (TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
TypeOracle oracle = context.getTypeOracle();
assert (oracle != null);
JClassType type = oracle.findType(typeName);
if (type == null) {
logger.log(ERROR, "Couldn't find type '" + typeName + "'");
throw new UnableToCompleteException();
}
if (type.isInterface() == null) {
logger.log(ERROR, "Type '" + typeName + "' must be an interface");
throw new UnableToCompleteException();
}
ReflectionCacheSourceCreator source = new ReflectionCacheSourceCreator(logger, context, type);
return source.create();
}
示例4: generate
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
@Override
public String generate( TreeLogger logger, GeneratorContext context, String typeName ) throws UnableToCompleteException
{
this.logger = logger;
this.context = context;
this.typeName = typeName;
if( typeName == null )
return null;
typeOracle = context.getTypeOracle();
try
{
type = typeOracle.getType( typeName );
}
catch( NotFoundException e )
{
e.printStackTrace();
throw new RuntimeException( e );
}
return generate();
}
示例5: generate
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
@Override
public String generate( TreeLogger logger, GeneratorContext context, String typeName ) throws UnableToCompleteException
{
this.logger = logger;
this.context = context;
this.askedTypeName = typeName;
// get the "reflection" machine of GWT compiler
TypeOracle typeOracle = context.getTypeOracle();
try
{
reflectedType = getReflectedType( typeOracle, typeName );
ClazzInfoBuilder builder = new ClazzInfoBuilder( logger, context );
return builder.buildClassInfoFor(reflectedType);
}
catch( Exception e )
{
// record to logger that Map generation threw an exception
logger.log( TreeLogger.ERROR, "ERROR when generating " + generatedClassName + " for " + typeName, e );
return null;
}
}
示例6: generate
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName) throws UnableToCompleteException {
try {
TypeOracle typeOracle = context.getTypeOracle();
JClassType eventBinderType = typeOracle.getType(typeName);
JClassType targetType = getTargetType(eventBinderType, typeOracle);
SourceWriter writer = createSourceWriter(logger, context, eventBinderType, targetType);
if (writer != null) {
write_doBindEventHandlers(targetType, typeOracle, writer, logger);
writer.commit(logger);
}
return getFullyQualifiedGeneratedClassName(eventBinderType);
} catch (NotFoundException e) {
logger.log(Type.ERROR, "Error generating " + typeName, e);
throw new UnableToCompleteException();
}
}
示例7: generate
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext generatorContext, String typeName)
throws UnableToCompleteException
{
TypeOracle types = generatorContext.getTypeOracle();
ClassName componentTypeName = ClassName.bestGuess(typeName.substring(0,
typeName.length() - COMPONENT_TEMPLATE_SUFFIX.length()));
JClassType componentJsType;
try
{
componentJsType =
types.getType(componentJsTypeName(componentTypeName).reflectionName());
}
catch (NotFoundException nfe)
{
logger.log(Type.ERROR, "Not Found", nfe);
throw new UnableToCompleteException();
}
ClassName templateImplTypeName = componentTemplateImplName(componentTypeName);
PrintWriter printWriter = generatorContext.tryCreate(logger,
templateImplTypeName.packageName(),
templateImplTypeName.simpleName());
if (printWriter != null)
{
generateOnce(printWriter, logger, generatorContext, componentJsType, componentTypeName);
}
return templateImplTypeName.reflectionName();
}
示例8: LogableSourceCreator
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
public LogableSourceCreator(TreeLogger logger, GeneratorContext context,
String typeName) {
this.logger = logger;
this.context = context;
this.typeOracle = context.getTypeOracle();
this.typeName = typeName;
}
示例9: generate
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = context.getTypeOracle();
JClassType extensionManager = typeOracle.findType(typeName);
if (extensionManager == null) {
logger.log(TreeLogger.ERROR, "Can't find interface type '" + typeName + "'", null);
throw new UnableToCompleteException();
}
if (extensionManager.isInterface() == null) {
logger.log(
TreeLogger.ERROR,
extensionManager.getQualifiedSourceName() + " is not an interface",
null);
throw new UnableToCompleteException();
}
List<JClassType> extensions = new ArrayList<>();
for (JClassType type : typeOracle.getTypes()) {
if (type.isAnnotationPresent(Extension.class)) {
extensions.add(type);
}
}
String packageName = extensionManager.getPackage().getName();
String className = extensionManager.getSimpleSourceName() + "Impl";
generateClass(logger, context, packageName, className, extensions);
return packageName + "." + className;
}
示例10: generateIncrementally
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
@Override
public RebindResult generateIncrementally(TreeLogger logger,
GeneratorContext generatorContext,
String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = generatorContext.getTypeOracle();
assert (typeOracle != null);
JClassType originalType = typeOracle.findType(typeName);
if (originalType == null) {
logger.log(TreeLogger.ERROR,
"Unable to find metadata for type '" + typeName + "'");
throw new UnableToCompleteException();
}
if (originalType.isInterface() == null) {
logger.log(TreeLogger.ERROR,
"'" + typeName + "' is not a interface");
throw new UnableToCompleteException();
}
TreeLogger moduleLogger = logger.branch(TreeLogger.DEBUG,
"Generating client proxy for remote service interface '" + originalType.getQualifiedSourceName() + "'",
null);
return create(originalType,
moduleLogger,
generatorContext,
typeName);
}
示例11: generateIncrementally
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
@Override
public RebindResult generateIncrementally(TreeLogger logger,
GeneratorContext generatorContext,
String moduleClass)
throws UnableToCompleteException {
TypeOracle typeOracle = generatorContext.getTypeOracle();
assert (typeOracle != null);
JClassType module = typeOracle.findType(moduleClass);
if (module == null) {
logger.log(TreeLogger.ERROR,
"Unable to find metadata for module class '" + moduleClass + "'");
throw new UnableToCompleteException();
}
if (module.isInterface() == null) {
logger.log(TreeLogger.ERROR,
"'" + moduleClass + "' is not a interface");
throw new UnableToCompleteException();
}
TreeLogger moduleLogger = logger.branch(TreeLogger.DEBUG,
"Generating mvp4g configuration for module class '" + module.getQualifiedSourceName() + "'",
null);
return create(moduleLogger,
generatorContext,
moduleClass);
}
示例12: Mvp4gConfiguration
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
/**
* Contruct a Mvp4gConfiguration object
*
* @param logger logger of the GWT compiler
* @param context context of the GWT compiler
*/
public Mvp4gConfiguration(TreeLogger logger,
GeneratorContext context) {
this.logger = logger;
this.oracle = context.getTypeOracle();
this.propertyOracle = context.getPropertyOracle();
}
示例13: generate
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
@Override
public String generate(TreeLogger logger, GeneratorContext context, String typeName)
throws UnableToCompleteException {
TypeOracle typeOracle = context.getTypeOracle();
JClassType subsystemExtensionManager = typeOracle.findType(typeName);
if (subsystemExtensionManager == null) {
logger.log(TreeLogger.ERROR, "Unable to find metadata for type '" + typeName + "'", null);
throw new UnableToCompleteException();
}
if (subsystemExtensionManager.isInterface() == null) {
logger.log(TreeLogger.ERROR, subsystemExtensionManager.getQualifiedSourceName() + " is not an interface",
null);
throw new UnableToCompleteException();
}
List<SubsystemExtension> subsystemExtensions = new ArrayList<SubsystemExtension>();
for (JClassType type : typeOracle.getTypes()) {
if (type.isAnnotationPresent(SubsystemExtension.class)) {
subsystemExtensions.add(type.getAnnotation(SubsystemExtension.class));
}
}
String packageName = subsystemExtensionManager.getPackage().getName();
String className = subsystemExtensionManager.getSimpleSourceName() + "Impl";
generateClass(logger, context, packageName, className, subsystemExtensions);
return packageName + "." + className;
}
示例14: getClassType
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
protected JClassType getClassType(GeneratorContext context, String qualifiedClassName) throws RebindException {
final String METHOD = "getClassType(GeneratorContext, String)";
JClassType classType = null;
try {
TypeOracle typeOracle = context.getTypeOracle();
classType = typeOracle.getType(qualifiedClassName);
} catch (NotFoundException e) {
String m = qualifiedClassName + " was not found";
LOG.logp(Level.SEVERE, CLASS, METHOD, m);
throw new RebindException(m);
}
return classType;
}
示例15: generate
import com.google.gwt.core.ext.GeneratorContext; //導入方法依賴的package包/類
@Override
public String generate( TreeLogger logger, GeneratorContext context, String typeName ) throws UnableToCompleteException
{
this.logger = logger;
this.context = context;
this.typeOracle = context.getTypeOracle();
try
{
// get classType and save instance variables
askedType = typeOracle.getType( typeName );
WithEntityClasses withEntityClassesAnnotation = askedType.getAnnotation( WithEntityClasses.class );
entityClasses = withEntityClassesAnnotation.classes();
generatedClassPackageName = askedType.getPackage().getName();
generatedClassName = askedType.getSimpleSourceName() + "_EntityConfigurationFactoryImpl";
// Generate class source code
generateClass();
}
catch( Exception e )
{
// record to logger that Map generation threw an exception
logger.log( TreeLogger.ERROR, "ERROR when generating " + generatedClassName + " for " + typeName, e );
}
// return the fully qualifed name of the class generated
return generatedClassPackageName + "." + generatedClassName;
}