*** empty log message ***
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / codeassist / complete / CompletionOnMemberAccess.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 access to a member (field reference or message send) 
16  * containing the completion identifier.
17  * e.g.
18  *
19  *      class X {
20  *    void foo() {
21  *      bar().fred[cursor]
22  *    }
23  *  }
24  *
25  *      ---> class X {
26  *         void foo() {
27  *           <CompleteOnMemberAccess:bar().fred>
28  *         }
29  *       }
30  *
31  * The source range of the completion node denotes the source range
32  * which should be replaced by the completion.
33  */
34
35 import net.sourceforge.phpdt.internal.compiler.ast.FieldReference;
36 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
37 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
38
39 public class CompletionOnMemberAccess extends FieldReference {
40         
41         public CompletionOnMemberAccess(char[] source, long pos) {
42                 super(source, pos);
43         }
44         
45         public TypeBinding resolveType(BlockScope scope) {
46                 TypeBinding receiverType = receiver.resolveType(scope);
47                 if (receiverType == null || receiverType.isBaseType())
48                         throw new CompletionNodeFound();
49                 else
50                         throw new CompletionNodeFound(this, receiverType, scope);
51                 // array types are passed along to find the length field
52         }
53         
54         public String toStringExpression() {
55
56                 return "<CompleteOnMemberAccess:" //$NON-NLS-1$
57                                                 + super.toStringExpression() + ">"; //$NON-NLS-1$
58         }
59 }