当前位置: 首页>>代码示例>>Java>>正文


Java ENamedElement类代码示例

本文整理汇总了Java中org.eclipse.emf.ecore.ENamedElement的典型用法代码示例。如果您正苦于以下问题:Java ENamedElement类的具体用法?Java ENamedElement怎么用?Java ENamedElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ENamedElement类属于org.eclipse.emf.ecore包,在下文中一共展示了ENamedElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetAllContentsFiltered

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:EcoreUtilN4Test.java

示例2: testGetAllContentsFilteredIgnoreRootPredicate

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:EcoreUtilN4Test.java

示例3: testGetAllContentsFilteredNoMatch

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:EcoreUtilN4Test.java

示例4: testPerformance

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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));
					}
				}
			}
		}
	}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:22,代码来源:EcoreResourceDescriptionManagerTest.java

示例5: createMessageForNameClashes

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
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());
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:XtextValidator.java

示例6: toVarName

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
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 = ((List<String>)Conversions.doWrapArray(reservedNames)).contains(name);
    if (_contains_1) {
      name = ("_" + name);
    }
    _xblockexpression = name;
  }
  return _xblockexpression;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:Formatter2Fragment2.java

示例7: testCreatedErrors_03

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:NamesAreUniqueValidationHelperTest.java

示例8: testCreatedErrors_04

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:NamesAreUniqueValidationHelperTest.java

示例9: testCreatedErrors_05

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:NamesAreUniqueValidationHelperTest.java

示例10: testCreatedErrors_06

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:NamesAreUniqueValidationHelperTest.java

示例11: testCreatedErrors_07

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:NamesAreUniqueValidationHelperTest.java

示例12: setUp

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:25,代码来源:DefaultResourceDescriptionManagerTest.java

示例13: setUp

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:27,代码来源:ResourceSetBasedResourceDescriptionsTest.java

示例14: testOneElement_Match

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:ResourceSetBasedResourceDescriptionsTest.java

示例15: testTwoElements_OneMatch

import org.eclipse.emf.ecore.ENamedElement; //导入依赖的package包/类
@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());
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:18,代码来源:ResourceSetBasedResourceDescriptionsTest.java


注:本文中的org.eclipse.emf.ecore.ENamedElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。