KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > core > search > MethodReferenceMatch


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.core.search;
12
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.jdt.core.IJavaElement;
15
16 /**
17  * A Java search match that represents a method reference.
18  * The element is the inner-most enclosing member that references this method.
19  * <p>
20  * This class is intended to be instantiated and subclassed by clients.
21  * </p>
22  *
23  * @since 3.0
24  */

25 public class MethodReferenceMatch extends SearchMatch {
26     private boolean constructor;
27     private boolean synthetic;
28     private boolean superInvocation;
29
30     /**
31      * Creates a new method reference match.
32      *
33      * @param enclosingElement the inner-most enclosing member that references this method
34      * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
35      * @param offset the offset the match starts at, or -1 if unknown
36      * @param length the length of the match, or -1 if unknown
37      * @param insideDocComment <code>true</code> if this search match is inside a doc
38      * comment, and <code>false</code> otherwise
39      * @param participant the search participant that created the match
40      * @param resource the resource of the element
41      */

42     public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean insideDocComment, SearchParticipant participant, IResource resource) {
43         super(enclosingElement, accuracy, offset, length, participant, resource);
44         setInsideDocComment(insideDocComment);
45     }
46
47     /**
48      * Creates a new method reference match.
49      *
50      * @param enclosingElement the inner-most enclosing member that references this method
51      * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
52      * @param offset the offset the match starts at, or -1 if unknown
53      * @param length the length of the match, or -1 if unknown
54      * @param constructor <code>true</code> if this search match a constructor
55      * <code>false</code> otherwise
56      * @param synthetic <code>true</code> if this search match a synthetic element
57      * <code>false</code> otherwise
58      * @param insideDocComment <code>true</code> if this search match is inside a doc
59      * comment, and <code>false</code> otherwise
60      * @param participant the search participant that created the match
61      * @param resource the resource of the element
62      * @since 3.1
63      */

64     public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean constructor, boolean synthetic, boolean insideDocComment, SearchParticipant participant, IResource resource) {
65         this(enclosingElement, accuracy, offset, length, insideDocComment, participant, resource);
66         this.constructor = constructor;
67         this.synthetic = synthetic;
68     }
69
70     /**
71      * Creates a new method reference match.
72      *
73      * @param enclosingElement the inner-most enclosing member that references this method
74      * @param accuracy one of {@link #A_ACCURATE} or {@link #A_INACCURATE}
75      * @param offset the offset the match starts at, or -1 if unknown
76      * @param length the length of the match, or -1 if unknown
77      * @param constructor <code>true</code> if this search matches a constructor
78      * <code>false</code> otherwise
79      * @param synthetic <code>true</code> if this search matches a synthetic element
80      * <code>false</code> otherwise
81      * @param superInvocation <code>true</code> if this search matches a super-type invocation
82      * element <code>false</code> otherwise
83      * @param insideDocComment <code>true</code> if this search match is inside a doc
84      * comment, and <code>false</code> otherwise
85      * @param participant the search participant that created the match
86      * @param resource the resource of the element
87      * @since 3.3
88      */

89     public MethodReferenceMatch(IJavaElement enclosingElement, int accuracy, int offset, int length, boolean constructor, boolean synthetic, boolean superInvocation, boolean insideDocComment, SearchParticipant participant, IResource resource) {
90         this(enclosingElement, accuracy, offset, length, constructor, synthetic, insideDocComment, participant, resource);
91         this.superInvocation = superInvocation;
92     }
93
94     /**
95      * Returns whether the reference is on a constructor.
96      *
97      * @return Returns whether the reference is on a constructor or not.
98      * @since 3.1
99      */

100     public final boolean isConstructor() {
101         return this.constructor;
102     }
103     
104     /**
105      * Returns whether the reference is on a synthetic element.
106      * Note that this field is only used for constructor reference. This happens when default constructor
107      * declaration is used or implicit super constructor is called.
108      *
109      * @return whether the reference is synthetic or not.
110      * @since 3.1
111      */

112     public final boolean isSynthetic() {
113         return this.synthetic;
114     }
115
116     /**
117      * Returns whether the reference is on a message sent from a type
118      * which is a super type of the searched method declaring type.
119      * If <code>true</code>, the method called at run-time may or may not be
120      * the search target, depending on the run-time type of the receiver object.
121      *
122      * @return <code>true</code> if the reference is on a message sent from
123      * a super-type of the searched method declaring class, <code>false </code> otherwise
124      * @since 3.3
125      */

126     public boolean isSuperInvocation() {
127         return this.superInvocation;
128     }
129 }
130
Popular Tags