IProject project = file.getProject();
IScriptProject scriptProject = DLTKCore.create(project);
IProjectFragment[] roots = scriptProject.getProjectFragments();
ISourceModule module = null;
for (int j = 0, rootCount = roots.length; j < rootCount; j++) {
final IProjectFragment root = roots[j];
IPath rootPath = root.getPath();
if (rootPath.isPrefixOf(path) && !Util.isExcluded(path, root, false)) {
IPath localPath = path.setDevice(null).removeFirstSegments(
rootPath.segmentCount());
if (localPath.segmentCount() >= 1) {
final IScriptFolder folder;
if (localPath.segmentCount() > 1) {
folder = root.getScriptFolder(localPath.removeLastSegments(1));
} else {
folder = root.getScriptFolder(Path.EMPTY);
}
module = folder.getSourceModule(localPath.lastSegment());
break;
}
}