1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.lookup;
13 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
15 public abstract class Binding implements CompilerModifiers, ProblemReasons {
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 PARAMETERIZED_TYPE = TYPE | ASTNode.Bit8;
27 public static final int WILDCARD_TYPE = TYPE | ASTNode.Bit9;
28 public static final int RAW_TYPE = TYPE | ASTNode.Bit10;
29 public static final int GENERIC_TYPE = TYPE | ASTNode.Bit11;
30 public static final int TYPE_PARAMETER = TYPE | ASTNode.Bit12;
31 public static final int ANNOTATION_BINDING = TYPE | ASTNode.Bit13; // for annotation refs
34 * Answer the receiver's binding type from Binding.BindingID.
36 * Note: Do NOT expect this to be used very often... only in switch statements with
37 * more than 2 possible choices.
39 public abstract int kind();
41 * Computes a key that uniquely identifies this binding.
42 * Returns null if binding is not a TypeBinding, a MethodBinding, a FieldBinding or a PackageBinding.
44 public char[] computeUniqueKey() {
48 public long getAnnotationTagBits() {
49 // TODO (philippe) need to generalize to methods & fields
54 * Answer true if the receiver is not a problem binding
56 public final boolean isValidBinding() {
57 return problemId() == NoError;
60 * Answer the problem id associated with the receiver.
61 * NoError if the receiver is a valid binding.
63 // TODO (philippe) should rename into problemReason()
64 public int problemId() {
67 /* Answer a printable representation of the receiver.
69 public abstract char[] readableName();
70 /* Shorter printable representation of the receiver (no qualified type)
72 public char[] shortReadableName(){
73 return readableName();