001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.jdt.core.search;
011:
012: import org.eclipse.core.resources.IResource;
013: import org.eclipse.jdt.core.IJavaElement;
014:
015: /**
016: * A Java search match that represents a method reference.
017: * The element is the inner-most enclosing member that references this method.
018: * <p>
019: * This class is intended to be instantiated and subclassed by clients.
020: * </p>
021: *
022: * @since 3.0
023: */
024: public class MethodReferenceMatch extends SearchMatch {
025: private boolean constructor;
026: private boolean synthetic;
027: private boolean super Invocation;
028:
029: /**
030: * Creates a new method reference match.
031: *
032: * @param enclosingElement the inner-most enclosing member that references this method
033: * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
034: * @param offset the offset the match starts at, or -1 if unknown
035: * @param length the length of the match, or -1 if unknown
036: * @param insideDocComment <code>true</code> if this search match is inside a doc
037: * comment, and <code>false</code> otherwise
038: * @param participant the search participant that created the match
039: * @param resource the resource of the element
040: */
041: public MethodReferenceMatch(IJavaElement enclosingElement,
042: int accuracy, int offset, int length,
043: boolean insideDocComment, SearchParticipant participant,
044: IResource resource) {
045: super (enclosingElement, accuracy, offset, length, participant,
046: resource);
047: setInsideDocComment(insideDocComment);
048: }
049:
050: /**
051: * Creates a new method reference match.
052: *
053: * @param enclosingElement the inner-most enclosing member that references this method
054: * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
055: * @param offset the offset the match starts at, or -1 if unknown
056: * @param length the length of the match, or -1 if unknown
057: * @param constructor <code>true</code> if this search match a constructor
058: * <code>false</code> otherwise
059: * @param synthetic <code>true</code> if this search match a synthetic element
060: * <code>false</code> otherwise
061: * @param insideDocComment <code>true</code> if this search match is inside a doc
062: * comment, and <code>false</code> otherwise
063: * @param participant the search participant that created the match
064: * @param resource the resource of the element
065: * @since 3.1
066: */
067: public MethodReferenceMatch(IJavaElement enclosingElement,
068: int accuracy, int offset, int length, boolean constructor,
069: boolean synthetic, boolean insideDocComment,
070: SearchParticipant participant, IResource resource) {
071: this (enclosingElement, accuracy, offset, length,
072: insideDocComment, participant, resource);
073: this .constructor = constructor;
074: this .synthetic = synthetic;
075: }
076:
077: /**
078: * Creates a new method reference match.
079: *
080: * @param enclosingElement the inner-most enclosing member that references this method
081: * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
082: * @param offset the offset the match starts at, or -1 if unknown
083: * @param length the length of the match, or -1 if unknown
084: * @param constructor <code>true</code> if this search matches a constructor
085: * <code>false</code> otherwise
086: * @param synthetic <code>true</code> if this search matches a synthetic element
087: * <code>false</code> otherwise
088: * @param superInvocation <code>true</code> if this search matches a super-type invocation
089: * element <code>false</code> otherwise
090: * @param insideDocComment <code>true</code> if this search match is inside a doc
091: * comment, and <code>false</code> otherwise
092: * @param participant the search participant that created the match
093: * @param resource the resource of the element
094: * @since 3.3
095: */
096: public MethodReferenceMatch(IJavaElement enclosingElement,
097: int accuracy, int offset, int length, boolean constructor,
098: boolean synthetic, boolean super Invocation,
099: boolean insideDocComment, SearchParticipant participant,
100: IResource resource) {
101: this (enclosingElement, accuracy, offset, length, constructor,
102: synthetic, insideDocComment, participant, resource);
103: this .super Invocation = super Invocation;
104: }
105:
106: /**
107: * Returns whether the reference is on a constructor.
108: *
109: * @return Returns whether the reference is on a constructor or not.
110: * @since 3.1
111: */
112: public final boolean isConstructor() {
113: return this .constructor;
114: }
115:
116: /**
117: * Returns whether the reference is on a synthetic element.
118: * Note that this field is only used for constructor reference. This happens when default constructor
119: * declaration is used or implicit super constructor is called.
120: *
121: * @return whether the reference is synthetic or not.
122: * @since 3.1
123: */
124: public final boolean isSynthetic() {
125: return this .synthetic;
126: }
127:
128: /**
129: * Returns whether the reference is on a message sent from a type
130: * which is a super type of the searched method declaring type.
131: * If <code>true</code>, the method called at run-time may or may not be
132: * the search target, depending on the run-time type of the receiver object.
133: *
134: * @return <code>true</code> if the reference is on a message sent from
135: * a super-type of the searched method declaring class, <code>false </code> otherwise
136: * @since 3.3
137: */
138: public boolean isSuperInvocation() {
139: return this.superInvocation;
140: }
141: }
|