int offset = invocationContext.getOffset();
PySelection base = edit.createPySelection();
if (!(this.edit instanceof PyEdit) || base == null) {
return new ICompletionProposal[0];
}
PyEdit editor = (PyEdit) this.edit;
List<ICompletionProposal> results = new ArrayList<ICompletionProposal>();
String sel = PyAction.getLineWithoutComments(base);
List<IAssistProps> assists = new ArrayList<IAssistProps>();
synchronized (PythonCorrectionProcessor.additionalAssists) {
for (IAssistProps prop : additionalAssists.values()) {
assists.add(prop);
}
}
assists.add(new AssistSurroundWith());
assists.add(new AssistImport());
assists.add(new AssistDocString());
assists.add(new AssistAssign());
assists.add(new AssistPercentToFormat());
assists.addAll(ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_CTRL_1));
ImageCache imageCache = PydevPlugin.getImageCache();
File editorFile = edit.getEditorFile();
IPythonNature pythonNature = null;
try {
pythonNature = edit.getPythonNature();
} catch (MisconfigurationException e1) {
Log.log(e1);
}
for (IAssistProps assist : assists) {
//Always create a new for each assist, as any given assist may change it.
PySelection ps = new PySelection(base);
try {
if (assist.isValid(ps, sel, editor, offset)) {
try {
results.addAll(assist.getProps(ps, imageCache, editorFile, pythonNature, editor, offset));
} catch (Exception e) {
Log.log(e);
}
}
} catch (Exception e) {
Log.log(e);
}
}
Collections.sort(results, IPyCodeCompletion.PROPOSAL_COMPARATOR);
try {
//handling spelling... (we only want to show spelling fixes if a spell problem annotation is found at the current location).
//we'll only show some spelling proposal if there's some spelling problem (so, we don't have to check the preferences at this place,
//as no annotations on spelling will be here if the spelling is not enabled).
ICompletionProposal[] spellProps = null;
IAnnotationModel annotationModel = editor.getPySourceViewer().getAnnotationModel();
Iterator<Object> it = annotationModel.getAnnotationIterator();
while (it.hasNext()) {
Object annotation = it.next();
if (annotation instanceof SpellingAnnotation) {
SpellingAnnotation spellingAnnotation = (SpellingAnnotation) annotation;