Example usage for org.eclipse.jdt.core.search FieldReferenceMatch FieldReferenceMatch

List of usage examples for org.eclipse.jdt.core.search FieldReferenceMatch FieldReferenceMatch

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.search FieldReferenceMatch FieldReferenceMatch.

Prototype

public FieldReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length,
        boolean isReadAccess, boolean isWriteAccess, boolean insideDocComment, SearchParticipant participant,
        IResource resource) 

Source Link

Document

Creates a new field reference match.

Usage

From source file:org.eclipse.ajdt.internal.core.search.ITDReferenceVisitor.java

License:Open Source License

private void checkFieldPattern(SimpleName name) {
    boolean isWrite = (name.getParent().getNodeType() == ASTNode.ASSIGNMENT
            && ((Assignment) name.getParent()).getLeftHandSide() == name);

    if (fieldPattern != null && String.valueOf(fieldPattern.getIndexKey()).equals(name.getIdentifier())) {
        definitiveMatches.add(new FieldReferenceMatch(itd, SearchMatch.A_ACCURATE, name.getStartPosition(),
                name.getLength(), !isWrite, isWrite, name.getParent().getNodeType() == ASTNode.MEMBER_REF,
                participant, itd.getResource()));
    }/*from w ww .j a v a 2s.c om*/
}

From source file:org.eclipse.jdt.internal.core.search.matching.MatchLocator.java

License:Open Source License

public FieldReferenceMatch newFieldReferenceMatch(IJavaElement enclosingElement, IJavaElement localElement,
        Binding enclosingBinding, int accuracy, int offset, int length, ASTNode reference) {
    int bits = reference.bits;
    boolean isCompoundAssigned = (bits & ASTNode.IsCompoundAssigned) != 0;
    boolean isReadAccess = isCompoundAssigned || (bits & ASTNode.IsStrictlyAssigned) == 0;
    boolean isWriteAccess = isCompoundAssigned || (bits & ASTNode.IsStrictlyAssigned) != 0;
    if (isWriteAccess) {
        if (reference instanceof QualifiedNameReference) {
            char[][] tokens = ((QualifiedNameReference) reference).tokens;
            char[] lastToken = tokens[tokens.length - 1];
            if (this.pattern instanceof OrPattern) {
                SearchPattern[] patterns = ((OrPattern) this.pattern).patterns;
                for (int i = 0, pLength = patterns.length; i < pLength; i++) {
                    if (!this.patternLocator.matchesName(((VariablePattern) patterns[i]).name, lastToken)) {
                        isWriteAccess = false;
                        isReadAccess = true;
                    }/*w  ww. j  ava 2  s  .  co  m*/
                }
            } else if (!this.patternLocator.matchesName(((VariablePattern) this.pattern).name, lastToken)) {
                isWriteAccess = false;
                isReadAccess = true;
            }
        }
    }
    boolean insideDocComment = (bits & ASTNode.InsideJavadoc) != 0;
    SearchParticipant participant = getParticipant();
    IResource resource = this.currentPossibleMatch.resource;
    if (enclosingBinding != null) {
        enclosingElement = ((JavaElement) enclosingElement).resolved(enclosingBinding);
    }
    FieldReferenceMatch match = new FieldReferenceMatch(enclosingElement, accuracy, offset, length,
            isReadAccess, isWriteAccess, insideDocComment, participant, resource);
    match.setLocalElement(localElement);
    return match;
}