|
From: <caw...@us...> - 2007-01-11 14:41:55
|
Revision: 1762
http://svn.sourceforge.net/rubyeclipse/?rev=1762&view=rev
Author: cawilliams
Date: 2007-01-11 06:41:53 -0800 (Thu, 11 Jan 2007)
Log Message:
-----------
try to fix some collateral damage from introducing the ISourceFolder stuff
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingContentProvider.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-11 14:17:59 UTC (rev 1761)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-11 14:41:53 UTC (rev 1762)
@@ -99,8 +99,6 @@
*/
Map getOptions(boolean inheritRubyCoreOptions);
- public abstract IRubyScript[] getRubyScripts() throws RubyModelException;
-
public abstract Object[] getNonRubyResources() throws RubyModelException;
public abstract ISourceFolder[] getSourceFolders() throws RubyModelException;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-01-11 14:17:59 UTC (rev 1761)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-01-11 14:41:53 UTC (rev 1762)
@@ -9,7 +9,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.rubypeople.rdt.core.IRubyProject;
-import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
@@ -63,13 +62,9 @@
try {
for (int x = 0; x < projects.length; x++) {
IRubyProject project = projects[x];
- IRubyScript[] scripts = project.getRubyScripts();
- for (int i = 0; i < scripts.length; i++) {
- IRubyScript script = scripts[i];
- IType type = findTypeInScript(typeName, script);
- if (type != null)
- return type;
- }
+ IType type = project.findType(typeName);
+ if (type != null)
+ return type;
}
} catch (RubyModelException e) {
// TODO Auto-generated catch block
@@ -77,17 +72,4 @@
}
return null;
}
-
- private IType findTypeInScript(String typeName, IRubyScript script)
- throws RubyModelException {
- IType[] types = script.getTypes();
- for (int j = 0; j < types.length; j++) {
- IType type = types[j];
- if (!type.getElementName().equals(typeName))
- continue;
- return type;
- }
- return null;
- }
-
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-01-11 14:17:59 UTC (rev 1761)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-01-11 14:41:53 UTC (rev 1762)
@@ -52,7 +52,6 @@
import org.rubypeople.rdt.core.IRubyModelStatus;
import org.rubypeople.rdt.core.IRubyModelStatusConstants;
import org.rubypeople.rdt.core.IRubyProject;
-import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.ISourceFolder;
import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.IType;
@@ -796,25 +795,16 @@
return null;
}
- public void resetCaches() {
- // TODO Auto-generated method stub
- }
+ /*
+ * Resets this project's caches
+ */
+ public void resetCaches() {
+ RubyProjectElementInfo info = (RubyProjectElementInfo) RubyModelManager.getRubyModelManager().peekAtInfo(this);
+ if (info != null){
+ info.resetCaches();
+ }
+ }
- public IRubyScript[] getRubyScripts() throws RubyModelException {
- Object[] children;
- int length;
- IRubyScript[] scripts;
-
- System.arraycopy(
- children = getChildren(),
- 0,
- scripts = new IRubyScript[length = children.length],
- 0,
- length);
-
- return scripts;
- }
-
/**
* Returns an array of non-ruby resources contained in the receiver.
*/
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingContentProvider.java 2007-01-11 14:17:59 UTC (rev 1761)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingContentProvider.java 2007-01-11 14:41:53 UTC (rev 1762)
@@ -23,6 +23,8 @@
import org.rubypeople.rdt.core.IRubyElementDelta;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolder;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.ISourceReference;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
@@ -63,25 +65,26 @@
startReadInDisplayThread();
try {
if (element instanceof Collection) {
- Collection elements = (Collection) element;
+ Collection elements= (Collection)element;
if (elements.isEmpty())
return NO_CHILDREN;
- Object[] result = new Object[0];
- Iterator iter = ((Collection) element).iterator();
+ Object[] result= new Object[0];
+ Iterator iter= ((Collection)element).iterator();
while (iter.hasNext()) {
- Object[] children = getChildren(iter.next());
+ Object[] children= getChildren(iter.next());
if (children != NO_CHILDREN)
- result = concatenate(result, children);
+ result= concatenate(result, children);
}
return result;
}
+ if (element instanceof ISourceFolder)
+ return getFolderContents((ISourceFolder)element);
if (fProvideMembers && element instanceof IType)
- return getChildren((IType) element);
- if (fProvideMembers && element instanceof ISourceReference
- && element instanceof IParent)
+ return getChildren((IType)element);
+ if (fProvideMembers && element instanceof ISourceReference && element instanceof IParent)
return super.getChildren(element);
if (element instanceof IRubyProject)
- return getRubyTypes((IRubyProject) element);
+ return getSourceFolderRoots((IRubyProject)element);
return super.getChildren(element);
} catch (RubyModelException e) {
return NO_CHILDREN;
@@ -90,6 +93,36 @@
}
}
+ private Object[] getFolderContents(ISourceFolder fragment) throws RubyModelException {
+ ISourceReference[] sourceRefs= fragment.getRubyScripts();
+ Object[] result= new Object[0];
+ for (int i= 0; i < sourceRefs.length; i++)
+ result= concatenate(result, getChildren(sourceRefs[i]));
+ return concatenate(result, fragment.getNonRubyResources());
+ }
+
+ protected Object[] getSourceFolderRoots(IRubyProject project) throws RubyModelException {
+ if (!project.getProject().isOpen())
+ return NO_CHILDREN;
+
+ ISourceFolderRoot[] roots= project.getSourceFolderRoots();
+ List list= new ArrayList(roots.length);
+ // filter out package fragments that correspond to projects and
+ // replace them with the package fragments directly
+ for (int i= 0; i < roots.length; i++) {
+ ISourceFolderRoot root= roots[i];
+ if (!root.isExternal()) {
+ Object[] children= root.getChildren();
+ for (int k= 0; k < children.length; k++)
+ list.add(children[k]);
+ }
+ else if (hasChildren(root)) {
+ list.add(root);
+ }
+ }
+ return concatenate(list.toArray(), project.getNonRubyResources());
+ }
+
private Object[] getChildren(IType type) throws RubyModelException{
IParent parent= type.getRubyScript();
@@ -106,28 +139,6 @@
return tempResult.toArray();
}
- private Object[] getRubyTypes(IRubyProject project)
- throws RubyModelException {
- Object[] scripts = getRubyScripts(project);
- List list = new ArrayList();
- for (int i = 0; i < scripts.length; i++) {
- IRubyScript script = (IRubyScript) scripts[i];
- Object[] types = script.getTypes();
- for (int j = 0; j < types.length; j++) {
- list.add(types[j]);
- }
- }
- return concatenate(list.toArray(), new Object[] {});
- }
-
- protected Object[] getRubyScripts(IRubyProject project)
- throws RubyModelException {
- if (!project.getProject().isOpen())
- return NO_CHILDREN;
-
- return project.getRubyScripts();
- }
-
private boolean isDisplayThread() {
Control ctrl = fViewer.getControl();
if (ctrl == null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|