KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > codeassist > select > SelectionOnFieldReference


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.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 org.eclipse.jdt.internal.compiler.ast.FieldReference;
33 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
34 import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
35 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
36
37 public class SelectionOnFieldReference extends FieldReference {
38     
39     public SelectionOnFieldReference(char[] source , long pos) {
40
41         super(source, pos);
42     }
43     
44     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output){
45         
46         output.append("<SelectionOnFieldReference:"); //$NON-NLS-1$
47
return super.printExpression(0, output).append('>');
48     }
49     
50     public TypeBinding resolveType(BlockScope scope) {
51
52         super.resolveType(scope);
53         // tolerate some error cases
54
if (binding == null ||
55                 !(binding.isValidBinding() ||
56                     binding.problemId() == ProblemReasons.NotVisible
57                     || binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName
58                     || binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation
59                     || binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext))
60             throw new SelectionNodeFound();
61         else
62             throw new SelectionNodeFound(binding);
63     }
64 }
65
Popular Tags