deleted: export="true"
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / codeassist / select / SelectionOnSingleTypeReference.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 type reference containing the selection identifier as a single
16  * name reference.
17  * e.g.
18  *
19  *      class X extends [start]Object[end]
20  *
21  *      ---> class X extends <SelectOnType:Object>
22  *
23  */
24  
25 import net.sourceforge.phpdt.internal.compiler.ast.SingleTypeReference;
26 import net.sourceforge.phpdt.internal.compiler.lookup.Binding;
27 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
28 import net.sourceforge.phpdt.internal.compiler.lookup.ProblemReasons;
29 import net.sourceforge.phpdt.internal.compiler.lookup.ReferenceBinding;
30 import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
31 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
32
33 public class SelectionOnSingleTypeReference extends SingleTypeReference {
34 public SelectionOnSingleTypeReference(char[] source, long pos) {
35         super(source, pos);
36 }
37 public void aboutToResolve(Scope scope) {
38         getTypeBinding(scope.parent); // step up from the ClassScope
39 }
40 public TypeBinding getTypeBinding(Scope scope) {
41         // it can be a package, type or member type
42         Binding binding = scope.getTypeOrPackage(new char[][] {token});
43         if (!binding.isValidBinding()) {
44                 scope.problemReporter().invalidType(this, (TypeBinding) binding);
45                 throw new SelectionNodeFound();
46         }
47
48         throw new SelectionNodeFound(binding);
49 }
50 public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) {
51         super.resolveTypeEnclosing(scope, enclosingType);
52
53                 // tolerate some error cases
54                 if (binding == null || 
55                                 !(binding.isValidBinding() || 
56                                         binding.problemId() == ProblemReasons.NotVisible))
57                 throw new SelectionNodeFound();
58         else
59                 throw new SelectionNodeFound(binding);
60 }
61 public String toStringExpression(int tab){
62
63         return "<SelectOnType:" + new String(token) + ">" ; //$NON-NLS-2$ //$NON-NLS-1$
64 }
65 }