当前位置: 首页>>代码示例>>Java>>正文


Java GeneratorConfig类代码示例

本文整理汇总了Java中org.eclipse.xtext.xbase.compiler.GeneratorConfig的典型用法代码示例。如果您正苦于以下问题:Java GeneratorConfig类的具体用法?Java GeneratorConfig怎么用?Java GeneratorConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GeneratorConfig类属于org.eclipse.xtext.xbase.compiler包,在下文中一共展示了GeneratorConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compile

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
/**
 * Parses, validates and compiles the given source. Calls the given acceptor for each
 * resource which is generated from the source.
 *  
 * @param resourceSet - the {@link ResourceSet} to use
 * @param acceptor gets called once for each file generated in {@link IGenerator}
 */
public void compile(final ResourceSet resourceSet, IAcceptor<Result> acceptor) {
	try {
		List<Resource> resourcesToCheck = newArrayList(resourceSet.getResources());
		if (generatorConfigProvider instanceof GeneratorConfigProvider) {
			GeneratorConfigProvider configProvider = (GeneratorConfigProvider) generatorConfigProvider;
			GeneratorConfig config = generatorConfigProvider.get(null);
			config.setJavaSourceVersion(javaCompiler.getJavaVersion());
			GeneratorConfig existent = configProvider.install(resourceSet, config);
			if (existent != null) {
				existent.setJavaSourceVersion(javaCompiler.getJavaVersion());
				configProvider.install(resourceSet, existent);
			}
		}
		Result result = resultProvider.get();
		result.setJavaCompiler(javaCompiler);
		result.setCheckMode(getCheckMode());
		result.setResources(resourcesToCheck);
		result.setResourceSet(resourceSet);
		result.setOutputConfigurations(getOutputConfigurations());
		result.doGenerate();
		acceptor.accept(result);
	} catch (Exception e) {
		Exceptions.throwUncheckedException(e);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:33,代码来源:CompilationTestHelper.java

示例2: install

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
public GeneratorConfig install(final ResourceSet resourceSet, final GeneratorConfig config) {
  GeneratorConfigProvider.GeneratorConfigAdapter _elvis = null;
  GeneratorConfigProvider.GeneratorConfigAdapter _findInEmfObject = GeneratorConfigProvider.GeneratorConfigAdapter.findInEmfObject(resourceSet);
  if (_findInEmfObject != null) {
    _elvis = _findInEmfObject;
  } else {
    GeneratorConfigProvider.GeneratorConfigAdapter _generatorConfigAdapter = new GeneratorConfigProvider.GeneratorConfigAdapter();
    final Procedure1<GeneratorConfigProvider.GeneratorConfigAdapter> _function = (GeneratorConfigProvider.GeneratorConfigAdapter it) -> {
      it.attachToEmfObject(resourceSet);
    };
    GeneratorConfigProvider.GeneratorConfigAdapter _doubleArrow = ObjectExtensions.<GeneratorConfigProvider.GeneratorConfigAdapter>operator_doubleArrow(_generatorConfigAdapter, _function);
    _elvis = _doubleArrow;
  }
  final GeneratorConfigProvider.GeneratorConfigAdapter adapter = _elvis;
  return adapter.language2GeneratorConfig.put(this.languageId, config);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:GeneratorConfigProvider.java

示例3: get

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
@Override
public GeneratorConfig get(final EObject context) {
  Resource _eResource = null;
  if (context!=null) {
    _eResource=context.eResource();
  }
  ResourceSet _resourceSet = null;
  if (_eResource!=null) {
    _resourceSet=_eResource.getResourceSet();
  }
  final ResourceSet resourceSet = _resourceSet;
  if ((resourceSet != null)) {
    final GeneratorConfigProvider.GeneratorConfigAdapter adapter = GeneratorConfigProvider.GeneratorConfigAdapter.findInEmfObject(resourceSet);
    if (((adapter != null) && adapter.language2GeneratorConfig.containsKey(this.languageId))) {
      return adapter.language2GeneratorConfig.get(this.languageId);
    }
  }
  return new GeneratorConfig();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:GeneratorConfigProvider.java

示例4: generateAnnotationMethod

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
public void generateAnnotationMethod(final JvmOperation it, final ITreeAppendable appendable, final GeneratorConfig config) {
  appendable.increaseIndentation().newLine();
  appendable.openScope();
  this.generateJavaDoc(it, appendable, config);
  final ITreeAppendable tracedAppendable = appendable.trace(it);
  this.generateAnnotations(it.getAnnotations(), tracedAppendable, true, config);
  this.generateModifier(it, tracedAppendable, config);
  this._errorSafeExtensions.serializeSafely(it.getReturnType(), "Object", tracedAppendable);
  tracedAppendable.append(" ");
  this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(this.makeJavaIdentifier(it.getSimpleName()));
  tracedAppendable.append("()");
  this.generateDefaultExpression(it, tracedAppendable, config);
  tracedAppendable.append(";");
  appendable.decreaseIndentation();
  appendable.closeScope();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:JvmModelGenerator.java

示例5: _generateModifier

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
protected ITreeAppendable _generateModifier(final JvmField it, final ITreeAppendable appendable, final GeneratorConfig config) {
  ITreeAppendable _xblockexpression = null;
  {
    this.generateVisibilityModifier(it, appendable);
    boolean _isFinal = it.isFinal();
    if (_isFinal) {
      appendable.append("final ");
    }
    boolean _isStatic = it.isStatic();
    if (_isStatic) {
      appendable.append("static ");
    }
    boolean _isTransient = it.isTransient();
    if (_isTransient) {
      appendable.append("transient ");
    }
    ITreeAppendable _xifexpression = null;
    boolean _isVolatile = it.isVolatile();
    if (_isVolatile) {
      _xifexpression = appendable.append("volatile ");
    }
    _xblockexpression = _xifexpression;
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:JvmModelGenerator.java

示例6: _generateMember

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
protected ITreeAppendable _generateMember(final JvmDeclaredType it, final ITreeAppendable appendable, final GeneratorConfig config) {
  ITreeAppendable _xblockexpression = null;
  {
    appendable.newLine();
    appendable.openScope();
    this.assignThisAndSuper(appendable, it, config);
    ITreeAppendable _xtrycatchfinallyexpression = null;
    try {
      _xtrycatchfinallyexpression = this.generateBody(it, appendable, config);
    } finally {
      appendable.closeScope();
    }
    _xblockexpression = _xtrycatchfinallyexpression;
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:JvmModelGenerator.java

示例7: generateParameters

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
public void generateParameters(final JvmExecutable it, final ITreeAppendable appendable, final GeneratorConfig config) {
  boolean _isEmpty = it.getParameters().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    int _size = it.getParameters().size();
    int _minus = (_size - 1);
    IntegerRange _upTo = new IntegerRange(0, _minus);
    for (final Integer i : _upTo) {
      {
        int _size_1 = it.getParameters().size();
        final boolean last = (((i).intValue() + 1) == _size_1);
        final JvmFormalParameter p = it.getParameters().get((i).intValue());
        this.generateParameter(p, appendable, (last && it.isVarArgs()), config);
        if ((!last)) {
          appendable.append(", ");
        }
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:JvmModelGenerator.java

示例8: generateParameter

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
public void generateParameter(final JvmFormalParameter it, final ITreeAppendable appendable, final boolean vararg, final GeneratorConfig config) {
  final ITreeAppendable tracedAppendable = appendable.trace(it);
  this.generateAnnotations(it.getAnnotations(), tracedAppendable, false, config);
  tracedAppendable.append("final ");
  if (vararg) {
    JvmTypeReference _parameterType = it.getParameterType();
    boolean _not = (!(_parameterType instanceof JvmGenericArrayTypeReference));
    if (_not) {
      tracedAppendable.append("/* Internal Error: Parameter was vararg but not an array type. */");
    } else {
      JvmTypeReference _parameterType_1 = it.getParameterType();
      this._errorSafeExtensions.serializeSafely(((JvmGenericArrayTypeReference) _parameterType_1).getComponentType(), "Object", tracedAppendable);
    }
    tracedAppendable.append("...");
  } else {
    this._errorSafeExtensions.serializeSafely(it.getParameterType(), "Object", tracedAppendable);
  }
  tracedAppendable.append(" ");
  final String name = tracedAppendable.declareVariable(it, this.makeJavaIdentifier(it.getSimpleName()));
  this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(name);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:JvmModelGenerator.java

示例9: generateJavaDoc

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
public void generateJavaDoc(final EObject it, final ITreeAppendable appendable, final GeneratorConfig config) {
  final DocumentationAdapter adapter = IterableExtensions.<DocumentationAdapter>head(Iterables.<DocumentationAdapter>filter(it.eAdapters(), DocumentationAdapter.class));
  String _documentation = null;
  if (adapter!=null) {
    _documentation=adapter.getDocumentation();
  }
  boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(_documentation);
  boolean _not = (!_isNullOrEmpty);
  if (_not) {
    final Set<EObject> sourceElements = this.getSourceElements(it);
    if (((sourceElements.size() == 1) && (this.documentationProvider instanceof IEObjectDocumentationProviderExtension))) {
      final List<INode> documentationNodes = ((IEObjectDocumentationProviderExtension) this.documentationProvider).getDocumentationNodes(IterableExtensions.<EObject>head(sourceElements));
      this.addJavaDocImports(it, appendable, documentationNodes);
      this.generateDocumentation(adapter.getDocumentation(), documentationNodes, appendable, config);
    } else {
      this.generateDocumentation(adapter.getDocumentation(), CollectionLiterals.<INode>emptyList(), appendable, config);
    }
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:JvmModelGenerator.java

示例10: toJava

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
public void toJava(final JvmAnnotationValue it, final ITreeAppendable appendable, final GeneratorConfig config) {
  JvmOperation _operation = it.getOperation();
  boolean _tripleNotEquals = (_operation != null);
  if (_tripleNotEquals) {
    String _simpleName = it.getOperation().getSimpleName();
    boolean _tripleEquals = (_simpleName == null);
    if (_tripleEquals) {
      return;
    }
    appendable.append(it.getOperation().getSimpleName());
    appendable.append(" = ");
  } else {
    EObject _eContainer = it.eContainer();
    int _size = ((JvmAnnotationReference) _eContainer).getExplicitValues().size();
    boolean _greaterThan = (_size > 1);
    if (_greaterThan) {
      appendable.append("value = ");
    }
  }
  this.toJavaLiteral(it, appendable, config);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:JvmModelGenerator.java

示例11: generateModifier

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
public ITreeAppendable generateModifier(final JvmMember it, final ITreeAppendable appendable, final GeneratorConfig config) {
  if (it instanceof JvmConstructor) {
    return _generateModifier((JvmConstructor)it, appendable, config);
  } else if (it instanceof JvmOperation) {
    return _generateModifier((JvmOperation)it, appendable, config);
  } else if (it instanceof JvmField) {
    return _generateModifier((JvmField)it, appendable, config);
  } else if (it instanceof JvmGenericType) {
    return _generateModifier((JvmGenericType)it, appendable, config);
  } else if (it instanceof JvmDeclaredType) {
    return _generateModifier((JvmDeclaredType)it, appendable, config);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, appendable, config).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:JvmModelGenerator.java

示例12: generateMember

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
public ITreeAppendable generateMember(final JvmMember it, final ITreeAppendable appendable, final GeneratorConfig config) {
  if (it instanceof JvmConstructor) {
    return _generateMember((JvmConstructor)it, appendable, config);
  } else if (it instanceof JvmOperation) {
    return _generateMember((JvmOperation)it, appendable, config);
  } else if (it instanceof JvmField) {
    return _generateMember((JvmField)it, appendable, config);
  } else if (it instanceof JvmDeclaredType) {
    return _generateMember((JvmDeclaredType)it, appendable, config);
  } else if (it != null) {
    return _generateMember(it, appendable, config);
  } else {
    throw new IllegalArgumentException("Unhandled parameter types: " +
      Arrays.<Object>asList(it, appendable, config).toString());
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:17,代码来源:JvmModelGenerator.java

示例13: getComplianceLevelArg

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
protected String getComplianceLevelArg() {
	JavaVersion javaVersion = JavaVersion.JAVA5;
	if (generatorConfigProvider != null) {
		GeneratorConfig generatorConfig = generatorConfigProvider.get(null);
		javaVersion = generatorConfig.getJavaSourceVersion();
	}
	return javaVersion.getComplianceLevelArg();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:OnTheFlyJavaCompiler.java

示例14: generateType

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
public CharSequence generateType(final JvmDeclaredType type, final GeneratorConfig config) {
  final ImportManager importManager = this.createImportManager(type);
  final TreeAppendable bodyAppendable = this.createAppendable(type, importManager, config);
  bodyAppendable.openScope();
  this.assignThisAndSuper(bodyAppendable, type, config);
  this.generateBody(type, bodyAppendable, config);
  bodyAppendable.closeScope();
  final TreeAppendable importAppendable = this.createAppendable(type, importManager, config);
  this.generateFileHeader(type, importAppendable, config);
  String _packageName = type.getPackageName();
  boolean _tripleNotEquals = (_packageName != null);
  if (_tripleNotEquals) {
    importAppendable.append("package ").append(type.getPackageName()).append(";");
    importAppendable.newLine().newLine();
  }
  List<String> _imports = importManager.getImports();
  for (final String i : _imports) {
    importAppendable.append("import ").append(i).append(";").newLine();
  }
  boolean _isEmpty = importManager.getImports().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    importAppendable.newLine();
  }
  importAppendable.append(bodyAppendable);
  return importAppendable;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:28,代码来源:JvmModelGenerator.java

示例15: _generateBody

import org.eclipse.xtext.xbase.compiler.GeneratorConfig; //导入依赖的package包/类
protected ITreeAppendable _generateBody(final JvmGenericType it, final ITreeAppendable appendable, final GeneratorConfig config) {
  ITreeAppendable _xblockexpression = null;
  {
    this.generateJavaDoc(it, appendable, config);
    final ITreeAppendable childAppendable = appendable.trace(it);
    this.generateAnnotations(it.getAnnotations(), childAppendable, true, config);
    this.generateModifier(it, childAppendable, config);
    boolean _isInterface = it.isInterface();
    if (_isInterface) {
      childAppendable.append("interface ");
    } else {
      childAppendable.append("class ");
    }
    this._treeAppendableUtil.traceSignificant(childAppendable, it).append(this.makeJavaIdentifier(it.getSimpleName()));
    this.generateTypeParameterDeclaration(it, childAppendable, config);
    boolean _isEmpty = it.getTypeParameters().isEmpty();
    if (_isEmpty) {
      childAppendable.append(" ");
    }
    this.generateExtendsClause(it, childAppendable, config);
    this.generateMembersInBody(it, childAppendable, config);
    ITreeAppendable _xifexpression = null;
    if (((!it.isAnonymous()) && (!(it.eContainer() instanceof JvmType)))) {
      _xifexpression = appendable.newLine();
    }
    _xblockexpression = _xifexpression;
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:30,代码来源:JvmModelGenerator.java


注:本文中的org.eclipse.xtext.xbase.compiler.GeneratorConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。