KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > contentassist > DynamicTypeContext


1 /*******************************************************************************
2  * Copyright (c) 2005 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.debug.ui.contentassist;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.jdt.core.IType;
15
16 /**
17  * Code completion for a dynamic type. Code completion is performed relative to the
18  * type with no position information, in a non-static context.
19  *
20  * @since 3.2
21  */

22 public class DynamicTypeContext extends TypeContext {
23     
24     /**
25      * Provides a type in which to perform completions.
26      * @since 3.2
27      */

28     public interface ITypeProvider {
29         /**
30          * Returns the type in which to perform completions or <code>null</code>
31          * if no type is available.
32          *
33          * @return type in which to perform completions or <code>null</code>
34          * @exception CoreException if a type cannot be resolved
35          */

36         public IType getType() throws CoreException;
37     }
38     
39     private ITypeProvider fTypeProvider;
40     
41     /**
42      * Constructs a completion context on the given type.
43      *
44      * @param type type in which to perform completions
45      */

46     public DynamicTypeContext(ITypeProvider type) {
47         super(null, -1);
48         fTypeProvider = type;
49     }
50
51     /* (non-Javadoc)
52      * @see org.eclipse.jdt.internal.debug.ui.text.IJavaDebugCompletionProcessorContext#getType()
53      */

54     public IType getType() throws CoreException {
55         IType type = fTypeProvider.getType();
56         if (type == null) {
57             return super.getType();
58         }
59         return type;
60     }
61
62 }
63
Popular Tags