added class fields to outline
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / CompilationUnitStructureRequestor.java
index ce3680d..cada744 100644 (file)
@@ -13,6 +13,7 @@ package net.sourceforge.phpdt.internal.core;
 import java.util.Map;
 import java.util.Stack;
 
+import net.sourceforge.phpdt.core.Flags;
 import net.sourceforge.phpdt.core.ICompilationUnit;
 import net.sourceforge.phpdt.core.IField;
 import net.sourceforge.phpdt.core.IJavaElement;
@@ -274,6 +275,7 @@ public class CompilationUnitStructureRequestor extends ReferenceInfoAdapter impl
       exceptionTypes,
       true);
   }
+
   /**
    * @see ISourceElementRequestor
    */
@@ -284,7 +286,7 @@ public class CompilationUnitStructureRequestor extends ReferenceInfoAdapter impl
     IField handle = null;
 
     if (parentHandle.getElementType() == IJavaElement.TYPE) {
-      handle = new SourceField((IType) parentHandle, new String(name));
+      handle = new SourceField(parentHandle, new String(name));
     } else {
       Assert.isTrue(false); // Should not happen
     }
@@ -407,15 +409,15 @@ public class CompilationUnitStructureRequestor extends ReferenceInfoAdapter impl
     }
 
     String[] parameterTypeSigs = convertTypeNamesToSigs(parameterTypes);
-    if (parentHandle.getElementType() == IJavaElement.TYPE) {
-      handle = new SourceMethod((IType) parentHandle, new String(name), parameterTypeSigs);
-    } else if (parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT) {
-      handle = new SourceMethod((ICompilationUnit) parentHandle, name==null?"":new String(name), parameterTypeSigs);
-    } else {
-      Assert.isTrue(false); // Should not happen
-    }
-    resolveDuplicates(handle);
-
+    // TODO : jsurfer changed
+//     if (parentHandle.getElementType() == IJavaElement.TYPE) {
+               handle = new SourceMethod(parentHandle, new String(name), parameterTypeSigs);
+//     }
+//     else {
+//             Assert.isTrue(false); // Should not happen
+//     }
+       resolveDuplicates(handle);
+       
     SourceMethodElementInfo info = new SourceMethodElementInfo();
     info.setSourceRangeStart(declarationStart);
     int flags = modifiers;
@@ -523,30 +525,30 @@ public class CompilationUnitStructureRequestor extends ReferenceInfoAdapter impl
   public void exitConstructor(int declarationEnd) {
     exitMember(declarationEnd);
   }
-  ///**
-  // * @see ISourceElementRequestor
-  // */
-  //public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
-  //   SourceFieldElementInfo info = (SourceFieldElementInfo) fInfoStack.pop();
-  //   info.setSourceRangeEnd(declarationSourceEnd);
-  //   
-  //   // remember initializer source if field is a constant
-  //   if (initializationStart != -1) {
-  //           int flags = info.flags;
-  //           Object typeInfo;
-  //           if (Flags.isStatic(flags) && Flags.isFinal(flags)
-  //                           || ((typeInfo = fInfoStack.peek()) instanceof SourceTypeElementInfo
-  //                                    && (Flags.isInterface(((SourceTypeElementInfo)typeInfo).flags)))) {
-  //                   int length = declarationEnd - initializationStart;
-  //                   if (length > 0) {
-  //                           char[] initializer = new char[length];
-  //                           System.arraycopy(this.parser.scanner.source, initializationStart, initializer, 0, length);
-  //                           info.initializationSource = initializer;
-  //                   }
-  //           }
-  //   }
-  //   fHandleStack.pop();
-  //}
+  /**
+   * @see ISourceElementRequestor
+   */
+  public void exitField(int initializationStart, int declarationEnd, int declarationSourceEnd) {
+       SourceFieldElementInfo info = (SourceFieldElementInfo) fInfoStack.pop();
+       info.setSourceRangeEnd(declarationSourceEnd);
+       
+       // remember initializer source if field is a constant
+       if (initializationStart != -1) {
+               int flags = info.flags;
+               Object typeInfo;
+               if (Flags.isStatic(flags) && Flags.isFinal(flags)
+                               || ((typeInfo = fInfoStack.peek()) instanceof SourceTypeElementInfo
+                                        && (Flags.isInterface(((SourceTypeElementInfo)typeInfo).flags)))) {
+                       int length = declarationEnd - initializationStart;
+                       if (length > 0) {
+                               char[] initializer = new char[length];
+                               System.arraycopy(this.parser.scanner.source, initializationStart, initializer, 0, length);
+                               info.initializationSource = initializer;
+                       }
+               }
+       }
+       fHandleStack.pop();
+  }
   /**
    * @see ISourceElementRequestor
    */