[Pydev-code] Re: PyDev WorkingCopyManager?
Brought to you by:
fabioz
|
From: Phil M. <pmu...@re...> - 2005-03-02 22:43:46
|
Aleks
Thanks for the reply. This looks just what I need. All the other parsers
use the C/C++/Java working model manager framework, so I (wrongly)
assumed that about PyDev. I'll integrate this code into the plug-in, and
see if I can get a changelog parser working for PyDev/Python
Many Regards
Phil
On Wed, 2005-03-02 at 14:17 -0800, Aleks Totic wrote:
> I have not worked on pydev in a while, but I do not recall ever
> touching the workingCopy class. We are not derived from the same
> code base. Are you looking for a way to detect the name of the
> current function underneath the cursor? We do something like this
> to show hyperlinks over function names:
>
> IDocument doc =
> pyEdit.getDocumentProvider().getDocument(pyEdit.getEditorInput());
> ITextSelection selection = (ITextSelection)
> pyEdit.getSelectionProvider().getSelection();
>
> Location loc = Location.offsetToLocation(doc, selection.getOffset());
> AbstractNode node =
> ModelUtils.getElement(pyEdit.getPythonModel(), loc,
> AbstractNode.PROP_CLICKABLE);
>
> Node should then contain the element you are hovering over.
>
> This all might be obsolete, but that's the way it looked last
> time I looked at it.
>
> Aleks
>
> Phil Muldoon wrote:
> > Hi guys,
> >
> > First let me apologize for not sending this to the list. I think my join
> > list request has gone awry.
> >
> > Anyway.
> >
> > I've been asked to write a changelog parser (for the changelog eclipse
> > plugin) for pydev. I currently have a C/C++ (from the CDT) parser and a
> > Java Parser. This just basically finds the current function under the
> > cursor. They are implemented very similarly, here is an example of a C
> > parser (the Java parser is almost exactly the same).
> >
> > if (editor instanceof CEditor) {
> >
> > CEditor c_editor = (CEditor) editor;
> > ITextSelection selection =
> > (ITextSelection) c_editor.getSelectionProvider
> > ().getSelection();
> >
> >
> > IEditorInput input = c_editor.getEditorInput();
> > IWorkingCopyManager manager = CUIPlugin.getDefault
> > ().getWorkingCopyManager();
> >
> > manager.connect(input);
> >
> > IWorkingCopy workingCopy = manager.getWorkingCopy(input);
> > ICElement method = workingCopy.getElementAtOffset(selection
> > .getOffset());
> > manager.disconnect(input);
> >
> > This would look exactly the same as the PyDev parser, except that I
> > cannot find where to get PyDev's working copy manager. So in this code
> >
> > if (editor instanceof PyEdit) {
> >
> > PyEdit python_editor = (PyEdit) editor;
> > ITextSelection selection = (ITextSelection)
> > python_editor.getSelectionProvider().getSelection();
> >
> >
> > IEditorInput input = python_editor.getEditorInput();
> >
> > IWorkingCopyManager manager = PydevPlugin.getDefault().
> > getWorkingCopyManager();
> >
> > I could be looking in the wrong place for it (PydevPlugin might not be
> > the appropriate place). Do either of you have any clues?
> >
> > Regards
> >
> > Phil Muldoon
> >
> >
>
|