Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14588/src/org/python/pydev/editor
Modified Files:
PythonCompletionProcessor.java
Log Message:
Extracting prefix to get only the template completions that start with
the string in the prefix.
Index: PythonCompletionProcessor.java
===================================================================
RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** PythonCompletionProcessor.java 10 Aug 2004 12:45:16 -0000 1.13
--- PythonCompletionProcessor.java 10 Aug 2004 14:09:38 -0000 1.14
***************
*** 140,171 ****
protected void addTemplateProposals(ITextViewer viewer, int documentOffset,
List propList) {
! String str = "";
! int i = documentOffset - 1;
! if (i <= 0)
! return;
char c;
try {
c = viewer.getDocument().getChar(i);
! while (c != ' ' && c != '\n' && c != '\r' && i > 0) {
str = c + str;
i--;
! c = viewer.getDocument().getChar(i);
! }
! char [] chars = getCompletionProposalAutoActivationCharacters();
!
! //we don't want templates on autocompletion proposals.
! for (int j = 0; j < chars.length; j++) {
! if(str.endsWith(chars[j]+""))
! return;
}
-
- ICompletionProposal[] templateProposals = super
- .computeCompletionProposals(viewer, documentOffset);
- propList.addAll(Arrays.asList(templateProposals));
-
} catch (BadLocationException e) {
e.printStackTrace();
}
}
--- 140,179 ----
protected void addTemplateProposals(ITextViewer viewer, int documentOffset,
List propList) {
! String str = extractPrefix(viewer, documentOffset);
!
! ICompletionProposal[] templateProposals = super
! .computeCompletionProposals(viewer, documentOffset);
!
! for (int j = 0; j < templateProposals.length; j++) {
! if ( templateProposals[j].getDisplayString().startsWith(str)){
! propList.add(templateProposals[j]);
! }
! }
!
! }
+ protected String extractPrefix(ITextViewer viewer, int offset) {
+ String str ="";
+ int i = offset - 1;
+ if (i == -1){
+ return "";
+ }
+
char c;
try {
c = viewer.getDocument().getChar(i);
! while (c != ' ' && c != '\n' && c != '\r') {
str = c + str;
i--;
! if(i < 0){
! break;
! }else{
! c = viewer.getDocument().getChar(i);
! }
}
} catch (BadLocationException e) {
e.printStackTrace();
}
+ return str;
}
***************
*** 295,301 ****
calcDocBoundary(theDoc, documentOffset);
}
!
! String before = theDoc.substring(0, this.docBoundary);
! return before;
}
--- 303,311 ----
calcDocBoundary(theDoc, documentOffset);
}
! if(this.docBoundary != -1){
! String before = theDoc.substring(0, this.docBoundary);
! return before;
! }
! return "";
}
|