]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/ui/org/eclipse/jdt/internal/ui/text/java/MemberProposalInfo.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / internal / ui / text / java / MemberProposalInfo.java
1 /*******************************************************************************
2  * Copyright (c) 2005, 2011 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 if accessing the java model fails
52          */
53         @Override
54         public IJavaElement getJavaElement() throws JavaModelException {
55                 if (!fJavaElementResolved) {
56                         fJavaElementResolved= true;
57                         fElement= resolveMember();
58                 }
59                 return fElement;
60         }
61
62         /**
63          * Resolves the member described by the receiver and returns it if found.
64          * Returns <code>null</code> if no corresponding member can be found.
65          *
66          * @return the resolved member or <code>null</code> if none is found
67          * @throws JavaModelException if accessing the java model fails
68          */
69         protected abstract IMember resolveMember() throws JavaModelException;
70
71
72 }