01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.codeassist.select;
11:
12: /*
13: * Selection node build by the parser in any case it was intending to
14: * reduce a field reference containing the cursor.
15: * e.g.
16: *
17: * class X {
18: * void foo() {
19: * bar().[start]fred[end]
20: * }
21: * }
22: *
23: * ---> class X {
24: * void foo() {
25: * <SelectOnFieldReference:bar().fred>
26: * }
27: * }
28: *
29: */
30:
31: import org.eclipse.jdt.internal.compiler.ast.FieldReference;
32: import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
33: import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons;
34: import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
35:
36: public class SelectionOnFieldReference extends FieldReference {
37:
38: public SelectionOnFieldReference(char[] source, long pos) {
39:
40: super (source, pos);
41: }
42:
43: public StringBuffer printExpression(int indent, StringBuffer output) {
44:
45: output.append("<SelectionOnFieldReference:"); //$NON-NLS-1$
46: return super .printExpression(0, output).append('>');
47: }
48:
49: public TypeBinding resolveType(BlockScope scope) {
50:
51: super .resolveType(scope);
52: // tolerate some error cases
53: if (binding == null
54: || !(binding.isValidBinding()
55: || binding.problemId() == ProblemReasons.NotVisible
56: || binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName
57: || binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation || binding
58: .problemId() == ProblemReasons.NonStaticReferenceInStaticContext))
59: throw new SelectionNodeFound();
60: else
61: throw new SelectionNodeFound(binding);
62: }
63: }
|