Java Code Examples for org.eclipse.emf.ecore.EPackage

The following examples show how to use org.eclipse.emf.ecore.EPackage. These examples are extracted from open source projects. 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 Project: xtext-core   Author: eclipse   File: OptionalEmptyTestLanguageSemanticSequencer.java    License: 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 #2
Source Project: dsl-devkit   Author: dsldevkit   File: ModelInferencePackageImpl.java    License: 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 #3
Source Project: xtext-eclipse   Author: eclipse   File: TwoContextsPackageImpl.java    License: 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 #4
Source Project: xtext-core   Author: eclipse   File: Xtext2EcoreTransformerTest.java    License: 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 #5
Source Project: fixflow   Author: fixteam   File: Bpmn2PackageImpl.java    License: 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 #6
Source Project: xtext-core   Author: eclipse   File: BeeLangTestLanguagePackageImpl.java    License: 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 Project: hybris-commerce-eclipse-plugin   Author: SAP   File: BeansPackageImpl.java    License: 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 Project: bonita-studio   Author: bonitasoft   File: ModelPackageImpl.java    License: 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 Project: xtext-core   Author: eclipse   File: ActionLangFactoryImpl.java    License: 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 Project: neoscada   Author: eclipse   File: ModbusFactoryImpl.java    License: 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 Project: neoscada   Author: eclipse   File: DetailViewPackageImpl.java    License: 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
@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 Project: xtext-core   Author: eclipse   File: XtextCrossReferenceSerializer.java    License: 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 Project: xtext-core   Author: eclipse   File: XtextPackageImpl.java    License: 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 #15
Source Project: xtext-core   Author: eclipse   File: Bug302128FactoryImpl.java    License: 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 #16
Source Project: xtext-eclipse   Author: eclipse   File: BuilderStatePackageImpl.java    License: 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 #17
Source Project: xtext-eclipse   Author: eclipse   File: Bug307519TestLanguagePackageImpl.java    License: 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 #18
Source Project: dsl-devkit   Author: dsldevkit   File: ScopeFactoryImpl.java    License: 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 #19
Source Project: xtext-core   Author: eclipse   File: DefaultResourceDescriptionTest.java    License: 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 #20
Source Project: BIMserver   Author: opensourceBIM   File: StorePackageImpl.java    License: 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 Project: xtext-core   Author: eclipse   File: Bug292245TestLanguageFactoryImpl.java    License: 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 #22
Source Project: xtext-core   Author: eclipse   File: XtextLinkingService.java    License: 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 #23
Source Project: xtext-eclipse   Author: eclipse   File: BuilderTestLanguageSemanticSequencer.java    License: 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 #24
Source Project: uima-uimaj   Author: apache   File: UimaTypeSystem2Ecore.java    License: 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 #25
Source Project: xtext-core   Author: eclipse   File: Bug296889TestLanguageSemanticSequencer.java    License: 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 #26
Source Project: statecharts   Author: Yakindu   File: BaseFactoryImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the default factory implementation.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public static BaseFactory init() {
	try {
		BaseFactory theBaseFactory = (BaseFactory)EPackage.Registry.INSTANCE.getEFactory(BasePackage.eNS_URI);
		if (theBaseFactory != null) {
			return theBaseFactory;
		}
	}
	catch (Exception exception) {
		EcorePlugin.INSTANCE.log(exception);
	}
	return new BaseFactoryImpl();
}
 
Example #27
Source Project: xtext-core   Author: eclipse   File: SequencertestPackageImpl.java    License: Eclipse Public License 2.0 5 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 SequencertestPackage#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 SequencertestPackage init()
{
  if (isInited) return (SequencertestPackage)EPackage.Registry.INSTANCE.getEPackage(SequencertestPackage.eNS_URI);

  // Obtain or create and register package
  Object registeredSequencertestPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
  SequencertestPackageImpl theSequencertestPackage = registeredSequencertestPackage instanceof SequencertestPackageImpl ? (SequencertestPackageImpl)registeredSequencertestPackage : new SequencertestPackageImpl();

  isInited = true;

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

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

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

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

  // Update the registry and return the package
  EPackage.Registry.INSTANCE.put(SequencertestPackage.eNS_URI, theSequencertestPackage);
  return theSequencertestPackage;
}
 
Example #28
Source Project: xtext-extras   Author: eclipse   File: Bug462047LangStandaloneSetupGenerated.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void register(Injector injector) {
	if (!EPackage.Registry.INSTANCE.containsKey("xbase.bug462047")) {
		EPackage.Registry.INSTANCE.put("xbase.bug462047", Bug462047Package.eINSTANCE);
	}
	IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
	IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
	
	Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("bug462047lang", resourceFactory);
	IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("bug462047lang", serviceProvider);
}
 
Example #29
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 #30
Source Project: xtext-core   Author: eclipse   File: EcorePerPlatformPluginPackageImpl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Complete the initialization of the package and its meta-model.  This
 * method is guarded to have no affect on any invocation but its first.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void initializePackageContents() {
	if (isInitialized) return;
	isInitialized = true;

	// Initialize package
	setName(eNAME);
	setNsPrefix(eNS_PREFIX);
	setNsURI(eNS_URI);

	// Obtain other dependent packages
	EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI);
	EcorePerNsURIPackage theEcorePerNsURIPackage = (EcorePerNsURIPackage)EPackage.Registry.INSTANCE.getEPackage(EcorePerNsURIPackage.eNS_URI);
	EcorePerPlatformResourcePackage theEcorePerPlatformResourcePackage = (EcorePerPlatformResourcePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePerPlatformResourcePackage.eNS_URI);

	// Create type parameters

	// Set bounds for type parameters

	// Add supertypes to classes
	extendsPluginEObjectEClass.getESuperTypes().add(theEcorePackage.getEObject());
	extendsEAttributeEClass.getESuperTypes().add(theEcorePackage.getEAttribute());

	// Initialize classes and features; add operations and parameters
	initEClass(extendsPluginEObjectEClass, ExtendsPluginEObject.class, "ExtendsPluginEObject", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
	initEAttribute(getExtendsPluginEObject_Name(), theEcorePackage.getEString(), "name", null, 0, 1, ExtendsPluginEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsPluginEObject_EObjectReference1(), theEcorePackage.getEObject(), null, "eObjectReference1", null, 0, 1, ExtendsPluginEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsPluginEObject_EObjectReference2(), theEcorePerNsURIPackage.getExtendsNsURIEObject(), null, "eObjectReference2", null, 0, 1, ExtendsPluginEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsPluginEObject_EObjectReference3(), this.getExtendsPluginEObject(), null, "eObjectReference3", null, 0, 1, ExtendsPluginEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsPluginEObject_EObjectReference4(), theEcorePerPlatformResourcePackage.getExtendsResourceEObject(), null, "eObjectReference4", null, 0, 1, ExtendsPluginEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsPluginEObject_EObjectContainment(), theEcorePackage.getEObject(), null, "eObjectContainment", null, 0, -1, ExtendsPluginEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

	initEClass(extendsEAttributeEClass, ExtendsEAttribute.class, "ExtendsEAttribute", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);

	// Create resource
	createResource(eNS_URI);
}