本文整理汇总了Java中org.eclipse.xtext.resource.EObjectDescription.create方法的典型用法代码示例。如果您正苦于以下问题:Java EObjectDescription.create方法的具体用法?Java EObjectDescription.create怎么用?Java EObjectDescription.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.resource.EObjectDescription
的用法示例。
在下文中一共展示了EObjectDescription.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCheckedDescription
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
@Override
protected IEObjectDescription getCheckedDescription(String name, TMember member) {
IEObjectDescription description = EObjectDescription.create(member.getName(), member);
QualifiedName qn = QualifiedName.create(name);
boolean allDescrWithError = true;
for (IScope currSubScope : subScopes) {
IEObjectDescription subDescription = currSubScope.getSingleElement(qn);
boolean descrWithError = subDescription == null || subDescription instanceof IEObjectDescriptionWithError;
allDescrWithError &= descrWithError;
}
if (allDescrWithError) {
return createComposedMemberDescriptionWithErrors(description);
}
return description;
}
示例2: getCheckedDescription
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
@Override
protected IEObjectDescription getCheckedDescription(String name, TMember member) {
IEObjectDescription description = EObjectDescription.create(member.getName(), member);
QualifiedName qn = QualifiedName.create(name);
for (IScope currSubScope : subScopes) {
IEObjectDescription subDescription = currSubScope.getSingleElement(qn);
boolean descrWithError = subDescription == null || subDescription instanceof IEObjectDescriptionWithError;
if (descrWithError) {
return createComposedMemberDescriptionWithErrors(description);
}
}
return description;
}
示例3: createFeatureCallSerializationScope
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
public IScope createFeatureCallSerializationScope(EObject context) {
if (!(context instanceof XAbstractFeatureCall)) {
return IScope.NULLSCOPE;
}
XAbstractFeatureCall call = (XAbstractFeatureCall) context;
JvmIdentifiableElement feature = call.getFeature();
// this and super - logical container aware FeatureScopes
if (feature instanceof JvmType) {
return getTypeScope(call, (JvmType) feature);
}
if (feature instanceof JvmConstructor) {
return getThisOrSuperScope(call, (JvmConstructor) feature);
}
if (feature instanceof JvmExecutable) {
return getExecutableScope(call, feature);
}
if (feature instanceof JvmFormalParameter || feature instanceof JvmField || feature instanceof XVariableDeclaration || feature instanceof XSwitchExpression) {
return new SingletonScope(EObjectDescription.create(feature.getSimpleName(), feature), IScope.NULLSCOPE);
}
return IScope.NULLSCOPE;
}
示例4: getLocalElementsByName
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
@Override
protected List<IEObjectDescription> getLocalElementsByName(QualifiedName name) {
XAbstractFeatureCall featureCall = getFeatureCall();
if (featureCall.isExplicitOperationCallOrBuilderSyntax())
return Collections.emptyList();
if (rawEnclosingType instanceof JvmDeclaredType && name.getSegmentCount() == 1) {
String singleSegment = name.getFirstSegment();
List<String> lookup = Collections.singletonList(singleSegment);
if (singleSegment.indexOf('$') != -1) {
lookup = Strings.split(singleSegment, '$');
}
JvmType result = findNestedType((JvmDeclaredType)rawEnclosingType, lookup.iterator());
if (result != null) {
IEObjectDescription description = EObjectDescription.create(name, result);
return Collections.<IEObjectDescription>singletonList(new TypeLiteralDescription(description, enclosingType, isVisible(result)));
}
}
return Collections.emptyList();
}
示例5: createEObjectDescriptions
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
protected boolean createEObjectDescriptions(IQualifiedNameProvider qualifiedNameProvider, boolean isNsURI,
EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
try {
QualifiedName qualifiedName = qualifiedNameProvider.getFullyQualifiedName(eObject);
if (qualifiedName != null) {
Map<String, String> userData = Maps.newHashMapWithExpectedSize(1);
userData.put(NS_URI_INDEX_ENTRY, Boolean.toString(isNsURI));
IEObjectDescription description = EObjectDescription.create(qualifiedName, eObject, userData);
acceptor.accept(description);
return true;
}
} catch (Exception exc) {
LOG.error(exc.getMessage(), exc);
}
return false;
}
示例6: testImports_01
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
@Test public void testImports_01() throws Exception {
final IEObjectDescription desc1 = EObjectDescription.create(QualifiedName.create("com","foo","bar"), EcorePackage.Literals.EANNOTATION);
final IEObjectDescription desc2 = EObjectDescription.create(QualifiedName.create("de","foo"), EcorePackage.Literals.EATTRIBUTE);
SimpleScope outer = new SimpleScope(newArrayList(desc1,desc2), false);
ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("com"), true, false);
ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("de","foo"), false, false);
TestableImportScope scope = new TestableImportScope(newArrayList(n1,n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, false);
final Iterable<IEObjectDescription> elements = scope.getAllElements();
Iterator<IEObjectDescription> iterator = elements.iterator();
assertEquals("foo.bar", iterator.next().getName().toString());
assertEquals("foo", iterator.next().getName().toString());
assertSame(desc1,iterator.next());
assertSame(desc2,iterator.next());
assertFalse(iterator.hasNext());
}
示例7: testRelativeImports_01
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
@Test public void testRelativeImports_01() throws Exception {
final IEObjectDescription desc1 = EObjectDescription.create(QualifiedName.create("com","foo","bar"), EcorePackage.Literals.EANNOTATION);
final IEObjectDescription desc2 = EObjectDescription.create(QualifiedName.create("de","foo"), EcorePackage.Literals.EATTRIBUTE);
IScope outer = new SimpleScope(newArrayList(desc1,desc2), false);
ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("com"), true, false);
ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("de"), true, false);
outer = new TestableImportScope(newArrayList(n1,n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, false);
n1 = new ImportNormalizer(QualifiedName.create("foo"), true, false);
n2 = new ImportNormalizer(QualifiedName.create("foo"), false, false);
TestableImportScope scope = new TestableImportScope(newArrayList(n1,n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, false);
final Iterable<IEObjectDescription> elements = scope.getAllElements();
Iterator<IEObjectDescription> iterator = elements.iterator();
assertEquals("bar", iterator.next().getName().toString());
assertEquals("foo", iterator.next().getName().toString());
assertEquals("foo.bar", iterator.next().getName().toString());
assertSame(desc1,iterator.next());
assertSame(desc2,iterator.next());
assertFalse(iterator.hasNext());
}
示例8: add
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
static void add(final EClass eClass, final String t, final OperatorProto o) {
final GamlDefinition stub = (GamlDefinition) EGaml.getFactory().create(eClass);
stub.setName(t);
Map<String, String> doc;
resources.get(eClass).getContents().add(stub);
final IGamlDescription d =
GAMA.isInHeadLessMode() ? null : GamlResourceServices.getResourceDocumenter().getGamlDocumentation(o);
if (d != null) {
doc = new ImmutableMap("doc", d.getDocumentation(), "title", d.getTitle(), "type", "operator");
} else {
doc = new ImmutableMap("type", "operator");
}
final IEObjectDescription e = EObjectDescription.create(t, stub, doc);
descriptions.get(eClass).put(e.getName(), e);
allNames.add(e.getName());
}
示例9: addVar
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
public static void addVar(final String t, final IGamlDescription o, final String keyword) {
final GamlDefinition stub = (GamlDefinition) EGaml.getFactory().create(eVar);
// TODO Add the fields definition here
stub.setName(t);
resources.get(eVar).getContents().add(stub);
final IGamlDescription d =
GAMA.isInHeadLessMode() ? null : GamlResourceServices.getResourceDocumenter().getGamlDocumentation(o);
Map<String, String> doc;
if (d != null) {
doc = new ImmutableMap("doc", d.getDocumentation(), "title", d.getTitle(), "type", keyword);
} else {
doc = new ImmutableMap("type", keyword);
}
final IEObjectDescription e = EObjectDescription.create(t, stub, doc);
descriptions.get(eVar).put(e.getName(), e);
allNames.add(e.getName());
}
示例10: addAction
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
static void addAction(final EClass eClass, final String t, final IGamlDescription o) {
final GamlDefinition stub = (GamlDefinition) EGaml.getFactory().create(eClass);
// TODO Add the fields definition here
stub.setName(t);
resources.get(eClass).getContents().add(stub);
final IGamlDescription d =
GAMA.isInHeadLessMode() ? null : GamlResourceServices.getResourceDocumenter().getGamlDocumentation(o);
GamlResourceServices.getResourceDocumenter().setGamlDocumentation(stub, o, false);
Map<String, String> doc;
if (d != null) {
doc = new ImmutableMap("doc", d.getDocumentation(), "title", d.getTitle(), "type", "action");
} else {
doc = new ImmutableMap("type", "action");
}
final IEObjectDescription e = EObjectDescription.create(t, stub, doc);
descriptions.get(eClass).put(e.getName(), e);
allNames.add(e.getName());
}
示例11: getSingleElement
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
@Override
public IEObjectDescription getSingleElement(QualifiedName name) {
IEObjectDescription result = getOutModel((TransformationDefinition) obj.eContainer(), name.getFirstSegment());
if ( result != null ) return result;
// TODO: REVIEW THIS STRATEGY BECAUSE THIS WORKS FOR COMPOSITE, BUT FOR A CHAIN THIS MEANS
// THAT TWO TRANSFORMATIONS GENERATE THE SAME MODEL...
ChainTransformation t = (ChainTransformation) EcoreUtil.getRootContainer(obj);
for(GeneratedModel generated : t.getGeneratedModels()) {
if ( generated.getName().equals(name.getFirstSegment()) ) {
return EObjectDescription.create(name.getFirstSegment(), generated);
}
}
GeneratedModel g = ChainFactory.eINSTANCE.createGeneratedModel();
g.setName(name.getFirstSegment());
t.getGeneratedModels().add(g);
return EObjectDescription.create(g.getName(), g);
}
示例12: buildMap
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
@Override
protected void buildMap(Resource resource, Map<QualifiedName, IEObjectDescription> elements) {
TypeDefs typeDefinitions = (TypeDefs) resource.getContents().get(0);
for (Type type : typeDefinitions.getTypes()) {
if (!(type instanceof VirtualBaseType)) {
IEObjectDescription description = EObjectDescription.create(type.getName(), type);
elements.put(description.getName(), description);
}
}
}
示例13: internalCreateEObjectDescription
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
/**
* Create EObjectDescriptions for elements for which N4JSQualifiedNameProvider provides a FQN; elements with a FQN
* of <code>null</code> will be ignored.
*/
private void internalCreateEObjectDescription(Type type, IAcceptor<IEObjectDescription> acceptor) {
final String exportedName = type.getExportedName();
final String typeName = exportedName != null ? exportedName : type.getName();
if (typeName != null && typeName.length() != 0) {
QualifiedName qualifiedName = qualifiedNameProvider.getFullyQualifiedName(type);
if (qualifiedName != null) { // e.g. non-exported declared functions will return null for FQN
Map<String, String> userData = Collections.singletonMap(
ACCESS_MODIFIERY_KEY,
String.valueOf(type.getTypeAccessModifier().ordinal()));
// Add additional user data for descriptions representing a TClass
if (type instanceof TClass) {
final TClass tClass = (TClass) type;
userData = newHashMap(userData);
if (tClass.isExported()) {
userData.put(EXPORTED_CLASS_KEY, Boolean.toString(tClass.isExported()));
}
userData.put(ABSTRACT_KEY, Boolean.toString(tClass.isAbstract()));
userData.put(FINAL_KEY, Boolean.toString(tClass.isFinal()));
userData.put(POLYFILL_KEY, Boolean.toString(tClass.isPolyfill()));
userData.put(STATIC_POLYFILL_KEY, Boolean.toString(tClass.isStaticPolyfill()));
userData.put(
TEST_CLASS_KEY,
Boolean.toString(tClass.getOwnedMembers().stream()
.filter(m -> m instanceof TMethod)
.anyMatch(m -> AnnotationDefinition.TEST_METHOD.hasAnnotation(m))));
}
IEObjectDescription eod = EObjectDescription.create(qualifiedName, type, userData);
acceptor.accept(eod);
}
}
}
示例14: getSingleElement
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
@Override
public IEObjectDescription getSingleElement(EObject object) {
IEObjectDescription result = parent.getSingleElement(object);
if (result == null) {
if (object instanceof IdentifiableElement) {
return EObjectDescription
.create(QualifiedName.create(((IdentifiableElement) object).getName()), object);
}
}
return result;
}
示例15: getThisOrSuperScope
import org.eclipse.xtext.resource.EObjectDescription; //导入方法依赖的package包/类
protected IScope getThisOrSuperScope(XAbstractFeatureCall call, JvmConstructor constructor) {
QualifiedName name = THIS;
JvmIdentifiableElement logicalContainer = logicalContainerProvider.getNearestLogicalContainer(call);
if (logicalContainer instanceof JvmConstructor) {
JvmDeclaredType thisType = ((JvmConstructor) logicalContainer).getDeclaringType();
if (thisType != constructor.getDeclaringType()) {
name = SUPER;
}
}
return new SingletonScope(EObjectDescription.create(name, constructor), IScope.NULLSCOPE);
}