Java 类org.eclipse.xtext.generator.GeneratorContext 实例源码

项目:xtext-extras    文件:CompilationTestHelper.java   
protected void doGenerate() {
    if (access == null) {
        doValidation();
        access = fileSystemAccessProvider.get();

        access.setOutputConfigurations(outputConfigurations);
        for (Resource resource : sources) {
            if (resource instanceof XtextResource) {
                access.setProjectName(PROJECT_NAME);
                XtextResource xtextResource = (XtextResource) resource;
                IResourceServiceProvider resourceServiceProvider = xtextResource.getResourceServiceProvider();
                GeneratorDelegate generator = resourceServiceProvider.get(GeneratorDelegate.class);
                if (generator != null) {
                    GeneratorContext context = new GeneratorContext();
                    context.setCancelIndicator(CancelIndicator.NullImpl);
                    generator.generate(xtextResource, access, context);
                }
            }
        }
        generatedCode = newHashMap();
        for (final GeneratedFile e : access.getGeneratedFiles()) {
            if (e.getJavaClassName() != null) {
                generatedCode.put(e.getJavaClassName(), e.getContents().toString());
            }
        }
    }
}
项目:xtext-extras    文件:StandaloneBuilder.java   
protected void generate(final List<Resource> sourceResources) {
  final GeneratorContext context = new GeneratorContext();
  context.setCancelIndicator(CancelIndicator.NullImpl);
  for (final Resource it : sourceResources) {
    {
      String _lastSegment = it.getURI().lastSegment();
      String _plus = ("Starting generator for input: \'" + _lastSegment);
      String _plus_1 = (_plus + "\'");
      StandaloneBuilder.LOG.info(_plus_1);
      this.registerCurrentSource(it.getURI());
      final LanguageAccess access = this.languageAccess(it.getURI());
      final JavaIoFileSystemAccess fileSystemAccess = this.getFileSystemAccess(access);
      boolean _isWriteStorageResources = this.isWriteStorageResources();
      if (_isWriteStorageResources) {
        boolean _matched = false;
        if (it instanceof StorageAwareResource) {
          IResourceStorageFacade _resourceStorageFacade = ((StorageAwareResource)it).getResourceStorageFacade();
          boolean _tripleNotEquals = (_resourceStorageFacade != null);
          if (_tripleNotEquals) {
            _matched=true;
            ((StorageAwareResource)it).getResourceStorageFacade().saveResource(((StorageAwareResource)it), fileSystemAccess);
          }
        }
      }
      access.getGenerator().generate(it, fileSystemAccess, context);
    }
  }
}
项目:CARMA    文件:MyCompilationTestHelper.java   
protected void doGenerate() {
    if (access == null) {
        doValidation();
        access = fileSystemAccessProvider.get();

        access.setOutputConfigurations(outputConfigurations);
        for (Resource resource : sources) {
            if (resource instanceof XtextResource) {
                access.setProjectName(PROJECT_NAME);
                XtextResource xtextResource = (XtextResource) resource;
                IResourceServiceProvider resourceServiceProvider = xtextResource.getResourceServiceProvider();
                GeneratorDelegate generator = resourceServiceProvider.get(GeneratorDelegate.class);
                if (generator != null) {
                    GeneratorContext context = new GeneratorContext();
                    context.setCancelIndicator(CancelIndicator.NullImpl);
                    generator.generate(xtextResource, access, context);
                }
            }
        }
        generatedCode = newHashMap();
        for (final GeneratedFile e : access.getGeneratedFiles()) {
            if (e.getJavaClassName() != null) {
                generatedCode.put(e.getJavaClassName(), e.getContents().toString());
            }
        }
    }
}