48cddcbba7b9cbe263c13e06a9408be6e571c485
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / codeassist / complete / CompletionOnFieldType.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 an type reference located as a potential return type for a class
16  * member, containing the cursor location.
17  * This node is only a fake-field wrapper of the actual completion node
18  * which is accessible as the fake-field type.
19  * e.g.
20  *
21  *      class X {
22  *    Obj[cursor]
23  *  }
24  *
25  *      ---> class X {
26  *         <CompleteOnType:Obj>;
27  *       }
28  *
29  * The source range is always of length 0.
30  * The arguments of the allocation expression are all the arguments defined
31  * before the cursor.
32  */
33  
34 import net.sourceforge.phpdt.internal.compiler.ast.FieldDeclaration;
35 import net.sourceforge.phpdt.internal.compiler.ast.TypeReference;
36 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
37 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
38
39 public class CompletionOnFieldType extends FieldDeclaration {
40         public boolean isLocalVariable;
41         
42 public CompletionOnFieldType(TypeReference type, boolean isLocalVariable){
43         super();
44         this.sourceStart = type.sourceStart;
45         this.sourceEnd = type.sourceEnd;
46         this.type = type;
47         this.name = NoChar;
48         this.isLocalVariable = isLocalVariable;
49 }
50 public TypeBinding getTypeBinding(Scope scope) {
51         if(type instanceof CompletionOnSingleTypeReference)
52                 throw new CompletionNodeFound(this, scope);
53         else // handle the qualified type ref directly
54                 return type.getTypeBinding(scope);
55 }
56 public String toString(int tab) {
57
58         return type.toString(tab);
59 }
60 }