Java Code Examples for org.eclipse.emf.ecore.ENamedElement#setName()

The following examples show how to use org.eclipse.emf.ecore.ENamedElement#setName() . 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: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testCreatedErrors_03() {
	maxCallCount = 0;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEClass(),
			createEDataType(),
			createEPackage()
	);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	expected.addAll(elements.subList(0, 2));
	helper.checkUniqueNames(
			Scopes.scopedElementsFor(elements), 
			this, this);
	assertEquals(elements.size(), callCount);
	assertTrue(expected.isEmpty());
}
 
Example 2
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testCreatedErrors_03_context() {
	maxCallCount = 0;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEClass(),
			createEDataType(),
			createEPackage()
	);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	expected.addAll(elements.subList(0, 2));
	helper.checkUniqueNames(
			new LocalUniqueNameContext(elements, this), this);
	assertEquals(elements.size(), callCount);
	assertTrue(expected.isEmpty());
}
 
Example 3
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testCreatedErrors_04() {
	maxCallCount = 0;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEClass(),
			createEDataType(),
			createEPackage(),
			createEPackage()
	);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	expected.addAll(elements);
	helper.checkUniqueNames(
			Scopes.scopedElementsFor(elements), 
			this, this);
	assertEquals(elements.size(), callCount);
	assertTrue(expected.isEmpty());
}
 
Example 4
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testCreatedErrors_04_context() {
	maxCallCount = 0;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEClass(),
			createEDataType(),
			createEPackage(),
			createEPackage()
			);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	expected.addAll(elements);
	helper.checkUniqueNames(
			new LocalUniqueNameContext(elements, this), this);
	assertEquals(elements.size(), callCount);
	assertTrue(expected.isEmpty());
}
 
Example 5
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testCreatedErrors_05() {
	maxCallCount = 0;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEPackage(),
			createEDataType(),
			createEPackage()
	);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	expected.add(elements.get(0));
	expected.add(elements.get(2));
	helper.checkUniqueNames(
			Scopes.scopedElementsFor(elements), 
			this, this);
	assertEquals(elements.size(), callCount);
	assertTrue(expected.isEmpty());
}
 
Example 6
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testCreatedErrors_05_context() {
	maxCallCount = 0;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEPackage(),
			createEDataType(),
			createEPackage()
			);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	expected.add(elements.get(0));
	expected.add(elements.get(2));
	helper.checkUniqueNames(
			new LocalUniqueNameContext(elements, this), this);
	assertEquals(elements.size(), callCount);
	assertTrue(expected.isEmpty());
}
 
Example 7
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testCreatedErrors_06() {
	maxCallCount = 1;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEPackage(),
			createEDataType(),
			createEPackage()
	);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	try {
		helper.checkUniqueNames(
				Scopes.scopedElementsFor(elements), 
				this, this);
		fail("cancellation expected");
	} catch (OperationCanceledError e) {
	}
	assertEquals(1, callCount);
}
 
Example 8
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testCreatedErrors_06_context() {
	maxCallCount = 1;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEPackage(),
			createEDataType(),
			createEPackage()
			);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	try {
		helper.checkUniqueNames(
				new LocalUniqueNameContext(elements, this), this);
		fail("cancellation expected");
	} catch (OperationCanceledError e) {
	}
	assertEquals(1, callCount);
}
 
Example 9
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testCreatedErrors_07() {
	maxCallCount = 0;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEPackage(),
			createEDataType(),
			EcoreFactory.eINSTANCE.createEEnumLiteral()
	);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	expected.add(elements.get(0));
	expected.add(elements.get(2));
	helper.checkUniqueNames(
			Scopes.scopedElementsFor(elements), 
			this, this);
	assertEquals(elements.size(), callCount);
	assertTrue(expected.isEmpty());
}
 
Example 10
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testCreatedErrors_07_context() {
	maxCallCount = 0;
	ImmutableList<ENamedElement> elements = ImmutableList.of(
			createEPackage(),
			createEDataType(),
			EcoreFactory.eINSTANCE.createEEnumLiteral()
			);
	for(ENamedElement classifier: elements) {
		classifier.setName("Same");
	}
	expected.add(elements.get(0));
	expected.add(elements.get(2));
	helper.checkUniqueNames(
			new LocalUniqueNameContext(elements, this), this);
	assertEquals(elements.size(), callCount);
	assertTrue(expected.isEmpty());
}
 
Example 11
Source File: ResourceSetBasedResourceDescriptionsTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
private ENamedElement createNamedElement(QualifiedName qualifiedName, EClass type, Resource resource) {
	ENamedElement result = (ENamedElement) EcoreUtil.create(type);
	if (qualifiedName != null)
		result.setName(qualifiedName.getFirstSegment());
	else
		result.setName("" + nameCount++);
	if (resource != null)
		resource.getContents().add(result);
	return result;
}