public boolean apply(IEObjectDescription input) { if (input.getEObjectOrProxy() == object) return true; if (uri.equals(input.getEObjectURI())) { return true; } return false; } });
protected boolean equals(IEObjectDescription oldObj, IEObjectDescription newObj) { if (oldObj == newObj) return true; if (oldObj.getEClass() != newObj.getEClass()) return false; if (oldObj.getName() != null && !oldObj.getName().equals(newObj.getName())) return false; if (!oldObj.getEObjectURI().equals(newObj.getEObjectURI())) return false; String[] oldKeys = oldObj.getUserDataKeys(); String[] newKeys = newObj.getUserDataKeys(); if (oldKeys.length != newKeys.length) return false; for (String key : oldKeys) { if (!Arrays.contains(newKeys, key)) return false; String oldValue = oldObj.getUserData(key); String newValue = newObj.getUserData(key); if (oldValue == null) { if (newValue != null) return false; } else if (!oldValue.equals(newValue)) { return false; } } return true; }
public int compare(IEObjectDescription o1, IEObjectDescription o2) { int diff = o1.getQualifiedName().compareToIgnoreCase(o2.getQualifiedName()); if (diff == 0) { String className1 = o1.getEClass().getName(); String className2 = o2.getEClass().getName(); if(className1 == null) diff = className2 == null ? 0 : -1; else diff = className2 == null ? 1 : className1.compareToIgnoreCase(className2); if (diff == 0) { diff = o1.getEObjectURI().toString().compareTo(o2.getEObjectURI().toString()); } } return diff; } });
public boolean apply(IEObjectDescription input) { IEObjectDescription description = getSingleLocalElementByName(input.getName()); if (description==null) return false; if (description.getEObjectOrProxy()==input.getEObjectOrProxy()) return true; if (input.getEObjectURI().equals(description.getEObjectURI())) return true; return false; } });
public Object text(IEObjectDescription element) { return element.getQualifiedName() + " - " + element.getEClass().getName(); }
@Override public EObject apply(IEObjectDescription input) { return input.getEObjectOrProxy(); } });
protected StyledString getStyledDisplayString(IEObjectDescription description) { return getStyledDisplayString(description.getEObjectOrProxy(), qualifiedNameConverter.toString(description.getQualifiedName()), qualifiedNameConverter.toString(description.getName())); }
@Override public boolean contains(Object o) { if (o instanceof IEObjectDescription) { return super.contains(((IEObjectDescription) o).getName()); } return super.contains(o); } };
@Check(CheckType.NORMAL) public void checkDuplicateViewSpecificationAcrossFiles(final ViewSpecification viewSpecification) { final Iterable<IEObjectDescription> descriptions = this.getVisibleEObjectDescriptions(viewSpecification, ModelPackage.Literals.VIEW_SPECIFICATION); for (final IEObjectDescription desc : descriptions) { if (((Objects.equal(desc.getQualifiedName().toString(), viewSpecification.getId()) && (!Objects.equal(desc.getEObjectOrProxy(), viewSpecification))) && (!Objects.equal(desc.getEObjectURI().trimFragment(), viewSpecification.eResource().getURI())))) { String _id = viewSpecification.getId(); String _plus = ("The part id " + _id); String _plus_1 = (_plus + " is already defined"); this.error(_plus_1, this.modelPackage.getViewSpecification_Id(), EmfParsleyDslValidator.DUPLICATE_ELEMENT); return; } } }
protected boolean isAliased(IEObjectDescription desc) { String actualName = ((JvmIdentifiableElement) desc.getEObjectOrProxy()).getSimpleName(); String usedName = desc.getName().getFirstSegment(); if (actualName.equals(usedName)) { return false; } return true; }
@Override public URI getEObjectURI() { return delegate.getEObjectURI(); }
protected QualifiedName computeSimpleName(Multimap<EObject, IEObjectDescription> descs, IEObjectDescription desc) { QualifiedName name = desc.getQualifiedName(); int segmentCount = name.getSegmentCount(); if (segmentCount < 2) { return name; } EObject container = desc.getEObjectOrProxy().eContainer(); while (container != null) { Collection<IEObjectDescription> candidates = descs.get(container); for (IEObjectDescription cand : candidates) { QualifiedName candName = cand.getQualifiedName(); int candCount = candName.getSegmentCount(); if (candCount < segmentCount && name.startsWith(candName)) { return name.skipFirst(candCount); } } container = container.eContainer(); } return name; }
public SimpleNameDescription(QualifiedName qName, EObject resolvedObject, IEObjectDescription source) { this.simpleName = qName; this.object = resolvedObject; this.qualifiedName = source.getQualifiedName(); Preconditions.checkArgument(!this.object.eIsProxy()); Preconditions.checkNotNull(this.simpleName); Preconditions.checkNotNull(this.qualifiedName); Map<String, String> userData = null; for (final String key : source.getUserDataKeys()) { if (userData == null) { userData = Maps.newHashMapWithExpectedSize(2); } userData.put(key, source.getUserData(key)); } this.userData = userData; }
protected void appendType(final IEObjectDescription description, Multimap<QualifiedName, IEObjectDescription> owner2nested, StringBuilder classSignatureBuilder) { classSignatureBuilder.append("\npublic "); if(isNestedType(description)) classSignatureBuilder.append("static "); if (description.getEClass() == TypesPackage.Literals.JVM_GENERIC_TYPE) { if (description.getUserData(JvmTypesResourceDescriptionStrategy.IS_INTERFACE) != null) { classSignatureBuilder.append("interface "); } else { classSignatureBuilder.append("class "); } } else if (description.getEClass() == TypesPackage.Literals.JVM_ENUMERATION_TYPE) { classSignatureBuilder.append("enum "); } else if (description.getEClass() == TypesPackage.Literals.JVM_ANNOTATION_TYPE) { classSignatureBuilder.append("@interface "); } String lastSegment = description.getQualifiedName().getLastSegment(); int trimIndex = lastSegment.lastIndexOf('$'); String simpleName = lastSegment.substring(trimIndex + 1); classSignatureBuilder.append(simpleName); String typeParameters = description.getUserData(JvmTypesResourceDescriptionStrategy.TYPE_PARAMETERS); if (typeParameters != null) { classSignatureBuilder.append(typeParameters); } classSignatureBuilder.append("{"); for(IEObjectDescription nested: owner2nested.get(description.getQualifiedName())) { appendType(nested, owner2nested, classSignatureBuilder); } classSignatureBuilder.append("\n}"); }
@Override public boolean apply(IEObjectDescription input) { return !isFiltered(input.getQualifiedName()); } });
private Type findTypeOnScope(final String typeName, final Function1<? super IEObjectDescription, ? extends Boolean> filter) { final QualifiedName qualifiedName = this.compilationUnit.getQualifiedNameConverter().toQualifiedName(typeName); final IEObjectDescription result = this.compilationUnit.getScopeProvider().getScope(this.compilationUnit.getXtendFile(), XtypePackage.Literals.XIMPORT_DECLARATION__IMPORTED_TYPE).getSingleElement(qualifiedName); if ((((result != null) && TypesPackage.Literals.JVM_TYPE.isSuperTypeOf(result.getEClass())) && (filter.apply(result)).booleanValue())) { EObject _eObjectOrProxy = result.getEObjectOrProxy(); return this.compilationUnit.toType(((JvmType) _eObjectOrProxy)); } return null; } }
protected boolean isJvmDeclaredType(IEObjectDescription description) { EClass eClass = description.getEClass(); return (eClass == TypesPackage.Literals.JVM_GENERIC_TYPE || eClass == TypesPackage.Literals.JVM_ENUMERATION_TYPE || eClass == TypesPackage.Literals.JVM_ANNOTATION_TYPE); }
@Override public IEObjectDescription getSingleElement(EObject object) { Iterator<IEObjectDescription> elements = getElements(object).iterator(); if (elements.hasNext()) { IEObjectDescription result = elements.next(); String resultName = result.getName().toString(); while(elements.hasNext()) { IEObjectDescription candidate = elements.next(); String candidateName = candidate.getName().toString(); if (candidateName.length() < resultName.length()) { result = candidate; resultName = candidateName; } else if (candidateName.length() == resultName.length()) { // prefer '.' over '$' if (candidate.getQualifiedName().getSegmentCount() > result.getQualifiedName().getSegmentCount()) { result = candidate; resultName = candidateName; } } } return result; } return null; }
protected boolean isUserDataEqual(IEObjectDescription oldObj, IEObjectDescription newObj) { String[] oldKeys = oldObj.getUserDataKeys(); String[] newKeys = newObj.getUserDataKeys(); if (oldKeys.length != newKeys.length) return false; for (String key : oldKeys) { if (!Arrays.contains(newKeys, key)) return false; String oldValue = oldObj.getUserData(key); String newValue = newObj.getUserData(key); if (!Objects.equal(oldValue, newValue)) return false; } return true; } }