X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java index 43e72ef..78afe4e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java @@ -18,12 +18,10 @@ import java.util.Comparator; import java.util.List; import java.util.TreeSet; +import net.sourceforge.phpdt.internal.compiler.parser.*; import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry; import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.phpeditor.phpparser.PHPClassDeclaration; -import net.sourceforge.phpeclipse.phpeditor.phpparser.PHPOutlineInfo; -import net.sourceforge.phpeclipse.phpeditor.phpparser.PHPParser; -import net.sourceforge.phpeclipse.phpeditor.phpparser.PHPSegment; + import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.BadPositionCategoryException; import org.eclipse.jface.text.DefaultPositionUpdater; @@ -42,6 +40,8 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.views.contentoutline.ContentOutlinePage; +import test.PHPParserSuperclass; +import test.PHPParserManager; /** * A content outline page which always represents the functions of the @@ -53,13 +53,13 @@ public class PHPContentOutlinePage extends ContentOutlinePage { protected static class SegmentComparator implements Comparator { public int compare(Object o1, Object o2) { - if (o1 instanceof PHPClassDeclaration && !(o2 instanceof PHPClassDeclaration)) { + if (o1 instanceof PHPSegmentWithChildren && !(o2 instanceof PHPSegmentWithChildren)) { return 1; } - if (o2 instanceof PHPClassDeclaration && !(o1 instanceof PHPClassDeclaration)) { + if (o2 instanceof PHPSegmentWithChildren && !(o1 instanceof PHPSegmentWithChildren)) { return -1; } - return ((PHPSegment) o1).toString().compareToIgnoreCase(((PHPSegment) o2).toString()); + return ((Outlineable) o1).toString().compareToIgnoreCase(((Outlineable) o2).toString()); } } @@ -80,7 +80,7 @@ public class PHPContentOutlinePage extends ContentOutlinePage { // StringBuffer identifier = new StringBuffer(); // while (i < textLength) { // c = text.charAt(i++); - // if (Character.isJavaIdentifierPart(c) || (c == '$')) { + // if (Scanner.isPHPIdentifierPart(c) || (c == '$')) { // identifier.append(c); // } else if ((i == firstIndex + 1) && (c == '$')) { // identifier.append(c); @@ -99,19 +99,18 @@ public class PHPContentOutlinePage extends ContentOutlinePage { String name; int index; String text = document.get(); - PHPParser parser = new PHPParser(null); + PHPParserSuperclass parser = PHPParserManager.getParser(null); PHPOutlineInfo outlineInfo = parser.parseInfo(fInput, text); fVariables = outlineInfo.getVariables(); - PHPClassDeclaration declarations = outlineInfo.getDeclarations(); - PHPSegment temp; + OutlineableWithChildren declarations = outlineInfo.getDeclarations(); + Outlineable temp; for (int i = 0; i < declarations.size(); i++) { temp = declarations.get(i); fContent.add(temp); } Collections.sort(fContent, new SegmentComparator()); - } /* @@ -182,8 +181,8 @@ public class PHPContentOutlinePage extends ContentOutlinePage { * @see ITreeContentProvider#hasChildren(Object) */ public boolean hasChildren(Object element) { - if (element instanceof PHPClassDeclaration) { - return !((PHPClassDeclaration) element).getList().isEmpty(); + if (element instanceof PHPSegmentWithChildren) { + return !((PHPSegmentWithChildren) element).getList().isEmpty(); } return element == fInput; } @@ -192,8 +191,8 @@ public class PHPContentOutlinePage extends ContentOutlinePage { * @see ITreeContentProvider#getParent(Object) */ public Object getParent(Object element) { - if (element instanceof PHPSegment) { - return ((PHPSegment) element).getParent(); + if (element instanceof Outlineable) { + return ((Outlineable) element).getParent(); } return null; } @@ -204,8 +203,8 @@ public class PHPContentOutlinePage extends ContentOutlinePage { public Object[] getChildren(Object element) { if (element == fInput) return fContent.toArray(); - if (element instanceof PHPClassDeclaration) - return ((PHPClassDeclaration) element).getList().toArray(); + if (element instanceof PHPSegmentWithChildren) + return ((PHPSegmentWithChildren) element).getList().toArray(); return new Object[0]; } }; @@ -223,8 +222,8 @@ public class PHPContentOutlinePage extends ContentOutlinePage { * override. */ public Image getImage(Object element) { - if (element instanceof PHPSegment) { - ImageDescriptor descriptor = ((PHPSegment) element).getImage(); + if (element instanceof Outlineable) { + ImageDescriptor descriptor = ((Outlineable) element).getImage(); return fRegistry.get(descriptor); } return null;