* @return as we're not below a source folder here, we have still not entered the 'python' domain,
* and as the starting point for the 'python' domain is always a source folder, the things
* that can be returned are IResources and PythonSourceFolders.
*/
private Object[] getChildrenForIResourceOrWorkingSet(Object parentElement) {
PythonNature nature = null;
IProject project = null;
if (parentElement instanceof IResource) {
project = ((IResource) parentElement).getProject();
}
//we can only get the nature if the project is open
if (project != null && project.isOpen()) {
nature = PythonNature.getPythonNature(project);
}
//replace folders -> source folders (we should only get here on a path that's not below a source folder)
Object[] childrenToReturn = super.getChildren(parentElement);
//if we don't have a python nature in this project, there is no way we can have a PythonSourceFolder
List<Object> ret = new ArrayList<Object>(childrenToReturn.length);
for (int i = 0; i < childrenToReturn.length; i++) {
PythonNature localNature = nature;
IProject localProject = project;
//now, first we have to try to get it (because it might already be created)
Object child = childrenToReturn[i];
if (child == null) {
continue;
}
//only add it if it wasn't null
ret.add(child);
if (!(child instanceof IResource)) {
//not an element that we can treat in pydev (but still, it was already added)
continue;
}
child = getResourceInPythonModel((IResource) child);
if (child == null) {
//ok, it was not in the python model (but it was already added with the original representation, so, that's ok)
continue;
} else {
ret.set(ret.size() - 1, child); //replace the element added for the one in the python model
}
//if it is a folder (that is not already a PythonSourceFolder, it might be that we have to create a PythonSourceFolder)
if (child instanceof IContainer && !(child instanceof PythonSourceFolder)) {
IContainer container = (IContainer) child;
try {
//check if it is a source folder (and if it is, create it)
if (localNature == null) {
if (container instanceof IProject) {
localProject = (IProject) container;
if (localProject.isOpen() == false) {
continue;
} else {
localNature = PythonNature.getPythonNature(localProject);
}
} else {
continue;
}
}
//if it's a python project, the nature can't be null
if (localNature == null) {
continue;
}
Set<String> sourcePathSet = localNature.getPythonPathNature().getProjectSourcePathSet(true);
IPath fullPath = container.getFullPath();
if (sourcePathSet.contains(fullPath.toString())) {
PythonSourceFolder createdSourceFolder;
if (container instanceof IFolder) {
createdSourceFolder = new PythonSourceFolder(parentElement, (IFolder) container);