use of org.eclipse.n4js.ts.types.TFunction in project n4js by eclipse.
the class InvisibleTypeOrVariableDescription method getMessage.
@Override
public String getMessage() {
EObject objectOrProxy = getEObjectOrProxy();
String name = getName().getLastSegment();
if (objectOrProxy instanceof TFunction) {
return IssueCodes.getMessageForVIS_ILLEGAL_FUN_ACCESS(name);
} else if (objectOrProxy instanceof Type) {
return IssueCodes.getMessageForVIS_ILLEGAL_TYPE_ACCESS(name);
}
return IssueCodes.getMessageForVIS_ILLEGAL_VARIABLE_ACCESS(name);
}
use of org.eclipse.n4js.ts.types.TFunction in project n4js by eclipse.
the class FunctionDefinitionImpl method getDefinedFunction.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TFunction getDefinedFunction() {
final Type defType = this.getDefinedType();
TFunction _xifexpression = null;
if ((defType instanceof TFunction)) {
_xifexpression = ((TFunction) defType);
}
return _xifexpression;
}
use of org.eclipse.n4js.ts.types.TFunction in project n4js by eclipse.
the class TypeUtils method createTypeRef.
/**
* Same as {@link #createTypeRef(Type, TypingStrategy, TypeArgument...)}, but will create unbounded wildcards as
* type arguments if fewer type arguments are provided than the number of type parameters of the given declared.
*/
public static ParameterizedTypeRef createTypeRef(Type declaredType, TypingStrategy typingStrategy, boolean autoCreateTypeArgs, TypeArgument... typeArgs) {
if (declaredType == null) {
// avoid creating a bogus ParameterizedTypeRef with a 'declaredType' property of 'null'
return null;
}
final ParameterizedTypeRef ref;
if (declaredType instanceof TFunction) {
ref = TypeRefsFactory.eINSTANCE.createFunctionTypeRef();
// } else if (declaredType instanceof TStructuralType) {
// throw new IllegalArgumentException("a TStructuralType should not be used as declared type of a TypeRef");
} else if (typingStrategy != TypingStrategy.DEFAULT && typingStrategy != TypingStrategy.NOMINAL) {
ref = TypeRefsFactory.eINSTANCE.createParameterizedTypeRefStructural();
} else {
ref = TypeRefsFactory.eINSTANCE.createParameterizedTypeRef();
}
ref.setDefinedTypingStrategy(typingStrategy);
ref.setDeclaredType(declaredType);
final EList<TypeArgument> refTypeArgs = ref.getTypeArgs();
for (TypeArgument typeArg : typeArgs) {
refTypeArgs.add(TypeUtils.copyIfContained(typeArg));
}
if (autoCreateTypeArgs) {
final int l = declaredType.getTypeVars().size();
for (int i = refTypeArgs.size(); i < l; i++) {
refTypeArgs.add(createWildcard());
}
}
return ref;
}
use of org.eclipse.n4js.ts.types.TFunction in project n4js by eclipse.
the class FunctionTypeExpressionImpl method getTypeVars.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<TypeVariable> getTypeVars() {
EList<TypeVariable> _xifexpression = null;
boolean _isBinding = this.isBinding();
if (_isBinding) {
_xifexpression = this.getUnboundTypeVars();
} else {
EList<TypeVariable> _xifexpression_1 = null;
TFunction _declaredType = this.getDeclaredType();
boolean _tripleNotEquals = (_declaredType != null);
if (_tripleNotEquals) {
_xifexpression_1 = this.getDeclaredType().getTypeVars();
} else {
_xifexpression_1 = this.getOwnedTypeVars();
}
_xifexpression = _xifexpression_1;
}
return _xifexpression;
}
use of org.eclipse.n4js.ts.types.TFunction in project n4js by eclipse.
the class TypeStatesAnalyser method getDeclaredStates.
private Set<String> getDeclaredStates(ControlFlowElement container, String stateName) {
Set<String> states = new HashSet<>();
if (container instanceof ParameterizedCallExpression) {
ParameterizedCallExpression pce = (ParameterizedCallExpression) container;
TFunction tFunc = (TFunction) ts.tau(pce);
for (TAnnotation ann : tFunc.getAnnotations()) {
if (stateName.equals(ann.getName())) {
for (TAnnotationArgument arg : ann.getArgs()) {
states.add(arg.getArgAsString());
}
}
}
}
return states;
}
Aggregations