private Object[] getSelectedObjects(IStructuredModel model,
ITextSelection selection) {
Object[] selectedStructures = null;
if (model != null) {
IndexedRegion region = model
.getIndexedRegion(selection.getOffset());
int end = selection.getOffset() + selection.getLength();
if (region != null) {
if (end <= region.getEndOffset()) {
// single selection
selectedStructures = new Object[1];
selectedStructures[0] = region;
} else {
// multiple selection
int maxLength = model.getStructuredDocument().getLength();
List structures = new ArrayList(2);
while (region != null && region.getEndOffset() <= end
&& region.getEndOffset() < maxLength) {
structures.add(region);
region = model
.getIndexedRegion(region.getEndOffset() + 1);
}
selectedStructures = structures.toArray();
}
}
}