Package com.google.gwt.dev

Examples of com.google.gwt.dev.CompilerContext


  }

  static StandardGeneratorContext createGeneratorContext(String moduleName,
      TreeLogger logger) throws UnableToCompleteException {
    CompilerContext.Builder compilerContextBuilder = new CompilerContext.Builder();
    CompilerContext compilerContext = compilerContextBuilder.build();
    ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, compilerContext, moduleName);
    compilerContext = compilerContextBuilder.module(module).build();
    compilerContext.getOptions().setGenDir(new File(System.getProperty("java.io.tmpdir")));

    ArtifactSet allGenreatedArtifacts = new ArtifactSet();
    boolean isProd = false;
    StandardGeneratorContext context = new StandardGeneratorContext(
        compilerContext, module.getCompilationState(logger, compilerContext), allGenreatedArtifacts,
View Full Code Here


  @Override
  public void setUp() throws Exception {
    super.setUp();
    logger = createCompileLogger();
    CompilationState state =
        CompilationStateBuilder.buildFrom(logger, new CompilerContext(), getJavaResources());
    types = state.getTypeOracle();
    rfedType = types.findType(RequestFactoryEditorDriver.class.getName());
    assertNotNull(rfedType);
  }
View Full Code Here

    TypeOracle oracle;
    synchronized (typeOracleMap) {
      oracle = typeOracleMap.get(moduleName);
      if (oracle == null) {
        CompilerContext.Builder compilerContextBuilder = new CompilerContext.Builder();
        CompilerContext compilerContext = compilerContextBuilder.build();
        ModuleDef moduleDef =
            ModuleDefLoader.loadFromClassPath(logger, compilerContext, moduleName);
        compilerContext = compilerContextBuilder.module(moduleDef).build();
        oracle = moduleDef.getCompilationState(logger, compilerContext).getTypeOracle();
        typeOracleMap.put(moduleName, oracle);
View Full Code Here

   * them in reverse order.
   */
  private final List<File> toDelete = new ArrayList<File>();

  public StandardGeneratorContextTest() {
    CompilerContext compilerContext =
        new CompilerContext.Builder().module(new MockModuleDef()).build();
    try {
      mockCompilationState = CompilationStateBuilder.buildFrom(
          TreeLogger.NULL, compilerContext, Collections.<Resource> emptySet());
    } catch (UnableToCompleteException e) {
View Full Code Here

      public CharSequence getContent() {
        return code;
      }
    });

    CompilerContext compilerContext = provideCompilerContext();
    CompilationState state =
        CompilationStateBuilder.buildFrom(logger, compilerContext,
            sourceOracle.getResources(), getAdditionalTypeProviderDelegate());
    ConfigProps config = new ConfigProps(Lists.newArrayList(configProps));

    jProgram =
        JavaAstConstructor.construct(logger, state, compilerContext.getOptions(), config,
            "test.EntryPoint", "com.google.gwt.lang.Exceptions");
    jProgram.addEntryMethod(findMethod(jProgram, "onModuleLoad"));

    optimizeJava();
    ComputeCastabilityInformation.exec(jProgram, false);
View Full Code Here

  protected CompilationState state;

  protected CompilationStateTestBase() {
    oracle = new MockResourceOracle(JavaResourceBase.getStandardResources());
    compilerContext = new CompilerContext();
    rebuildCompilationState();
  }
View Full Code Here

    return compile(builders);
  }

  protected List<CompilationUnit> compile(Collection<CompilationUnitBuilder> builders)
      throws UnableToCompleteException {
    CompilerContext compilerContext = new CompilerContext();
    compilerContext.getOptions().setSourceLevel(getSourceLevel());
    return JdtCompiler.compile(TreeLogger.NULL, compilerContext, builders);
  }
View Full Code Here

        code.append("  }\n");
        code.append("}\n");
        return code;
      }
    });
    CompilerContext compilerContext =
        new CompilerContext.Builder().options(new PrecompileTaskOptionsImpl() {
          @Override
          public boolean shouldJDTInlineCompileTimeConstants() {
            return false;
          }
        }).compileMonolithic(compileMonolithic).build();
    compilerContext.getOptions().setSourceLevel(sourceLevel);
    compilerContext.getOptions().setStrict(true);
    CompilationState state =
        CompilationStateBuilder.buildFrom(logger, compilerContext,
            sourceOracle.getResources(), getAdditionalTypeProviderDelegate());
    JProgram program =
        JavaAstConstructor.construct(logger, state, compilerContext.getOptions(),
            null, "test.EntryPoint", "com.google.gwt.lang.Exceptions");
    return program;
  }
View Full Code Here

  public static CompilationState buildCompilationState(TreeLogger logger, Set<Resource> resources,
      Set<GeneratedUnit> generatedUnits) {
    try {
      CompilationState state =
          CompilationStateBuilder.buildFrom(logger, new CompilerContext(), resources);
      state.addGeneratedCompilationUnits(logger, generatedUnits);
      return state;
    } catch (UnableToCompleteException e) {
      throw new RuntimeException(e);
    }
View Full Code Here

  public static TypeOracle buildLibraryTypeOracle(TreeLogger logger, Set<Resource> resources,
      Set<GeneratedUnit> generatedUnits) {
    try {
      // Compile resources to compilation units and place in an old library.
      CompilerContext oldCompilerContext = new CompilerContext();
      oldCompilerContext.getOptions().setStrict(true);
      CompilationState oldState =
          CompilationStateBuilder.buildFrom(logger, oldCompilerContext, resources);
      oldState.addGeneratedCompilationUnits(logger, generatedUnits);
      MockLibrary oldLibrary = new MockLibrary("OldLib");
      Collection<CompilationUnit> oldCompilationUnits =
          Lists.newArrayList(oldState.getCompilationUnits());
      CompilationUnitInvalidator.retainValidUnits(logger, oldCompilationUnits,
          oldState.getValidClasses(), new CompilationErrorsIndexImpl());
      for (CompilationUnit compilationUnit : oldCompilationUnits) {
        oldLibrary.addCompilationUnit(compilationUnit);
      }

      // Create and return a LibraryTypeOracle that doesn't have any compilation units loaded but
      // which can lazy load all of them out of a previously compiled library.
      LibraryGroup libraryGroup = LibraryGroup.fromLibraries(Lists.newArrayList(oldLibrary), false);
      CompilerContext newCompilerContext =
          new CompilerContext.Builder().compileMonolithic(false).libraryGroup(libraryGroup).build();
      newCompilerContext.getOptions().setStrict(true);
      CompilationState state = CompilationStateBuilder.buildFrom(logger, newCompilerContext,
          Sets.<Resource> newHashSet());
      return state.getTypeOracle();
    } catch (UnableToCompleteException e) {
      throw new RuntimeException(e);
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.CompilerContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.