deleted: export="true"
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / codeassist / select / SelectionOnFieldReference.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.select;
12
13 /*
14  * Selection node build by the parser in any case it was intending to
15  * reduce a field reference containing the cursor.
16  * e.g.
17  *
18  *      class X {
19  *    void foo() {
20  *      bar().[start]fred[end]
21  *    }
22  *  }
23  *
24  *      ---> class X {
25  *         void foo() {
26  *           <SelectOnFieldReference:bar().fred>
27  *         }
28  *       }
29  *
30  */
31  
32 import net.sourceforge.phpdt.internal.compiler.ast.FieldReference;
33 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
34 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons;
35 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
36
37 public class SelectionOnFieldReference extends FieldReference {
38 public SelectionOnFieldReference(char[] source , long pos) {
39         super(source, pos);
40 }
41 public TypeBinding resolveType(BlockScope scope) {
42         super.resolveType(scope);
43
44                 // tolerate some error cases
45                 if (binding == null || 
46                                 !(binding.isValidBinding() || 
47                                         binding.problemId() == ProblemReasons.NotVisible
48                                         || binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName
49                                         || binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation
50                                         || binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext))
51                 throw new SelectionNodeFound();
52         else
53                 throw new SelectionNodeFound(binding);
54 }
55 public String toStringExpression(){
56         return  "<SelectionOnFieldReference:"  //$NON-NLS-1$
57                         + super.toStringExpression() 
58                         + ">"; //$NON-NLS-1$
59 }
60 }