KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > java > MemberProposalInfo


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.internal.ui.text.java;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.jdt.core.CompletionProposal;
16 import org.eclipse.jdt.core.IJavaElement;
17 import org.eclipse.jdt.core.IJavaProject;
18 import org.eclipse.jdt.core.IMember;
19 import org.eclipse.jdt.core.JavaModelException;
20
21 /**
22  * Proposal info that computes the javadoc lazily when it is queried.
23  *
24  * @since 3.1
25  */

26 public abstract class MemberProposalInfo extends ProposalInfo {
27     /* configuration */
28     protected final IJavaProject fJavaProject;
29     protected final CompletionProposal fProposal;
30
31     /* cache filled lazily */
32     private boolean fJavaElementResolved= false;
33
34     /**
35      * Creates a new proposal info.
36      *
37      * @param project the java project to reference when resolving types
38      * @param proposal the proposal to generate information for
39      */

40     public MemberProposalInfo(IJavaProject project, CompletionProposal proposal) {
41         Assert.isNotNull(project);
42         Assert.isNotNull(proposal);
43         fJavaProject= project;
44         fProposal= proposal;
45     }
46
47     /**
48      * Returns the java element that this computer corresponds to, possibly <code>null</code>.
49      *
50      * @return the java element that this computer corresponds to, possibly <code>null</code>
51      * @throws JavaModelException
52      */

53     public IJavaElement getJavaElement() throws JavaModelException {
54         if (!fJavaElementResolved) {
55             fJavaElementResolved= true;
56             fElement= resolveMember();
57         }
58         return fElement;
59     }
60
61     /**
62      * Resolves the member described by the receiver and returns it if found.
63      * Returns <code>null</code> if no corresponding member can be found.
64      *
65      * @return the resolved member or <code>null</code> if none is found
66      * @throws JavaModelException if accessing the java model fails
67      */

68     protected abstract IMember resolveMember() throws JavaModelException;
69
70
71 }
72
Popular Tags