};
@Override
public final Description matchVariable(VariableTree variableTree, VisitorState state) {
if (constructorAssistedParameterMatcher.matches(variableTree, state)) {
Compound thisParamsAssisted = null;
for (Compound c : ASTHelpers.getSymbol(variableTree).getAnnotationMirrors()) {
if (((TypeElement) c.getAnnotationType().asElement()).getQualifiedName()
.contentEquals(ASSISTED_ANNOTATION)) {
thisParamsAssisted = c;
}
}
MethodTree enclosingMethod = (MethodTree) state.getPath().getParentPath().getLeaf();
// count the number of parameters of this type and value. One is expected since we
// will be iterating through all parameters including the one we're matching.
int numIdentical = 0;
for (VariableTree parameter : enclosingMethod.getParameters()) {
if (Matchers.<VariableTree>isSameType(variableTree).matches(parameter, state)) {
Compound otherParamsAssisted = null;
for (Compound c : ASTHelpers.getSymbol(parameter).getAnnotationMirrors()) {
if (((TypeElement) c.getAnnotationType().asElement()).getQualifiedName()
.contentEquals(ASSISTED_ANNOTATION)) {
otherParamsAssisted = c;
}
}
if (otherParamsAssisted != null) {
if (thisParamsAssisted.getElementValues().isEmpty()
&& otherParamsAssisted.getElementValues().isEmpty()) {
//both have unnamed @Assisted annotations
numIdentical++;
}
//if value is specified, check that they are equal
//also, there can only be one value which is why I didn't check for equality
//in both directions
for (MethodSymbol m : thisParamsAssisted.getElementValues().keySet())
if (otherParamsAssisted.getElementValues().get(m).getValue()
.equals(thisParamsAssisted.getElementValues().get(m).getValue())) {
numIdentical++;
}
}
if (numIdentical > 1) {