KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > lookup > Binding


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.compiler.lookup;
12
13 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
14
15 public abstract class Binding {
16
17     // binding kinds
18
public static final int FIELD = ASTNode.Bit1;
19     public static final int LOCAL = ASTNode.Bit2;
20     public static final int VARIABLE = FIELD | LOCAL;
21     public static final int TYPE = ASTNode.Bit3;
22     public static final int METHOD = ASTNode.Bit4;
23     public static final int PACKAGE = ASTNode.Bit5;
24     public static final int IMPORT = ASTNode.Bit6;
25     public static final int ARRAY_TYPE = TYPE | ASTNode.Bit7;
26     public static final int BASE_TYPE = TYPE | ASTNode.Bit8;
27     public static final int PARAMETERIZED_TYPE = TYPE | ASTNode.Bit9;
28     public static final int WILDCARD_TYPE = TYPE | ASTNode.Bit10;
29     public static final int RAW_TYPE = TYPE | ASTNode.Bit11;
30     public static final int GENERIC_TYPE = TYPE | ASTNode.Bit12;
31     public static final int TYPE_PARAMETER = TYPE | ASTNode.Bit13;
32     
33     // Shared binding collections
34
public static final TypeBinding[] NO_TYPES = new TypeBinding[0];
35     public static final TypeBinding[] NO_PARAMETERS = new TypeBinding[0];
36     public static final ReferenceBinding[] NO_EXCEPTIONS = new ReferenceBinding[0];
37     public static final ReferenceBinding[] ANY_EXCEPTION = new ReferenceBinding[] { null }; // special handler for all exceptions
38
public static final FieldBinding[] NO_FIELDS = new FieldBinding[0];
39     public static final MethodBinding[] NO_METHODS = new MethodBinding[0];
40     public static final ReferenceBinding[] NO_SUPERINTERFACES = new ReferenceBinding[0];
41     public static final ReferenceBinding[] NO_MEMBER_TYPES = new ReferenceBinding[0];
42     public static final TypeVariableBinding[] NO_TYPE_VARIABLES = new TypeVariableBinding[0];
43     public static final AnnotationBinding[] NO_ANNOTATIONS = new AnnotationBinding[0];
44     public static final ElementValuePair[] NO_ELEMENT_VALUE_PAIRS = new ElementValuePair[0];
45
46     /*
47     * Answer the receiver's binding type from Binding.BindingID.
48     */

49     public abstract int kind();
50     /*
51      * Computes a key that uniquely identifies this binding.
52      * Returns null if binding is not a TypeBinding, a MethodBinding, a FieldBinding or a PackageBinding.
53      */

54     public char[] computeUniqueKey() {
55         return computeUniqueKey(true/*leaf*/);
56     }
57     /*
58      * Computes a key that uniquely identifies this binding. Optinaly include access flags.
59      * Returns null if binding is not a TypeBinding, a MethodBinding, a FieldBinding or a PackageBinding.
60      */

61     public char[] computeUniqueKey(boolean isLeaf) {
62         return null;
63     }
64     
65     /**
66      * Compute the tagbits for standard annotations. For source types, these could require
67      * lazily resolving corresponding annotation nodes, in case of forward references.
68      * @see org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding#getAnnotationTagBits()
69      */

70     public long getAnnotationTagBits() {
71         return 0;
72     }
73     
74     /**
75      * Compute the tag bits for @Deprecated annotations, avoiding resolving
76      * entire annotation if not necessary.
77      * @see org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding#initializeDeprecatedAnnotationTagBits()
78      */

79     public void initializeDeprecatedAnnotationTagBits() {
80         // empty block
81
}
82
83     /* API
84     * Answer true if the receiver is not a problem binding
85     */

86     public final boolean isValidBinding() {
87         return problemId() == ProblemReasons.NoError;
88     }
89     /* API
90     * Answer the problem id associated with the receiver.
91     * NoError if the receiver is a valid binding.
92     */

93     // TODO (philippe) should rename into problemReason()
94
public int problemId() {
95         return ProblemReasons.NoError;
96     }
97     /* Answer a printable representation of the receiver.
98     */

99     public abstract char[] readableName();
100     /* Shorter printable representation of the receiver (no qualified type)
101      */

102     public char[] shortReadableName(){
103         return readableName();
104     }
105 }
106
Popular Tags