- added include declarations to Outline view
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / CompilationUnitStructureRequestor.java
index cada744..2e24f0c 100644 (file)
@@ -16,6 +16,7 @@ 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.IImportContainer;
 import net.sourceforge.phpdt.core.IJavaElement;
 import net.sourceforge.phpdt.core.IMethod;
 import net.sourceforge.phpdt.core.IType;
@@ -134,41 +135,42 @@ public class CompilationUnitStructureRequestor extends ReferenceInfoAdapter impl
   /**
    * @see ISourceElementRequestor
    */
-  //public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand) {
-  //   JavaElementInfo parentInfo = (JavaElementInfo) fInfoStack.peek();
-  //   JavaElement parentHandle= (JavaElement)fHandleStack.peek();
-  //   if (!(parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT)) {
-  //           Assert.isTrue(false); // Should not happen
-  //   }
-  //
-  //   ICompilationUnit parentCU= (ICompilationUnit)parentHandle;
-  //   //create the import container and its info
-  //   IImportContainer importContainer= parentCU.getImportContainer();
-  //   if (fImportContainerInfo == null) {
-  //           fImportContainerInfo= new JavaElementInfo();
-  //           fImportContainerInfo.setIsStructureKnown(true);
-  //           parentInfo.addChild(importContainer);
-  //           fNewElements.put(importContainer, fImportContainerInfo);
-  //   }
-  //   
-  //   // tack on the '.*' if it is onDemand
-  //   String importName;
-  //   if (onDemand) {
-  //           importName= new String(name) + ".*"; //$NON-NLS-1$
-  //   } else {
-  //           importName= new String(name);
-  //   }
-  //   
-  //   ImportDeclaration handle = new ImportDeclaration(importContainer, importName);
-  //   resolveDuplicates(handle);
-  //   
-  //   SourceRefElementInfo info = new SourceRefElementInfo();
-  //   info.setSourceRangeStart(declarationStart);
-  //   info.setSourceRangeEnd(declarationEnd);
-  //
-  //   fImportContainerInfo.addChild(handle);
-  //   fNewElements.put(handle, info);
-  //}
+  public void acceptImport(int declarationStart, int declarationEnd, char[] name, boolean onDemand) {
+       JavaElementInfo parentInfo = (JavaElementInfo) fInfoStack.peek();
+       JavaElement parentHandle= (JavaElement)fHandleStack.peek();
+       if (!(parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT)) {
+               Assert.isTrue(false); // Should not happen
+       }
+  
+       ICompilationUnit parentCU= (ICompilationUnit)parentHandle;
+       //create the import container and its info
+       ImportContainer importContainer= parentCU.getImportContainer();
+       if (fImportContainerInfo == null) {
+               fImportContainerInfo= new JavaElementInfo();
+               fImportContainerInfo.setIsStructureKnown(true);
+               parentInfo.addChild(importContainer);
+               fNewElements.put(importContainer, fImportContainerInfo);
+       }
+       
+       // tack on the '.*' if it is onDemand
+       String importName;
+       if (onDemand) {
+               importName= new String(name) + ".*"; //$NON-NLS-1$
+       } else {
+               importName= new String(name);
+       }
+       
+       ImportDeclaration handle = new ImportDeclaration(importContainer, importName);
+//     ImportDeclaration handle = new ImportDeclaration(null, importName);
+//     resolveDuplicates(handle);
+       
+       SourceRefElementInfo info = new SourceRefElementInfo();
+       info.setSourceRangeStart(declarationStart);
+       info.setSourceRangeEnd(declarationEnd);
+  
+       fImportContainerInfo.addChild(handle);
+       fNewElements.put(handle, info);
+  }
   /*
    * Table of line separator position. This table is passed once at the end
    * of the parse action, so as to allow computation of normalized ranges.