a72d1f51113163c3b4adf8882dd39f5b92c9bf21
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / codeassist / complete / CompletionOnSingleTypeReference.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.codeassist.complete;
12
13 /*
14  * Completion node build by the parser in any case it was intending to
15  * reduce a type reference containing the completion identifier as a single
16  * name reference.
17  * e.g.
18  *
19  *      class X extends Obj[cursor]
20  *
21  *      ---> class X extends <CompleteOnType:Obj>
22  *
23  * The source range of the completion node denotes the source range
24  * which should be replaced by the completion.
25  */
26  
27 import net.sourceforge.phpdt.internal.compiler.ast.*;
28 import net.sourceforge.phpdt.internal.compiler.lookup.*;
29
30 public class CompletionOnSingleTypeReference extends SingleTypeReference {
31 public boolean isCompletionNode;
32 public CompletionOnSingleTypeReference(char[] source, long pos) {
33         super(source, pos);
34         isCompletionNode = true;
35 }
36 public void aboutToResolve(Scope scope) {
37         getTypeBinding(scope);
38 }
39 /*
40  * No expansion of the completion reference into an array one
41  */
42 public TypeReference copyDims(int dim){
43         return this;
44 }
45 public TypeBinding getTypeBinding(Scope scope) {
46         if(isCompletionNode) {
47                 throw new CompletionNodeFound(this, scope);
48         } else {
49                 return super.getTypeBinding(scope);
50         }
51 }
52 public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
53         if(isCompletionNode) {
54                 throw new CompletionNodeFound(this, enclosingType, scope);
55         } else {
56                 return super.resolveTypeEnclosing(scope, enclosingType);
57         }
58 }
59 public String toStringExpression(int tab){
60
61         return "<CompleteOnType:" + new String(token) + ">" ; //$NON-NLS-2$ //$NON-NLS-1$
62 }
63 }