01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.core.search;
11:
12: import org.eclipse.core.resources.IResource;
13: import org.eclipse.jdt.core.IJavaElement;
14:
15: /**
16: * A Java search match that represents a field reference.
17: * The element is the inner-most enclosing member that references this field.
18: * <p>
19: * This class is intended to be instantiated and subclassed by clients.
20: * </p>
21: *
22: * @since 3.0
23: */
24: public class FieldReferenceMatch extends SearchMatch {
25:
26: private boolean isReadAccess;
27: private boolean isWriteAccess;
28:
29: /**
30: * Creates a new field reference match.
31: *
32: * @param enclosingElement the inner-most enclosing member that references this field
33: * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
34: * @param offset the offset the match starts at, or -1 if unknown
35: * @param length the length of the match, or -1 if unknown
36: * @param isReadAccess whether the match represents a read access
37: * @param isWriteAccess whethre the match represents a write access
38: * @param insideDocComment <code>true</code> if this search match is inside a doc
39: * comment, and <code>false</code> otherwise
40: * @param participant the search participant that created the match
41: * @param resource the resource of the element
42: */
43: public FieldReferenceMatch(IJavaElement enclosingElement,
44: int accuracy, int offset, int length, boolean isReadAccess,
45: boolean isWriteAccess, boolean insideDocComment,
46: SearchParticipant participant, IResource resource) {
47: super (enclosingElement, accuracy, offset, length, participant,
48: resource);
49: this .isReadAccess = isReadAccess;
50: this .isWriteAccess = isWriteAccess;
51: setInsideDocComment(insideDocComment);
52: }
53:
54: /**
55: * Returns whether the field reference is a read access to the field.
56: * Note that a field reference can be read and written at once in case of compound assignments (e.g. i += 0;)
57: *
58: * @return whether the field reference is a read access to the field.
59: */
60: public final boolean isReadAccess() {
61: return this .isReadAccess;
62: }
63:
64: /**
65: * Returns whether the field reference is a write access to the field.
66: * Note that a field reference can be read and written at once in case of compound assignments (e.g. i += 0;)
67: *
68: * @return whether the field reference is a write access to the field.
69: */
70: public final boolean isWriteAccess() {
71: return this.isWriteAccess;
72: }
73:
74: }
|