use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method applyRuleExpectedTypeInJSXPropertyAttribute.
protected Result<TypeRef> applyRuleExpectedTypeInJSXPropertyAttribute(final RuleEnvironment G, final RuleApplicationTrace _trace_, final JSXPropertyAttribute container, final Expression expr) throws RuleFailedException {
// output parameter
TypeRef T = null;
T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef();
final EObject jsxElem = container.eContainer();
if ((jsxElem instanceof JSXElement)) {
final TypeRef propsTypeRef = this.reactHelper.getPropsType(((JSXElement) jsxElem));
if ((propsTypeRef != null)) {
final RuleEnvironment G2 = RuleEnvironmentExtensions.wrap(G);
this.typeSystemHelper.addSubstitutions(G2, propsTypeRef);
RuleEnvironmentExtensions.addThisType(G2, propsTypeRef);
/* G2 |- container.getProperty() : var TypeRef propertyTypeRef */
IdentifiableElement _property = container.getProperty();
TypeRef propertyTypeRef = null;
Result<TypeRef> result = typeInternal(G2, _trace_, _property);
checkAssignableTo(result.getFirst(), TypeRef.class);
propertyTypeRef = (TypeRef) result.getFirst();
/* G2 |- propertyTypeRef ~> T */
Result<TypeArgument> result_1 = substTypeVariablesInternal(G2, _trace_, propertyTypeRef);
checkAssignableTo(result_1.getFirst(), TypeRef.class);
T = (TypeRef) result_1.getFirst();
}
}
return new Result<TypeRef>(T);
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method applyRuleTypeGetterDeclaration.
protected Result<TypeRef> applyRuleTypeGetterDeclaration(final RuleEnvironment G, final RuleApplicationTrace _trace_, final GetterDeclaration getter) throws RuleFailedException {
// output parameter
TypeRef T = null;
TypeRef _declaredTypeRef = getter.getDeclaredTypeRef();
boolean _tripleNotEquals = (_declaredTypeRef != null);
if (_tripleNotEquals) {
T = getter.getDeclaredTypeRef();
} else {
TGetter _definedGetter = getter.getDefinedGetter();
TypeRef _declaredTypeRef_1 = null;
if (_definedGetter != null) {
_declaredTypeRef_1 = _definedGetter.getDeclaredTypeRef();
}
boolean _tripleNotEquals_1 = (_declaredTypeRef_1 != null);
if (_tripleNotEquals_1) {
T = getter.getDefinedGetter().getDeclaredTypeRef();
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
}
return new Result<TypeRef>(T);
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method expectedTypeInImpl.
protected Result<TypeRef> expectedTypeInImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final VariableDeclaration vdecl, final Expression rhs) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleExpectedTypeOfRightSideInVariableDeclaration(G, _subtrace_, vdecl, rhs);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("expectedTypeOfRightSideInVariableDeclaration") + stringRepForEnv(G) + " |- " + stringRep(vdecl) + " |> " + stringRep(rhs) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleExpectedTypeOfRightSideInVariableDeclaration) {
expectedTypeInThrowException(ruleName("expectedTypeOfRightSideInVariableDeclaration") + stringRepForEnv(G) + " |- " + stringRep(vdecl) + " |> " + stringRep(rhs) + " : " + "TypeRef", EXPECTEDTYPEOFRIGHTSIDEINVARIABLEDECLARATION, e_applyRuleExpectedTypeOfRightSideInVariableDeclaration, vdecl, rhs, new ErrorInformation[] { new ErrorInformation(vdecl), new ErrorInformation(rhs) });
return null;
}
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method typeImpl.
protected Result<TypeRef> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final TemplateLiteral l) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleTypeTemplateLiteral(G, _subtrace_, l);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("typeTemplateLiteral") + stringRepForEnv(G) + " |- " + stringRep(l) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleTypeTemplateLiteral) {
typeThrowException(ruleName("typeTemplateLiteral") + stringRepForEnv(G) + " |- " + stringRep(l) + " : " + "ParameterizedTypeRef", TYPETEMPLATELITERAL, e_applyRuleTypeTemplateLiteral, l, new ErrorInformation[] { new ErrorInformation(l) });
return null;
}
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method applyRuleTypeBinaryLogicalExpression.
protected Result<TypeRef> applyRuleTypeBinaryLogicalExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final BinaryLogicalExpression e) throws RuleFailedException {
// output parameter
TypeRef T = null;
final Expression lhs = e.getLhs();
final Expression rhs = e.getRhs();
boolean _xifexpression = false;
if ((lhs instanceof ArrayLiteral)) {
_xifexpression = ((ArrayLiteral) lhs).getElements().isEmpty();
}
final boolean lhsIsEmptyArrayLiteral = _xifexpression;
boolean _xifexpression_1 = false;
if ((rhs instanceof ArrayLiteral)) {
_xifexpression_1 = ((ArrayLiteral) rhs).getElements().isEmpty();
}
final boolean rhsIsEmptyArrayLiteral = _xifexpression_1;
/* G |- e.lhs : var TypeRef L */
Expression _lhs = e.getLhs();
TypeRef L = null;
Result<TypeRef> result = typeInternal(G, _trace_, _lhs);
checkAssignableTo(result.getFirst(), TypeRef.class);
L = (TypeRef) result.getFirst();
/* G |- e.rhs : var TypeRef R */
Expression _rhs = e.getRhs();
TypeRef R = null;
Result<TypeRef> result_1 = typeInternal(G, _trace_, _rhs);
checkAssignableTo(result_1.getFirst(), TypeRef.class);
R = (TypeRef) result_1.getFirst();
boolean _and = false;
boolean _lhsIsEmptyArrayLiteral = lhsIsEmptyArrayLiteral;
if (!_lhsIsEmptyArrayLiteral) {
_and = false;
} else {
Type _declaredType = null;
if (R != null) {
_declaredType = R.getDeclaredType();
}
TObjectPrototype _arrayType = RuleEnvironmentExtensions.arrayType(G);
boolean _tripleEquals = (_declaredType == _arrayType);
_and = _tripleEquals;
}
if (_and) {
T = R;
} else {
boolean _and_1 = false;
boolean _rhsIsEmptyArrayLiteral = rhsIsEmptyArrayLiteral;
if (!_rhsIsEmptyArrayLiteral) {
_and_1 = false;
} else {
Type _declaredType_1 = null;
if (L != null) {
_declaredType_1 = L.getDeclaredType();
}
TObjectPrototype _arrayType_1 = RuleEnvironmentExtensions.arrayType(G);
boolean _tripleEquals_1 = (_declaredType_1 == _arrayType_1);
_and_1 = _tripleEquals_1;
}
if (_and_1) {
T = L;
} else {
T = this.typeSystemHelper.createUnionType(G, L, R);
}
}
return new Result<TypeRef>(T);
}
Aggregations