public int match(MemberValuePair node, MatchingNodeSet nodeSet) { if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; if (!matchesName(this.pattern.selector, node.name)) return IMPOSSIBLE_MATCH; return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); }
// public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) - SKIP IT // public int match(Expression node, MatchingNodeSet nodeSet) - SKIP IT // public int match(FieldDeclaration node, MatchingNodeSet nodeSet) - SKIP IT public int match(MethodDeclaration node, MatchingNodeSet nodeSet) { if (!this.pattern.findDeclarations) return IMPOSSIBLE_MATCH; // Verify method name if (!matchesName(this.pattern.selector, node.selector)) return IMPOSSIBLE_MATCH; // Verify parameters types boolean resolve = this.pattern.mustResolve; if (this.pattern.parameterSimpleNames != null) { int length = this.pattern.parameterSimpleNames.length; ASTNode[] args = node.arguments; int argsLength = args == null ? 0 : args.length; if (length != argsLength) return IMPOSSIBLE_MATCH; for (int i = 0; i < argsLength; i++) { if (args != null && !matchesTypeReference( this.pattern.parameterSimpleNames[i], ((Argument) args[i]).type)) { // Do not return as impossible when source level is at least 1.5 if (this.mayBeGeneric) { if (!this.pattern.mustResolve) { // Set resolution flag on node set in case of types was inferred in parameterized // types from generic ones... // (see bugs https://bugs.eclipse.org/bugs/show_bug.cgi?id=79990, 96761, 96763) nodeSet.mustResolve = true; resolve = true; } this.methodDeclarationsWithInvalidParam.put(node, null); } else { return IMPOSSIBLE_MATCH; } } } } // Verify type arguments (do not reject if pattern has no argument as it can be an erasure // match) if (this.pattern.hasMethodArguments()) { if (node.typeParameters == null || node.typeParameters.length != this.pattern.methodArguments.length) return IMPOSSIBLE_MATCH; } // Method declaration may match pattern return nodeSet.addMatch(node, resolve ? POSSIBLE_MATCH : ACCURATE_MATCH); }
public int match(MessageSend node, MatchingNodeSet nodeSet) { if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; if (!matchesName(this.pattern.selector, node.selector)) return IMPOSSIBLE_MATCH; if (this.pattern.parameterSimpleNames != null && (!this.pattern.varargs || ((node.bits & ASTNode.InsideJavadoc) != 0))) { int length = this.pattern.parameterSimpleNames.length; ASTNode[] args = node.arguments; int argsLength = args == null ? 0 : args.length; if (length != argsLength) return IMPOSSIBLE_MATCH; } return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); }
// public int match(Reference node, MatchingNodeSet nodeSet) - SKIP IT public int match(Annotation node, MatchingNodeSet nodeSet) { if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; MemberValuePair[] pairs = node.memberValuePairs(); if (pairs == null || pairs.length == 0) return IMPOSSIBLE_MATCH; int length = pairs.length; MemberValuePair pair = null; for (int i = 0; i < length; i++) { pair = node.memberValuePairs()[i]; if (matchesName(this.pattern.selector, pair.name)) { ASTNode possibleNode = (node instanceof SingleMemberAnnotation) ? (ASTNode) node : pair; return nodeSet.addMatch( possibleNode, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); } } return IMPOSSIBLE_MATCH; }
public int match(ASTNode node, MatchingNodeSet nodeSet) { int declarationsLevel = IMPOSSIBLE_MATCH; if (this.pattern.findReferences) { if (node instanceof ImportReference) { // With static import, we can have static method reference in import reference ImportReference importRef = (ImportReference) node; int length = importRef.tokens.length - 1; if (importRef.isStatic() && ((importRef.bits & ASTNode.OnDemand) == 0) && matchesName(this.pattern.selector, importRef.tokens[length])) { char[][] compoundName = new char[length][]; System.arraycopy(importRef.tokens, 0, compoundName, 0, length); char[] declaringType = CharOperation.concat( this.pattern.declaringQualification, this.pattern.declaringSimpleName, '.'); if (matchesName(declaringType, CharOperation.concatWith(compoundName, '.'))) { declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; } } } } return nodeSet.addMatch(node, declarationsLevel); }