Java Code Examples for org.eclipse.xtext.generator.IFileSystemAccess#DEFAULT_OUTPUT

The following examples show how to use org.eclipse.xtext.generator.IFileSystemAccess#DEFAULT_OUTPUT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JvmModelGeneratorTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public String generate(final Resource res, final JvmDeclaredType type) {
  String _xblockexpression = null;
  {
    res.eSetDeliver(false);
    EList<EObject> _contents = res.getContents();
    this.builder.<JvmDeclaredType>operator_add(_contents, type);
    res.eSetDeliver(true);
    final InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    this.generator.doGenerate(res, fsa);
    Map<String, CharSequence> _textFiles = fsa.getTextFiles();
    String _replace = type.getIdentifier().replace(".", "/");
    String _plus = (IFileSystemAccess.DEFAULT_OUTPUT + _replace);
    String _plus_1 = (_plus + ".java");
    _xblockexpression = _textFiles.get(_plus_1).toString();
  }
  return _xblockexpression;
}
 
Example 2
Source File: SARLJvmGenerator.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
protected void _internalDoGenerate(JvmDeclaredType type, IFileSystemAccess fsa) {
	if (DisableCodeGenerationAdapter.isDisabled(type)) {
		return;
	}
	final String qn = type.getQualifiedName();
	if (!Strings.isEmpty(qn)) {
		final String fn = qn.replace('.', '/') + ".java"; //$NON-NLS-1$
		final CharSequence content = generateType(type, this.generatorConfigProvider.get(type));
		final String outputConfigurationName;
		final Boolean isTest = this.resourceTypeDetector.isTestResource(type.eResource());
		if (isTest != null && isTest.booleanValue()) {
			outputConfigurationName = SARLConfig.TEST_OUTPUT_CONFIGURATION;
		} else {
			outputConfigurationName = IFileSystemAccess.DEFAULT_OUTPUT;
		}
		fsa.generateFile(fn, outputConfigurationName, content);
	}
}
 
Example 3
Source File: StandaloneBuilderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Set<OutputConfiguration> getOutputConfigurations() {
	OutputConfiguration config = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
	config.setOutputDirectory("src-gen");
	if (useOutputPerSource) {
		SourceMapping sourceMapping = new OutputConfiguration.SourceMapping("src2");
		sourceMapping.setOutputDirectory("src2-gen");
		config.getSourceMappings().add(sourceMapping);
		config.setUseOutputPerSourceFolder(true);
	}
	return ImmutableSet.of(config);
}
 
Example 4
Source File: StandaloneBuilderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Set<OutputConfiguration> getOutputConfigurations() {
	OutputConfiguration config = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
	config.setOutputDirectory("src-gen");
	if (useOutputPerSource) {
		SourceMapping sourceMapping = new OutputConfiguration.SourceMapping("src2");
		sourceMapping.setOutputDirectory("src2-gen");
		config.getSourceMappings().add(sourceMapping);
		config.setUseOutputPerSourceFolder(true);
	}
	return ImmutableSet.of(config);
}
 
Example 5
Source File: XtendOutputConfigurationProvider.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Set<OutputConfiguration> getOutputConfigurations() {
	OutputConfiguration defaultOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
	defaultOutput.setDescription("Output folder for generated Java files");
	defaultOutput.setOutputDirectory("xtend-gen");
	defaultOutput.setOverrideExistingResources(true);
	defaultOutput.setCreateOutputDirectory(true);
	defaultOutput.setCanClearOutputDirectory(false);
	defaultOutput.setCleanUpDerivedResources(true);
	defaultOutput.setSetDerivedProperty(true);
	defaultOutput.setKeepLocalHistory(false);
	return newHashSet(defaultOutput);
}
 
Example 6
Source File: ExportOutputConfigurationProvider.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates output configuration for regular generated files.
 *
 * @return output configuration
 */
private OutputConfiguration getDefaultConfig() {
  OutputConfiguration config = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
  config.setDescription("Output configuration for generated classes"); //$NON-NLS-1$
  config.setOverrideExistingResources(true);
  config.setOutputDirectory("src-gen"); //$NON-NLS-1$
  return config;
}
 
Example 7
Source File: SarlOutputConfigurationProvider.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Create the standard output configuration.
 *
 * @return the configuration, never {@code null}.
 * @since 0.8
 */
@SuppressWarnings("static-method")
protected OutputConfiguration createStandardOutputConfiguration() {
	final OutputConfiguration defaultOutput = new OutputConfiguration(IFileSystemAccess.DEFAULT_OUTPUT);
	defaultOutput.setDescription(Messages.SarlOutputConfigurationProvider_0);
	defaultOutput.setOutputDirectory(SARLConfig.FOLDER_SOURCE_GENERATED);
	defaultOutput.setOverrideExistingResources(true);
	defaultOutput.setCreateOutputDirectory(true);
	defaultOutput.setCanClearOutputDirectory(false);
	defaultOutput.setCleanUpDerivedResources(true);
	defaultOutput.setSetDerivedProperty(true);
	defaultOutput.setKeepLocalHistory(false);
	return defaultOutput;
}
 
Example 8
Source File: JvmModelGeneratorTest.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void bug390290InnerClassMemberImport() {
  try {
    final XExpression expression = this.expression("null");
    final Procedure1<JvmGenericType> _function = (JvmGenericType it) -> {
      final JvmGenericType innerClass = this.builder.toClass(it, "InnerClass");
      final JvmGenericType innerClassString = this.builder.toClass(it, "String");
      EList<JvmMember> _members = it.getMembers();
      this.builder.<JvmGenericType>operator_add(_members, innerClass);
      EList<JvmMember> _members_1 = it.getMembers();
      this.builder.<JvmGenericType>operator_add(_members_1, innerClassString);
      EList<JvmMember> _members_2 = it.getMembers();
      final Procedure1<JvmOperation> _function_1 = (JvmOperation fooMethod) -> {
        EList<JvmFormalParameter> _parameters = fooMethod.getParameters();
        JvmFormalParameter _parameter = this.builder.toParameter(it, "p1", this.references.createTypeRef(innerClass));
        this.builder.<JvmFormalParameter>operator_add(_parameters, _parameter);
        EList<JvmFormalParameter> _parameters_1 = fooMethod.getParameters();
        JvmFormalParameter _parameter_1 = this.builder.toParameter(it, "p2", this.references.createTypeRef(innerClassString));
        this.builder.<JvmFormalParameter>operator_add(_parameters_1, _parameter_1);
        this.builder.setBody(fooMethod, expression);
      };
      JvmOperation _method = this.builder.toMethod(it, "foo", this.references.getTypeForName(String.class, expression), _function_1);
      this.builder.<JvmOperation>operator_add(_members_2, _method);
    };
    final JvmGenericType clazz = this.builder.toClass(expression, "my.test.Outer", _function);
    expression.eResource().eSetDeliver(false);
    EList<EObject> _contents = expression.eResource().getContents();
    this.builder.<JvmGenericType>operator_add(_contents, clazz);
    expression.eResource().eSetDeliver(true);
    final InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess();
    this.generator.doGenerate(expression.eResource(), fsa);
    Map<String, CharSequence> _textFiles = fsa.getTextFiles();
    String _replace = clazz.getIdentifier().replace(".", "/");
    String _plus = (IFileSystemAccess.DEFAULT_OUTPUT + _replace);
    String _plus_1 = (_plus + ".java");
    final String code = _textFiles.get(_plus_1).toString();
    Assert.assertFalse(code.contains("import"));
    Assert.assertTrue(code, code.contains("java.lang.String foo"));
    final Class<?> compiledClass = this.javaCompiler.compileToClass(clazz.getIdentifier(), code);
    this.helper.assertNoErrors(IterableExtensions.<EObject>head(expression.eResource().getContents()));
    Assert.assertEquals(2, ((List<Class<?>>)Conversions.doWrapArray(compiledClass.getDeclaredClasses())).size());
    Assert.assertNotNull(compiledClass.getMethod("foo", IterableExtensions.<Class<?>>head(((Iterable<Class<?>>)Conversions.doWrapArray(compiledClass.getDeclaredClasses()))), IterableExtensions.<Class<?>>last(((Iterable<Class<?>>)Conversions.doWrapArray(compiledClass.getDeclaredClasses())))));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 9
Source File: AbstractBuilderParticipantTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected String getDefaultOutputDirectoryKey() {
	return OUTPUT_PREFERENCE_TAG + PreferenceConstants.SEPARATOR + IFileSystemAccess.DEFAULT_OUTPUT
			+ PreferenceConstants.SEPARATOR + OUTPUT_DIRECTORY;
}
 
Example 10
Source File: AbstractBuilderParticipantTest.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected String getUseOutputPerSourceFolderKey() {
	return OUTPUT_PREFERENCE_TAG + PreferenceConstants.SEPARATOR + IFileSystemAccess.DEFAULT_OUTPUT
			+ PreferenceConstants.SEPARATOR + USE_OUTPUT_PER_SOURCE_FOLDER;
}