Java Code Examples for org.eclipse.xtext.resource.IEObjectDescription#getUserDataKeys()

The following examples show how to use org.eclipse.xtext.resource.IEObjectDescription#getUserDataKeys() . 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 File: EObjectDescriptionProvider.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: N4JSResourceDescriptionDelta.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
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) {
		// ------------------------------------------------ START of changes w.r.t. super class
		if (isIgnoredUserDataKey(key)) {
			continue;
		}
		// ------------------------------------------------ END of changes w.r.t. super class
		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;
}
 
Example 3
Source File: BuilderStateUtil.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public static EObjectDescriptionImpl create(IEObjectDescription desc) {
	EObjectDescriptionImpl objectDescription = (EObjectDescriptionImpl) BuilderStateFactory.eINSTANCE.createEObjectDescription();
	objectDescription.setEClass(desc.getEClass());
	objectDescription.setFragment(desc.getEObjectURI().fragment());
	objectDescription.setName(desc.getName());
	for (String key : desc.getUserDataKeys()) {
		objectDescription.getUserData().put(key, desc.getUserData(key));
	}
	return objectDescription;
}
 
Example 4
Source File: SerializableResourceDescription.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private static SerializableEObjectDescription createCopy(IEObjectDescription desc) {
	if (desc instanceof SerializableEObjectDescriptionProvider)
		return ((SerializableEObjectDescriptionProvider) desc).toSerializableEObjectDescription();
	SerializableEObjectDescription result = new SerializableEObjectDescription();
	result.setEClass(desc.getEClass());
	result.setEObjectURI(desc.getEObjectURI());
	result.qualifiedName = desc.getQualifiedName();
	result.userData = new HashMap<String, String>(desc.getUserDataKeys().length);
	for (String key : desc.getUserDataKeys())
		result.userData.put(key, desc.getUserData(key));
	return result;
}
 
Example 5
Source File: DefaultResourceDescriptionDelta.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: EObjectDescriptionDeltaProvider.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
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;
}