[Pydev-cvs] org.python.pydev/src_completions/org/python/pydev/editor/codecompletion PyStringCodeCo
Brought to you by:
fabioz
Update of /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_completions/org/python/pydev/editor/codecompletion Modified Files: PyStringCodeCompletion.java PyCodeCompletionInitializer.java PyCodeCompletion.java PyContentAssistant.java AbstractPyCompletionProposalExtension2.java PyCompletionProposal.java PythonCompletionProcessor.java ProposalsComparator.java PyCodeCompletionPreferencesPage.java PythonStringCompletionProcessor.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: PyStringCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyStringCodeCompletion.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyStringCodeCompletion.java 1 May 2008 14:26:00 -0000 1.3 --- PyStringCodeCompletion.java 28 Sep 2008 12:45:42 -0000 1.4 *************** *** 35,40 **** */ public static String[] EPYDOC_FIELDS = new String[]{ ! //function or method ! "param", "param ${param}: ${cursor}", "A description of the parameter for a function or method.", "type", "type ${param}: ${cursor}", "The expected type for the parameter, var or property", "return", "return: ", "The return value for a function or method.", --- 35,40 ---- */ public static String[] EPYDOC_FIELDS = new String[]{ ! //function or method ! "param", "param ${param}: ${cursor}", "A description of the parameter for a function or method.", "type", "type ${param}: ${cursor}", "The expected type for the parameter, var or property", "return", "return: ", "The return value for a function or method.", *************** *** 111,148 **** PySelection ps = new PySelection(request.doc, request.documentOffset); try { ! String lineContentsToCursor = ps.getLineContentsToCursor(); ! String trimmed = lineContentsToCursor.trim(); ! ! //only add params on param and type tags ! if(!trimmed.startsWith("@param") && !trimmed.startsWith("@type")){ ! return; ! } ! ! //for params, we never have an activation token (just a qualifier) ! if(request.activationToken.trim().length() != 0){ ! return; ! } ! ! String initial = request.qualifier; ! DocIterator iterator = new DocIterator(false, ps); ! while(iterator.hasNext()){ ! String line = iterator.next().trim(); ! if(line.startsWith("def ")){ ! int currentLine = iterator.getCurrentLine() + 1; ! PySelection selection = new PySelection(request.doc, currentLine, 0); ! if(selection.isInFunctionLine()){ ! Tuple<List<String>,Integer> insideParentesisToks = selection.getInsideParentesisToks(false); ! for (String str : insideParentesisToks.o1) { ! if(str.startsWith(initial)){ ! ret.add(new PyLinkedModeCompletionProposal(str, request.documentOffset - request.qlen, request.qlen, str.length(), ! PyCodeCompletionImages.getImageForType(IToken.TYPE_PARAM), null, null, "", 0, PyCompletionProposal.ON_APPLY_DEFAULT, "")); ! } ! } ! return; ! } ! } ! } ! } catch (BadLocationException e) { } --- 111,148 ---- PySelection ps = new PySelection(request.doc, request.documentOffset); try { ! String lineContentsToCursor = ps.getLineContentsToCursor(); ! String trimmed = lineContentsToCursor.trim(); ! ! //only add params on param and type tags ! if(!trimmed.startsWith("@param") && !trimmed.startsWith("@type")){ ! return; ! } ! ! //for params, we never have an activation token (just a qualifier) ! if(request.activationToken.trim().length() != 0){ ! return; ! } ! ! String initial = request.qualifier; ! DocIterator iterator = new DocIterator(false, ps); ! while(iterator.hasNext()){ ! String line = iterator.next().trim(); ! if(line.startsWith("def ")){ ! int currentLine = iterator.getCurrentLine() + 1; ! PySelection selection = new PySelection(request.doc, currentLine, 0); ! if(selection.isInFunctionLine()){ ! Tuple<List<String>,Integer> insideParentesisToks = selection.getInsideParentesisToks(false); ! for (String str : insideParentesisToks.o1) { ! if(str.startsWith(initial)){ ! ret.add(new PyLinkedModeCompletionProposal(str, request.documentOffset - request.qlen, request.qlen, str.length(), ! PyCodeCompletionImages.getImageForType(IToken.TYPE_PARAM), null, null, "", 0, PyCompletionProposal.ON_APPLY_DEFAULT, "")); ! } ! } ! return; ! } ! } ! } ! } catch (BadLocationException e) { } *************** *** 152,179 **** * @param ret OUT: this is where the completions are stored */ ! private void fillWithEpydocFields(ITextViewer viewer, CompletionRequest request, ArrayList<ICompletionProposal> ret) { ! try{ ! Region region = new Region(request.documentOffset - request.qlen, request.qlen); ! Image image = PyCodeCompletionImages.getImageForType(IToken.TYPE_EPYDOC); ! TemplateContext context = createContext(viewer, region, request.doc); ! char c = request.doc.getChar(request.documentOffset - request.qualifier.length() -1); if(c == '@'){ //ok, looking for epydoc filters ! for (int i = 0; i < EPYDOC_FIELDS.length; i++) { ! String f = EPYDOC_FIELDS[i]; if(f.startsWith(request.qualifier)){ Template t = new Template(f, EPYDOC_FIELDS[i+2], "", EPYDOC_FIELDS[i+1], false); ret.add(new TemplateProposal(t, context, region, image, 5){ ! @Override ! public String getDisplayString() { ! try{ ! return super.getDisplayString(); ! }catch(NoClassDefFoundError e){ ! //just for tests ! return this.getPrefixCompletionText(null, 0).toString(); ! } ! ! } }); } --- 152,179 ---- * @param ret OUT: this is where the completions are stored */ ! private void fillWithEpydocFields(ITextViewer viewer, CompletionRequest request, ArrayList<ICompletionProposal> ret) { ! try{ ! Region region = new Region(request.documentOffset - request.qlen, request.qlen); ! Image image = PyCodeCompletionImages.getImageForType(IToken.TYPE_EPYDOC); ! TemplateContext context = createContext(viewer, region, request.doc); ! char c = request.doc.getChar(request.documentOffset - request.qualifier.length() -1); if(c == '@'){ //ok, looking for epydoc filters ! for (int i = 0; i < EPYDOC_FIELDS.length; i++) { ! String f = EPYDOC_FIELDS[i]; if(f.startsWith(request.qualifier)){ Template t = new Template(f, EPYDOC_FIELDS[i+2], "", EPYDOC_FIELDS[i+1], false); ret.add(new TemplateProposal(t, context, region, image, 5){ ! @Override ! public String getDisplayString() { ! try{ ! return super.getDisplayString(); ! }catch(NoClassDefFoundError e){ ! //just for tests ! return this.getPrefixCompletionText(null, 0).toString(); ! } ! ! } }); } *************** *** 184,190 **** //just ignore it } ! } ! ! /** --- 184,190 ---- //just ignore it } ! } ! ! /** Index: PyCompletionProposal.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCompletionProposal.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyCompletionProposal.java 18 May 2008 20:02:17 -0000 1.5 --- PyCompletionProposal.java 28 Sep 2008 12:45:42 -0000 1.6 *************** *** 16,37 **** */ public class PyCompletionProposal implements ICompletionProposal, IPyCompletionProposal, ICompletionProposalExtension4 { ! ! /** The string to be displayed in the completion proposal popup. */ ! protected String fDisplayString; ! /** The replacement string. */ ! protected String fReplacementString; ! /** The replacement offset. */ ! protected int fReplacementOffset; ! /** The replacement length. */ ! protected int fReplacementLength; ! /** The cursor position after this proposal has been applied. */ ! protected int fCursorPosition; ! /** The image to be displayed in the completion proposal popup. */ ! protected Image fImage; ! /** The context information of this proposal. */ ! protected IContextInformation fContextInformation; ! /** The additional info of this proposal. */ ! protected String fAdditionalProposalInfo; ! /** The priority for showing the proposal */ protected int priority; --- 16,37 ---- */ public class PyCompletionProposal implements ICompletionProposal, IPyCompletionProposal, ICompletionProposalExtension4 { ! ! /** The string to be displayed in the completion proposal popup. */ ! protected String fDisplayString; ! /** The replacement string. */ ! protected String fReplacementString; ! /** The replacement offset. */ ! protected int fReplacementOffset; ! /** The replacement length. */ ! protected int fReplacementLength; ! /** The cursor position after this proposal has been applied. */ ! protected int fCursorPosition; ! /** The image to be displayed in the completion proposal popup. */ ! protected Image fImage; ! /** The context information of this proposal. */ ! protected IContextInformation fContextInformation; ! /** The additional info of this proposal. */ ! protected String fAdditionalProposalInfo; ! /** The priority for showing the proposal */ protected int priority; *************** *** 57,125 **** public String fArgs; ! /** ! * Creates a new completion proposal based on the provided information. The replacement string is ! * considered being the display string too. All remaining fields are set to <code>null</code>. ! * ! * @param replacementString the actual string to be inserted into the document ! * @param replacementOffset the offset of the text to be replaced ! * @param replacementLength the length of the text to be replaced ! * @param cursorPosition the position of the cursor following the insert relative to replacementOffset ! */ ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, int priority) { ! this(replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null, priority); ! } ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo,int priority) { this(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo,priority, ON_APPLY_DEFAULT, ""); } ! /** ! * Creates a new completion proposal. All fields are initialized based on the provided information. ! * ! * @param replacementString the actual string to be inserted into the document ! * @param replacementOffset the offset of the text to be replaced ! * @param replacementLength the length of the text to be replaced ! * @param cursorPosition the position of the cursor following the insert relative to replacementOffset ! * @param image the image to display for this proposal ! * @param displayString the string to be displayed for the proposal ! * @param contextInformation the context information associated with this proposal ! * @param additionalProposalInfo the additional information associated with this proposal * @param onApplyAction if we should not actually apply the changes when the completion is applied ! */ ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo,int priority, int onApplyAction, String args) { ! Assert.isNotNull(replacementString); ! Assert.isTrue(replacementOffset >= 0); ! Assert.isTrue(replacementLength >= 0); ! Assert.isTrue(cursorPosition >= 0); ! ! fReplacementString= replacementString; ! fReplacementOffset= replacementOffset; ! fReplacementLength= replacementLength; ! fCursorPosition= cursorPosition; ! fImage= image; ! fDisplayString= displayString; ! fContextInformation= contextInformation; ! fAdditionalProposalInfo= additionalProposalInfo; ! this.priority = priority; this.onApplyAction = onApplyAction; this.fArgs = args; ! } ! /* ! * @see ICompletionProposal#apply(IDocument) ! */ ! public void apply(IDocument document) { ! if(onApplyAction == ON_APPLY_JUST_SHOW_CTX_INFO){ return; } ! if(onApplyAction == ON_APPLY_DEFAULT){ ! try { ! document.replace(fReplacementOffset, fReplacementLength, fReplacementString); ! } catch (BadLocationException x) { ! // ignore ! } return; } ! if(onApplyAction == ON_APPLY_SHOW_CTX_INFO_AND_ADD_PARAMETETRS){ ! try { String args; if(fArgs.length() > 0){ --- 57,125 ---- public String fArgs; ! /** ! * Creates a new completion proposal based on the provided information. The replacement string is ! * considered being the display string too. All remaining fields are set to <code>null</code>. ! * ! * @param replacementString the actual string to be inserted into the document ! * @param replacementOffset the offset of the text to be replaced ! * @param replacementLength the length of the text to be replaced ! * @param cursorPosition the position of the cursor following the insert relative to replacementOffset ! */ ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, int priority) { ! this(replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null, priority); ! } ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo,int priority) { this(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo,priority, ON_APPLY_DEFAULT, ""); } ! /** ! * Creates a new completion proposal. All fields are initialized based on the provided information. ! * ! * @param replacementString the actual string to be inserted into the document ! * @param replacementOffset the offset of the text to be replaced ! * @param replacementLength the length of the text to be replaced ! * @param cursorPosition the position of the cursor following the insert relative to replacementOffset ! * @param image the image to display for this proposal ! * @param displayString the string to be displayed for the proposal ! * @param contextInformation the context information associated with this proposal ! * @param additionalProposalInfo the additional information associated with this proposal * @param onApplyAction if we should not actually apply the changes when the completion is applied ! */ ! public PyCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo,int priority, int onApplyAction, String args) { ! Assert.isNotNull(replacementString); ! Assert.isTrue(replacementOffset >= 0); ! Assert.isTrue(replacementLength >= 0); ! Assert.isTrue(cursorPosition >= 0); ! ! fReplacementString= replacementString; ! fReplacementOffset= replacementOffset; ! fReplacementLength= replacementLength; ! fCursorPosition= cursorPosition; ! fImage= image; ! fDisplayString= displayString; ! fContextInformation= contextInformation; ! fAdditionalProposalInfo= additionalProposalInfo; ! this.priority = priority; this.onApplyAction = onApplyAction; this.fArgs = args; ! } ! /* ! * @see ICompletionProposal#apply(IDocument) ! */ ! public void apply(IDocument document) { ! if(onApplyAction == ON_APPLY_JUST_SHOW_CTX_INFO){ return; } ! if(onApplyAction == ON_APPLY_DEFAULT){ ! try { ! document.replace(fReplacementOffset, fReplacementLength, fReplacementString); ! } catch (BadLocationException x) { ! // ignore ! } return; } ! if(onApplyAction == ON_APPLY_SHOW_CTX_INFO_AND_ADD_PARAMETETRS){ ! try { String args; if(fArgs.length() > 0){ *************** *** 127,148 **** document.replace(fReplacementOffset+fReplacementLength, 0, args); } ! } catch (BadLocationException x) { ! // ignore x.printStackTrace(); ! } ! return; } ! throw new RuntimeException("Unexpected apply mode:"+onApplyAction); ! } ! ! /* ! * @see ICompletionProposal#getSelection(IDocument) ! */ ! public Point getSelection(IDocument document) { ! if(onApplyAction == ON_APPLY_JUST_SHOW_CTX_INFO){ ! return null; ! } ! if(onApplyAction == ON_APPLY_DEFAULT){ ! return new Point(fReplacementOffset + fCursorPosition, 0); } if(onApplyAction == ON_APPLY_SHOW_CTX_INFO_AND_ADD_PARAMETETRS){ --- 127,148 ---- document.replace(fReplacementOffset+fReplacementLength, 0, args); } ! } catch (BadLocationException x) { ! // ignore x.printStackTrace(); ! } ! return; } ! throw new RuntimeException("Unexpected apply mode:"+onApplyAction); ! } ! ! /* ! * @see ICompletionProposal#getSelection(IDocument) ! */ ! public Point getSelection(IDocument document) { ! if(onApplyAction == ON_APPLY_JUST_SHOW_CTX_INFO){ ! return null; ! } ! if(onApplyAction == ON_APPLY_DEFAULT){ ! return new Point(fReplacementOffset + fCursorPosition, 0); } if(onApplyAction == ON_APPLY_SHOW_CTX_INFO_AND_ADD_PARAMETETRS){ *************** *** 150,186 **** } throw new RuntimeException("Unexpected apply mode:"+onApplyAction); ! } ! /* ! * @see ICompletionProposal#getContextInformation() ! */ ! public IContextInformation getContextInformation() { ! return fContextInformation; ! } ! /* ! * @see ICompletionProposal#getImage() ! */ ! public Image getImage() { ! return fImage; ! } ! /* ! * @see ICompletionProposal#getDisplayString() ! */ ! public String getDisplayString() { ! if (fDisplayString != null) ! return fDisplayString; ! return fReplacementString; ! } ! /* ! * @see ICompletionProposal#getAdditionalProposalInfo() ! */ ! public String getAdditionalProposalInfo() { ! return fAdditionalProposalInfo; ! } ! /** * @see java.lang.Object#hashCode() */ --- 150,186 ---- } throw new RuntimeException("Unexpected apply mode:"+onApplyAction); ! } ! /* ! * @see ICompletionProposal#getContextInformation() ! */ ! public IContextInformation getContextInformation() { ! return fContextInformation; ! } ! /* ! * @see ICompletionProposal#getImage() ! */ ! public Image getImage() { ! return fImage; ! } ! /* ! * @see ICompletionProposal#getDisplayString() ! */ ! public String getDisplayString() { ! if (fDisplayString != null) ! return fDisplayString; ! return fReplacementString; ! } ! /* ! * @see ICompletionProposal#getAdditionalProposalInfo() ! */ ! public String getAdditionalProposalInfo() { ! return fAdditionalProposalInfo; ! } ! /** * @see java.lang.Object#hashCode() */ *************** *** 190,194 **** ! /** * @see java.lang.Object#equals(java.lang.Object) */ --- 190,194 ---- ! /** * @see java.lang.Object#equals(java.lang.Object) */ Index: PythonStringCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PythonStringCompletionProcessor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonStringCompletionProcessor.java 25 Mar 2007 16:08:59 -0000 1.1 --- PythonStringCompletionProcessor.java 28 Sep 2008 12:45:42 -0000 1.2 *************** *** 8,20 **** public class PythonStringCompletionProcessor extends PythonCompletionProcessor{ ! public PythonStringCompletionProcessor(PyEdit edit, PyContentAssistant pyContentAssistant) { ! super(edit, pyContentAssistant); ! } ! ! @Override ! public char[] getCompletionProposalAutoActivationCharacters() { ! //no auto-activation within strings. ! return new char[]{'@'}; ! } protected IPyCodeCompletion getCodeCompletionEngine() { --- 8,20 ---- public class PythonStringCompletionProcessor extends PythonCompletionProcessor{ ! public PythonStringCompletionProcessor(PyEdit edit, PyContentAssistant pyContentAssistant) { ! super(edit, pyContentAssistant); ! } ! ! @Override ! public char[] getCompletionProposalAutoActivationCharacters() { ! //no auto-activation within strings. ! return new char[]{'@'}; ! } protected IPyCodeCompletion getCodeCompletionEngine() { Index: PyContentAssistant.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyContentAssistant.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyContentAssistant.java 17 Aug 2008 00:26:46 -0000 1.8 --- PyContentAssistant.java 28 Sep 2008 12:45:42 -0000 1.9 *************** *** 44,50 **** try{ ! setRepeatedInvocationTrigger(KeyBindingHelper.getContentAssistProposalBinding()); }catch(Exception e){ ! //no need to log } --- 44,50 ---- try{ ! setRepeatedInvocationTrigger(KeyBindingHelper.getContentAssistProposalBinding()); }catch(Exception e){ ! //no need to log } *************** *** 52,56 **** setStatusLineVisible(true); }catch(Exception e){ ! //no need to log } } --- 52,56 ---- setStatusLineVisible(true); }catch(Exception e){ ! //no need to log } } Index: PyCodeCompletionInitializer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletionInitializer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyCodeCompletionInitializer.java 25 Mar 2007 16:08:59 -0000 1.1 --- PyCodeCompletionInitializer.java 28 Sep 2008 12:45:42 -0000 1.2 *************** *** 15,27 **** Preferences node = new DefaultScope().getNode(PydevPlugin.DEFAULT_PYDEV_SCOPE); ! node.putBoolean(PyCodeCompletionPreferencesPage.USE_CODECOMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_USE_CODECOMPLETION); ! node.putInt(PyCodeCompletionPreferencesPage.ATTEMPTS_CODECOMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_ATTEMPTS_CODECOMPLETION); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_DOT, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_DOT); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_ALL_ASCII_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_ALL_ASCII_CHARS); ! node.putBoolean(PyCodeCompletionPreferencesPage.USE_AUTOCOMPLETE, PyCodeCompletionPreferencesPage.DEFAULT_USE_AUTOCOMPLETE); ! node.putInt(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_DELAY, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_DELAY); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_PAR, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_PAR); ! node.putBoolean(PyCodeCompletionPreferencesPage.DEBUG_CODE_COMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_DEBUG_CODE_COMPLETION); ! node.putInt(PyCodeCompletionPreferencesPage.ARGUMENTS_DEEP_ANALYSIS_N_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS); } --- 15,27 ---- Preferences node = new DefaultScope().getNode(PydevPlugin.DEFAULT_PYDEV_SCOPE); ! node.putBoolean(PyCodeCompletionPreferencesPage.USE_CODECOMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_USE_CODECOMPLETION); ! node.putInt(PyCodeCompletionPreferencesPage.ATTEMPTS_CODECOMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_ATTEMPTS_CODECOMPLETION); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_DOT, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_DOT); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_ALL_ASCII_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_ALL_ASCII_CHARS); ! node.putBoolean(PyCodeCompletionPreferencesPage.USE_AUTOCOMPLETE, PyCodeCompletionPreferencesPage.DEFAULT_USE_AUTOCOMPLETE); ! node.putInt(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_DELAY, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_DELAY); ! node.putBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_PAR, PyCodeCompletionPreferencesPage.DEFAULT_AUTOCOMPLETE_ON_PAR); ! node.putBoolean(PyCodeCompletionPreferencesPage.DEBUG_CODE_COMPLETION, PyCodeCompletionPreferencesPage.DEFAULT_DEBUG_CODE_COMPLETION); ! node.putInt(PyCodeCompletionPreferencesPage.ARGUMENTS_DEEP_ANALYSIS_N_CHARS, PyCodeCompletionPreferencesPage.DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS); } Index: PyCodeCompletionPreferencesPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletionPreferencesPage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyCodeCompletionPreferencesPage.java 15 Jun 2008 21:03:31 -0000 1.2 --- PyCodeCompletionPreferencesPage.java 28 Sep 2008 12:45:42 -0000 1.3 *************** *** 30,54 **** public static final int DEFAULT_ATTEMPTS_CODECOMPLETION = 20; ! public static final String AUTOCOMPLETE_ON_DOT = "AUTOCOMPLETE_ON_DOT"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_DOT = true; ! ! public static final String AUTOCOMPLETE_ON_ALL_ASCII_CHARS = "AUTOCOMPLETE_ON_ALL_ASCII_CHARS"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_ALL_ASCII_CHARS = false; ! public static final String USE_AUTOCOMPLETE = "USE_AUTOCOMPLETE"; ! public static final boolean DEFAULT_USE_AUTOCOMPLETE = true; ! public static final String AUTOCOMPLETE_DELAY = "AUTOCOMPLETE_DELAY"; ! public static final int DEFAULT_AUTOCOMPLETE_DELAY = 0; ! public static final String AUTOCOMPLETE_ON_PAR = "AUTOCOMPLETE_ON_PAR"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_PAR = false; ! ! public static final String DEBUG_CODE_COMPLETION = "DEBUG_CODE_COMPLETION"; ! public static final boolean DEFAULT_DEBUG_CODE_COMPLETION = false; ! ! public static final String ARGUMENTS_DEEP_ANALYSIS_N_CHARS = "DEEP_ANALYSIS_N_CHARS"; ! public static final int DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS = 1; ! /** */ --- 30,54 ---- public static final int DEFAULT_ATTEMPTS_CODECOMPLETION = 20; ! public static final String AUTOCOMPLETE_ON_DOT = "AUTOCOMPLETE_ON_DOT"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_DOT = true; ! ! public static final String AUTOCOMPLETE_ON_ALL_ASCII_CHARS = "AUTOCOMPLETE_ON_ALL_ASCII_CHARS"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_ALL_ASCII_CHARS = false; ! public static final String USE_AUTOCOMPLETE = "USE_AUTOCOMPLETE"; ! public static final boolean DEFAULT_USE_AUTOCOMPLETE = true; ! public static final String AUTOCOMPLETE_DELAY = "AUTOCOMPLETE_DELAY"; ! public static final int DEFAULT_AUTOCOMPLETE_DELAY = 0; ! public static final String AUTOCOMPLETE_ON_PAR = "AUTOCOMPLETE_ON_PAR"; ! public static final boolean DEFAULT_AUTOCOMPLETE_ON_PAR = false; ! ! public static final String DEBUG_CODE_COMPLETION = "DEBUG_CODE_COMPLETION"; ! public static final boolean DEFAULT_DEBUG_CODE_COMPLETION = false; ! ! public static final String ARGUMENTS_DEEP_ANALYSIS_N_CHARS = "DEEP_ANALYSIS_N_CHARS"; ! public static final int DEFAULT_ARGUMENTS_DEEP_ANALYSIS_N_CHARS = 1; ! /** */ *************** *** 67,82 **** addField(new IntegerFieldEditor( ! ATTEMPTS_CODECOMPLETION, "Timeout to connect to shell (secs).", p)); ! addField(new IntegerFieldEditor( ! AUTOCOMPLETE_DELAY, "Autocompletion delay: ", p)); ! String tooltip = WordUtils.wrap("Determines the number of chars in the qualifier request " + ! "for which constructs such as 'from xxx import yyy' should be " + ! "analyzed to get its actual token and if it maps to a method, its paramaters will be added in the completion.", 80); ! IntegerFieldEditor deepAnalysisFieldEditor = new IntegerFieldEditor( ! ARGUMENTS_DEEP_ANALYSIS_N_CHARS, "Minimum number of chars in qualifier for\ndeep analysis for parameters in 'from' imports:", p); addField(deepAnalysisFieldEditor); deepAnalysisFieldEditor.getLabelControl(p).setToolTipText(tooltip); --- 67,82 ---- addField(new IntegerFieldEditor( ! ATTEMPTS_CODECOMPLETION, "Timeout to connect to shell (secs).", p)); ! addField(new IntegerFieldEditor( ! AUTOCOMPLETE_DELAY, "Autocompletion delay: ", p)); ! String tooltip = WordUtils.wrap("Determines the number of chars in the qualifier request " + ! "for which constructs such as 'from xxx import yyy' should be " + ! "analyzed to get its actual token and if it maps to a method, its paramaters will be added in the completion.", 80); ! IntegerFieldEditor deepAnalysisFieldEditor = new IntegerFieldEditor( ! ARGUMENTS_DEEP_ANALYSIS_N_CHARS, "Minimum number of chars in qualifier for\ndeep analysis for parameters in 'from' imports:", p); addField(deepAnalysisFieldEditor); deepAnalysisFieldEditor.getLabelControl(p).setToolTipText(tooltip); *************** *** 85,107 **** ! addField(new BooleanFieldEditor( ! USE_CODECOMPLETION, "Use code completion?", p)); ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_DOT, "Autocomplete on '.'?", p)); ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_PAR, "Autocomplete on '('?", p)); ! ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_PAR, "Autocomplete on ','?", p)); ! ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_ALL_ASCII_CHARS, "Autocomplete on all letter chars and '_'?", p)); ! ! addField(new BooleanFieldEditor( DEBUG_CODE_COMPLETION, "Debug code completion?", p)); ! } --- 85,107 ---- ! addField(new BooleanFieldEditor( ! USE_CODECOMPLETION, "Use code completion?", p)); ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_DOT, "Autocomplete on '.'?", p)); ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_PAR, "Autocomplete on '('?", p)); ! ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_PAR, "Autocomplete on ','?", p)); ! ! addField(new BooleanFieldEditor( ! AUTOCOMPLETE_ON_ALL_ASCII_CHARS, "Autocomplete on all letter chars and '_'?", p)); ! ! addField(new BooleanFieldEditor( DEBUG_CODE_COMPLETION, "Debug code completion?", p)); ! } Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PythonCompletionProcessor.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PythonCompletionProcessor.java 2 May 2008 23:24:14 -0000 1.6 --- PythonCompletionProcessor.java 28 Sep 2008 12:45:42 -0000 1.7 *************** *** 133,175 **** if(nature == null || !nature.startRequests()){ ! return new ICompletionProposal[0]; } try{ ! CompletionRequest request = new CompletionRequest(edit.getEditorFile(), ! nature, doc, documentOffset, codeCompletion); ! ! ! ! //SECOND: getting code completions and deciding if templates should be shown too. ! //Get code completion proposals ! if(PyCodeCompletionPreferencesPage.useCodeCompletion()){ ! if(whatToShow == SHOW_ALL){ ! try { ! pythonAndTemplateProposals.addAll(getPythonProposals(viewer, documentOffset, doc, request)); ! } catch (Throwable e) { ! setError(e); ! } ! } ! ! } ! ! ! String[] strs = PySelection.getActivationTokenAndQual(doc, documentOffset, false); ! ! String activationToken = strs[0]; ! String qualifier = strs[1]; ! ! ! //THIRD: Get template proposals (if asked for) ! if(request.showTemplates && (activationToken == null || activationToken.trim().length() == 0)){ ! List templateProposals = getTemplateProposals(viewer, documentOffset, activationToken, qualifier); ! pythonAndTemplateProposals.addAll(templateProposals); ! } ! ! ! //to show the valid ones, we'll get the qualifier from the initial request ! proposals = PyCodeCompletionUtils.onlyValidSorted(pythonAndTemplateProposals, request.qualifier, request.isInCalltip); }finally{ ! nature.endRequests(); } } catch (RuntimeException e) { --- 133,175 ---- if(nature == null || !nature.startRequests()){ ! return new ICompletionProposal[0]; } try{ ! CompletionRequest request = new CompletionRequest(edit.getEditorFile(), ! nature, doc, documentOffset, codeCompletion); ! ! ! ! //SECOND: getting code completions and deciding if templates should be shown too. ! //Get code completion proposals ! if(PyCodeCompletionPreferencesPage.useCodeCompletion()){ ! if(whatToShow == SHOW_ALL){ ! try { ! pythonAndTemplateProposals.addAll(getPythonProposals(viewer, documentOffset, doc, request)); ! } catch (Throwable e) { ! setError(e); ! } ! } ! ! } ! ! ! String[] strs = PySelection.getActivationTokenAndQual(doc, documentOffset, false); ! ! String activationToken = strs[0]; ! String qualifier = strs[1]; ! ! ! //THIRD: Get template proposals (if asked for) ! if(request.showTemplates && (activationToken == null || activationToken.trim().length() == 0)){ ! List templateProposals = getTemplateProposals(viewer, documentOffset, activationToken, qualifier); ! pythonAndTemplateProposals.addAll(templateProposals); ! } ! ! ! //to show the valid ones, we'll get the qualifier from the initial request ! proposals = PyCodeCompletionUtils.onlyValidSorted(pythonAndTemplateProposals, request.qualifier, request.isInCalltip); }finally{ ! nature.endRequests(); } } catch (RuntimeException e) { *************** *** 236,248 **** */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { ! //System.out.println("computeContextInformation"); ! if(viewer.getDocument() != this.contextInformationValidator.doc){ ! return null; ! } ! //System.out.println("this.contextInformationValidator.returnedFalseOnce:"+this.contextInformationValidator.returnedFalseOnce); ! //if we didn't return false at least once, it is already installed. ! if(this.contextInformationValidator.returnedFalseOnce && this.contextInformationValidator.isContextInformationValid(documentOffset)){ ! return new IContextInformation[]{this.contextInformationValidator.fInformation}; ! } return null; } --- 236,248 ---- */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { ! //System.out.println("computeContextInformation"); ! if(viewer.getDocument() != this.contextInformationValidator.doc){ ! return null; ! } ! //System.out.println("this.contextInformationValidator.returnedFalseOnce:"+this.contextInformationValidator.returnedFalseOnce); ! //if we didn't return false at least once, it is already installed. ! if(this.contextInformationValidator.returnedFalseOnce && this.contextInformationValidator.isContextInformationValid(documentOffset)){ ! return new IContextInformation[]{this.contextInformationValidator.fInformation}; ! } return null; } *************** *** 264,296 **** */ public static char[] getStaticCompletionProposalAutoActivationCharacters() { ! if(!listenerToClearAutoActivationAlreadySetup){ ! //clears the cache when the preferences are changed. ! IPreferenceStore preferenceStore = PydevPlugin.getDefault().getPreferenceStore(); ! preferenceStore.addPropertyChangeListener(new IPropertyChangeListener(){ ! ! public void propertyChange(PropertyChangeEvent event) { ! activationChars = null; //clear the cache when it changes ! } ! ! }); ! listenerToClearAutoActivationAlreadySetup = true; ! } - if(activationChars == null){ //let's cache this ! ! if(!PyCodeCompletionPreferencesPage.useAutocomplete()){ ! activationChars = new char[0]; ! ! }else{ ! char[] c = new char[0]; ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnDot()) { ! c = addChar(c, '.'); ! } ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnPar()) { ! c = addChar(c, '('); ! } ! activationChars = c; ! } } return activationChars; --- 264,296 ---- */ public static char[] getStaticCompletionProposalAutoActivationCharacters() { ! if(!listenerToClearAutoActivationAlreadySetup){ ! //clears the cache when the preferences are changed. ! IPreferenceStore preferenceStore = PydevPlugin.getDefault().getPreferenceStore(); ! preferenceStore.addPropertyChangeListener(new IPropertyChangeListener(){ ! ! public void propertyChange(PropertyChangeEvent event) { ! activationChars = null; //clear the cache when it changes ! } ! ! }); ! listenerToClearAutoActivationAlreadySetup = true; ! } ! if(activationChars == null){ //let's cache this ! ! if(!PyCodeCompletionPreferencesPage.useAutocomplete()){ ! activationChars = new char[0]; ! ! }else{ ! char[] c = new char[0]; ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnDot()) { ! c = addChar(c, '.'); ! } ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnPar()) { ! c = addChar(c, '('); ! } ! activationChars = c; ! } } return activationChars; Index: ProposalsComparator.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/ProposalsComparator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProposalsComparator.java 24 Mar 2008 01:53:22 -0000 1.2 --- ProposalsComparator.java 28 Sep 2008 12:45:42 -0000 1.3 *************** *** 18,52 **** if(o1 instanceof IPyCompletionProposal && o2 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p1 = (IPyCompletionProposal) o1; ! IPyCompletionProposal p2 = (IPyCompletionProposal) o2; ! if(p1.getPriority() < p2.getPriority()){ ! return -1; ! } ! if(p1.getPriority() > p2.getPriority()){ ! return 1; ! } } //if it is not an IPyCompletionProposal, it has default priority. else if(o1 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p1 = (IPyCompletionProposal) o1; ! if(p1.getPriority() < IPyCompletionProposal.PRIORITY_DEFAULT){ ! return -1; ! } ! if(p1.getPriority() > IPyCompletionProposal.PRIORITY_DEFAULT){ ! return 1; ! } } else if(o2 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p2 = (IPyCompletionProposal) o2; ! if(IPyCompletionProposal.PRIORITY_DEFAULT < p2.getPriority()){ ! return -1; ! } ! if(IPyCompletionProposal.PRIORITY_DEFAULT > p2.getPriority()){ ! return 1; ! } } --- 18,52 ---- if(o1 instanceof IPyCompletionProposal && o2 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p1 = (IPyCompletionProposal) o1; ! IPyCompletionProposal p2 = (IPyCompletionProposal) o2; ! if(p1.getPriority() < p2.getPriority()){ ! return -1; ! } ! if(p1.getPriority() > p2.getPriority()){ ! return 1; ! } } //if it is not an IPyCompletionProposal, it has default priority. else if(o1 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p1 = (IPyCompletionProposal) o1; ! if(p1.getPriority() < IPyCompletionProposal.PRIORITY_DEFAULT){ ! return -1; ! } ! if(p1.getPriority() > IPyCompletionProposal.PRIORITY_DEFAULT){ ! return 1; ! } } else if(o2 instanceof IPyCompletionProposal){ ! IPyCompletionProposal p2 = (IPyCompletionProposal) o2; ! if(IPyCompletionProposal.PRIORITY_DEFAULT < p2.getPriority()){ ! return -1; ! } ! if(IPyCompletionProposal.PRIORITY_DEFAULT > p2.getPriority()){ ! return 1; ! } } Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyCodeCompletion.java 13 Aug 2008 21:12:16 -0000 1.7 --- PyCodeCompletion.java 28 Sep 2008 12:45:42 -0000 1.8 *************** *** 79,86 **** */ public List getCodeCompletionProposals(ITextViewer viewer, CompletionRequest request) throws CoreException, BadLocationException { ! if(request.getPySelection().getCursorLineContents().trim().startsWith("#")){ ! //this may happen if the context is still not correctly computed in python ! return new PyStringCodeCompletion().getCodeCompletionProposals(viewer, request); ! } if(DEBUG_CODE_COMPLETION){ Log.toLogFile(this,"Starting getCodeCompletionProposals"); --- 79,86 ---- */ public List getCodeCompletionProposals(ITextViewer viewer, CompletionRequest request) throws CoreException, BadLocationException { ! if(request.getPySelection().getCursorLineContents().trim().startsWith("#")){ ! //this may happen if the context is still not correctly computed in python ! return new PyStringCodeCompletion().getCodeCompletionProposals(viewer, request); ! } if(DEBUG_CODE_COMPLETION){ Log.toLogFile(this,"Starting getCodeCompletionProposals"); *************** *** 110,118 **** List<Object> tokensList = new ArrayList<Object>(); try { ! lazyStartShell(request); ! } catch (NotConfiguredInterpreterException e) { ! Log.log(IStatus.WARNING, "Warning: unable to get code-completion for builtins: No interpreter configured.", null); ! } ! String trimmed = request.activationToken.replace('.', ' ').trim(); ImportInfo importsTipper = getImportsTipperStr(request); --- 110,118 ---- List<Object> tokensList = new ArrayList<Object>(); try { ! lazyStartShell(request); ! } catch (NotConfiguredInterpreterException e) { ! Log.log(IStatus.WARNING, "Warning: unable to get code-completion for builtins: No interpreter configured.", null); ! } ! String trimmed = request.activationToken.replace('.', ' ').trim(); ImportInfo importsTipper = getImportsTipperStr(request); *************** *** 190,199 **** } if(token2 == null || ! (token2.equals(token) && ! token2.getArgs().equals(token.getArgs()) && ! token2.getParentPackage().equals(token.getParentPackage()))){ ! ! token2.equals(token); ! break; } token = token2; --- 190,199 ---- } if(token2 == null || ! (token2.equals(token) && ! token2.getArgs().equals(token.getArgs()) && ! token2.getParentPackage().equals(token.getParentPackage()))){ ! ! token2.equals(token); ! break; } token = token2; *************** *** 215,224 **** changeItokenToCompletionPropostal(viewer, request, ret, tokensList, importsTip, state); } catch (CompletionRecursionException e) { ! if(onCompletionRecursionException != null){ ! onCompletionRecursionException.call(e); ! } ! if(DEBUG_CODE_COMPLETION){ ! Log.toLogFile(e); ! } //PydevPlugin.log(e); //ret.add(new CompletionProposal("",request.documentOffset,0,0,null,e.getMessage(), null,null)); --- 215,224 ---- changeItokenToCompletionPropostal(viewer, request, ret, tokensList, importsTip, state); } catch (CompletionRecursionException e) { ! if(onCompletionRecursionException != null){ ! onCompletionRecursionException.call(e); ! } ! if(DEBUG_CODE_COMPLETION){ ! Log.toLogFile(e); ! } //PydevPlugin.log(e); //ret.add(new CompletionProposal("",request.documentOffset,0,0,null,e.getMessage(), null,null)); *************** *** 338,342 **** } } catch (RuntimeException e) { ! throw e; } catch (Exception e) { throw new RuntimeException(e); --- 338,342 ---- } } catch (RuntimeException e) { ! throw e; } catch (Exception e) { throw new RuntimeException(e); *************** *** 369,412 **** */ @SuppressWarnings("unchecked") ! public static boolean getSelfOrClsCompletions(CompletionRequest request, List theList, ICompletionState state, ! boolean getOnlySupers, boolean checkIfInCorrectScope, String lookForRep) { ! SimpleNode s = PyParser.reparseDocument(new PyParser.ParserInfo(request.doc, true, request.nature, state.getLine())).o1; if(s != null){ ! FindScopeVisitor visitor = new FindScopeVisitor(state.getLine(), 0); ! try { ! s.accept(visitor); ! if(checkIfInCorrectScope){ ! boolean scopeCorrect = false; ! ! FastStack<SimpleNode> scopeStack = visitor.scope.getScopeStack(); ! for(Iterator<SimpleNode> it=scopeStack.topDownIterator();scopeCorrect == false && it.hasNext();){ ! SimpleNode node = it.next(); ! if (node instanceof FunctionDef) { ! FunctionDef funcDef = (FunctionDef) node; ! if(funcDef.args != null && funcDef.args.args != null || funcDef.args.args.length > 0){ ! //ok, we have some arg, let's check for self or cls ! String rep = NodeUtils.getRepresentationString(funcDef.args.args[0]); ! if(rep != null && (rep.equals("self") || rep.equals("cls"))){ ! scopeCorrect = true; ! } ! } ! } ! } ! if(!scopeCorrect){ ! return false; ! } ! } ! if(lookForRep.equals("self")){ ! state.setLookingFor(ICompletionState.LOOKING_FOR_INSTANCED_VARIABLE); ! }else{ ! state.setLookingFor(ICompletionState.LOOKING_FOR_CLASSMETHOD_VARIABLE); ! } ! getSelfOrClsCompletions(visitor.scope, request, theList, state, getOnlySupers); ! } catch (Exception e1) { ! PydevPlugin.log(e1); ! } ! return true; ! } return false; } --- 369,412 ---- */ @SuppressWarnings("unchecked") ! public static boolean getSelfOrClsCompletions(CompletionRequest request, List theList, ICompletionState state, ! boolean getOnlySupers, boolean checkIfInCorrectScope, String lookForRep) { ! SimpleNode s = PyParser.reparseDocument(new PyParser.ParserInfo(request.doc, true, request.nature, state.getLine())).o1; if(s != null){ ! FindScopeVisitor visitor = new FindScopeVisitor(state.getLine(), 0); ! try { ! s.accept(visitor); ! if(checkIfInCorrectScope){ ! boolean scopeCorrect = false; ! ! FastStack<SimpleNode> scopeStack = visitor.scope.getScopeStack(); ! for(Iterator<SimpleNode> it=scopeStack.topDownIterator();scopeCorrect == false && it.hasNext();){ ! SimpleNode node = it.next(); ! if (node instanceof FunctionDef) { ! FunctionDef funcDef = (FunctionDef) node; ! if(funcDef.args != null && funcDef.args.args != null || funcDef.args.args.length > 0){ ! //ok, we have some arg, let's check for self or cls ! String rep = NodeUtils.getRepresentationString(funcDef.args.args[0]); ! if(rep != null && (rep.equals("self") || rep.equals("cls"))){ ! scopeCorrect = true; ! } ! } ! } ! } ! if(!scopeCorrect){ ! return false; ! } ! } ! if(lookForRep.equals("self")){ ! state.setLookingFor(ICompletionState.LOOKING_FOR_INSTANCED_VARIABLE); ! }else{ ! state.setLookingFor(ICompletionState.LOOKING_FOR_CLASSMETHOD_VARIABLE); ! } ! getSelfOrClsCompletions(visitor.scope, request, theList, state, getOnlySupers); ! } catch (Exception e1) { ! PydevPlugin.log(e1); ! } ! return true; ! } return false; } *************** *** 427,438 **** if(d.bases[i] instanceof Name){ Name n = (Name) d.bases[i]; ! state.setActivationToken(n.id); ! IToken[] completions; ! try { ! completions = request.nature.getAstManager().getCompletionsForToken(request.editorFile, request.doc, state); ! gottenComps.addAll(Arrays.asList(completions)); ! } catch (CompletionRecursionException e) { ! //ok... ! } } } --- 427,438 ---- if(d.bases[i] instanceof Name){ Name n = (Name) d.bases[i]; ! state.setActivationToken(n.id); ! IToken[] completions; ! try { ! completions = request.nature.getAstManager().getCompletionsForToken(request.editorFile, request.doc, state); ! gottenComps.addAll(Arrays.asList(completions)); ! } catch (CompletionRecursionException e) { ! //ok... ! } } } *************** *** 452,461 **** //ok, it's just really self, let's get on to get the completions state.setActivationToken(NodeUtils.getNameFromNameTok((NameTok) d.name)); ! try { theList.addAll(Arrays.asList(request.nature.getAstManager().getCompletionsForToken(request.editorFile, request.doc, state))); ! } catch (CompletionRecursionException e) { ! //ok ! } ! }else{ //it's not only self, so, first we have to get the definition of the token --- 452,461 ---- //ok, it's just really self, let's get on to get the completions state.setActivationToken(NodeUtils.getNameFromNameTok((NameTok) d.name)); ! try { theList.addAll(Arrays.asList(request.nature.getAstManager().getCompletionsForToken(request.editorFile, request.doc, state))); ! } catch (CompletionRecursionException e) { ! //ok ! } ! }else{ //it's not only self, so, first we have to get the definition of the token Index: AbstractPyCompletionProposalExtension2.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_completions/org/python/pydev/editor/codecompletion/AbstractPyCompletionProposalExtension2.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractPyCompletionProposalExtension2.java 15 Jun 2008 21:03:31 -0000 1.1 --- AbstractPyCompletionProposalExtension2.java 28 Sep 2008 12:45:42 -0000 1.2 *************** *** 84,88 **** */ private boolean isValidChar(char c) { ! return Character.isJavaIdentifierPart(c); } --- 84,88 ---- */ private boolean isValidChar(char c) { ! return Character.isJavaIdentifierPart(c); } |