Merged "Open PHP Declaration" and "Open Include File" into one action "Open Declarati...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / lookup / ReferenceBinding.java
index d72bc99..ab0d9cf 100644 (file)
@@ -1,17 +1,17 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
+ * Copyright (c) 2000, 2003 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v0.5 
+ * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
+ * http://www.eclipse.org/legal/cpl-v10.html
  * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
- ******************************************************************************/
+ *******************************************************************************/
 package net.sourceforge.phpdt.internal.compiler.lookup;
 
+import net.sourceforge.phpdt.core.compiler.CharOperation;
 import net.sourceforge.phpdt.internal.compiler.env.IDependent;
-import net.sourceforge.phpdt.internal.compiler.util.CharOperation;
 
 /*
 Not all fields defined by this type (& its subclasses) are initialized when it is created.
@@ -123,26 +123,22 @@ public final boolean canBeSeenBy(ReferenceBinding receiverType, SourceTypeBindin
        } while ((type = type.superclass()) != null);
        return false;
 }
-/* Answer true if the receiver is visible to the type provided by the scope.
-*
-* NOTE: Cannot invoke this method with a compilation unit scope.
-*/
+/* 
+ * Answer true if the receiver is visible to the type provided by the scope.
+ */
 
 public final boolean canBeSeenBy(Scope scope) {
+       
        if (isPublic()) return true;
 
+       if (scope.kind == Scope.COMPILATION_UNIT_SCOPE){
+               return this.canBeSeenBy(((CompilationUnitScope)scope).fPackage);
+       }
+       
        SourceTypeBinding invocationType = scope.enclosingSourceType();
        if (invocationType == this) return true;
 
        if (isProtected()) {
-               // answer true if the receiver (or its enclosing type) is the superclass 
-               //      of the invocationType or in the same package
-               return invocationType.fPackage == fPackage 
-                               || isSuperclassOf(invocationType)
-                               || enclosingType().isSuperclassOf(invocationType); // protected types always have an enclosing one
-       }
-
-       if (isProtected()) {
                // answer true if the invocationType is the declaringClass or they are in the same package
                // OR the invocationType is a subclass of the declaringClass
                //    AND the invocationType is the invocationType or its subclass
@@ -184,121 +180,121 @@ public final boolean canBeSeenBy(Scope scope) {
        // isDefault()
        return invocationType.fPackage == fPackage;
 }
-public void computeId() {
-       if (compoundName.length != 3) {
-               if (compoundName.length == 4 && CharOperation.equals(JAVA_LANG_REFLECT_CONSTRUCTOR, compoundName)) {
-                       id = T_JavaLangReflectConstructor;
-                       return;
-               }
-               return;         // all other types are in java.*.*
-       }
-
-       if (!CharOperation.equals(JAVA, compoundName[0]))
-               return;         // assumes we only look up types in java
-
-       if (!CharOperation.equals(LANG, compoundName[1])) {
-               if (CharOperation.equals(JAVA_IO_PRINTSTREAM, compoundName)) {
-                       id = T_JavaIoPrintStream;
-                       return;
-               }
-               return;         // all other types are in java.lang
-       }
-
-       if (CharOperation.equals(JAVA_LANG_OBJECT, compoundName)) {
-               id = T_JavaLangObject;
-               return;
-       }
-       if (CharOperation.equals(JAVA_LANG_STRING, compoundName)) {
-               id = T_JavaLangString;
-               return;
-       }
-
-       // well-known exception types
-       if (CharOperation.equals(JAVA_LANG_THROWABLE, compoundName)) {
-               id = T_JavaLangThrowable;
-               return;
-       }
-       if (CharOperation.equals(JAVA_LANG_ERROR, compoundName)) {
-               id = T_JavaLangError;
-               return;
-       }
-       if (CharOperation.equals(JAVA_LANG_EXCEPTION, compoundName)) {
-               id = T_JavaLangException;
-               return;
-       }
-       if (CharOperation.equals(JAVA_LANG_CLASSNOTFOUNDEXCEPTION, compoundName)) {
-               id = T_JavaLangClassNotFoundException;
-               return;
-       }
-       if (CharOperation.equals(JAVA_LANG_NOCLASSDEFERROR, compoundName)) {
-               id = T_JavaLangNoClassDefError;
-               return;
-       }
-
-       // other well-known types
-       if (CharOperation.equals(JAVA_LANG_CLASS, compoundName)) {
-               id = T_JavaLangClass;
-               return;
-       }
-       if (CharOperation.equals(JAVA_LANG_STRINGBUFFER, compoundName)) {
-               id = T_JavaLangStringBuffer;
-               return;
-       }
-       if (CharOperation.equals(JAVA_LANG_SYSTEM, compoundName)) {
-               id = T_JavaLangSystem;
-               return;
-       }
-
-       if (CharOperation.equals(JAVA_LANG_INTEGER, compoundName)) {
-               id = T_JavaLangInteger;
-               return;
-       }
-
-       if (CharOperation.equals(JAVA_LANG_BYTE, compoundName)) {
-               id = T_JavaLangByte;
-               return;
-       }       
-
-       if (CharOperation.equals(JAVA_LANG_CHARACTER, compoundName)) {
-               id = T_JavaLangCharacter;
-               return;
-       }
-
-       if (CharOperation.equals(JAVA_LANG_FLOAT, compoundName)) {
-               id = T_JavaLangFloat;
-               return;
-       }
-
-       if (CharOperation.equals(JAVA_LANG_DOUBLE, compoundName)) {
-               id = T_JavaLangDouble;
-               return;
-       }
-
-       if (CharOperation.equals(JAVA_LANG_BOOLEAN, compoundName)) {
-               id = T_JavaLangBoolean;
-               return;
-       }
-
-       if (CharOperation.equals(JAVA_LANG_SHORT, compoundName)) {
-               id = T_JavaLangShort;
-               return;
-       }
-
-       if (CharOperation.equals(JAVA_LANG_LONG, compoundName)) {
-               id = T_JavaLangLong;
-               return;
-       }
-
-       if (CharOperation.equals(JAVA_LANG_VOID, compoundName)) {
-               id = T_JavaLangVoid;
-               return;
-       }
-       
-       if (CharOperation.equals(JAVA_LANG_ASSERTIONERROR, compoundName)) {
-               id = T_JavaLangAssertionError;
-               return;
-       }
-}
+//public void computeId() {
+//     if (compoundName.length != 3) {
+//             if (compoundName.length == 4 && CharOperation.equals(JAVA_LANG_REFLECT_CONSTRUCTOR, compoundName)) {
+//                     id = T_JavaLangReflectConstructor;
+//                     return;
+//             }
+//             return;         // all other types are in java.*.*
+//     }
+//
+//     if (!CharOperation.equals(JAVA, compoundName[0]))
+//             return;         // assumes we only look up types in java
+//
+//     if (!CharOperation.equals(LANG, compoundName[1])) {
+//             if (CharOperation.equals(JAVA_IO_PRINTSTREAM, compoundName)) {
+//                     id = T_JavaIoPrintStream;
+//                     return;
+//             }
+//             return;         // all other types are in java.lang
+//     }
+//
+//     if (CharOperation.equals(JAVA_LANG_OBJECT, compoundName)) {
+//             id = T_JavaLangObject;
+//             return;
+//     }
+//     if (CharOperation.equals(JAVA_LANG_STRING, compoundName)) {
+//             id = T_JavaLangString;
+//             return;
+//     }
+//
+//     // well-known exception types
+//     if (CharOperation.equals(JAVA_LANG_THROWABLE, compoundName)) {
+//             id = T_JavaLangThrowable;
+//             return;
+//     }
+//     if (CharOperation.equals(JAVA_LANG_ERROR, compoundName)) {
+//             id = T_JavaLangError;
+//             return;
+//     }
+//     if (CharOperation.equals(JAVA_LANG_EXCEPTION, compoundName)) {
+//             id = T_JavaLangException;
+//             return;
+//     }
+//     if (CharOperation.equals(JAVA_LANG_CLASSNOTFOUNDEXCEPTION, compoundName)) {
+//             id = T_JavaLangClassNotFoundException;
+//             return;
+//     }
+//     if (CharOperation.equals(JAVA_LANG_NOCLASSDEFERROR, compoundName)) {
+//             id = T_JavaLangNoClassDefError;
+//             return;
+//     }
+//
+//     // other well-known types
+//     if (CharOperation.equals(JAVA_LANG_CLASS, compoundName)) {
+//             id = T_JavaLangClass;
+//             return;
+//     }
+//     if (CharOperation.equals(JAVA_LANG_STRINGBUFFER, compoundName)) {
+//             id = T_JavaLangStringBuffer;
+//             return;
+//     }
+//     if (CharOperation.equals(JAVA_LANG_SYSTEM, compoundName)) {
+//             id = T_JavaLangSystem;
+//             return;
+//     }
+//
+//     if (CharOperation.equals(JAVA_LANG_INTEGER, compoundName)) {
+//             id = T_JavaLangInteger;
+//             return;
+//     }
+//
+//     if (CharOperation.equals(JAVA_LANG_BYTE, compoundName)) {
+//             id = T_JavaLangByte;
+//             return;
+//     }       
+//
+//     if (CharOperation.equals(JAVA_LANG_CHARACTER, compoundName)) {
+//             id = T_JavaLangCharacter;
+//             return;
+//     }
+//
+//     if (CharOperation.equals(JAVA_LANG_FLOAT, compoundName)) {
+//             id = T_JavaLangFloat;
+//             return;
+//     }
+//
+//     if (CharOperation.equals(JAVA_LANG_DOUBLE, compoundName)) {
+//             id = T_JavaLangDouble;
+//             return;
+//     }
+//
+//     if (CharOperation.equals(JAVA_LANG_BOOLEAN, compoundName)) {
+//             id = T_JavaLangBoolean;
+//             return;
+//     }
+//
+//     if (CharOperation.equals(JAVA_LANG_SHORT, compoundName)) {
+//             id = T_JavaLangShort;
+//             return;
+//     }
+//
+//     if (CharOperation.equals(JAVA_LANG_LONG, compoundName)) {
+//             id = T_JavaLangLong;
+//             return;
+//     }
+//
+//     if (CharOperation.equals(JAVA_LANG_VOID, compoundName)) {
+//             id = T_JavaLangVoid;
+//             return;
+//     }
+//     
+//     if (CharOperation.equals(JAVA_LANG_ASSERTIONERROR, compoundName)) {
+//             id = T_JavaLangAssertionError;
+//             return;
+//     }
+//}
 /* Answer the receiver's constant pool name.
 *
 * NOTE: This method should only be used during/after code gen.
@@ -444,7 +440,7 @@ public final boolean isClass() {
 /* Answer true if the receiver type can be assigned to the argument type (right)
 */
        
-boolean isCompatibleWith(TypeBinding right) {
+public boolean isCompatibleWith(TypeBinding right) {
        if (right == this)
                return true;
        if (right.id == T_Object)
@@ -495,6 +491,12 @@ public final boolean isNestedType() {
 public final boolean isPrivate() {
        return (modifiers & AccPrivate) != 0;
 }
+/* Answer true if the receiver has private visibility and is used locally
+*/
+
+public final boolean isPrivateUsed() {
+       return (modifiers & AccPrivateUsed) != 0;
+}
 /* Answer true if the receiver has protected visibility
 */
 
@@ -517,9 +519,9 @@ public final boolean isStatic() {
 /* Answer true if all float operations must adher to IEEE 754 float/double rules
 */
 
-public final boolean isStrictfp() {
-       return (modifiers & AccStrictfp) != 0;
-}
+//public final boolean isStrictfp() {
+//     return (modifiers & AccStrictfp) != 0;
+//}
 /* Answer true if the receiver is in the superclass hierarchy of aType
 *
 * NOTE: Object.isSuperclassOf(Object) -> false
@@ -564,6 +566,14 @@ public char[] readableName() /*java.lang.Object*/ {
        else
                return CharOperation.concatWith(compoundName, '.');
 }
+
+public char[] shortReadableName() /*Object*/ {
+       if (isMemberType())
+               return CharOperation.concat(enclosingType().shortReadableName(), sourceName, '.');
+       else
+               return sourceName;
+}
+
 /* Answer the receiver's signature.
 *
 * NOTE: This method should only be used during/after code gen.