KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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 type reference.
18  * The element is the inner-most enclosing member that references this type.
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 TypeReferenceMatch extends SearchMatch {
26
27     private IJavaElement localElement;
28     private IJavaElement[] otherElements;
29
30     /**
31      * Creates a new type reference match.
32      *
33      * @param enclosingElement the inner-most enclosing member that references this type
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 TypeReferenceMatch(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      * Returns the local element of this search match.
49      * This may be a local variable which declaring type is the referenced one
50      * or a type parameter which extends it.
51      *
52      * @return the element of the search match, or <code>null</code> if none or there's
53      * no more specific local element than the element itself ({@link SearchMatch#getElement()}).
54      * @since 3.2
55      */

56     public final IJavaElement getLocalElement() {
57         return this.localElement;
58     }
59
60     /**
61      * Returns other enclosing elements of this search match.
62      *
63      * If {@link #getLocalElement()} is not <code>null</code>, these may be other
64      * local elements such as additional local variables of a multiple local
65      * variables declaration. Otherwise, these may be other elements such as
66      * additional fields of a multiple fields declaration.
67      *
68      * @return the other elements of the search match, or <code>null</code> if none
69      * @since 3.2
70      */

71     public final IJavaElement[] getOtherElements() {
72         return this.otherElements;
73     }
74
75     /**
76      * Sets the local element of this search match.
77      *
78      * @param localElement A more specific local element that corresponds to the match,
79      * or <code>null</code> if none
80      * @since 3.2
81      */

82     public final void setLocalElement(IJavaElement localElement) {
83         this.localElement = localElement;
84     }
85
86     /**
87      * Sets the other elements of this search match.
88      *
89      * @param otherElements the other elements of the match,
90      * or <code>null</code> if none
91      * @since 3.2
92      */

93     public final void setOtherElements(IJavaElement[] otherElements) {
94         this.otherElements = otherElements;
95     }
96 }
97
Popular Tags