Java 类org.eclipse.xtext.xtext.generator.util.GenModelUtil2 实例源码

项目:xtext-extras    文件:EMFGeneratorFragment.java   
/**
 * @since 2.11
 */
@Override
public Set<Binding> getGuiceBindingsRt(Grammar grammar) {
    if (isBindEPackageAndEFactory()) {
        BindFactory bindFactory = new BindFactory();
        // Register generated EPackage and EFactory instances in the runtime module
        for (EPackage pkg: getGeneratedEPackages(grammar)) {
            GenPackage genPkg = GenModelUtil2.getGenPackage(pkg, grammar.eResource().getResourceSet());
            bindFactory
                .addTypeToInstance(genPkg.getQualifiedPackageInterfaceName(), genPkg.getQualifiedPackageInterfaceName()+".eINSTANCE")
                .addTypeToInstance(genPkg.getQualifiedFactoryInterfaceName(), genPkg.getQualifiedFactoryInterfaceName()+".eINSTANCE");
        }
        return bindFactory.getBindings();
    } else {
        return Collections.emptySet();
    }
}
项目:xtext-core    文件:TypeReference.java   
private static TypeReference.QualifiedClassName getQualifiedName(final EPackage epackage, final ResourceSet resourceSet) {
  TypeReference.QualifiedClassName _xblockexpression = null;
  {
    final GenPackage genPackage = GenModelUtil2.getGenPackage(epackage, resourceSet);
    String _xifexpression = null;
    boolean _isSuppressEMFMetaData = genPackage.getGenModel().isSuppressEMFMetaData();
    if (_isSuppressEMFMetaData) {
      _xifexpression = genPackage.getQualifiedPackageClassName();
    } else {
      _xifexpression = genPackage.getReflectionPackageName();
    }
    final String packageName = _xifexpression;
    String _packageInterfaceName = genPackage.getPackageInterfaceName();
    _xblockexpression = new TypeReference.QualifiedClassName(packageName, _packageInterfaceName);
  }
  return _xblockexpression;
}
项目:xtext-core    文件:EMFGeneratorFragment2.java   
private Map<String, EPackage> findEPackagesInGenPackages(final Collection<String> packageNsURIs, final ResourceSet resourceSet) {
  final HashMap<String, EPackage> result = CollectionLiterals.<String, EPackage>newHashMap();
  for (final String nsURI : packageNsURIs) {
    {
      final Resource resource = GenModelUtil2.getGenModelResource(null, nsURI, resourceSet);
      if ((resource != null)) {
        final GenModel loadedGenModel = IterableExtensions.<GenModel>head(Iterables.<GenModel>filter(resource.getContents(), GenModel.class));
        if ((loadedGenModel != null)) {
          final GenPackage genPackage = this.findGenPackageByNsURI(loadedGenModel, nsURI);
          result.put(nsURI, genPackage.getEcorePackage());
        }
      }
    }
  }
  return result;
}
项目:xtext-core    文件:EMFGeneratorFragment2.java   
protected List<GenPackage> getGenPackagesForPackages(final GenModel existingGenModel, final Collection<EPackage> packs) {
  final ArrayList<GenPackage> result = CollectionLiterals.<GenPackage>newArrayList();
  for (final EPackage pkg : packs) {
    final Function1<GenPackage, Boolean> _function = (GenPackage it) -> {
      EPackage _ecorePackage = it.getEcorePackage();
      String _nsURI = null;
      if (_ecorePackage!=null) {
        _nsURI=_ecorePackage.getNsURI();
      }
      String _nsURI_1 = pkg.getNsURI();
      return Boolean.valueOf(Objects.equal(_nsURI, _nsURI_1));
    };
    boolean _exists = IterableExtensions.<GenPackage>exists(existingGenModel.getGenPackages(), _function);
    boolean _not = (!_exists);
    if (_not) {
      result.add(GenModelUtil2.getGenPackage(pkg, existingGenModel.eResource().getResourceSet()));
    }
  }
  final Comparator<GenPackage> _function_1 = (GenPackage o1, GenPackage o2) -> {
    return EcoreUtil.getURI(o1).toString().compareTo(EcoreUtil.getURI(o2).toString());
  };
  Collections.<GenPackage>sort(result, _function_1);
  return result;
}
项目:xtext-core    文件:Formatter2Fragment2.java   
protected String getGetAccessor(final EStructuralFeature feature) {
  return GenModelUtil2.getGenFeature(feature, this.getLanguage().getResourceSet()).getGetAccessor();
}