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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.text.java;
13 import org.eclipse.core.runtime.Assert;
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;
22 * Proposal info that computes the javadoc lazily when it is queried.
26 public abstract class MemberProposalInfo extends ProposalInfo {
28 protected final IJavaProject fJavaProject;
29 protected final CompletionProposal fProposal;
31 /* cache filled lazily */
32 private boolean fJavaElementResolved= false;
35 * Creates a new proposal info.
37 * @param project the java project to reference when resolving types
38 * @param proposal the proposal to generate information for
40 public MemberProposalInfo(IJavaProject project, CompletionProposal proposal) {
41 Assert.isNotNull(project);
42 Assert.isNotNull(proposal);
43 fJavaProject= project;
48 * Returns the java element that this computer corresponds to, possibly <code>null</code>.
50 * @return the java element that this computer corresponds to, possibly <code>null</code>
51 * @throws JavaModelException if accessing the java model fails
54 public IJavaElement getJavaElement() throws JavaModelException {
55 if (!fJavaElementResolved) {
56 fJavaElementResolved= true;
57 fElement= resolveMember();
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.
66 * @return the resolved member or <code>null</code> if none is found
67 * @throws JavaModelException if accessing the java model fails
69 protected abstract IMember resolveMember() throws JavaModelException;