@Override protected int matchReference(Reference node, MatchingNodeSet nodeSet, boolean writeOnlyAccess) { if (node instanceof FieldReference) { if (matchesName(this.pattern.name, ((FieldReference) node).token)) return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); return IMPOSSIBLE_MATCH; } return super.matchReference(node, nodeSet, writeOnlyAccess); } @Override
protected int matchReference(Reference node, MatchingNodeSet nodeSet, boolean writeOnlyAccess) { if (node instanceof FieldReference) { if (matchesName(this.pattern.name, ((FieldReference) node).token)) return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); return IMPOSSIBLE_MATCH; } return super.matchReference(node, nodeSet, writeOnlyAccess); } protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
protected int matchReference(Reference node, MatchingNodeSet nodeSet, boolean writeOnlyAccess) { if (node instanceof FieldReference) { if (matchesName(this.pattern.name, ((FieldReference) node).token)) return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); return IMPOSSIBLE_MATCH; } return super.matchReference(node, nodeSet, writeOnlyAccess); } protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
public int match(FieldDeclaration node, MatchingNodeSet nodeSet) { int referencesLevel = IMPOSSIBLE_MATCH; if (this.pattern.findReferences) // must be a write only access with an initializer if (this.pattern.writeAccess && !this.pattern.readAccess && node.initialization != null) if (matchesName(this.pattern.name, node.name)) referencesLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; int declarationsLevel = IMPOSSIBLE_MATCH; if (this.pattern.findDeclarations) { switch (node.getKind()) { case AbstractVariableDeclaration.FIELD : case AbstractVariableDeclaration.ENUM_CONSTANT : if (matchesName(this.pattern.name, node.name)) if (matchesTypeReference(((FieldPattern)this.pattern).typeSimpleName, node.type)) declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; break; } } return nodeSet.addMatch(node, referencesLevel >= declarationsLevel ? referencesLevel : declarationsLevel); // use the stronger match } //public int match(MethodDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
public int match(FieldDeclaration node, MatchingNodeSet nodeSet) { int referencesLevel = IMPOSSIBLE_MATCH; if (this.pattern.findReferences) // must be a write only access with an initializer if (this.pattern.writeAccess && !this.pattern.readAccess && node.initialization != null) if (matchesName(this.pattern.name, node.name)) referencesLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; int declarationsLevel = IMPOSSIBLE_MATCH; if (this.pattern.findDeclarations) { switch (node.getKind()) { case AbstractVariableDeclaration.FIELD : case AbstractVariableDeclaration.ENUM_CONSTANT : if (matchesName(this.pattern.name, node.name)) if (matchesTypeReference(((FieldPattern)this.pattern).typeSimpleName, node.type)) declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; break; } } return nodeSet.addMatch(node, referencesLevel >= declarationsLevel ? referencesLevel : declarationsLevel); // use the stronger match } //public int match(MethodDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
protected int matchReference(Reference node, MatchingNodeSet nodeSet, boolean writeOnlyAccess) { if (node instanceof FieldReference) { if (matchesName(this.pattern.name, ((FieldReference) node).token)) return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); return IMPOSSIBLE_MATCH; } return super.matchReference(node, nodeSet, writeOnlyAccess); } protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
protected int matchReference(Reference node, MatchingNodeSet nodeSet, boolean writeOnlyAccess) { if (node instanceof FieldReference) { if (matchesName(this.pattern.name, ((FieldReference) node).token)) return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); return IMPOSSIBLE_MATCH; } return super.matchReference(node, nodeSet, writeOnlyAccess); } protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
protected int matchReference(Reference node, MatchingNodeSet nodeSet, boolean writeOnlyAccess) { if (node instanceof FieldReference) { if (matchesName(this.pattern.name, ((FieldReference) node).token)) return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); return IMPOSSIBLE_MATCH; } return super.matchReference(node, nodeSet, writeOnlyAccess); } protected void matchReportReference(ASTNode reference, IJavaElement element, Binding elementBinding, int accuracy, MatchLocator locator) throws CoreException {
public int match(FieldDeclaration node, MatchingNodeSet nodeSet) { int referencesLevel = IMPOSSIBLE_MATCH; if (this.pattern.findReferences) // must be a write only access with an initializer if (this.pattern.writeAccess && !this.pattern.readAccess && node.initialization != null) if (matchesName(this.pattern.name, node.name)) referencesLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; int declarationsLevel = IMPOSSIBLE_MATCH; if (this.pattern.findDeclarations) { switch (node.getKind()) { case AbstractVariableDeclaration.FIELD : case AbstractVariableDeclaration.ENUM_CONSTANT : if (matchesName(this.pattern.name, node.name)) if (matchesTypeReference(((FieldPattern)this.pattern).typeSimpleName, node.type)) declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; break; } } return nodeSet.addMatch(node, referencesLevel >= declarationsLevel ? referencesLevel : declarationsLevel); // use the stronger match } //public int match(MethodDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
public int match(FieldDeclaration node, MatchingNodeSet nodeSet) { int referencesLevel = IMPOSSIBLE_MATCH; if (this.pattern.findReferences) // must be a write only access with an initializer if (this.pattern.writeAccess && !this.pattern.readAccess && node.initialization != null) if (matchesName(this.pattern.name, node.name)) referencesLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; int declarationsLevel = IMPOSSIBLE_MATCH; if (this.pattern.findDeclarations) { switch (node.getKind()) { case AbstractVariableDeclaration.FIELD : case AbstractVariableDeclaration.ENUM_CONSTANT : if (matchesName(this.pattern.name, node.name)) if (matchesTypeReference(((FieldPattern)this.pattern).typeSimpleName, node.type)) declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; break; } } return nodeSet.addMatch(node, referencesLevel >= declarationsLevel ? referencesLevel : declarationsLevel); // use the stronger match } //public int match(MethodDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
public int match(FieldDeclaration node, MatchingNodeSet nodeSet) { int referencesLevel = IMPOSSIBLE_MATCH; if (this.pattern.findReferences) // must be a write only access with an initializer if (this.pattern.writeAccess && !this.pattern.readAccess && node.initialization != null) if (matchesName(this.pattern.name, node.name)) referencesLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; int declarationsLevel = IMPOSSIBLE_MATCH; if (this.pattern.findDeclarations) { switch (node.getKind()) { case AbstractVariableDeclaration.FIELD : case AbstractVariableDeclaration.ENUM_CONSTANT : if (matchesName(this.pattern.name, node.name)) if (matchesTypeReference(((FieldPattern)this.pattern).typeSimpleName, node.type)) declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; break; } } return nodeSet.addMatch(node, referencesLevel >= declarationsLevel ? referencesLevel : declarationsLevel); // use the stronger match } //public int match(MethodDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
@Override public int match(FieldDeclaration node, MatchingNodeSet nodeSet) { int referencesLevel = IMPOSSIBLE_MATCH; if (this.pattern.findReferences) // must be a write only access with an initializer if (this.pattern.writeAccess && !this.pattern.readAccess && node.initialization != null) if (matchesName(this.pattern.name, node.name)) referencesLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; int declarationsLevel = IMPOSSIBLE_MATCH; if (this.pattern.findDeclarations) { switch (node.getKind()) { case AbstractVariableDeclaration.FIELD : case AbstractVariableDeclaration.ENUM_CONSTANT : if (matchesName(this.pattern.name, node.name)) if (matchesTypeReference(((FieldPattern)this.pattern).typeSimpleName, node.type)) declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; break; } } return nodeSet.addMatch(node, referencesLevel >= declarationsLevel ? referencesLevel : declarationsLevel); // use the stronger match } //public int match(MethodDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
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 field 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.name, importRef.tokens[length])) { char[][] compoundName = new char[length][]; System.arraycopy(importRef.tokens, 0, compoundName, 0, length); FieldPattern fieldPattern = (FieldPattern) this.pattern; char[] declaringType = CharOperation.concat(fieldPattern.declaringQualification, fieldPattern.declaringSimpleName, '.'); if (matchesName(declaringType, CharOperation.concatWith(compoundName, '.'))) { declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; } } } } return nodeSet.addMatch(node, declarationsLevel); } //public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
@Override 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 field 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.name, importRef.tokens[length])) { char[][] compoundName = new char[length][]; System.arraycopy(importRef.tokens, 0, compoundName, 0, length); FieldPattern fieldPattern = (FieldPattern) this.pattern; char[] declaringType = CharOperation.concat(fieldPattern.declaringQualification, fieldPattern.declaringSimpleName, '.'); if (matchesName(declaringType, CharOperation.concatWith(compoundName, '.'))) { declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; } } } } return nodeSet.addMatch(node, declarationsLevel); } //public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
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 field 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.name, importRef.tokens[length])) { char[][] compoundName = new char[length][]; System.arraycopy(importRef.tokens, 0, compoundName, 0, length); FieldPattern fieldPattern = (FieldPattern) this.pattern; char[] declaringType = CharOperation.concat(fieldPattern.declaringQualification, fieldPattern.declaringSimpleName, '.'); if (matchesName(declaringType, CharOperation.concatWith(compoundName, '.'))) { declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; } } } } return nodeSet.addMatch(node, declarationsLevel); } //public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
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 field 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.name, importRef.tokens[length])) { char[][] compoundName = new char[length][]; System.arraycopy(importRef.tokens, 0, compoundName, 0, length); FieldPattern fieldPattern = (FieldPattern) this.pattern; char[] declaringType = CharOperation.concat(fieldPattern.declaringQualification, fieldPattern.declaringSimpleName, '.'); if (matchesName(declaringType, CharOperation.concatWith(compoundName, '.'))) { declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; } } } } return nodeSet.addMatch(node, declarationsLevel); } //public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
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 field 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.name, importRef.tokens[length])) { char[][] compoundName = new char[length][]; System.arraycopy(importRef.tokens, 0, compoundName, 0, length); FieldPattern fieldPattern = (FieldPattern) this.pattern; char[] declaringType = CharOperation.concat(fieldPattern.declaringQualification, fieldPattern.declaringSimpleName, '.'); if (matchesName(declaringType, CharOperation.concatWith(compoundName, '.'))) { declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; } } } } return nodeSet.addMatch(node, declarationsLevel); } //public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
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 field 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.name, importRef.tokens[length])) { char[][] compoundName = new char[length][]; System.arraycopy(importRef.tokens, 0, compoundName, 0, length); FieldPattern fieldPattern = (FieldPattern) this.pattern; char[] declaringType = CharOperation.concat(fieldPattern.declaringQualification, fieldPattern.declaringSimpleName, '.'); if (matchesName(declaringType, CharOperation.concatWith(compoundName, '.'))) { declarationsLevel = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; } } } } return nodeSet.addMatch(node, declarationsLevel); } //public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
protected int resolveLevel(NameReference nameRef) { if (nameRef instanceof SingleNameReference) return resolveLevel(nameRef.binding); Binding binding = nameRef.binding; QualifiedNameReference qNameRef = (QualifiedNameReference) nameRef; FieldBinding fieldBinding = null; if (binding instanceof FieldBinding) { fieldBinding = (FieldBinding) binding; char[] bindingName = fieldBinding.name; int lastDot = CharOperation.lastIndexOf('.', bindingName); if (lastDot > -1) bindingName = CharOperation.subarray(bindingName, lastDot+1, bindingName.length); if (matchesName(this.pattern.name, bindingName)) { int level = matchField(fieldBinding, false); if (level != IMPOSSIBLE_MATCH) return level; } } int otherMax = qNameRef.otherBindings == null ? 0 : qNameRef.otherBindings.length; for (int i = 0; i < otherMax; i++) { char[] token = qNameRef.tokens[i + qNameRef.indexOfFirstFieldBinding]; if (matchesName(this.pattern.name, token)) { FieldBinding otherBinding = qNameRef.otherBindings[i]; int level = matchField(otherBinding, false); if (level != IMPOSSIBLE_MATCH) return level; } } return IMPOSSIBLE_MATCH; } /* (non-Javadoc)
protected int matchField(FieldBinding field, boolean matchName) { if (field == null) return INACCURATE_MATCH; if (matchName && !matchesName(this.pattern.name, field.readableName())) return IMPOSSIBLE_MATCH;