[Pydev-cvs] org.python.pydev/src/org/python/pydev/editor/correctionassist PythonCorrectionProcesso
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-06-28 12:35:31
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12157/src/org/python/pydev/editor/correctionassist Modified Files: PythonCorrectionProcessor.java Log Message: Backwards support for Eclipse 3.2. Index: PythonCorrectionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/PythonCorrectionProcessor.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** PythonCorrectionProcessor.java 3 May 2008 13:37:35 -0000 1.38 --- PythonCorrectionProcessor.java 28 Jun 2008 12:35:38 -0000 1.39 *************** *** 171,209 **** ! ! //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 = edit.getPySourceViewer().getAnnotationModel(); ! Iterator it = annotationModel.getAnnotationIterator(); ! while(it.hasNext()){ ! Object annotation = it.next(); ! if(annotation instanceof SpellingAnnotation){ ! SpellingAnnotation spellingAnnotation = (SpellingAnnotation) annotation; ! SpellingProblem spellingProblem = spellingAnnotation.getSpellingProblem(); ! ! int problemOffset = spellingProblem.getOffset(); ! int problemLen = spellingProblem.getLength(); ! if(problemOffset <= offset && problemOffset+problemLen >= offset){ ! SpellingCorrectionProcessor spellingCorrectionProcessor = new SpellingCorrectionProcessor(); ! spellProps = spellingCorrectionProcessor.computeQuickAssistProposals(invocationContext); ! break; ! } } } - - - if(spellProps == null || (spellProps.length == 1 && spellProps[0] instanceof NoCompletionsProposal)){ - //no proposals from the spelling - return (ICompletionProposal[]) results.toArray(new ICompletionProposal[results.size()]); - } - - //ok, add the spell problems and return... - ICompletionProposal[] ret = (ICompletionProposal[]) results.toArray(new ICompletionProposal[results.size()+spellProps.length]); - System.arraycopy(spellProps, 0, ret, results.size(), spellProps.length); - return ret; } --- 171,218 ---- ! 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 = edit.getPySourceViewer().getAnnotationModel(); ! Iterator it = annotationModel.getAnnotationIterator(); ! while(it.hasNext()){ ! Object annotation = it.next(); ! if(annotation instanceof SpellingAnnotation){ ! SpellingAnnotation spellingAnnotation = (SpellingAnnotation) annotation; ! SpellingProblem spellingProblem = spellingAnnotation.getSpellingProblem(); ! ! int problemOffset = spellingProblem.getOffset(); ! int problemLen = spellingProblem.getLength(); ! if(problemOffset <= offset && problemOffset+problemLen >= offset){ ! SpellingCorrectionProcessor spellingCorrectionProcessor = new SpellingCorrectionProcessor(); ! spellProps = spellingCorrectionProcessor.computeQuickAssistProposals(invocationContext); ! break; ! } ! } ! } ! ! ! ! if(spellProps == null || (spellProps.length == 1 && spellProps[0] instanceof NoCompletionsProposal)){ ! //no proposals from the spelling ! return (ICompletionProposal[]) results.toArray(new ICompletionProposal[results.size()]); ! } ! ! //ok, add the spell problems and return... ! ICompletionProposal[] ret = (ICompletionProposal[]) results.toArray(new ICompletionProposal[results.size()+spellProps.length]); ! System.arraycopy(spellProps, 0, ret, results.size(), spellProps.length); ! return ret; ! }catch(Throwable e){ ! if(e instanceof ClassNotFoundException || e instanceof LinkageError || e instanceof NoSuchMethodException || ! e instanceof NoSuchMethodError || e instanceof NoClassDefFoundError){ ! //Eclipse 3.2 support ! return (ICompletionProposal[]) results.toArray(new ICompletionProposal[results.size()]); } + throw new RuntimeException(e); } } |