Added patch from #1437426: error in assign template
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / lookup / Scope.java
index 7678e2a..2957f65 100644 (file)
 package net.sourceforge.phpdt.internal.compiler.lookup;
 
 import net.sourceforge.phpdt.core.compiler.CharOperation;
+import net.sourceforge.phpdt.internal.compiler.ast.AbstractMethodDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.CompilationUnitDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.ImportReference;
+import net.sourceforge.phpdt.internal.compiler.ast.TypeDeclaration;
 import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
 import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
 import net.sourceforge.phpdt.internal.compiler.util.ObjectVector;
-import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
-import net.sourceforge.phpeclipse.internal.compiler.ast.ImportReference;
-import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration;
 
 public abstract class Scope
        implements
@@ -815,6 +815,42 @@ public abstract class Scope
                        unitScope = scope;
                return ((CompilationUnitScope) unitScope).fPackage;
        }
+       /**
+        * Returns the modifiers of the innermost enclosing declaration.
+        * @return modifiers
+        */
+       public int getDeclarationModifiers(){
+               switch(this.kind){
+                       case Scope.BLOCK_SCOPE :
+                       case Scope.METHOD_SCOPE :
+                               MethodScope methodScope = methodScope();
+                               if (!methodScope.isInsideInitializer()){
+                                       // check method modifiers to see if deprecated
+                                       MethodBinding context = ((AbstractMethodDeclaration)methodScope.referenceContext).binding;
+                                       if (context != null) {
+                                               return context.modifiers;
+                                       }
+                               } else {
+                                       SourceTypeBinding type = ((BlockScope)this).referenceType().binding;
+
+                                       // inside field declaration ? check field modifier to see if deprecated
+                                       if (methodScope.initializedField != null) {
+                                               return methodScope.initializedField.modifiers;
+                                       }
+                                       if (type != null) {
+                                               return type.modifiers;
+                                       }
+                               }
+                               break;
+                       case Scope.CLASS_SCOPE :
+                               ReferenceBinding context = ((ClassScope)this).referenceType().binding;
+                               if (context != null) {
+                                       return context.modifiers;
+                               }
+                               break;
+               }
+               return -1;
+       }
 
        public final ReferenceBinding getJavaIoSerializable() {
                compilationUnitScope().recordQualifiedReference(JAVA_IO_SERIALIZABLE);
@@ -892,7 +928,7 @@ public abstract class Scope
                ReferenceBinding type = environment().getType(JAVA_LANG_THROWABLE);
                if (type != null) return type;
        
-               problemReporter().isClassPathCorrect(JAVA_LANG_THROWABLE, referenceCompilationUnit());
+//             problemReporter().isClassPathCorrect(JAVA_LANG_THROWABLE, referenceCompilationUnit());
                return null; // will not get here since the above error aborts the compilation
        }