public Map<String, Long> getTypeLastModifiedTimes() { if (!canBeCacheable) { return null; } Map<String, Long> typeLastModifiedTimeMap = new HashMap<String, Long>(); for (JClassType type : types) { String typeName = type.getQualifiedSourceName(); assert type instanceof JRealClassType; JRealClassType sourceRealType = (JRealClassType) type; typeLastModifiedTimeMap.put(typeName, sourceRealType.getLastModifiedTime()); } return typeLastModifiedTimeMap; }
private static boolean isThrowable(@Nonnull JType type) { if (type.getQualifiedSourceName().equals(Throwable.class.getCanonicalName())) { return true; } if (type instanceof JRealClassType && ((JRealClassType) type).getSuperclass() != null) { return isThrowable(((JRealClassType) type).getSuperclass()); } return false; }
List<JClassType> subtypes = Arrays.asList(baseType.getSubtypes()); candidates.addAll(subtypes); problems.add(baseType, baseType.getParameterizedQualifiedSourceName() + " has no available instantiable subtypes.", Priority.DEFAULT, possibilities);
protected void injectLocation(final TreeLogger logger, final ClassBuffer cls, final JRealClassType injectionType) { String location; try { location = (String)injectionType.getClass().getMethod("getLocation").invoke(injectionType); } catch (final Exception e) { if (logOnce) { logOnce = false; logger.log(Type.ERROR, "Unable to call "+injectionType.getClass().getName()+".getLocation on "+injectionType.getJNISignature()); logger.log(Type.ERROR, "Ensure that you have the jar/artifact net.wetheinter:gwt-reflect before gwt-dev on your classpath."); logger.log(Type.TRACE, "The artifact net.wetheinter:com.google.gwt.thirdparty.xapi-gwt-api contains a class, ClasspathFixer, which can help you."); logger.log(Type.TRACE, "For unit tests, com.google.gwt.thirdparty.xapi-gwt-test overrides JUnitShell to fix the classpath for you.", e); } return; } cls.addImports(ProtectionDomain.class); cls .println("private ProtectionDomain domain;") .createMethod("public ProtectionDomain getProtectionDomain()") .println("if (domain == null) ") .indentln("domain = new ProtectionDomain(\"" +location+"\");") .println("return domain;"); }
String location = ((JRealClassType)injectionType).getLocation(); cls.addImports(ProtectionDomain.class); cls
List<JClassType> subtypes = Arrays.asList(baseType.getSubtypes()); candidates.addAll(subtypes); problems.add(baseType, baseType.getParameterizedQualifiedSourceName() + " has no available instantiable subtypes.", Priority.DEFAULT, possibilities);
protected void injectLocation(TreeLogger logger, ClassBuffer cls, JRealClassType injectionType) { String location; try { location = (String)injectionType.getClass().getMethod("getLocation").invoke(injectionType); } catch (Exception e) { if (logOnce) { logOnce = false; logger.log(Type.ERROR, "Unable to call "+injectionType.getClass().getName()+".getLocation on "+injectionType.getJNISignature()); logger.log(Type.ERROR, "Ensure that you have the jar/artifact net.wetheinter:gwt-reflect before gwt-dev on your classpath."); logger.log(Type.TRACE, "The artifact net.wetheinter:xapi-gwt-api contains a class, ClasspathFixer, which can help you."); logger.log(Type.TRACE, "For unit tests, xapi-gwt-test overrides JUnitShell to fix the classpath for you.", e); } return; } cls.addImports(ProtectionDomain.class); cls .println("private ProtectionDomain domain;") .createMethod("public ProtectionDomain getProtectionDomain()") .println("if (domain == null) ") .indentln("domain = new ProtectionDomain(\"" +location+"\");") .println("return domain;"); }
public Map<String, Long> getTypeLastModifiedTimes() { if (!canBeCacheable) { return null; } Map<String, Long> typeLastModifiedTimeMap = new HashMap<String, Long>(); for (JClassType type : types) { String typeName = type.getQualifiedSourceName(); assert type instanceof JRealClassType; JRealClassType sourceRealType = (JRealClassType) type; typeLastModifiedTimeMap.put(typeName, sourceRealType.getLastModifiedTime()); } return typeLastModifiedTimeMap; }
private static boolean isThrowable(@Nonnull JType type) { if (type.getQualifiedSourceName().equals(Throwable.class.getCanonicalName())) { return true; } if (type instanceof JRealClassType && ((JRealClassType) type).getSuperclass() != null) { return isThrowable(((JRealClassType) type).getSuperclass()); } return false; }
private boolean checkModule(TreeLogger logger, GeneratorContext ctx, JClassType module) { long lastTimeGenerated = ctx.getCachedGeneratorResult() .getTimeGenerated(); if (module == null) { logger.log(TreeLogger.TRACE, "Found previously dependent type that's no longer present: " + Mvp4gModule.class.getName()); return false; } assert module instanceof JRealClassType; JRealClassType realClass = (JRealClassType) module; if (realClass == null || realClass.getLastModifiedTime() > lastTimeGenerated) { return false; } return true; }
private boolean checkModule(TreeLogger logger, GeneratorContext ctx, JClassType module) { long lastTimeGenerated = ctx.getCachedGeneratorResult() .getTimeGenerated(); if (module == null) { logger.log(TreeLogger.TRACE, "Found previously dependent type that's no longer present: " + Mvp4gModule.class.getName()); return false; } assert module instanceof JRealClassType; JRealClassType realClass = (JRealClassType) module; if (realClass == null || realClass.getLastModifiedTime() > lastTimeGenerated) { return false; } return true; }
/** * Check that the cached last modified times match those from the current * typeOracle. */ private boolean checkCachedTypeLastModifiedTimes(TreeLogger logger, GeneratorContext generatorContext, Map<String, Long> typeLastModifiedTimes) { TypeOracle oracle = generatorContext.getTypeOracle(); for (String sourceTypeName : typeLastModifiedTimes.keySet()) { JClassType sourceType = oracle.findType(sourceTypeName); if (sourceType == null) { logger.log(TreeLogger.TRACE, "Found previously dependent type that's no longer present: " + sourceTypeName); return false; } assert sourceType instanceof JRealClassType; JRealClassType sourceRealType = (JRealClassType) sourceType; if (sourceRealType.getLastModifiedTime() != typeLastModifiedTimes.get(sourceTypeName)) { logger.log(TreeLogger.TRACE, "Found dependent type that has changed: " + sourceTypeName); return false; } } return true; }
/** * Check that the cached last modified times match those from the current * typeOracle. */ private boolean checkCachedTypeLastModifiedTimes(TreeLogger logger, GeneratorContext generatorContext, Map<String, Long> typeLastModifiedTimes) { TypeOracle oracle = generatorContext.getTypeOracle(); for (String sourceTypeName : typeLastModifiedTimes.keySet()) { JClassType sourceType = oracle.findType(sourceTypeName); if (sourceType == null) { logger.log(TreeLogger.TRACE, "Found previously dependent type that's no longer present: " + sourceTypeName); return false; } assert sourceType instanceof JRealClassType; JRealClassType sourceRealType = (JRealClassType) sourceType; if (sourceRealType.getLastModifiedTime() != typeLastModifiedTimes.get(sourceTypeName)) { logger.log(TreeLogger.TRACE, "Found dependent type that has changed: " + sourceTypeName); return false; } } return true; }
private boolean checkEventBus(TreeLogger logger, GeneratorContext ctx) { long lastTimeGenerated = ctx.getCachedGeneratorResult() .getTimeGenerated(); JClassType sourceType = ctx.getTypeOracle() .findType(EventBusElement.class.getName()); if (sourceType == null) { logger.log(TreeLogger.TRACE, "Found previously dependent type that's no longer present: " + EventBusElement.class.getName()); return false; } assert sourceType instanceof JRealClassType; JRealClassType realClass = (JRealClassType) sourceType; if (realClass == null || realClass.getLastModifiedTime() > lastTimeGenerated) { return false; } return true; }
private boolean checkEventBus(TreeLogger logger, GeneratorContext ctx) { long lastTimeGenerated = ctx.getCachedGeneratorResult() .getTimeGenerated(); JClassType sourceType = ctx.getTypeOracle() .findType(EventBusElement.class.getName()); if (sourceType == null) { logger.log(TreeLogger.TRACE, "Found previously dependent type that's no longer present: " + EventBusElement.class.getName()); return false; } assert sourceType instanceof JRealClassType; JRealClassType realClass = (JRealClassType) sourceType; if (realClass == null || realClass.getLastModifiedTime() > lastTimeGenerated) { return false; } return true; }
private long getLastModifiedTime(JType type) { if (type instanceof JArrayType) { return getLastModifiedTime(type.getLeafType()); } else if (type instanceof JRawType) { return getLastModifiedTime(((JRawType) type).getGenericType()); } if (type instanceof JRealClassType) { return ((JRealClassType) type).getLastModifiedTime(); } else { // we have a type that is an array with a primitive leafType assert type instanceof JPrimitiveType; // this type is never out of date return Long.MAX_VALUE; } }
private long getLastModifiedTime(JType type) { if (type instanceof JArrayType) { return getLastModifiedTime(type.getLeafType()); } else if (type instanceof JRawType) { return getLastModifiedTime(((JRawType) type).getGenericType()); } if (type instanceof JRealClassType) { return ((JRealClassType) type).getLastModifiedTime(); } else { // we have a type that is an array with a primitive leafType assert type instanceof JPrimitiveType; // this type is never out of date return Long.MAX_VALUE; } }
private boolean checkSet(TreeLogger logger, GeneratorContext ctx, Set<? extends Mvp4gElement> setOfElements) { long lastTimeGenerated = ctx.getCachedGeneratorResult() .getTimeGenerated(); for (Mvp4gElement element : setOfElements) { JClassType sourceType = ctx.getTypeOracle() .findType(element.getProperty("class")); if (sourceType == null) { logger.log(TreeLogger.TRACE, "Found previously dependent type that's no longer present: " + element.getProperty("class")); return false; } assert sourceType instanceof JRealClassType; JRealClassType realClass = (JRealClassType) sourceType; if (realClass == null || realClass.getLastModifiedTime() > lastTimeGenerated) { return false; } } return true; }
private boolean checkSet(TreeLogger logger, GeneratorContext ctx, Set<? extends Mvp4gElement> setOfElements) { long lastTimeGenerated = ctx.getCachedGeneratorResult() .getTimeGenerated(); for (Mvp4gElement element : setOfElements) { JClassType sourceType = ctx.getTypeOracle() .findType(element.getProperty("class")); if (sourceType == null) { logger.log(TreeLogger.TRACE, "Found previously dependent type that's no longer present: " + element.getProperty("class")); return false; } assert sourceType instanceof JRealClassType; JRealClassType realClass = (JRealClassType) sourceType; if (realClass == null || realClass.getLastModifiedTime() > lastTimeGenerated) { return false; } } return true; }