List of usage examples for org.eclipse.jdt.internal.compiler.lookup ParameterizedGenericMethodBinding ParameterizedGenericMethodBinding
public ParameterizedGenericMethodBinding(MethodBinding originalMethod, RawTypeBinding rawType,
LookupEnvironment environment)
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.RoleMigrationImplementor.java
License:Open Source License
/** * PHASE 2: Type checking for invocations of migrateToXXX(). * * @param originalMethod method before type parameter substitution * @param arguments actual argument types of the current invocation * @param substitutes type variable bindings * @param scope/*w w w. ja v a2s .co m*/ * @param invocationSite * @return null if not a migrate-method call, otherwise (a) a problem method binding (ProblemAlreadyReported) or (b) a valid method substitute */ public static MethodBinding getMigrateMethodSubstitute(MethodBinding originalMethod, TypeBinding[] arguments, TypeBinding[] substitutes, Scope scope, InvocationSite invocationSite) { if (!(invocationSite instanceof MessageSend)) return null; MessageSend send = (MessageSend) invocationSite; if (!(send.actualReceiverType instanceof ReferenceBinding)) return null; ReferenceBinding roleType = ((ReferenceBinding) send.actualReceiverType).getRealType(); TypeBinding typeArgument = null; boolean haveReportedError = false; if (CharOperation.equals(originalMethod.selector, IOTConstants.MIGRATE_TO_TEAM)) { Expression sendArgument = send.arguments[0]; ITeamAnchor anchorBinding = TeamAnchor.getTeamAnchor(sendArgument); if (anchorBinding == null) { scope.problemReporter().migrateToNonTeam(sendArgument); haveReportedError = true; } else { ReferenceBinding anchorType = (ReferenceBinding) anchorBinding.getResolvedType(); if (TypeBinding.notEquals(anchorType.getRealClass(), roleType.enclosingType())) { scope.problemReporter().migrateToWrongTeam(sendArgument, anchorType, roleType); haveReportedError = true; } } if (!haveReportedError) typeArgument = RoleTypeCreator.getAnchoredType(scope, send, anchorBinding, roleType, null, 0); // FIXME(SH): type parameters } else if (CharOperation.equals(originalMethod.selector, IOTConstants.MIGRATE_TO_BASE)) { TypeBinding baseType = arguments[0]; if (!baseType.isCompatibleWith(roleType.baseclass())) { scope.problemReporter().migrateToWrongBase(send.arguments[0], baseType, roleType, roleType.baseclass()); haveReportedError = true; } typeArgument = baseType; } else { return null; } if (haveReportedError) return new ProblemMethodBinding(originalMethod, originalMethod.selector, substitutes, ProblemReasons.ProblemAlreadyReported); // substitution was successful return new ParameterizedGenericMethodBinding(originalMethod, new TypeBinding[] { typeArgument }, scope.environment()); }