|
From: <caw...@us...> - 2007-07-25 18:34:31
|
Revision: 2876
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=2876&view=rev
Author: cawilliams
Date: 2007-07-25 11:34:28 -0700 (Wed, 25 Jul 2007)
Log Message:
-----------
hide org.rubypeople.rdt.internal.core.builder
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/RubyTypeSelectionDialog.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/RubyTypeSelectionDialog.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/RubyTypeSelectionDialog.java 2007-07-25 18:19:35 UTC (rev 2875)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/RubyTypeSelectionDialog.java 2007-07-25 18:34:28 UTC (rev 2876)
@@ -4,98 +4,82 @@
import java.util.Arrays;
import java.util.List;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+import org.rubypeople.rdt.core.IParent;
import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.core.RubyElement;
-import org.rubypeople.rdt.internal.core.builder.RubySourceFileCollectingVisitor;
-import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.ui.RubyElementLabelProvider;
public class RubyTypeSelectionDialog extends ElementListSelectionDialog {
- public RubyTypeSelectionDialog(Shell parent) {
- super(parent, new RubyElementLabelProvider(RubyElementLabelProvider.SHOW_DEFAULT | RubyElementLabelProvider.SHOW_POST_QUALIFIED));
- setElements(getElements());
- setMultipleSelection(false);
- }
-
- /**
- * Meant for subclasses to override what elements to show
- * @return
- */
- protected Object[] getElements() {
- // FIXME This doesn't pick up all the classes in loadpaths (Ruby library)! We need to search through rubProject.getSourceFolders to do that.
- // FIXME If we move to grabbing all types via source fodlers it gets way too slow. We need to make this set up liek JDT so it runs a search job based on input and caches results.
- return getAllTypes();
- }
+ public RubyTypeSelectionDialog(Shell parent) {
+ super(parent, new RubyElementLabelProvider(
+ RubyElementLabelProvider.SHOW_DEFAULT
+ | RubyElementLabelProvider.SHOW_POST_QUALIFIED));
+ setElements(getElements());
+ setMultipleSelection(false);
+ }
- /**
- * @return
- */
- private IRubyElement[] getAllTypes() {
- List typeList = new ArrayList();
- IProject[] projects = RubyCore.getRubyProjects();
- for (int i = 0; i < projects.length; i++) {
- IRubyElement[] types = findElements(projects[i], IRubyElement.TYPE);
- typeList.addAll(Arrays.asList(types));
- }
- IRubyElement[] allTypes = new IRubyElement[typeList.size()];
- System.arraycopy(typeList.toArray(), 0, allTypes, 0, allTypes.length);
- return allTypes;
- }
+ /**
+ * Meant for subclasses to override what elements to show
+ *
+ * @return
+ */
+ protected Object[] getElements() {
+ // FIXME This doesn't pick up all the classes in loadpaths (Ruby
+ // library)! We need to search through rubProject.getSourceFolders to do
+ // that.
+ // FIXME If we move to grabbing all types via source fodlers it gets way
+ // too slow. We need to make this set up liek JDT so it runs a search
+ // job based on input and caches results.
+ return getAllTypes();
+ }
- public static IRubyElement[] findElements(final IFile file, int elementType) {
- IRubyScript script = RubyCore.create(file);
- if (script == null) return new IRubyElement[0];
- try {
- script.reconcile();
- IRubyElement[] children = script.getChildren();
- List types = new ArrayList();
- for (int i = 0; i < children.length; i++) {
- if (children[i].isType(elementType)) types.add(children[i]);
- }
- IRubyElement[] array = new IRubyElement[types.size()];
- System.arraycopy(types.toArray(), 0, array, 0, types.size());
- return array;
- } catch (RubyModelException e) {
- RubyPlugin.log(e);
- }
- return new IRubyElement[0];
- }
+ /**
+ * @return
+ */
+ private IRubyElement[] getAllTypes() {
+ List typeList = new ArrayList();
+ IProject[] projects = RubyCore.getRubyProjects();
+ for (int i = 0; i < projects.length; i++) {
+ IRubyElement[] types = findElements(projects[i], IRubyElement.TYPE);
+ typeList.addAll(Arrays.asList(types));
+ }
+ IRubyElement[] allTypes = new IRubyElement[typeList.size()];
+ System.arraycopy(typeList.toArray(), 0, allTypes, 0, allTypes.length);
+ return allTypes;
+ }
- /**
- * @param rubyProject
- * @param elementType
- */
- public static IRubyElement[] findElements(IProject rubyProject, int elementType) {
- if (rubyProject == null) { return new IRubyElement[0]; }
- try {
- List files = new ArrayList();
- RubySourceFileCollectingVisitor yeah = new RubySourceFileCollectingVisitor(files);
- rubyProject.accept(yeah, 0);
- List allElements = new ArrayList();
- for (int i = 0; i < files.size(); i++) {
- IFile rubyFile = (IFile) files.get(i);
- IRubyElement[] fileElements = findElements(rubyFile, elementType);
- for (int j = 0; j < fileElements.length; j++) {
- allElements.add(fileElements[j]);
- }
- }
- Object[] listArray = allElements.toArray();
- IRubyElement[] array = new IRubyElement[allElements.size()];
- System.arraycopy(listArray, 0, array, 0, listArray.length);
- return array;
- } catch (CoreException e) {
- e.printStackTrace();
- }
- return new RubyElement[0];
- }
+ public static IRubyElement[] findElements(final IRubyElement element, int elementType) {
+ List<IRubyElement> allElements = new ArrayList<IRubyElement>();
+ if (element.isType(elementType))
+ allElements.add(element);
+ if (element instanceof IParent) {
+ IParent parent = (IParent) element;
+ IRubyElement[] fileElements = findElements(element, elementType);
+ for (int j = 0; j < fileElements.length; j++) {
+ allElements.add(fileElements[j]);
+ }
+ }
+ IRubyElement[] elements = new IRubyElement[allElements.size()];
+ elements = allElements.toArray(new IRubyElement[allElements.size()]);
+ return elements;
+ }
+ /**
+ * @param rubyProject
+ * @param elementType
+ */
+ public static IRubyElement[] findElements(IProject rubyProject,
+ int elementType) {
+ if (rubyProject == null) {
+ return new IRubyElement[0];
+ }
+ IRubyProject proj = RubyCore.create(rubyProject);
+ return findElements(proj, elementType);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|