use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendValidator method checkMemberNamesAreUnique.
@Check
public void checkMemberNamesAreUnique(XtendTypeDeclaration xtendType) {
final Multimap<String, XtendField> name2field = HashMultimap.create();
final Multimap<String, XtendTypeDeclaration> name2type = HashMultimap.create();
final Multimap<JvmType, XtendField> type2extension = HashMultimap.create();
for (XtendMember member : xtendType.getMembers()) {
if (member instanceof XtendField) {
XtendField field = (XtendField) member;
if (isEmpty(field.getName())) {
if (field.isExtension()) {
JvmTypeReference typeReference = field.getType();
if (typeReference != null) {
JvmType type = typeReference.getType();
if (type != null)
type2extension.put(type, field);
}
}
} else {
name2field.put(field.getName(), field);
}
} else if (member instanceof XtendTypeDeclaration) {
String name = ((XtendTypeDeclaration) member).getName();
if (name != null && name.length() > 0) {
name2type.put(name, (XtendTypeDeclaration) member);
}
}
}
for (String name : name2field.keySet()) {
Collection<XtendField> fields = name2field.get(name);
if (fields.size() > 1) {
for (XtendField field : fields) error("Duplicate field " + name, field, XtendPackage.Literals.XTEND_FIELD__NAME, DUPLICATE_FIELD);
}
}
for (String name : name2type.keySet()) {
Collection<XtendTypeDeclaration> types = name2type.get(name);
if (types.size() > 1) {
for (XtendTypeDeclaration type : types) error("Duplicate nested type " + name, type, XtendPackage.Literals.XTEND_TYPE_DECLARATION__NAME, DUPLICATE_TYPE_NAME);
}
}
for (JvmType type : type2extension.keySet()) {
Collection<XtendField> fields = type2extension.get(type);
if (fields.size() > 1) {
for (XtendField field : fields) error("Duplicate extension with same type", field, XTEND_FIELD__TYPE, DUPLICATE_FIELD);
}
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class ProblemSupportImpl method getSignificantFeature.
public EStructuralFeature getSignificantFeature(final EObject obj) {
EStructuralFeature _switchResult = null;
boolean _matched = false;
if (obj instanceof XtendTypeDeclaration) {
_matched = true;
_switchResult = XtendPackage.eINSTANCE.getXtendTypeDeclaration_Name();
}
if (!_matched) {
if (obj instanceof XtendField) {
_matched = true;
_switchResult = XtendPackage.eINSTANCE.getXtendField_Name();
}
}
if (!_matched) {
if (obj instanceof XtendFunction) {
_matched = true;
_switchResult = XtendPackage.eINSTANCE.getXtendFunction_Name();
}
}
if (!_matched) {
if (obj instanceof JvmFormalParameter) {
_matched = true;
_switchResult = TypesPackage.eINSTANCE.getJvmFormalParameter_Name();
}
}
if (!_matched) {
if (obj instanceof XAnnotation) {
_matched = true;
_switchResult = XAnnotationsPackage.eINSTANCE.getXAnnotation_AnnotationType();
}
}
return _switchResult;
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class TypeLookupImpl method findSourceType.
private XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> findSourceType(final String qualifiedName) {
EObject _head = IterableExtensions.<EObject>head(this.compilationUnit.getXtendFile().eResource().getContents());
final Function1<XtendTypeDeclaration, String> _function = (XtendTypeDeclaration type) -> {
return this.compilationUnit.getQualifiedNameConverter().toString(this.compilationUnit.getQualifiedNameProvider().getFullyQualifiedName(type));
};
final Function1<XtendTypeDeclaration, Iterable<? extends XtendTypeDeclaration>> _function_1 = (XtendTypeDeclaration type) -> {
return Iterables.<XtendTypeDeclaration>filter(type.getMembers(), XtendTypeDeclaration.class);
};
final XtendTypeDeclaration result = this.<XtendTypeDeclaration>recursiveFindType(qualifiedName, ((XtendFile) _head).getXtendTypes(), _function, _function_1);
XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> _xifexpression = null;
if ((result != null)) {
_xifexpression = this.compilationUnit.toXtendTypeDeclaration(result);
}
return _xifexpression;
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendMemberDeclarationImpl method getDeclaringType.
@Override
public TypeDeclaration getDeclaringType() {
XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> _switchResult = null;
EObject _eContainer = this.getDelegate().eContainer();
final EObject container = _eContainer;
boolean _matched = false;
if (container instanceof XtendTypeDeclaration) {
_matched = true;
_switchResult = this.getCompilationUnit().toXtendTypeDeclaration(((XtendTypeDeclaration) container));
}
if (!_matched) {
_switchResult = null;
}
return _switchResult;
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class XtendTypeDeclarationImpl method getQualifiedName.
private String getQualifiedName(final XtendTypeDeclaration decl) {
boolean _isAnonymous = decl.isAnonymous();
if (_isAnonymous) {
return null;
}
final EObject container = decl.eContainer();
if ((container instanceof XtendFile)) {
final String package_ = ((XtendFile) container).getPackage();
if ((package_ == null)) {
return decl.getName();
}
String _name = decl.getName();
return ((package_ + ".") + _name);
}
if ((container instanceof XtendTypeDeclaration)) {
final String containerName = this.getQualifiedName(((XtendTypeDeclaration) container));
if ((containerName == null)) {
return null;
}
String _name_1 = decl.getName();
return ((containerName + ".") + _name_1);
}
return null;
}
Aggregations