use of org.eclipse.n4js.ts.types.TStructMember in project n4js by eclipse.
the class ParameterizedTypeRefStructural_IMImpl method getStructuralMembers.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<TStructMember> getStructuralMembers() {
EList<TStructMember> _xifexpression = null;
TStructuralType _structuralType = this.getStructuralType();
boolean _tripleNotEquals = (_structuralType != null);
if (_tripleNotEquals) {
_xifexpression = this.getStructuralType().getOwnedMembers();
} else {
EList<TStructMember> _xifexpression_1 = null;
boolean _isEmpty = this.getAstStructuralMembers().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
_xifexpression_1 = this.getAstStructuralMembers();
} else {
_xifexpression_1 = this.getGenStructuralMembers();
}
_xifexpression = _xifexpression_1;
}
return ECollections.<TStructMember>unmodifiableEList(_xifexpression);
}
use of org.eclipse.n4js.ts.types.TStructMember in project n4js by eclipse.
the class ParameterizedTypeRefStructural_IMImpl method getTypeRefAsString.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getTypeRefAsString() {
TypingStrategy _typingStrategy = this.getTypingStrategy();
Type _declaredType = this.getDeclaredType();
String _rawTypeAsString = null;
if (_declaredType != null) {
_rawTypeAsString = _declaredType.getRawTypeAsString();
}
String _plus = (_typingStrategy + _rawTypeAsString);
String _xifexpression = null;
boolean _isEmpty = this.getTypeArgs().isEmpty();
if (_isEmpty) {
_xifexpression = "";
} else {
final Function1<TypeArgument, String> _function = new Function1<TypeArgument, String>() {
public String apply(final TypeArgument it) {
return it.getTypeRefAsString();
}
};
String _join = IterableExtensions.join(XcoreEListExtensions.<TypeArgument, String>map(this.getTypeArgs(), _function), ",");
String _plus_1 = ("<" + _join);
_xifexpression = (_plus_1 + ">");
}
String _plus_2 = (_plus + _xifexpression);
String _xifexpression_1 = null;
boolean _isEmpty_1 = this.getStructuralMembers().isEmpty();
if (_isEmpty_1) {
_xifexpression_1 = "";
} else {
final Function1<TStructMember, String> _function_1 = new Function1<TStructMember, String>() {
public String apply(final TStructMember it) {
return it.getMemberAsString();
}
};
String _join_1 = IterableExtensions.join(XcoreEListExtensions.<TStructMember, String>map(this.getStructuralMembers(), _function_1), "; ");
String _plus_3 = (" with { " + _join_1);
String _plus_4 = (_plus_3 + " }");
String _xifexpression_2 = null;
boolean _isEmpty_2 = this.getPostponedSubstitutions().isEmpty();
if (_isEmpty_2) {
_xifexpression_2 = "";
} else {
final Function1<TypeVariableMapping, String> _function_2 = new Function1<TypeVariableMapping, String>() {
public String apply(final TypeVariableMapping it) {
String _typeAsString = it.getTypeVar().getTypeAsString();
String _plus = (_typeAsString + "->");
String _typeRefAsString = it.getTypeArg().getTypeRefAsString();
return (_plus + _typeRefAsString);
}
};
String _join_2 = IterableExtensions.join(XcoreEListExtensions.<TypeVariableMapping, String>map(this.getPostponedSubstitutions(), _function_2), ", ");
String _plus_5 = (" [[" + _join_2);
_xifexpression_2 = (_plus_5 + "]]");
}
_xifexpression_1 = (_plus_4 + _xifexpression_2);
}
return (_plus_2 + _xifexpression_1);
}
use of org.eclipse.n4js.ts.types.TStructMember in project n4js by eclipse.
the class BoundThisTypeRefImpl method getStructuralMembers.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<TStructMember> getStructuralMembers() {
EList<TStructMember> _xifexpression = null;
TStructuralType _structuralType = this.getStructuralType();
boolean _tripleNotEquals = (_structuralType != null);
if (_tripleNotEquals) {
_xifexpression = this.getStructuralType().getOwnedMembers();
} else {
EList<TStructMember> _xifexpression_1 = null;
boolean _isEmpty = this.getAstStructuralMembers().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
_xifexpression_1 = this.getAstStructuralMembers();
} else {
_xifexpression_1 = this.getGenStructuralMembers();
}
_xifexpression = _xifexpression_1;
}
return ECollections.<TStructMember>unmodifiableEList(_xifexpression);
}
use of org.eclipse.n4js.ts.types.TStructMember in project n4js by eclipse.
the class TypeCompareLogic method compare.
/**
* WARNING: fqnProvider may be <code>null</code>, but then the lower/greater info will be unreliable!
*/
/* package */
static int compare(IQualifiedNameProvider fqnProvider, TypeArgument arg1, TypeArgument arg2) {
if (arg1 == arg2) {
return 0;
}
if (arg1 == null) {
return -1;
}
if (arg2 == null) {
return 1;
}
if (arg1 instanceof Wildcard || arg2 instanceof Wildcard) {
if (arg1 instanceof Wildcard && arg2 instanceof Wildcard) {
final Wildcard w1 = (Wildcard) arg1;
final Wildcard w2 = (Wildcard) arg2;
int c;
// lower bounds
c = compare(fqnProvider, w1.getDeclaredLowerBound(), w2.getDeclaredLowerBound());
if (c != 0) {
return c;
}
// upper bounds
c = compare(fqnProvider, w1.getDeclaredUpperBound(), w2.getDeclaredUpperBound());
if (c != 0) {
return c;
}
return 0;
}
return compareEClasses(arg1.eClass(), arg2.eClass());
}
// now, we know we have two TypeRefs
final TypeRef ref1 = (TypeRef) arg1;
final TypeRef ref2 = (TypeRef) arg2;
// @formatter:on
if (ref1 instanceof ExistentialTypeRef && ref2 instanceof ExistentialTypeRef) {
return compare(fqnProvider, ((ExistentialTypeRef) ref1).getWildcard(), ((ExistentialTypeRef) ref2).getWildcard());
}
// its subclasses
if (ref1 instanceof FunctionTypeExprOrRef && ref2 instanceof FunctionTypeExprOrRef) {
final FunctionTypeExprOrRef f1 = (FunctionTypeExprOrRef) ref1;
final FunctionTypeExprOrRef f2 = (FunctionTypeExprOrRef) ref2;
return compareFunctionTypeExprOrRefs(fqnProvider, f1, f2);
}
int c;
c = compareEClasses(ref1.eClass(), ref2.eClass());
if (c != 0) {
return c;
}
// note: ref1 and ref2 are of the same type, otherwise c would not be 0
// declared type
c = compare(fqnProvider, ref1.getDeclaredType(), ref2.getDeclaredType());
if (c != 0) {
return c;
}
// if we got a subclass of StructuralTypeRef -> check properties of StructuralTypeRef beforehand
if (ref1 instanceof StructuralTypeRef) {
final StructuralTypeRef sref1 = (StructuralTypeRef) ref1;
final StructuralTypeRef sref2 = (StructuralTypeRef) ref2;
// note: for simplicity, we here require sref1/sref2.structuralMembers to have the same order
// (we aren't doing a semantic compare anyway)
c = compareComparables(sref1.getTypingStrategy(), sref2.getTypingStrategy());
if (c != 0) {
return c;
}
c = compare(fqnProvider, sref1.getStructuralType(), sref2.getStructuralType());
if (c != 0) {
return c;
}
final Iterator<TStructMember> iter1 = sref1.getStructuralMembers().iterator();
final Iterator<TStructMember> iter2 = sref2.getStructuralMembers().iterator();
while (iter1.hasNext() && iter2.hasNext()) {
c = compareMembers(fqnProvider, iter1.next(), iter2.next());
if (c != 0) {
return c;
}
}
if (iter1.hasNext()) {
return 1;
}
if (iter2.hasNext()) {
return -1;
}
}
if (ref1 instanceof ParameterizedTypeRef) {
final ParameterizedTypeRef pref1 = (ParameterizedTypeRef) ref1;
final ParameterizedTypeRef pref2 = (ParameterizedTypeRef) ref2;
c = compareTypeArguments(fqnProvider, pref1.getTypeArgs(), pref2.getTypeArgs());
if (c != 0) {
return c;
}
} else if (ref1 instanceof ComposedTypeRef) {
final ComposedTypeRef cref1 = (ComposedTypeRef) ref1;
final ComposedTypeRef cref2 = (ComposedTypeRef) ref2;
c = compareTypeArguments(fqnProvider, cref1.getTypeRefs(), cref2.getTypeRefs());
if (c != 0) {
return c;
}
} else if (ref1 instanceof TypeTypeRef) {
final TypeTypeRef cref1 = (TypeTypeRef) ref1;
final TypeTypeRef cref2 = (TypeTypeRef) ref2;
c = compareComparables(cref1.isConstructorRef(), cref2.isConstructorRef());
if (c != 0) {
return c;
}
c = compare(fqnProvider, cref1.getTypeArg(), cref2.getTypeArg());
if (c != 0) {
return c;
}
} else if (ref1 instanceof BoundThisTypeRef) {
final BoundThisTypeRef bref1 = (BoundThisTypeRef) ref1;
final BoundThisTypeRef bref2 = (BoundThisTypeRef) ref2;
c = compare(fqnProvider, bref1.getActualThisTypeRef(), bref2.getActualThisTypeRef());
if (c != 0) {
return c;
}
}
// dynamic
c = Boolean.compare(ref1.isDynamic(), ref2.isDynamic());
if (c != 0) {
return c;
}
return 0;
}
use of org.eclipse.n4js.ts.types.TStructMember in project n4js by eclipse.
the class ParameterizedTypeRefStructuralImpl method getTypeRefAsString.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getTypeRefAsString() {
TypingStrategy _typingStrategy = this.getTypingStrategy();
Type _declaredType = this.getDeclaredType();
String _rawTypeAsString = null;
if (_declaredType != null) {
_rawTypeAsString = _declaredType.getRawTypeAsString();
}
String _plus = (_typingStrategy + _rawTypeAsString);
String _xifexpression = null;
boolean _isEmpty = this.getTypeArgs().isEmpty();
if (_isEmpty) {
_xifexpression = "";
} else {
final Function1<TypeArgument, String> _function = new Function1<TypeArgument, String>() {
public String apply(final TypeArgument it) {
return it.getTypeRefAsString();
}
};
String _join = IterableExtensions.join(XcoreEListExtensions.<TypeArgument, String>map(this.getTypeArgs(), _function), ",");
String _plus_1 = ("<" + _join);
_xifexpression = (_plus_1 + ">");
}
String _plus_2 = (_plus + _xifexpression);
String _xifexpression_1 = null;
boolean _isEmpty_1 = this.getStructuralMembers().isEmpty();
if (_isEmpty_1) {
_xifexpression_1 = "";
} else {
final Function1<TStructMember, String> _function_1 = new Function1<TStructMember, String>() {
public String apply(final TStructMember it) {
return it.getMemberAsString();
}
};
String _join_1 = IterableExtensions.join(XcoreEListExtensions.<TStructMember, String>map(this.getStructuralMembers(), _function_1), "; ");
String _plus_3 = (" with { " + _join_1);
String _plus_4 = (_plus_3 + " }");
String _xifexpression_2 = null;
boolean _isEmpty_2 = this.getPostponedSubstitutions().isEmpty();
if (_isEmpty_2) {
_xifexpression_2 = "";
} else {
final Function1<TypeVariableMapping, String> _function_2 = new Function1<TypeVariableMapping, String>() {
public String apply(final TypeVariableMapping it) {
String _typeAsString = it.getTypeVar().getTypeAsString();
String _plus = (_typeAsString + "->");
String _typeRefAsString = it.getTypeArg().getTypeRefAsString();
return (_plus + _typeRefAsString);
}
};
String _join_2 = IterableExtensions.join(XcoreEListExtensions.<TypeVariableMapping, String>map(this.getPostponedSubstitutions(), _function_2), ", ");
String _plus_5 = (" [[" + _join_2);
_xifexpression_2 = (_plus_5 + "]]");
}
_xifexpression_1 = (_plus_4 + _xifexpression_2);
}
return (_plus_2 + _xifexpression_1);
}
Aggregations