Search in sources :

Example 1 with TreeLogger

use of com.google.gwt.core.ext.TreeLogger in project gwt-cs by iSergio.

the class CesiumScriptInjector method forceScriptLoad.

private boolean forceScriptLoad(TreeLogger logger, String moduleName, Float gwtVersion) {
    try {
        ModuleDef module;
        Method getModuleDef;
        if (gwtVersion < 2.6f) {
            getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath", new Class[] { TreeLogger.class, String.class });
            module = (ModuleDef) getModuleDef.invoke(null, logger, moduleName);
        } else if (gwtVersion < 2.8f) {
            Class compilerContextClass = Class.forName("com.google.gwt.dev.CompilerContext");
            Object context = compilerContextClass.getDeclaredConstructor().newInstance();
            getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath", new Class[] { TreeLogger.class, compilerContextClass, String.class });
            module = (ModuleDef) getModuleDef.invoke(null, logger, compilerContextClass.cast(context), moduleName);
        } else {
            getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath", new Class[] { TreeLogger.class, String.class, boolean.class });
            module = (ModuleDef) getModuleDef.invoke(null, logger, moduleName, false);
        }
        if (module != null)
            return CrossSiteIframeLinker.class.equals(module.getActivePrimaryLinker());
        logger.log(TreeLogger.WARN, "Can't find module reference - not injecting scripts.");
    } catch (Throwable t) {
        logger.log(TreeLogger.ERROR, "Encountered an exception while trying to resolve the ModuleDef for " + moduleName, t);
    }
    return false;
}
Also used : CrossSiteIframeLinker(com.google.gwt.core.linker.CrossSiteIframeLinker) TreeLogger(com.google.gwt.core.ext.TreeLogger) ModuleDef(com.google.gwt.dev.cfg.ModuleDef) Method(java.lang.reflect.Method) ModuleDefLoader(com.google.gwt.dev.cfg.ModuleDefLoader)

Example 2 with TreeLogger

use of com.google.gwt.core.ext.TreeLogger in project mvp4g by mvp4g.

the class Mvp4gGenerator method generateIncrementally.

@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);
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) TypeOracle(com.google.gwt.core.ext.typeinfo.TypeOracle) TreeLogger(com.google.gwt.core.ext.TreeLogger) UnableToCompleteException(com.google.gwt.core.ext.UnableToCompleteException)

Example 3 with TreeLogger

use of com.google.gwt.core.ext.TreeLogger in project mvp4g by mvp4g.

the class Mvp4gConfigurationFileReaderTest method setUp.

@Before
public void setUp() {
    sourceWriter = new SourceWriterTestStub();
    TreeLogger tl = new UnitTestTreeLogger.Builder().createLogger();
    configuration = new Mvp4gConfiguration(tl, new GeneratorContextStub());
    writer = new Mvp4gConfigurationFileWriter(sourceWriter, configuration);
    String eventBusInterface = EventBus.class.getName();
    String eventBusClass = BaseEventBus.class.getName();
    configuration.setEventBus(new EventBusElement(eventBusInterface, eventBusClass, false));
    ViewElement view = new ViewElement();
    view.setClassName(Object.class.getName());
    view.setName("startView");
    configuration.getViews().add(view);
    PresenterElement presenter = new PresenterElement();
    presenter.setClassName(SimplePresenter01.class.getCanonicalName());
    presenter.setName("startPresenter");
    presenter.setView("startView");
    configuration.getPresenters().add(presenter);
    StartElement start = new StartElement();
    start.setPresenter("startPresenter");
    configuration.setStart(start);
    GinModuleElement ginModule = new GinModuleElement();
    ginModule.setModules(new String[] { DefaultMvp4gGinModule.class.getCanonicalName() });
    configuration.setGinModule(ginModule);
    TypeOracleStub oracle = (TypeOracleStub) configuration.getOracle();
    configuration.setModule(oracle.addClass(Mvp4gModule.class));
}
Also used : TypeOracleStub(com.google.gwt.dev.javac.typemodel.TypeOracleStub) Mvp4gConfiguration(com.mvp4g.rebind.config.Mvp4gConfiguration) Mvp4gModule(com.mvp4g.client.Mvp4gModule) UnitTestTreeLogger(com.google.gwt.dev.util.UnitTestTreeLogger) TreeLogger(com.google.gwt.core.ext.TreeLogger) UnitTestTreeLogger(com.google.gwt.dev.util.UnitTestTreeLogger) DefaultMvp4gGinModule(com.mvp4g.client.DefaultMvp4gGinModule) SimplePresenter01(com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01) Before(org.junit.Before)

Example 4 with TreeLogger

use of com.google.gwt.core.ext.TreeLogger in project mvp4g by mvp4g.

the class Mvp4gRunAsyncGenerator method generateIncrementally.

@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);
}
Also used : JClassType(com.google.gwt.core.ext.typeinfo.JClassType) TypeOracle(com.google.gwt.core.ext.typeinfo.TypeOracle) TreeLogger(com.google.gwt.core.ext.TreeLogger) UnableToCompleteException(com.google.gwt.core.ext.UnableToCompleteException)

Example 5 with TreeLogger

use of com.google.gwt.core.ext.TreeLogger in project google-gin by gwtplus.

the class BindingResolver method resolveBindings.

public void resolveBindings(GinjectorBindings origin) {
    TreeLogger branch = logger.branch(TreeLogger.DEBUG, PrettyPrinter.format("Resolving bindings for %s", origin));
    // Use providers so that the instances are cleaned up after this method.  This ensures that even
    // though BindingResolver may be held on to (eg, {@link GinjectorBindings}, we won't leak
    // memory used for temporary storage during resolution.
    DependencyExplorerOutput output = explorerFactory.create(branch).explore(origin);
    UnresolvedBindingValidator validator = validatorFactory.create(branch);
    InvalidKeys invalidKeys = validator.getInvalidKeys(output);
    if (validator.validate(output, invalidKeys)) {
        validator.pruneInvalidOptional(output, invalidKeys);
        installerFactory.create(branch).installBindings(output);
    }
}
Also used : TreeLogger(com.google.gwt.core.ext.TreeLogger) DependencyExplorerOutput(com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput) InvalidKeys(com.google.gwt.inject.rebind.resolution.UnresolvedBindingValidator.InvalidKeys)

Aggregations

TreeLogger (com.google.gwt.core.ext.TreeLogger)5 UnableToCompleteException (com.google.gwt.core.ext.UnableToCompleteException)2 JClassType (com.google.gwt.core.ext.typeinfo.JClassType)2 TypeOracle (com.google.gwt.core.ext.typeinfo.TypeOracle)2 CrossSiteIframeLinker (com.google.gwt.core.linker.CrossSiteIframeLinker)1 ModuleDef (com.google.gwt.dev.cfg.ModuleDef)1 ModuleDefLoader (com.google.gwt.dev.cfg.ModuleDefLoader)1 TypeOracleStub (com.google.gwt.dev.javac.typemodel.TypeOracleStub)1 UnitTestTreeLogger (com.google.gwt.dev.util.UnitTestTreeLogger)1 DependencyExplorerOutput (com.google.gwt.inject.rebind.resolution.DependencyExplorer.DependencyExplorerOutput)1 InvalidKeys (com.google.gwt.inject.rebind.resolution.UnresolvedBindingValidator.InvalidKeys)1 DefaultMvp4gGinModule (com.mvp4g.client.DefaultMvp4gGinModule)1 Mvp4gModule (com.mvp4g.client.Mvp4gModule)1 Mvp4gConfiguration (com.mvp4g.rebind.config.Mvp4gConfiguration)1 SimplePresenter01 (com.mvp4g.rebind.test_tools.annotation.presenters.SimplePresenter01)1 Method (java.lang.reflect.Method)1 Before (org.junit.Before)1