org.eclipse.emf.ecore.EPackage Java Examples

The following examples show how to use org.eclipse.emf.ecore.EPackage. 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: Bug296889TestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == Bug296889TestPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case Bug296889TestPackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		case Bug296889TestPackage.POSTOP:
			sequence_Postop(context, (Postop) semanticObject); 
			return; 
		case Bug296889TestPackage.PREOP:
			sequence_Preop(context, (Preop) semanticObject); 
			return; 
		case Bug296889TestPackage.VARIABLE:
			sequence_Variable(context, (Variable) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #2
Source File: Bpmn2PackageImpl.java    From fixflow with Apache License 2.0 6 votes vote down vote up
/**
 * Laods the package and any sub-packages from their serialized form.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void loadPackage() {
    if (isLoaded)
        return;
    isLoaded = true;

    URL url = getClass().getResource(packageFilename);
    if (url == null) {
        throw new RuntimeException("Missing serialized package: " + packageFilename);
    }
    URI uri = URI.createURI(url.toString());
    Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
    try {
        resource.load(null);
    } catch (IOException exception) {
        throw new WrappedException(exception);
    }
    initializeFromLoadedEPackage(this, (EPackage) resource.getContents().get(0));
    createResource(eNS_URI);
}
 
Example #3
Source File: ModelInferencePackageImpl.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 * 
 * <p>This method is used to initialize {@link ModelInferencePackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static ModelInferencePackage init()
{
	if (isInited) return (ModelInferencePackage)EPackage.Registry.INSTANCE.getEPackage(ModelInferencePackage.eNS_URI);

	// Obtain or create and register package
	ModelInferencePackageImpl theModelInferencePackage = (ModelInferencePackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ModelInferencePackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ModelInferencePackageImpl());

	isInited = true;

	// Create package meta-data objects
	theModelInferencePackage.createPackageContents();

	// Initialize created meta-data
	theModelInferencePackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theModelInferencePackage.freeze();

 
	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(ModelInferencePackage.eNS_URI, theModelInferencePackage);
	return theModelInferencePackage;
}
 
Example #4
Source File: TwoContextsPackageImpl.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link TwoContextsPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static TwoContextsPackage init()
{
  if (isInited) return (TwoContextsPackage)EPackage.Registry.INSTANCE.getEPackage(TwoContextsPackage.eNS_URI);

  // Obtain or create and register package
  Object registeredTwoContextsPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
  TwoContextsPackageImpl theTwoContextsPackage = registeredTwoContextsPackage instanceof TwoContextsPackageImpl ? (TwoContextsPackageImpl)registeredTwoContextsPackage : new TwoContextsPackageImpl();

  isInited = true;

  // Create package meta-data objects
  theTwoContextsPackage.createPackageContents();

  // Initialize created meta-data
  theTwoContextsPackage.initializePackageContents();

  // Mark meta-data to indicate it can't be changed
  theTwoContextsPackage.freeze();

  // Update the registry and return the package
  EPackage.Registry.INSTANCE.put(TwoContextsPackage.eNS_URI, theTwoContextsPackage);
  return theTwoContextsPackage;
}
 
Example #5
Source File: Xtext2EcoreTransformerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testSimpleHierarchy() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test with org.eclipse.xtext.common.Terminals generate test \'http://test\' RuleA: RuleB; RuleB: featureB= INT;");
  final String grammar = _builder.toString();
  EPackage ePackage = this.getEPackageFromGrammar(grammar);
  Assert.assertEquals(2, ePackage.getEClassifiers().size());
  EClassifier _type = this.<EClassifier>type(ePackage, "RuleA");
  EClass ruleA = ((EClass) _type);
  Assert.assertNotNull(ruleA);
  EClassifier _type_1 = this.<EClassifier>type(ePackage, "RuleB");
  EClass ruleB = ((EClass) _type_1);
  Assert.assertNotNull(ruleB);
  Assert.assertTrue(ruleA.getESuperTypes().isEmpty());
  Assert.assertEquals(1, ruleB.getESuperTypes().size());
  EClass superClass = IterableExtensions.<EClass>head(ruleB.getESuperTypes());
  Assert.assertEquals(ruleA, superClass);
}
 
Example #6
Source File: BeeLangTestLanguagePackageImpl.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link BeeLangTestLanguagePackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static BeeLangTestLanguagePackage init()
{
  if (isInited) return (BeeLangTestLanguagePackage)EPackage.Registry.INSTANCE.getEPackage(BeeLangTestLanguagePackage.eNS_URI);

  // Obtain or create and register package
  Object registeredBeeLangTestLanguagePackage = EPackage.Registry.INSTANCE.get(eNS_URI);
  BeeLangTestLanguagePackageImpl theBeeLangTestLanguagePackage = registeredBeeLangTestLanguagePackage instanceof BeeLangTestLanguagePackageImpl ? (BeeLangTestLanguagePackageImpl)registeredBeeLangTestLanguagePackage : new BeeLangTestLanguagePackageImpl();

  isInited = true;

  // Create package meta-data objects
  theBeeLangTestLanguagePackage.createPackageContents();

  // Initialize created meta-data
  theBeeLangTestLanguagePackage.initializePackageContents();

  // Mark meta-data to indicate it can't be changed
  theBeeLangTestLanguagePackage.freeze();

  // Update the registry and return the package
  EPackage.Registry.INSTANCE.put(BeeLangTestLanguagePackage.eNS_URI, theBeeLangTestLanguagePackage);
  return theBeeLangTestLanguagePackage;
}
 
Example #7
Source File: BeansPackageImpl.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 * 
 * <p>This method is used to initialize {@link BeansPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static BeansPackage init() {
	if (isInited) return (BeansPackage)EPackage.Registry.INSTANCE.getEPackage(BeansPackage.eNS_URI);

	// Obtain or create and register package
	BeansPackageImpl theBeansPackage = (BeansPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof BeansPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new BeansPackageImpl());

	isInited = true;

	// Initialize simple dependencies
	XMLTypePackage.eINSTANCE.eClass();

	// Create package meta-data objects
	theBeansPackage.createPackageContents();

	// Initialize created meta-data
	theBeansPackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theBeansPackage.freeze();

 
	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(BeansPackage.eNS_URI, theBeansPackage);
	return theBeansPackage;
}
 
Example #8
Source File: ModelPackageImpl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Laods the package and any sub-packages from their serialized form.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void loadPackage() {
	if (isLoaded) return;
	isLoaded = true;

	URL url = getClass().getResource(packageFilename);
	if (url == null) {
		throw new RuntimeException("Missing serialized package: " + packageFilename);
	}
	URI uri = URI.createURI(url.toString());
	Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
	try {
		resource.load(null);
	}
	catch (IOException exception) {
		throw new WrappedException(exception);
	}
	initializeFromLoadedEPackage(this, (EPackage)resource.getContents().get(0));
	createResource(eNS_URI);
}
 
Example #9
Source File: ActionLangFactoryImpl.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates the default factory implementation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public static ActionLangFactory init()
{
  try
  {
    ActionLangFactory theActionLangFactory = (ActionLangFactory)EPackage.Registry.INSTANCE.getEFactory(ActionLangPackage.eNS_URI);
    if (theActionLangFactory != null)
    {
      return theActionLangFactory;
    }
  }
  catch (Exception exception)
  {
    EcorePlugin.INSTANCE.log(exception);
  }
  return new ActionLangFactoryImpl();
}
 
Example #10
Source File: ModbusFactoryImpl.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the default factory implementation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public static ModbusFactory init ()
{
    try
    {
        ModbusFactory theModbusFactory = (ModbusFactory)EPackage.Registry.INSTANCE.getEFactory ( ModbusPackage.eNS_URI );
        if ( theModbusFactory != null )
        {
            return theModbusFactory;
        }
    }
    catch ( Exception exception )
    {
        EcorePlugin.INSTANCE.log ( exception );
    }
    return new ModbusFactoryImpl ();
}
 
Example #11
Source File: DetailViewPackageImpl.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model,
 * and for any others upon which it depends.
 * <p>
 * This method is used to initialize {@link DetailViewPackage#eINSTANCE}
 * when that field is accessed. Clients should not invoke it directly.
 * Instead, they should simply access that field to obtain the package. <!--
 * begin-user-doc --> <!-- end-user-doc -->
 * 
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static DetailViewPackage init ()
{
    if ( isInited )
        return (DetailViewPackage)EPackage.Registry.INSTANCE.getEPackage ( DetailViewPackage.eNS_URI );

    // Obtain or create and register package
    DetailViewPackageImpl theDetailViewPackage = (DetailViewPackageImpl) ( EPackage.Registry.INSTANCE.get ( eNS_URI ) instanceof DetailViewPackageImpl ? EPackage.Registry.INSTANCE.get ( eNS_URI ) : new DetailViewPackageImpl () );

    isInited = true;

    // Create package meta-data objects
    theDetailViewPackage.createPackageContents ();

    // Initialize created meta-data
    theDetailViewPackage.initializePackageContents ();

    // Mark meta-data to indicate it can't be changed
    theDetailViewPackage.freeze ();

    // Update the registry and return the package
    EPackage.Registry.INSTANCE.put ( DetailViewPackage.eNS_URI, theDetailViewPackage );
    return theDetailViewPackage;
}
 
Example #12
Source File: IgnoreCaseImportsTestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == IgnoreCaseImportsTestPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case IgnoreCaseImportsTestPackage.IMPORT:
			sequence_Import(context, (Import) semanticObject); 
			return; 
		case IgnoreCaseImportsTestPackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	else if (epackage == IgnoreCaseLinkingTestPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case IgnoreCaseLinkingTestPackage.ELEMENT:
			sequence_Element(context, (Element) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #13
Source File: XtextCrossReferenceSerializer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected String getUnconvertedLinkText(EObject object, EReference reference, EObject context) {
	if (reference == XtextPackage.eINSTANCE.getGrammar_UsedGrammars())
		return ((Grammar) object).getName();
	if (reference == XtextPackage.eINSTANCE.getTypeRef_Metamodel()) {
		AbstractMetamodelDeclaration casted = (AbstractMetamodelDeclaration) object;
		return casted.getAlias();
	}
	if (reference == XtextPackage.eINSTANCE.getAbstractMetamodelDeclaration_EPackage())
		return ((EPackage) object).getNsURI();
	if (object instanceof AbstractRule) {
		if (reference == XtextPackage.eINSTANCE.getRuleCall_Rule()) {
			if (((RuleCall)context).isExplicitlyCalled()) {
				return super.getUnconvertedLinkText(object, reference, context);
			}
		}
		return ((AbstractRule) object).getName();
	}
	return super.getUnconvertedLinkText(object, reference, context);
}
 
Example #14
Source File: Bug302128FactoryImpl.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates the default factory implementation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public static Bug302128Factory init()
{
  try
  {
    Bug302128Factory theBug302128Factory = (Bug302128Factory)EPackage.Registry.INSTANCE.getEFactory(Bug302128Package.eNS_URI);
    if (theBug302128Factory != null)
    {
      return theBug302128Factory;
    }
  }
  catch (Exception exception)
  {
    EcorePlugin.INSTANCE.log(exception);
  }
  return new Bug302128FactoryImpl();
}
 
Example #15
Source File: OptionalEmptyTestLanguageSemanticSequencer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == OptionalEmptyPackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case OptionalEmptyPackage.GREETING:
			sequence_Greeting(context, (Greeting) semanticObject); 
			return; 
		case OptionalEmptyPackage.MODEL:
			sequence_Model(context, (Model) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #16
Source File: UimaTypeSystem2Ecore.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Load uima builtins ecore.
 *
 * @param resourceSet the resource set
 * @param aSchemaLocationMap the a schema location map
 * @return the resource
 */
private static Resource loadUimaBuiltinsEcore(ResourceSet resourceSet, Map aSchemaLocationMap) {
  // load Ecore model for UIMA built-in types (use classloader to locate)
  URL uimaEcoreUrl = UimaTypeSystem2Ecore.class.getResource("/uima.ecore");
  if (uimaEcoreUrl == null) {
    throw new UIMARuntimeException(UIMARuntimeException.UIMA_ECORE_NOT_FOUND, new Object[0]);
  }
  Resource uimaEcoreResource = resourceSet.getResource(URI.createURI(uimaEcoreUrl.toString()),
          true);
  // register core UIMA packages (I'm surprised I need to do this manually)
  TreeIterator iter = uimaEcoreResource.getAllContents();
  while (iter.hasNext()) {
    Object current = iter.next();
    if (current instanceof EPackage) {
      EPackage pkg = (EPackage) current;
      EPackage.Registry.INSTANCE.put(pkg.getNsURI(), pkg);
      if (aSchemaLocationMap != null) {
        String schemaLoc = uimaEcoreResource.getURI() + "#"
                + uimaEcoreResource.getURIFragment(pkg);
        aSchemaLocationMap.put(pkg.getNsURI(), schemaLoc);
      }
    }
  }
  return uimaEcoreResource;
}
 
Example #17
Source File: BuilderTestLanguageSemanticSequencer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
	EPackage epackage = semanticObject.eClass().getEPackage();
	ParserRule rule = context.getParserRule();
	Action action = context.getAssignedAction();
	Set<Parameter> parameters = context.getEnabledBooleanParameters();
	if (epackage == BuilderTestLanguagePackage.eINSTANCE)
		switch (semanticObject.eClass().getClassifierID()) {
		case BuilderTestLanguagePackage.ELEMENT:
			sequence_Element(context, (Element) semanticObject); 
			return; 
		case BuilderTestLanguagePackage.IMPORT:
			sequence_Import(context, (Import) semanticObject); 
			return; 
		case BuilderTestLanguagePackage.NAMESPACE:
			sequence_Namespace(context, (Namespace) semanticObject); 
			return; 
		}
	if (errorAcceptor != null)
		errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
 
Example #18
Source File: XtextLinkingService.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
private List<EObject> createPackage(GeneratedMetamodel generatedMetamodel, ILeafNode text) {
	final String nsURI = getMetamodelNsURI(text);
	final URI uri = URI.createURI(nsURI);
	if (uri == null || isReferencedByUsedGrammar(generatedMetamodel, nsURI))
		return Collections.emptyList();
	EPackage pack = ((GeneratedMetamodelImpl)generatedMetamodel).basicGetEPackage();
	if (pack != null && !pack.eIsProxy())
		return singletonList((EObject)pack);
	final EPackage generatedEPackage = EcoreFactory.eINSTANCE.createEPackage();
	generatedEPackage.setName(generatedMetamodel.getName());
	generatedEPackage.setNsPrefix(generatedMetamodel.getName());
	generatedEPackage.setNsURI(nsURI);
	final Resource generatedPackageResource = new EcoreResourceFactoryImpl().createResource(uri);
	XtextResourceSet resourceSet = (XtextResourceSet) generatedMetamodel.eResource().getResourceSet();
	if (!resourceSet.getURIResourceMap().containsKey(generatedPackageResource.getURI())) {
		generatedMetamodel.eResource().getResourceSet().getResources().add(generatedPackageResource);
	} else {
		generatedPackageResource.setURI(URI.createURI(nsURI+"_"+generatedMetamodel.hashCode()));
		generatedMetamodel.eResource().getResourceSet().getResources().add(generatedPackageResource);
	}
	generatedPackageResource.getContents().add(generatedEPackage);
	return Collections.<EObject>singletonList(generatedEPackage);
}
 
Example #19
Source File: Bug292245TestLanguageFactoryImpl.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates the default factory implementation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public static Bug292245TestLanguageFactory init()
{
  try
  {
    Bug292245TestLanguageFactory theBug292245TestLanguageFactory = (Bug292245TestLanguageFactory)EPackage.Registry.INSTANCE.getEFactory(Bug292245TestLanguagePackage.eNS_URI);
    if (theBug292245TestLanguageFactory != null)
    {
      return theBug292245TestLanguageFactory;
    }
  }
  catch (Exception exception)
  {
    EcorePlugin.INSTANCE.log(exception);
  }
  return new Bug292245TestLanguageFactoryImpl();
}
 
Example #20
Source File: StorePackageImpl.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Laods the package and any sub-packages from their serialized form.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void loadPackage() {
	if (isLoaded)
		return;
	isLoaded = true;

	URL url = getClass().getResource(packageFilename);
	if (url == null) {
		throw new RuntimeException("Missing serialized package: " + packageFilename);
	}
	URI uri = URI.createURI(url.toString());
	Resource resource = new EcoreResourceFactoryImpl().createResource(uri);
	try {
		resource.load(null);
	} catch (IOException exception) {
		throw new WrappedException(exception);
	}
	initializeFromLoadedEPackage(this, (EPackage) resource.getContents().get(0));
	createResource(eNS_URI);
}
 
Example #21
Source File: DefaultResourceDescriptionTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testGetExportedObject_1() throws Exception {
	strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() {
		@Override
		public QualifiedName getFullyQualifiedName(EObject obj) {
			if (obj instanceof EPackage)
				return QualifiedName.create(((EPackage) obj).getName());
			return null;
		}
	});

	Iterable<IEObjectDescription> iterable = description.getExportedObjects();
	ArrayList<IEObjectDescription> list = Lists.newArrayList(iterable);
	assertEquals(1, list.size());
	assertEquals(pack.getName(), list.get(0).getName().toString());
	assertEquals(pack, list.get(0).getEObjectOrProxy());
}
 
Example #22
Source File: ScopeFactoryImpl.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the default factory implementation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public static ScopeFactory init()
{
  try
  {
    ScopeFactory theScopeFactory = (ScopeFactory)EPackage.Registry.INSTANCE.getEFactory(ScopePackage.eNS_URI);
    if (theScopeFactory != null)
    {
      return theScopeFactory;
    }
  }
  catch (Exception exception)
  {
    EcorePlugin.INSTANCE.log(exception);
  }
  return new ScopeFactoryImpl();
}
 
Example #23
Source File: Bug307519TestLanguagePackageImpl.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link Bug307519TestLanguagePackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static Bug307519TestLanguagePackage init()
{
  if (isInited) return (Bug307519TestLanguagePackage)EPackage.Registry.INSTANCE.getEPackage(Bug307519TestLanguagePackage.eNS_URI);

  // Obtain or create and register package
  Object registeredBug307519TestLanguagePackage = EPackage.Registry.INSTANCE.get(eNS_URI);
  Bug307519TestLanguagePackageImpl theBug307519TestLanguagePackage = registeredBug307519TestLanguagePackage instanceof Bug307519TestLanguagePackageImpl ? (Bug307519TestLanguagePackageImpl)registeredBug307519TestLanguagePackage : new Bug307519TestLanguagePackageImpl();

  isInited = true;

  // Create package meta-data objects
  theBug307519TestLanguagePackage.createPackageContents();

  // Initialize created meta-data
  theBug307519TestLanguagePackage.initializePackageContents();

  // Mark meta-data to indicate it can't be changed
  theBug307519TestLanguagePackage.freeze();

  // Update the registry and return the package
  EPackage.Registry.INSTANCE.put(Bug307519TestLanguagePackage.eNS_URI, theBug307519TestLanguagePackage);
  return theBug307519TestLanguagePackage;
}
 
Example #24
Source File: BuilderStatePackageImpl.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link BuilderStatePackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static BuilderStatePackage init() {
	if (isInited) return (BuilderStatePackage)EPackage.Registry.INSTANCE.getEPackage(BuilderStatePackage.eNS_URI);

	// Obtain or create and register package
	Object registeredBuilderStatePackage = EPackage.Registry.INSTANCE.get(eNS_URI);
	BuilderStatePackageImpl theBuilderStatePackage = registeredBuilderStatePackage instanceof BuilderStatePackageImpl ? (BuilderStatePackageImpl)registeredBuilderStatePackage : new BuilderStatePackageImpl();

	isInited = true;

	// Create package meta-data objects
	theBuilderStatePackage.createPackageContents();

	// Initialize created meta-data
	theBuilderStatePackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theBuilderStatePackage.freeze();

	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(BuilderStatePackage.eNS_URI, theBuilderStatePackage);
	return theBuilderStatePackage;
}
 
Example #25
Source File: XtextPackageImpl.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 * 
 * <p>This method is used to initialize {@link XtextPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static XtextPackage init() {
	if (isInited) return (XtextPackage)EPackage.Registry.INSTANCE.getEPackage(XtextPackage.eNS_URI);

	// Obtain or create and register package
	XtextPackageImpl theXtextPackage = (XtextPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof XtextPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new XtextPackageImpl());

	isInited = true;

	// Initialize simple dependencies
	EcorePackage.eINSTANCE.eClass();

	// Create package meta-data objects
	theXtextPackage.createPackageContents();

	// Initialize created meta-data
	theXtextPackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theXtextPackage.freeze();

 
	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, theXtextPackage);
	return theXtextPackage;
}
 
Example #26
Source File: GrammarParserTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testEnum_10() throws Exception {
	String modelAsString =
		"grammar TestLanguage with org.eclipse.xtext.enumrules.EnumRulesTestLanguage\n" +
		"import 'classpath:/org/eclipse/xtext/enumrules/enums.ecore'\n" +
		"generate testLanguage 'http://www.eclipse.org/2009/tmf/xtext/AbstractEnumRulesTest/TestEnum/10'\n" +
		"Model: enumValue=ExistingEnum;\n" +
		"enum ExistingEnum: SameName;";
	Grammar grammar = (Grammar) getModel(modelAsString);
	assertTrue(grammar.eResource().getErrors().toString(), grammar.eResource().getErrors().isEmpty());
	checkEnums(grammar);
	EPackage pack = grammar.getMetamodelDeclarations().get(0).getEPackage();
	assertEquals("http://www.eclipse.org/2009/tmf/xtext/EnumRulesTestLanguage/imported", pack.getNsURI());
	EEnum eEnum = (EEnum) pack.getEClassifier("ExistingEnum");
	assertNotNull(eEnum);
	assertEquals(3, eEnum.getELiterals().size());
	EEnumLiteral value = eEnum.getELiterals().get(0);
	assertEquals(ExistingEnum.SAME_NAME.getName(), value.getName());
	assertEquals(ExistingEnum.SAME_NAME.getValue(), value.getValue());
	assertEquals(ExistingEnum.SAME_NAME.getLiteral(), value.getLiteral());
	
	EnumRule rule = (EnumRule) grammar.getRules().get(1);
	assertEquals(eEnum, rule.getType().getClassifier());
	EnumLiteralDeclaration decl = (EnumLiteralDeclaration) rule.getAlternatives();
	assertEquals(value, decl.getEnumLiteral());
	assertNotNull(decl.getLiteral());
	assertEquals("SameName", decl.getLiteral().getValue());
}
 
Example #27
Source File: KeywordHelperTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Before
@Override
public void setUp() throws Exception {
	globalStateMemento = GlobalRegistries.makeCopyOfGlobalState();
	super.setUp();
	EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE);
	with(XtextStandaloneSetup.class);
}
 
Example #28
Source File: ImportUriTestLanguageStandaloneSetupGenerated.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public void register(Injector injector) {
	IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
	IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
	
	Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("importuritestlanguage", resourceFactory);
	IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("importuritestlanguage", serviceProvider);
	if (!EPackage.Registry.INSTANCE.containsKey("http://eclipse.org/xtext/importUriTestLanguage")) {
		EPackage.Registry.INSTANCE.put("http://eclipse.org/xtext/importUriTestLanguage", ImportedURIPackage.eINSTANCE);
	}
}
 
Example #29
Source File: ParametersTestLanguageStandaloneSetupGenerated.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public void register(Injector injector) {
	if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.org/2015/tmf/xtext/parameters")) {
		EPackage.Registry.INSTANCE.put("http://www.eclipse.org/2015/tmf/xtext/parameters", ParametersTestLanguagePackage.eINSTANCE);
	}
	IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
	IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
	
	Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("parameterstestlanguage", resourceFactory);
	IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("parameterstestlanguage", serviceProvider);
}
 
Example #30
Source File: MigrationFactoryImpl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates the default factory implementation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated
 */
public static MigrationFactory init() {
	try {
		final MigrationFactory theMigrationFactory = (MigrationFactory) EPackage.Registry.INSTANCE
			.getEFactory("http://www.eclipse.org/emf/edapt/migration/0.3"); //$NON-NLS-1$
		if (theMigrationFactory != null) {
			return theMigrationFactory;
		}
	} catch (final Exception exception) {
		EcorePlugin.INSTANCE.log(exception);
	}
	return new MigrationFactoryImpl();
}