本文整理匯總了Java中org.eclipse.emf.ecore.util.EcoreUtil.create方法的典型用法代碼示例。如果您正苦於以下問題:Java EcoreUtil.create方法的具體用法?Java EcoreUtil.create怎麽用?Java EcoreUtil.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.emf.ecore.util.EcoreUtil
的用法示例。
在下文中一共展示了EcoreUtil.create方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: discardAST
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
* Discard the AST and proxify all referenced nodes. Does nothing if the AST is already unloaded.
*/
private void discardAST() {
EObject script = getScript();
if (script != null && !script.eIsProxy()) {
// Create a proxy for the AST.
InternalEObject scriptProxy = (InternalEObject) EcoreUtil.create(script.eClass());
scriptProxy.eSetProxyURI(EcoreUtil.getURI(script));
TModule module = null;
ModuleAwareContentsList theContents = (ModuleAwareContentsList) contents;
if (isFullyInitialized()) {
module = getModule();
if (module != null && !module.eIsProxy()) {
proxifyASTReferences(module);
module.setAstElement(scriptProxy);
}
}
// Unload the AST.
unloadElements(theContents.subList(0, 1));
theContents.sneakyClear();
if (module != null) {
theContents.sneakyAdd(scriptProxy);
theContents.sneakyAdd(module);
} else {
// there was no module (not even a proxy)
// -> don't add the script proxy
// (i.e. transition from resource load state "Loaded" to "Created", not to "Loaded from Description")
}
// Clear AST meta cache and Xtext cache
this.setASTMetaInfoCache(null);
getCache().clear(this);
}
}
示例2: proxifyASTReferences
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private void proxifyASTReferences(EObject object) {
if (object instanceof SyntaxRelatedTElement) {
SyntaxRelatedTElement element = (SyntaxRelatedTElement) object;
EObject astElement = element.getAstElement();
if (astElement != null && !astElement.eIsProxy()) {
InternalEObject proxy = (InternalEObject) EcoreUtil.create(astElement.eClass());
proxy.eSetProxyURI(EcoreUtil.getURI(astElement));
element.setAstElement(proxy);
}
}
for (EObject child : object.eContents()) {
proxifyASTReferences(child);
}
}
示例3: createExporter
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private Endpoint createExporter ( final EClass exporterClass, final Node node, final EquinoxApplication application, final int port )
{
final Exporter exporter = (Exporter)EcoreUtil.create ( exporterClass );
final Endpoint ep = Endpoints.registerEndpoint ( node, port, Endpoints.reference ( exporter ), String.format ( "Exporter Endpoint: %s - %s", exporter.getTypeTag (), exporter.getName () ) );
node.getEndpoints ().add ( ep );
exporter.setName ( application.getName () + "/exporter" );
exporter.getEndpoints ().add ( ep );
application.getExporter ().add ( exporter );
return ep;
}
示例4: getEObjectByName
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private EObject getEObjectByName(final Resource resource, final String name) {
final EClass type = (EClass) feature.getEType();
final String uriFragment = getUriFragment(name);
final EObject resolvedType;
final String[] segments = name.split("\\.");
if (segments.length == 1) {
final EObject eObject = getEObject(uriFragment);
if (eObject != null) {
resolvedType = eObject;
} else {
final InternalEObject internalEObject = (InternalEObject) EcoreUtil.create(type);
internalEObject.eSetProxyURI(resource.getURI().appendFragment(uriFragment));
resolvedType = internalEObject;
}
} else if (segments.length == 2) {
final String libraryName = segments[0];
final Library usedLibrary = getUsedLibrary(libraryName);
if (usedLibrary == null) {
addError("Library use {0} doesn't exist in {1}", libraryName, resource.getURI());
resolvedType = null;
} else {
final String resolvedId = segments[1];
final Scope usedLibraryScope = with(usedLibrary.eResource());
resolvedType = usedLibraryScope.getEObjectByName(resolvedId);
}
} else {
addError("Uses has invalid format {0}", name);
resolvedType = null;
}
return resolvedType;
}
示例5: constructType
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private EObject constructType(final ParserRuleContext context, final EObject superType) {
final EObject declaredType;
final Token nameToken = context.getStart();
final Optional<BuiltinType> optionalBuiltinType = BuiltinType.of(nameToken.getText());
if (optionalBuiltinType.isPresent() || superType == null || !superType.eIsProxy()) {
final EClass eClass = optionalBuiltinType
.map(builtinType -> builtinType.getScopedMetaType(scope))
.orElseGet(() -> superType == null ? BuiltinType.STRING.getScopedMetaType(scope) : superType.eClass());
declaredType = create(eClass, context);
final Scope typeScope = scope.with(declaredType);
final String name = nameToken.getText();
typeScope.with(declaredType.eClass().getEStructuralFeature("name"))
.setValue(name, nameToken);
if (!optionalBuiltinType.isPresent()) {
typeScope.with(declaredType.eClass().getEStructuralFeature("type"))
.setValue(superType, nameToken);
}
} else {
final InternalEObject proxy = (InternalEObject) EcoreUtil.create(superType.eClass());
final String uriFragment = scope.getUriFragment(nameToken.getText());
proxy.eSetProxyURI(scope.getResource().getURI().appendFragment(uriFragment));
declaredType = proxy;
}
scope.setValue(declaredType, nameToken);
return declaredType;
}
示例6: visitArrayType
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
public EObject visitArrayType(final TypeExpressionParser.ArrayTypeContext ctx) {
final EObject arrayType = EcoreUtil.create(arrayTypeDeclarationType);
scope.addValue(INLINE_TYPE_CONTAINER__INLINE_TYPES, arrayType);
final EObject itemsType = visit(ctx.primary_type_expr());
arrayType.eSet(itemsFeature, itemsType);
return arrayType;
}
示例7: visitUnionType
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
public EObject visitUnionType(final TypeExpressionParser.UnionTypeContext ctx) {
final UnionType unionType = (UnionType) EcoreUtil.create(UNION_TYPE);
scope.addValue(INLINE_TYPE_CONTAINER__INLINE_TYPES, unionType);
final EList<AnyType> oneOfType = ECollections.asEList(ctx.primary_type_expr().stream()
.map(this::visit)
.filter(AnyType.class::isInstance) // TODO report errors
.map(AnyType.class::cast)
.collect(Collectors.toList()));
unionType.getOneOf().addAll(oneOfType);
return unionType;
}
示例8: createEObject
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
public EObject createEObject(String sigTypeName, String atomName, IMarker source)
throws TraceException {
SigTrace trace = getSigTraceByType(sigTypeName);
EClass eClass = trace.getEClass();
EObject eObject = EcoreUtil.create(eClass);
EcoreUtilities.eSetAttributeByName(eObject, "name", atomName);
EcoreUtilities.putIntoContainer(
source == null ? trace.getLoad().getInstanceRoot() : findEObject(source), eObject);
EcoreUtilities.saveResource(trace.getLoad().getInstanceRoot());
return eObject;
}
示例9: createProxy
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
@Override
protected EObject createProxy(EObject obj, INode node, EReference eRef) {
if (eRef.equals(OCCIPackage.eINSTANCE.getExtension_Import())
|| eRef.equals(OCCIPackage.eINSTANCE.getConfiguration_Use())) {
EClass referenceType = getProxyType(obj, eRef);
final EObject proxy = EcoreUtil.create(referenceType);
((InternalEObject) proxy)
.eSetProxyURI(URI.createURI(node.getText().replaceAll("'", "").replaceAll("\"", "")));
return proxy;
}
return super.createProxy(obj, node, eRef);
}
示例10: createProxy
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
/**
* Creates the proxy with a custom encoded URI format (starting with "|"). The object used to produce the encoded
* URI are collected as tuple inside {@link N4JSResource}. Then the node text is checked if it is convertible to a
* valid value. If there is a {@link BadEscapementException} is thrown then there is either a warning or an error
* produced via the diagnosticProducer.
*
*
* @param resource
* the N4JSResource
* @param obj
* the EObject containing the cross reference
* @param node
* the node representing the EObject
* @param eRef
* the cross reference in the domain model
* @param xref
* the cross reference in the node model
* @param diagnosticProducer
* to produce errors or warnings
* @return the created proxy
*/
private EObject createProxy(N4JSResource resource, EObject obj, INode node, EReference eRef, CrossReference xref,
IDiagnosticProducer diagnosticProducer) {
final URI uri = resource.getURI();
/*
* as otherwise with 0 the EObjectDescription created for Script would be fetched
*/
final int fragmentNumber = resource.addLazyProxyInformation(obj, eRef, node);
final URI encodedLink = uri.appendFragment("|" + fragmentNumber);
EClass referenceType = findInstantiableCompatible(eRef.getEReferenceType());
final EObject proxy = EcoreUtil.create(referenceType);
((InternalEObject) proxy).eSetProxyURI(encodedLink);
AbstractElement terminal = xref.getTerminal();
if (!(terminal instanceof RuleCall)) {
throw new IllegalArgumentException(String.valueOf(xref));
}
AbstractRule rule = ((RuleCall) terminal).getRule();
try {
String tokenText = NodeModelUtils.getTokenText(node);
Object value = valueConverterService.toValue(tokenText, rule.getName(), node);
if (obj instanceof IdentifierRef && value instanceof String) {
((IdentifierRef) obj).setIdAsText((String) value);
} else if (obj instanceof LabelRef && value instanceof String) {
((LabelRef) obj).setLabelAsText((String) value);
} else if (obj instanceof ParameterizedPropertyAccessExpression && value instanceof String) {
((ParameterizedPropertyAccessExpression) obj).setPropertyAsText((String) value);
} else if (obj instanceof NamedImportSpecifier && value instanceof String) {
((NamedImportSpecifier) obj).setImportedElementAsText((String) value);
} else if ((obj instanceof JSXPropertyAttribute) && (value instanceof String)) {
((JSXPropertyAttribute) obj).setPropertyAsText((String) value);
} else {
setOtherElementAsText(tokenText, obj, value);
}
} catch (BadEscapementException e) {
diagnosticProducer.addDiagnostic(new DiagnosticMessage(e.getMessage(), e.getSeverity(), e.getIssueCode(),
Strings.EMPTY_ARRAY));
} catch (N4JSValueConverterException vce) {
diagnosticProducer.addDiagnostic(new DiagnosticMessage(vce.getMessage(), vce.getSeverity(),
vce.getIssueCode(), Strings.EMPTY_ARRAY));
} catch (N4JSValueConverterWithValueException vcwve) {
diagnosticProducer.addDiagnostic(new DiagnosticMessage(vcwve.getMessage(), vcwve.getSeverity(),
vcwve.getIssueCode(), Strings.EMPTY_ARRAY));
}
return proxy;
}
示例11: create
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
protected <T extends EObject> T create(final EClass eClass, final ParserRuleContext ruleContext) {
final T newEObject = (T) EcoreUtil.create(eClass);
final RAMLTokenProviderAdapter adapter = RAMLTokenProviderAdapter.of((RamlToken) ruleContext.getStart());
newEObject.eAdapters().add(adapter);
return newEObject;
}
示例12: getXmlNsList
import org.eclipse.emf.ecore.util.EcoreUtil; //導入方法依賴的package包/類
private final static List<BasicEMap.Entry<String, String>> getXmlNsList()
{
List<EPackage> packages = new ArrayList<EPackage>();
// resource packages
packages.add(Db2ResourcePackage.eINSTANCE);
packages.add(DirectoryResourcePackage.eINSTANCE);
packages.add(FileResourcePackage.eINSTANCE);
packages.add(InformixResourcePackage.eINSTANCE);
packages.add(MqResourcePackage.eINSTANCE);
packages.add(OracleResourcePackage.eINSTANCE);
packages.add(QueryResourcePackage.eINSTANCE);
packages.add(ReferenceResourcePackage.eINSTANCE);
packages.add(ShadowDirectResourcePackage.eINSTANCE);
packages.add(SoapIOResourcePackage.eINSTANCE);
packages.add(SybaseResourcePackage.eINSTANCE);
packages.add(TeradataResourcePackage.eINSTANCE);
packages.add(UdbResourcePackage.eINSTANCE);
packages.add(NullResourcePackage.eINSTANCE);
packages.add(TransactionResourcePackage.eINSTANCE);
packages.add(SemaphoreResourcePackage.eINSTANCE);
packages.add(LdapResourcePackage.eINSTANCE);
packages.add(LdapQueryResourcePackage.eINSTANCE);
packages.add(SqliteResourcePackage.eINSTANCE);
packages.add(MssqlResourcePackage.eINSTANCE);
// global packages
packages.add(ValuesPackage.eINSTANCE);
packages.add(TypesPackage.eINSTANCE);
packages.add(ListenersPackage.eINSTANCE);
packages.add(RepetitionPackage.eINSTANCE);
packages.add(SaturnWebPackage.eINSTANCE);
packages.add(SaturnReportPackage.eINSTANCE);
// module packages
packages.add(CpsModulePackage.eINSTANCE);
packages.add(DatacompareModulePackage.eINSTANCE);
packages.add(DsConvertModulePackage.eINSTANCE);
packages.add(DsValidatorModulePackage.eINSTANCE);
packages.add(EnvValidatorModulePackage.eINSTANCE);
packages.add(ExtractDDLModulePackage.eINSTANCE);
packages.add(MailModulePackage.eINSTANCE);
packages.add(MqModulePackage.eINSTANCE);
packages.add(ProcedureCallModulePackage.eINSTANCE);
packages.add(PsManagerModulePackage.eINSTANCE);
packages.add(RuncmdsModulePackage.eINSTANCE);
packages.add(SingularityModulePackage.eINSTANCE);
packages.add(SoapIOModulePackage.eINSTANCE);
packages.add(SqlModulePackage.eINSTANCE);
packages.add(Xml2csvModulePackage.eINSTANCE);
packages.add(XmlDiffModulePackage.eINSTANCE);
packages.add(XmlGenModulePackage.eINSTANCE);
packages.add(XmlManipModulePackage.eINSTANCE);
packages.add(XmlValidatorModulePackage.eINSTANCE);
packages.add(CometModulePackage.eINSTANCE);
packages.add(XSplitModulePackage.eINSTANCE);
packages.add(ReferenceModulePackage.eINSTANCE);
packages.add(DocumentumModulePackage.eINSTANCE);
List<BasicEMap.Entry<String, String>> xmlNsList = new ArrayList<BasicEMap.Entry<String, String>>();
for (EPackage ePackage : packages)
{
((EcoreFactoryImpl) EcoreFactory.eINSTANCE).createEStringToStringMapEntry();
BasicEMap.Entry<String, String> newEntry = (BasicEMap.Entry<String, String>) EcoreUtil
.create((EClass) SaturnPackage.eINSTANCE.getDocumentRoot_XMLNSPrefixMap().getEType());
// new EStringToStringMapEntryImpl();
// //((EcoreFactoryImpl)EcoreFactory.eINSTANCE).createEStringToStringMapEntry();
xmlNsList.add(newEntry);
newEntry.setKey(ePackage.getNsPrefix());
newEntry.setValue(ePackage.getNsURI());
}
return xmlNsList;
}