*** empty log message ***
[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.SingleTypeReference;
28 import net.sourceforge.phpdt.internal.compiler.ast.TypeReference;
29 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
30 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
31 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
32 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
33
34 public class CompletionOnSingleTypeReference extends SingleTypeReference {
35 public boolean isCompletionNode;
36 public CompletionOnSingleTypeReference(char[] source, long pos) {
37         super(source, pos);
38         isCompletionNode = true;
39 }
40 public void aboutToResolve(Scope scope) {
41         getTypeBinding(scope);
42 }
43 /*
44  * No expansion of the completion reference into an array one
45  */
46 public TypeReference copyDims(int dim){
47         return this;
48 }
49 public TypeBinding getTypeBinding(Scope scope) {
50         if(isCompletionNode) {
51                 throw new CompletionNodeFound(this, scope);
52         } else {
53                 return super.getTypeBinding(scope);
54         }
55 }
56 public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
57         if(isCompletionNode) {
58                 throw new CompletionNodeFound(this, enclosingType, scope);
59         } else {
60                 return super.resolveTypeEnclosing(scope, enclosingType);
61         }
62 }
63 public String toStringExpression(int tab){
64
65         return "<CompleteOnType:" + new String(token) + ">" ; //$NON-NLS-2$ //$NON-NLS-1$
66 }
67 }