KickJava   Java API By Example, From Geeks To Geeks.

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


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.core.runtime.IStatus;
15 import org.eclipse.core.runtime.Status;
16 import org.eclipse.jdt.core.IType;
17 import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants;
18 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
19
20 /**
21  * Code completion for a type with position information and no locals.
22  *
23  * @since 3.2
24  */

25 public class TypeContext implements IJavaDebugContentAssistContext {
26     
27     private IType fType;
28     private int fPosition;
29     
30     /**
31      * Constructs a completion context on the given type.
32      *
33      * @param type type in which to perform completions
34      * @param insertionPoistion position in source to perform completions or -1
35      */

36     public TypeContext(IType type, int insertionPoistion) {
37         fType = type;
38         fPosition = insertionPoistion;
39     }
40
41     /* (non-Javadoc)
42      * @see org.eclipse.jdt.internal.debug.ui.text.IJavaDebugCompletionProcessorContext#getType()
43      */

44     public IType getType() throws CoreException {
45         if (fType == null) {
46             unableToResolveType();
47         }
48         return fType;
49     }
50
51     /**
52      * Throws an exception when unable to resolve a type
53      *
54      * @throws CoreException
55      */

56     protected void unableToResolveType() throws CoreException {
57         IStatus status = new Status(IStatus.INFO, JDIDebugUIPlugin.getUniqueIdentifier(), IJavaDebugUIConstants.INTERNAL_ERROR,
58                 Messages.TypeContext_0, null);
59         throw new CoreException(status);
60     }
61
62     /* (non-Javadoc)
63      * @see org.eclipse.jdt.internal.debug.ui.text.IJavaDebugCompletionProcessorContext#getInsertionPosition()
64      */

65     public int getInsertionPosition() throws CoreException {
66         return fPosition;
67     }
68
69     /* (non-Javadoc)
70      * @see org.eclipse.jdt.internal.debug.ui.text.IJavaDebugCompletionProcessorContext#getLocalVariables()
71      */

72     public String JavaDoc[][] getLocalVariables() throws CoreException {
73         return new String JavaDoc[0][];
74     }
75
76     /* (non-Javadoc)
77      * @see org.eclipse.jdt.internal.debug.ui.text.IJavaDebugCompletionProcessorContext#isStatic()
78      */

79     public boolean isStatic() throws CoreException {
80         return false;
81     }
82
83     /* (non-Javadoc)
84      * @see org.eclipse.jdt.internal.debug.ui.contentassist.IJavaDebugContentAssistContext#getSnippet(java.lang.String)
85      */

86     public String JavaDoc getSnippet(String JavaDoc snippet) throws CoreException {
87         return snippet;
88     }
89
90 }
91
Popular Tags