本文整理汇总了Java中org.eclipse.emf.ecore.EObject.eContainer方法的典型用法代码示例。如果您正苦于以下问题:Java EObject.eContainer方法的具体用法?Java EObject.eContainer怎么用?Java EObject.eContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.EObject
的用法示例。
在下文中一共展示了EObject.eContainer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isArrayOrObjectLiteralBeingDestructured
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* Returns true iff given object is an array/object literal used <b>as input to</b> a destructuring pattern (i.e. as
* expression of a VariableBinding, on rhs of an assignment or in a for..in/of loop or it is a nested literal within
* such an array/object literal).
* <p>
* TODO this method does not properly support nesting yet, i.e. in code like
*
* <pre>
* var [string a, Array<?> arr, number b] = ["hello", [1,2,3], 42];
* </pre>
*
* it will return <code>true</code> for the nested array <code>[1,2,3]</code>, which is wrong.
*/
public static boolean isArrayOrObjectLiteralBeingDestructured(EObject obj) {
if (!(obj instanceof ArrayLiteral || obj instanceof ObjectLiteral))
return false;
final EObject root = getRootOfDestructuringPattern(obj);
final EObject parent = root.eContainer();
if (parent instanceof VariableBinding)
return ((VariableBinding) parent).getExpression() == root;
if (parent instanceof AssignmentExpression && isDestructuringAssignment((AssignmentExpression) parent))
return ((AssignmentExpression) parent).getRhs() == root;
if (parent instanceof ForStatement && isDestructuringForStatement((ForStatement) parent)) {
// reason why we require obj!=root below:
// in code like "for([a,b] of [ ["hello",42], ["world",43] ]) {}" the top-level array literal after
// the "of" is *NOT* an array being destructured; instead, it's the array being iterated over.
return !((ForStatement) parent).isForPlain() && ((ForStatement) parent).getExpression() == root
&& obj != root;
}
return false;
}
示例2: calculateLogicallyQualifiedDisplayName
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* Calculate the hierarchically qualified name of an EObject.
*
* @param eob
* the EObject to calculate logical name for
* @param labelProvider
* the label provider that knows how to display EObject instances
*
* @return the hierarchically
*/
public static String calculateLogicallyQualifiedDisplayName(EObject eob, LabelProvider labelProvider,
boolean includeRoot) {
// Calculate hierarchical logical name, e.g. C.m
String text = labelProvider.getText(eob);
EObject currContainer = eob.eContainer();
while (currContainer != null) {
if (isShowable(currContainer)) {
text = labelProvider.getText(currContainer) + "." + text;
}
currContainer = currContainer.eContainer();
if (currContainer != null && !includeRoot && currContainer instanceof Script)
break;
}
return text;
}
示例3: persistMetamodel
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
public static void persistMetamodel(ResourceSet resourceSet, EPackage generated, String path) throws IOException {
if (new File(path).exists()) {
EPackage existing = (EPackage) OcciHelper.getRootElement(resourceSet, "file:/" + path);
for (Iterator<EObject> iterator = existing.eAllContents(); iterator.hasNext();) {
EObject eo = iterator.next();
if (eo instanceof EAnnotation && isOCLRelated((EAnnotation) eo)) {
EModelElement existingContainer = (EModelElement) eo.eContainer();
EModelElement generatedContainer = (EModelElement) getGeneratedElement(generated,
existingContainer);
if (generatedContainer == null) {
throw new RuntimeException("Unable to find " + existingContainer + " to reattach " + eo + " "
+ ((EAnnotation) eo).getEAnnotations());
} else {
generatedContainer.getEAnnotations().add((EAnnotation) EcoreUtil.copy(eo));
}
}
}
}
ConverterUtils.save(resourceSet, generated, "file:/" + path);
}
示例4: isInherited
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
public boolean isInherited() {
final EObject implParent = parent != null ? parent.getElementAPI() : null;
final EObject impl = getElementAPI();
if (implParent instanceof ContainerType<?> && impl instanceof TMember) {
return impl.eContainer() != implParent;
}
return false;
}
示例5: findContainer
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
public static <T> T findContainer ( EObject current, final Class<T> clazz )
{
while ( current != null && !clazz.isAssignableFrom ( current.getClass () ) )
{
current = current.eContainer ();
}
if ( current == null )
{
return null;
}
return clazz.cast ( current );
}
示例6: evadeStaticPolyfillResource
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* Static polyfill modules are integrated into their corresponding polyfill aware modules. Whenever a static
* polyfill module is found, this method retrieves the corresponding aware module and returns its resource.
*/
private Resource evadeStaticPolyfillResource(IdentifiableElement idElement) {
TModule module = idElement.getContainingModule();
if (module == null) // happens when executing tests
return null;
Resource res = module.eResource();
if (!module.isStaticPolyfillModule())
return res;
EObject container = idElement;
while (container != null && !(container instanceof TClass))
container = container.eContainer();
if (container == null)
return res;
TClass tClass = (TClass) container;
assert (tClass.isPolyfill());
TClass superClass = tClass.getSuperClass();
if (superClass == null) // happens when executing tests
return res;
TModule superClassModule = superClass.getContainingModule();
assert (superClassModule.isStaticPolyfillAware());
return superClassModule.eResource();
}
示例7: addInstanceModel
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
@Override
public void addInstanceModel(InstanceModel instanceModel) throws PortException {
int timer = Timer.start("IM to Ecore");
this.m_eObjects.clear();
visitInstanceModel(instanceModel);
List<EObject> rootObjects = new ArrayList<>();
for (EObject object : this.m_eObjects) {
if (object.eContainer() != null) {
continue;
}
rootObjects.add(object);
}
if (rootObjects.size() == 0) {
// This effectively means there is a containment cycle
throw new PortException("Unable to find any root object");
}
Timer.stop(timer);
timer = Timer.cont("Ecore save");
Resource typeResource =
this.m_ecoreResource.getInstanceResource(instanceModel.getQualName());
EList<EObject> contents = typeResource.getContents();
//contents.add(rootObject);
contents.addAll(rootObjects);
Timer.stop(timer);
}
示例8: getBestDisplayedStep
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* @param function
* @param displayedFunctions
* @return the function or one of its container contained in the map keys
*/
public Set<DDiagramElement> getBestDisplayedStep(Step function, Map<Step, Set<DDiagramElement>> displayedFunctions) {
if (displayedFunctions.containsKey(function)) {
return displayedFunctions.get(function);
}
EObject ancestor = function.eContainer();
while ((ancestor != null) && (ancestor instanceof Step)) {
if (displayedFunctions.containsKey(ancestor)) {
return displayedFunctions.get(ancestor);
}
ancestor = ancestor.eContainer();
}
return null;
}
示例9: isParentPartOfSameDestructuringPattern
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private static boolean isParentPartOfSameDestructuringPattern(EObject obj) {
final EObject parent = obj != null ? obj.eContainer() : null;
return parent instanceof ArrayLiteral || parent instanceof ArrayElement
|| parent instanceof ObjectLiteral || parent instanceof PropertyAssignment
|| (parent instanceof AssignmentExpression
&& obj == ((AssignmentExpression) parent).getLhs()
&& (parent.eContainer() instanceof ArrayElement
|| parent.eContainer() instanceof PropertyAssignment))
|| parent instanceof BindingPattern || parent instanceof BindingElement
|| parent instanceof BindingProperty;
}
示例10: currentInstructionChanged
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.eclipse.gemoc.dsl.debug.ide.adapter.IDSLCurrentInstructionListener#currentInstructionChanged(String,
* org.eclipse.gemoc.dsl.debug.StackFrame))
*/
public void currentInstructionChanged(String debugModelID, StackFrame frame) {
EObject currentInstruction = frame.getCurrentInstruction();
final Set<URI> instructionURIs = new HashSet<URI>();
if (currentInstruction instanceof ParallelStep) {
addMseOccurenceAndCallerToInstructionsURIs(instructionURIs,
((ParallelStep<?, ?>)currentInstruction).getMseoccurrence());
for (Step step : ((ParallelStep<?, ?>)currentInstruction).getSubSteps()) {
addMseOccurenceAndCallerToInstructionsURIs(instructionURIs, step.getMseoccurrence());
}
} else if (currentInstruction instanceof Step) {
if (!(currentInstruction.eContainer() instanceof ParallelStep)) {
// do not show internal step of parallel step, because they are already shown as a
// parallel
addMseOccurenceAndCallerToInstructionsURIs(instructionURIs, ((Step)currentInstruction)
.getMseoccurrence());
}
} else {
instructionURIs.add(EcoreUtil.getURI(currentInstruction));
}
final Set<URI> lastInstructions = CURRENT_INSTRUCTIONS_PER_FRAME.remove(frame);
if (lastInstructions != null) {
notifySirius(lastInstructions, debugModelID);
}
CURRENT_INSTRUCTIONS_PER_FRAME.put(frame, instructionURIs);
notifySirius(instructionURIs, debugModelID);
}
示例11: getDocumentation
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private String getDocumentation(/* @NonNull */EObject object) {
if (object.eContainer() == null) {
// if a comment is at the beginning of the file it will be returned for
// the root element (e.g. Script in N4JS) as well -> avoid this!
return null;
}
ICompositeNode node = NodeModelUtils.getNode(object);
if (node != null) {
// get the last multi line comment before a non hidden leaf node
for (ILeafNode leafNode : node.getLeafNodes()) {
if (!leafNode.isHidden())
break;
EObject grammarElem = leafNode.getGrammarElement();
if (grammarElem instanceof TerminalRule
&& "ML_COMMENT".equalsIgnoreCase(((TerminalRule) grammarElem).getName())) {
String comment = leafNode.getText();
if (commentStartTagRegex.matcher(comment).matches()) {
return leafNode.getText();
}
}
}
}
return null;
}
示例12: getContainingFunction
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* The function or method in which the expression is (indirectly) contained, may be null In most cases it is
* recommended to call {@link #getContainingFunctionOrAccessor(EObject)} instead.
*/
public static FunctionDefinition getContainingFunction(EObject eobj) {
if (eobj == null || eobj.eContainer() == null) {
return null;
}
return EcoreUtil2.getContainerOfType(eobj.eContainer(), FunctionDefinition.class);
}
示例13: getKeywordLabel
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* Returns a prefix that should be used in the label, e.g. 'class' of the context is a class declaration.
*/
protected String getKeywordLabel(EObject source) {
while (source instanceof TypeRef) {
source = source.eContainer();
}
if (source != null) {
return keywordProvider.keyword(source);
}
return null;
}
示例14: getConfiguration
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* Get the configuration containing a given entity.
*
* @param entity
* the given entity.
* @return the entity configuration.
* @throws java.lang.IllegalArgumentException
* If the given entity is not a resource or a link.
*/
public static Configuration getConfiguration(final Entity entity) {
if (entity instanceof Resource) {
return (Configuration) entity.eContainer();
} else if (entity instanceof Link) {
EObject econtainer = entity.eContainer();
return (econtainer == null) ? null : (Configuration) econtainer.eContainer();
} else {
throw new IllegalArgumentException(entity.toString() + " is not a resource or link!");
}
}
示例15: isValueTransient
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
@Override
public ValueTransient isValueTransient(EObject semanticObject, EStructuralFeature feature) {
if (feature == OCCIPackage.Literals.ATTRIBUTE__MUTABLE) {
if (semanticObject.eContainer() instanceof Type || semanticObject.eContainer() instanceof RecordType) {
if ((boolean)semanticObject.eGet(feature)) {
return ValueTransient.NO;
}
}
}
if (feature == OCCIPackage.Literals.RESOURCE__RLINKS) {
return ValueTransient.YES;
}
return super.isValueTransient(semanticObject, feature);
}