public static String eventToString(MSE mse) { StringBuilder builder = new StringBuilder(); if (mse.getCaller() != null) { builder.append(mse.getCaller().eClass().getName()); builder.append("->"); builder.append(SimpleAttributeResolver.NAME_RESOLVER.apply(mse.getCaller())); } if (mse.getAction() != null) { builder.append("."); builder.append(mse.getAction().getName()); builder.append("()"); } return builder.toString(); }
@Override public String getNameLabel(final Object element) { String _switchResult = null; boolean _matched = false; if (element instanceof EObject) { _matched=true; _switchResult = SimpleAttributeResolver.NAME_RESOLVER.apply(((EObject)element)); } if (!_matched) { if (element instanceof IEObjectDescription) { _matched=true; _switchResult = ((IEObjectDescription)element).getName().getLastSegment(); } } if (!_matched) { _switchResult = null; } return _switchResult; }
/** * Add information about the given object to this cache. * * @param object * the object to handle */ public void add(EObject object) { this.applicableTypes.add(object.eClass()); this.valueStrings.add(SimpleAttributeResolver.NAME_RESOLVER.apply(object)); // Handle composed members if (object instanceof TMember && ((TMember) object).isComposed()) { List<TMember> constituentMembers = ((TMember) object).getConstituentMembers(); for (TMember constituentMember : constituentMembers) { addFQNs(constituentMember); } } else { addFQNs(object); } }
@Override public QualifiedName getFullyQualifiedName(EObject obj) { String name = SimpleAttributeResolver.NAME_RESOLVER.apply(obj); if (name == null || name.length() == 0) return null; return converter.toQualifiedName(name); }
@Override public QualifiedName getFullyQualifiedName(EObject obj) { String name = SimpleAttributeResolver.NAME_RESOLVER.apply(obj); if(name == null || name.length() == 0) return null; return qualifiedNameConverter.toQualifiedName(name); }
protected IResourceDescription createResourceDescription(Resource testResource) { DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy(); strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() { @Override public QualifiedName getFullyQualifiedName(EObject obj) { String name = SimpleAttributeResolver.NAME_RESOLVER.apply(obj); return (name != null) ? QualifiedName.create(name) : null; } }); IResourceDescription resourceDescription = new DefaultResourceDescription(testResource, strategy); return resourceDescription; }
protected IResourceDescription createResourceDescription(Resource testResource) { DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy(); strategy.setQualifiedNameProvider(new IQualifiedNameProvider.AbstractImpl() { @Override public QualifiedName getFullyQualifiedName(EObject obj) { String name = SimpleAttributeResolver.NAME_RESOLVER.apply(obj); return (name != null) ? QualifiedName.create(name) : null; } }); strategy.setLazyURIEncoder(new LazyURIEncoder()); IResourceDescription resourceDescription = new DefaultResourceDescription(testResource, strategy); return resourceDescription; }
protected String getElementName(EObject primaryTarget) { QualifiedName qualifiedName = qualifiedNameProvider.getFullyQualifiedName(primaryTarget); if (qualifiedName != null) { return qualifiedNameConverter.toString(qualifiedName); } String simpleName = SimpleAttributeResolver.NAME_RESOLVER.getValue(primaryTarget); return (simpleName != null) ? simpleName : primaryTarget.eResource().getURIFragment(primaryTarget); }
public QualifiedName qualifiedName(Scope ele) { QualifiedName name = null; String nameString = SimpleAttributeResolver.NAME_RESOLVER.apply(ele); if (!Strings.isEmpty(nameString)) { name = nameConverter.toQualifiedName(nameString); } QualifiedName namespace = getNamespace(ele); if (namespace != null && name != null) { name = namespace.append(name); } return name; }
protected EStructuralFeature getNameFeature(EObject object) { return SimpleAttributeResolver.NAME_RESOLVER.getAttribute(object); }
/** * creates a scope using {@link SimpleAttributeResolver#NAME_RESOLVER} to compute the names */ public static IScope scopeFor(Iterable<? extends EObject> elements, IScope outer) { return scopeFor(elements, QualifiedName.wrapper(SimpleAttributeResolver.NAME_RESOLVER), outer); }
public SimpleAttributeResolver<EObject, String> getResolver() { if (resolver == null) { resolver = SimpleAttributeResolver.newResolver(String.class, attributeName); } return resolver; }
@Before public void setUp() throws Exception { factory = EcoreFactory.eINSTANCE; nameResolver = SimpleAttributeResolver.newResolver(String.class, "name"); superClassResolver = SimpleAttributeResolver.newResolver(EList.class, "eSuperTypes"); }
protected EAttribute getNameAttribute(EObject targetElement) { return SimpleAttributeResolver.NAME_RESOLVER.getAttribute(targetElement); }
protected String _toString(EObject element) { return element.eClass().getName() + " '" + notNull(SimpleAttributeResolver.NAME_RESOLVER.apply(element)) + "' in " + _toString(element.eResource().getURI()); }
@Override protected Function<EObject, String> getResolver() { return SimpleAttributeResolver.NAME_RESOLVER; }
/** * transforms an {@link Iterable} of {@link EObject}s into an {@link Iterable} of {@link IEObjectDescription}s computing * the {@link EAttribute} 'name' to compute the {@link IEObjectDescription}'s name. If not existent the object is * filtered out. */ public static Iterable<IEObjectDescription> scopedElementsFor(Iterable<? extends EObject> elements) { return scopedElementsFor(elements, QualifiedName.wrapper(SimpleAttributeResolver.NAME_RESOLVER)); }