org.eclipse.emf.ecore.ENamedElement Java Examples

The following examples show how to use org.eclipse.emf.ecore.ENamedElement. 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_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 #2
Source File: AbstractLabelingTest.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Tests that the expected elements and their labels are exactly identical to all elements of the default test resource.
 */
@Test
public void testLabels() {
  if (getExpectedElementLabels() == null) {
    return; // TODO: remove this check once all tests have been refactored
  }
  for (Pair<ENamedElement, String> elementLabel : getExpectedElementLabels()) {
    if (elementLabel.getFirst() instanceof EClass) {
      // TODO: remove this once all tests have been refactored
      assertHasLabel(((EClass) elementLabel.getFirst()).getInstanceClass(), elementLabel.getSecond());
    } else {
      assertHasLabel(elementLabel.getFirst(), elementLabel.getSecond());
    }
  }
  // assertLabelMapConsistsOf(getExpectedElementLabels()); // TODO : revisit and enable this once all tests have been refactored
}
 
Example #3
Source File: EcoreResourceDescriptionManagerTest.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testPerformance() throws Exception {
		GenericResourceDescriptionManager manager = getEmfResourceDescriptionsManager();
		Collection<String> uris = ImmutableList.copyOf(EPackage.Registry.INSTANCE.keySet());
		for(String uri: uris) {
			EPackage pack = EPackage.Registry.INSTANCE.getEPackage(uri);
			IResourceDescription description = manager.getResourceDescription(pack.eResource());
			assertNotNull(description);
			for(int i = 0; i < 10; i++) {
				Iterator<EObject> iter = EcoreUtil.getAllProperContents(pack, true);
				while(iter.hasNext()) {
					EObject next = iter.next();
					if (next instanceof ENamedElement) {
						String name = ((ENamedElement) next).getName();
//						Iterable<IEObjectDescription> objects = 
						description.getExportedObjects(EcorePackage.Literals.EOBJECT, QualifiedName.create(name), false);
//						assertFalse(name + " - " + uri + " - " + next, Iterables.isEmpty(objects));
					}
				}
			}
		}
	}
 
Example #4
Source File: EcoreUtilN4Test.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("javadoc")
@Test
public void testGetAllContentsFilteredNoMatch() {

	EPackage root = epack("root",
			epack("filteredSub1", ecl("Sub1A"), edt("Sub1C")), //
			epack("filteredSub2", ecl("Sub2A"), ecl("Sub2B"), edt("Sub2C"))
			);
	Iterator<EObject> iter = EcoreUtilN4.getAllContentsFiltered(root, new Predicate<EObject>() {

		@Override
		public boolean apply(EObject input) {
			return !((ENamedElement) input).getName().startsWith("filtered");
		}
	});
	assertEqualsByNames("", iter);
}
 
Example #5
Source File: EcoreUtilN4Test.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("javadoc")
@Test
public void testGetAllContentsFilteredIgnoreRootPredicate() {

	EPackage root = epack("filteredRoot",
			ecl("A"), ecl("B"), edt("C"), //
			epack("notfiltered", ecl("Sub1A"), edt("Sub1C")), //
			ecl("D"), //
			epack("filtered", ecl("Sub2A"), ecl("Sub2B"), edt("Sub2C")),
			ecl("E"), edt("F"));
	Iterator<EObject> iter = EcoreUtilN4.getAllContentsFiltered(root, new Predicate<EObject>() {

		@Override
		public boolean apply(EObject input) {
			return !((ENamedElement) input).getName().startsWith("filtered");
		}
	});
	assertEqualsByNames("A,B,C,D,E,F,notfiltered,Sub1A,Sub1C", iter);
}
 
Example #6
Source File: EcoreUtilN4Test.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@SuppressWarnings("javadoc")
@Test
public void testGetAllContentsFiltered() {

	EPackage root = epack("root",
			ecl("A"), ecl("B"), edt("C"), //
			epack("notfiltered", ecl("Sub1A"), edt("Sub1C")), //
			ecl("D"), //
			epack("filteredSub", ecl("Sub2A"), ecl("Sub2B"), edt("Sub2C")),
			ecl("E"), edt("F"));
	Iterator<EObject> iter = EcoreUtilN4.getAllContentsFiltered(root, new Predicate<EObject>() {

		@Override
		public boolean apply(EObject input) {
			return !((ENamedElement) input).getName().startsWith("filtered");
		}
	});
	assertEqualsByNames("A,B,C,D,E,F,notfiltered,Sub1A,Sub1C", iter);
}
 
Example #7
Source File: ResourceSetBasedResourceDescriptionsTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testTwoElements_OneMatch() {
	QualifiedName qualifiedName = QualifiedName.create("SomeName");
	EClass type = EcorePackage.Literals.EPACKAGE;
	Resource resource = createResource();
	ENamedElement element = createNamedElement(qualifiedName, type, resource);
	ENamedElement other = createNamedElement(null, EcorePackage.Literals.ECLASS, resource);
	Iterable<IEObjectDescription> iterable = container.getExportedObjectsByType(EcorePackage.Literals.EPACKAGE);
	assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
	iterable = container.getExportedObjectsByType(EcorePackage.Literals.ECLASSIFIER);
	assertSame(other, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
	iterable = container.getExportedObjects(EcorePackage.Literals.EPACKAGE, qualifiedName, false);
	assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
	iterable = container.getExportedObjects(EcorePackage.Literals.ENAMED_ELEMENT, qualifiedName, false);
	assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
	iterable = container.getExportedObjects(EcorePackage.Literals.EOBJECT, qualifiedName, false);
	assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
}
 
Example #8
Source File: Case_9.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
protected CharSequence _generateTypeRef(final ENamedElement c) {
  CharSequence _xifexpression = null;
  EObject _eContainer = c.eContainer();
  boolean _tripleNotEquals = (_eContainer != null);
  if (_tripleNotEquals) {
    _xifexpression = this.generateTypeRef(c.eContainer());
  } else {
    CharSequence _xifexpression_1 = null;
    boolean _eIsProxy = c.eIsProxy();
    if (_eIsProxy) {
      StringConcatenation _builder = new StringConcatenation();
      String _name = c.getName();
      _builder.append(_name);
      _xifexpression_1 = _builder;
    } else {
      StringConcatenation _builder_1 = new StringConcatenation();
      _xifexpression_1 = _builder_1;
    }
    _xifexpression = _xifexpression_1;
  }
  return _xifexpression;
}
 
Example #9
Source File: ResourceSetBasedResourceDescriptionsTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testOneElement_Match() {
	QualifiedName qualifiedName = QualifiedName.create("SomeName");
	EClass type = EcorePackage.Literals.EPACKAGE;
	Resource resource = createResource();
	ENamedElement element = createNamedElement(qualifiedName, type, resource);
	Iterable<IEObjectDescription> iterable = container.getExportedObjectsByType(EcorePackage.Literals.EPACKAGE);
	assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
	iterable = container.getExportedObjectsByType(EcorePackage.Literals.EOBJECT);
	assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
	iterable = container.getExportedObjects(EcorePackage.Literals.EPACKAGE, qualifiedName, false);
	assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
	iterable = container.getExportedObjects(EcorePackage.Literals.ENAMED_ELEMENT, qualifiedName, false);
	assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
	iterable = container.getExportedObjects(EcorePackage.Literals.EOBJECT, qualifiedName, false);
	assertSame(element, Iterables.getOnlyElement(iterable).getEObjectOrProxy());
}
 
Example #10
Source File: XtextValidator.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
public void createMessageForNameClashes(Multimap<String, ENamedElement> nameToElement) {
	for(Entry<String, Collection<ENamedElement>> entry: nameToElement.asMap().entrySet()) {
		if (entry.getValue().size() > 1) {
			if (!Iterables.isEmpty(Iterables.filter(entry.getValue(), EStructuralFeature.class))
					&&!Iterables.isEmpty(Iterables.filter(entry.getValue(), EClassifier.class))) {
				String constantName = entry.getKey();
				String message = "Name clash in generated code: '" + constantName + "'.";
				for(ENamedElement element: entry.getValue()) {
					String myMessage = message;
					if (element.getName().indexOf('_') >= 0) {
						myMessage = myMessage + " Try to avoid underscores in names to prevent conflicts.";
					}
					createMessageForSource(myMessage, null, Diagnostic.ERROR, element, getMessageAcceptor());
				}
			}
		}
	}
}
 
Example #11
Source File: DefaultResourceDescriptionManagerTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
	EObject copy = EcoreUtil.copy(EcorePackage.eINSTANCE);
	resource = new ResourceImpl();
	resource.getContents().add(copy);
	IQualifiedNameProvider nameProvider = new IQualifiedNameProvider.AbstractImpl() {
		@Override
		public QualifiedName getFullyQualifiedName(EObject obj) {
			if (obj instanceof ENamedElement)
				return QualifiedName.create(((ENamedElement) obj).getName());
			return null;
		}
	};
	DefaultResourceDescriptionStrategy descriptionStrategy = new DefaultResourceDescriptionStrategy();
	descriptionStrategy.setQualifiedNameProvider(nameProvider);
	resourceDescription = new DefaultResourceDescription(resource, descriptionStrategy) {
		@Override
		public Iterable<QualifiedName> getImportedNames() {
			return importedNames;
		}
	};
	manager = new DefaultResourceDescriptionManager();
	importedNames = Collections.emptySet();
}
 
Example #12
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Test public void testManyManyDup() {
	List<ENamedElement> elements = new ArrayList<>();
	for(int i = 0, j = 0; i < MANY; i++) {
		if (i % 100 == 0) {
			j++;
		}
		EClass c = createEClass();
		c.setName("i" + j);
		elements.add(c);
	}
	maxCallCount = 0;
	expected.addAll(elements);
	helper.checkUniqueNames(
			Scopes.scopedElementsFor(elements), 
			this, this);
}
 
Example #13
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 #14
Source File: ResourceSetBasedResourceDescriptionsTest.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
	resourceSet = new ResourceSetImpl();
	IQualifiedNameProvider qualifiedNameProvider = new IQualifiedNameProvider.AbstractImpl() {
		
		@Override
		public QualifiedName getFullyQualifiedName(EObject obj) {
			return QualifiedName.create(((ENamedElement) obj).getName());
		}

		@Override
		public QualifiedName apply(EObject from) {
			return QualifiedName.create(((ENamedElement) from).getName());
		}
		
	};
	resourceDescriptionManager = new DefaultResourceDescriptionManager();
	resourceDescriptionManager.setCache(IResourceScopeCache.NullImpl.INSTANCE);
	DefaultResourceDescriptionStrategy strategy = new DefaultResourceDescriptionStrategy();
	strategy.setQualifiedNameProvider(qualifiedNameProvider);
	resourceDescriptionManager.setStrategy(strategy);
	resDescs = new ResourceSetBasedResourceDescriptions();
	resDescs.setContext(resourceSet);
	resDescs.setRegistry(this);
	container = new ResourceDescriptionsBasedContainer(resDescs);
}
 
Example #15
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 #16
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 #17
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 #18
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 #19
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 #20
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 #21
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 #22
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 #23
Source File: Formatter2Fragment2.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
protected String toVarName(final ENamedElement element, final String... reservedNames) {
  String _xblockexpression = null;
  {
    if ((element instanceof EReference)) {
      return this.toVarName(((EReference)element).getEReferenceType(), reservedNames);
    }
    String name = StringExtensions.toFirstLower(element.getName());
    boolean _contains = XtendFileAccess.XTEND_KEYWORDS.contains(name);
    if (_contains) {
      name = ("_" + name);
    }
    boolean _contains_1 = ArrayExtensions.contains(reservedNames, name);
    if (_contains_1) {
      name = ("_" + name);
    }
    _xblockexpression = name;
  }
  return _xblockexpression;
}
 
Example #24
Source File: ColorAndFontPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void applyLineColor() {
	List commands = new ArrayList();
	Iterator it = getInputIterator();

	RGB colorToReturn = lineColor;
	RGB color = lineColor;
	while (it.hasNext()) {
		final IGraphicalEditPart editPart = (IGraphicalEditPart) it.next();

		color = lineColor;
		// If we are using default colors, we want to return the color of the first selected element to be consistent
		if (colorToReturn == null) {
			colorToReturn = color;
		}

		if (color != null) {
			final RGB finalColor = color; // need a final variable
			commands.add(createCommand("Line Color", ((View) editPart.getModel())
					.eResource(), new Runnable() {

				public void run() {
					ENamedElement element = PackageUtil
					.getElement(Properties.ID_LINECOLOR);
					if (element instanceof EStructuralFeature)
						editPart.setStructuralFeatureValue(NotationPackage.eINSTANCE.getLineStyle_LineColor(),
								FigureUtilities.RGBToInteger(finalColor));
				}
			}));
		}
	}
	if (!commands.isEmpty()){
		executeAsCompositeCommand("Line Color", commands);
		Image overlyedImage = new ColorOverlayImageDescriptor(DiagramUIPropertiesImages.DESC_LINE_COLOR.getImageData(), color).createImage();
		disposeImage(lineColorButton.getImage());
		lineColorButton.setImage(overlyedImage);
	}
}
 
Example #25
Source File: ColorAndFontPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void applyFontColor() {
	List commands = new ArrayList();
	Iterator it = getInputIterator();

	RGB colorToReturn = fontColor;
	RGB color = fontColor;
	while (it.hasNext()) {
		final IGraphicalEditPart editPart = (IGraphicalEditPart) it.next();

		color = fontColor;
		// If we are using default colors, we want to return the color of the first selected element to be consistent
		if (colorToReturn == null) {
			colorToReturn = color;
		}

		if (color != null) {
			final RGB finalColor = color; // need a final variable
			commands.add(createCommand("Font Color", ((View) editPart.getModel())
					.eResource(), new Runnable() {

				public void run() {
					ENamedElement element = PackageUtil
					.getElement(Properties.ID_FONTCOLOR);
					if (element instanceof EStructuralFeature)
						editPart.setStructuralFeatureValue(NotationPackage.eINSTANCE.getFontStyle_FontColor(),
								FigureUtilities.RGBToInteger(finalColor));
				}
			}));
		}
	}
	if (!commands.isEmpty()){
		executeAsCompositeCommand("Font Color", commands);
		Image overlyedImage = new ColorOverlayImageDescriptor(DiagramUIPropertiesImages.DESC_FONT_COLOR.getImageData(), color).createImage();
		disposeImage(fontColorButton.getImage());
		fontColorButton.setImage(overlyedImage);
	}
}
 
Example #26
Source File: AbstractOutlineTreeProvider.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Check if the given {@link EObject} is a relevant element.
 * An element is relevant if it is a relevant {@link EClass}, or if it is contained in a relevant {@link EStructuralFeature}.
 *
 * @param modelElement
 *          the {@link EObject} to check
 * @return {@code true} if the given {@link EObject} is relevant, {@code false} otherwise
 */
private boolean isRelevantElement(final EObject modelElement) {
  // check if modelElement is a relevant EClass
  for (ENamedElement element : getRelevantElements()) {
    if (element instanceof EClass && ((EClass) element).isInstance(modelElement)) {
      return true;
    }
  }
  // check if modelElement is contained in a relevant EStructuralFeature
  return isContainedInRelevantFeature(modelElement);
}
 
Example #27
Source File: AbstractOutlineTest.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Tests that the outline of the default test resource contains exactly the expected elements.
 */
@Test
public void testOutline() {
  if (getExpectedElements() == null) {
    return; // TODO: remove this once all tests have been refactored
  }
  for (ENamedElement element : getExpectedElements()) {
    assertHasOutlineNode(element);
  }
  // assertOutlineNodeTreeConsistsOf(getExpectedElements()); // TODO : enable this once all tests have been refactored
}
 
Example #28
Source File: ProcessElementTypes.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* Returns 'type' of the ecore object associated with the hint.
* 
* @generated
*/
public static ENamedElement getElement(IAdaptable hint) {
	Object type = hint.getAdapter(IElementType.class);
	if (elements == null) {
		initElements();
	}
	return (ENamedElement) elements.get(type);
}
 
Example #29
Source File: NamesAreUniqueValidationHelperTest.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testManyManyDup_context() {
	List<ENamedElement> elements = new ArrayList<>();
	for(int i = 0, j = 0; i < MANY; i++) {
		if (i % 100 == 0) {
			j++;
		}
		EClass c = createEClass();
		c.setName("i" + j);
		elements.add(c);
	}
	maxCallCount = 0;
	expected.addAll(elements);
	helper.checkUniqueNames(
			new LocalUniqueNameContext(elements, this), this);
}
 
Example #30
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;
}