@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
private void matchTypeReferences(MatchLocator locator, TypeReferencePattern typeReferencePattern, TypeBinding[] types) throws CoreException { if (types == null) return; for (TypeBinding type : types) { int level = locator.patternLocator.resolveLevel(type); if (level == PatternLocator.IMPOSSIBLE_MATCH) continue; int accuracy = level == PatternLocator.ACCURATE_MATCH ? SearchMatch.A_ACCURATE : SearchMatch.A_INACCURATE; TypeReferenceMatch match = locator.newTypeReferenceMatch(this.moduleDesc, null, accuracy, -1, 0, null); locator.report(match); } } }
@Override protected void consumeSingleStaticImportDeclarationName() { super.consumeSingleStaticImportDeclarationName(); if (this.reportImportMatch) { this.patternLocator.match(this.astStack[this.astPtr], this.nodeSet); } } @Override
private void reportPackageMatch(MatchLocator locator, PackageBinding packageBinding) throws CoreException{ if (packageBinding == null) return; int level = locator.patternLocator.resolveLevel(packageBinding); if (level == PatternLocator.IMPOSSIBLE_MATCH) return; int accuracy = level == PatternLocator.ACCURATE_MATCH ? SearchMatch.A_ACCURATE : SearchMatch.A_INACCURATE; PackageReferenceMatch match = locator.newPackageReferenceMatch(this.moduleDesc, accuracy, -1, 0, null); locator.report(match); } private void matchPackReferences(MatchLocator locator, PackageReferencePattern packReferencePattern,
@Override public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) { if (this.pattern.fineGrain != 0 && !this.pattern.findDeclarations) return IMPOSSIBLE_MATCH; int referencesLevel = this.pattern.findReferences ? matchLevelForReferences(node) : IMPOSSIBLE_MATCH; int declarationsLevel = this.pattern.findDeclarations ? matchLevelForDeclarations(node) : IMPOSSIBLE_MATCH; return nodeSet.addMatch(node, referencesLevel >= declarationsLevel ? referencesLevel : declarationsLevel); // use the stronger match } @Override
public int match(TypeReference node, MatchingNodeSet nodeSet) { // interested in QualifiedTypeReference only if (node instanceof JavadocSingleTypeReference) { char[][] tokens = new char[][] { ((JavadocSingleTypeReference) node).token }; return nodeSet.addMatch(node, matchLevelForTokens(tokens)); } if (!(node instanceof QualifiedTypeReference)) return IMPOSSIBLE_MATCH; return nodeSet.addMatch(node, matchLevelForTokens(((QualifiedTypeReference) node).tokens)); }
@Override public int match(TypeReference node, MatchingNodeSet nodeSet) { if (this.pattern.findReferences) { if (node instanceof SingleTypeReference) { // Type parameter cannot be qualified if (matchesName(this.pattern.name, ((SingleTypeReference) node).token)) { int level = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; return nodeSet.addMatch(node, level); } } } return IMPOSSIBLE_MATCH; }
/** * Reports the match of the given import reference. */ protected void matchReportImportRef(ImportReference importRef, Binding binding, IJavaElement element, int accuracy, MatchLocator locator) throws CoreException { if (locator.encloses(element)) { // default is to report a match as a regular ref. this.matchReportReference(importRef, element, null/*no binding*/, accuracy, locator); } } /**
public int match(ASTNode node, MatchingNodeSet nodeSet) { // interested in ImportReference if (!(node instanceof ImportReference)) return IMPOSSIBLE_MATCH; return nodeSet.addMatch(node, matchLevel((ImportReference) node)); } //public int match(ConstructorDeclaration node, MatchingNodeSet nodeSet) - SKIP IT
@Override protected void consumeStaticImportOnDemandDeclarationName() { super.consumeStaticImportOnDemandDeclarationName(); if (this.reportImportMatch) { this.patternLocator.match(this.astStack[this.astPtr], this.nodeSet); } } @Override
@Override protected void consumeTypeImportOnDemandDeclarationName() { super.consumeTypeImportOnDemandDeclarationName(); if (this.reportImportMatch) { this.patternLocator.match(this.astStack[this.astPtr], this.nodeSet); } }
@Override public int match(TypeDeclaration node, MatchingNodeSet nodeSet) { if (this.pattern.simpleName == null || matchesName(this.pattern.simpleName, node.name)) return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); return IMPOSSIBLE_MATCH; } //public int match(TypeReference node, MatchingNodeSet nodeSet) - SKIP IT
@Override public int match(ASTNode node, MatchingNodeSet nodeSet) { // interested in ExplicitConstructorCall if (!this.pattern.findReferences) return IMPOSSIBLE_MATCH; if (!(node instanceof ExplicitConstructorCall)) return IMPOSSIBLE_MATCH; if (!matchParametersCount(node, ((ExplicitConstructorCall) node).arguments)) return IMPOSSIBLE_MATCH; return nodeSet.addMatch(node, this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH); } @Override
public static MatchLocatorParser createParser(ProblemReporter problemReporter, MatchLocator locator) { if ((locator.matchContainer & PatternLocator.COMPILATION_UNIT_CONTAINER) != 0) { return new ImportMatchLocatorParser(problemReporter, locator); } return new MatchLocatorParser(problemReporter, locator); }
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 {
@Override public int match(TypeReference node, MatchingNodeSet nodeSet) { // interested in QualifiedTypeReference only if (node instanceof JavadocSingleTypeReference) { char[][] tokens = new char[][] { ((JavadocSingleTypeReference) node).token }; return nodeSet.addMatch(node, matchLevelForTokens(tokens)); } if (!(node instanceof QualifiedTypeReference)) return IMPOSSIBLE_MATCH; return nodeSet.addMatch(node, matchLevelForTokens(((QualifiedTypeReference) node).tokens)); }
@Override public int match(TypeParameter node, MatchingNodeSet nodeSet) { if (this.pattern.findDeclarations) { if (matchesName(this.pattern.name, node.name)) { int level = this.pattern.mustResolve ? POSSIBLE_MATCH : ACCURATE_MATCH; return nodeSet.addMatch(node, level); } } return IMPOSSIBLE_MATCH; }
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 {