pydev-cvs Mailing List for PyDev for Eclipse (Page 301)
Brought to you by:
fabioz
You can subscribe to this list here.
2004 |
Jan
|
Feb
(4) |
Mar
(48) |
Apr
(56) |
May
(64) |
Jun
(27) |
Jul
(66) |
Aug
(81) |
Sep
(148) |
Oct
(194) |
Nov
(78) |
Dec
(46) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(125) |
Feb
(126) |
Mar
(163) |
Apr
(133) |
May
(115) |
Jun
(307) |
Jul
(387) |
Aug
(417) |
Sep
(283) |
Oct
(148) |
Nov
(45) |
Dec
(53) |
2006 |
Jan
(240) |
Feb
(200) |
Mar
(267) |
Apr
(231) |
May
(245) |
Jun
(361) |
Jul
(142) |
Aug
(12) |
Sep
(210) |
Oct
(99) |
Nov
(7) |
Dec
(30) |
2007 |
Jan
(161) |
Feb
(511) |
Mar
(265) |
Apr
(74) |
May
(147) |
Jun
(151) |
Jul
(94) |
Aug
(68) |
Sep
(98) |
Oct
(144) |
Nov
(26) |
Dec
(36) |
2008 |
Jan
(98) |
Feb
(107) |
Mar
(199) |
Apr
(113) |
May
(119) |
Jun
(112) |
Jul
(92) |
Aug
(71) |
Sep
(101) |
Oct
(16) |
Nov
|
Dec
|
From: Aleksandar T. <at...@us...> - 2004-09-23 22:20:40
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30089/src/org/python/pydev/debug/core Modified Files: PydevDebugPlugin.java Log Message: Fixed failure to log error when not on UI thread. Index: PydevDebugPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core/PydevDebugPlugin.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PydevDebugPlugin.java 2 Jul 2004 02:26:01 -0000 1.7 --- PydevDebugPlugin.java 23 Sep 2004 22:20:31 -0000 1.8 *************** *** 69,73 **** public static void errorDialog(final String message, final Throwable t) { ! Display disp = Display.getCurrent(); disp.asyncExec(new Runnable() { public void run() { --- 69,73 ---- public static void errorDialog(final String message, final Throwable t) { ! Display disp = Display.getDefault(); disp.asyncExec(new Runnable() { public void run() { |
From: Aleksandar T. <at...@us...> - 2004-09-23 22:16:10
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29122/src/org/python/pydev/debug/model Modified Files: XMLUtils.java Log Message: Fix null dereference, bug 1028530 Index: XMLUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/XMLUtils.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** XMLUtils.java 17 May 2004 20:17:15 -0000 1.3 --- XMLUtils.java 23 Sep 2004 22:15:53 -0000 1.4 *************** *** 152,156 **** currentFrame = thread.findStackFrameByID(id);; if (currentFrame == null) ! currentFrame = new PyStackFrame(thread, id, name, filePath, Integer.parseInt(line)); else { currentFrame.setName(name); --- 152,156 ---- currentFrame = thread.findStackFrameByID(id);; if (currentFrame == null) ! currentFrame = new PyStackFrame(thread, id, name, filePath, Integer.parseInt(line)); else { currentFrame.setName(name); *************** *** 161,172 **** } // local variables belong to the stack frame // when private void startVar(Attributes attributes) { ! if (locals == null) { ! locals = new ArrayList(); ! PyVariableCollection global = new PyVariableCollection(target, "Globals", "frame.f_global", "Global variables", currentFrame.getGlobalLocator()); ! locals.add(global); // locals always include global as the top ! } // create a local variable, and add it to locals PyVariable newLocal = createVariable(target, currentFrame.getLocalsLocator(), attributes); --- 161,175 ---- } + private void initializeLocals() { + locals = new ArrayList(); + PyVariableCollection global = new PyVariableCollection(target, "Globals", "frame.f_global", "Global variables", currentFrame.getGlobalLocator()); + locals.add(global); // locals always include global as the top + } + // local variables belong to the stack frame // when private void startVar(Attributes attributes) { ! if (locals == null) ! initializeLocals(); // create a local variable, and add it to locals PyVariable newLocal = createVariable(target, currentFrame.getLocalsLocator(), attributes); *************** *** 201,204 **** --- 204,209 ---- if (qName.equals("frame")) { // when frame ends, we need to assign all the local variables + if (locals == null) + initializeLocals(); IVariable[] locArry = new IVariable[locals.size()]; for (int i=0; i < locArry.length; i++) |
From: Fabio Z. <fa...@us...> - 2004-09-23 18:07:14
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6871/src/org/python/pydev/editor/correctionassist Modified Files: PythonCorrectionProcessor.java Log Message: Making correction assistant on Ctrl+1 Index: PythonCorrectionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/PythonCorrectionProcessor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonCorrectionProcessor.java 23 Sep 2004 17:59:59 -0000 1.1 --- PythonCorrectionProcessor.java 23 Sep 2004 18:06:31 -0000 1.2 *************** *** 9,13 **** import java.util.List; - import org.eclipse.jdt.internal.corext.util.Strings; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.ITextViewer; --- 9,12 ---- |
From: Fabio Z. <fa...@us...> - 2004-09-23 18:06:50
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6871 Modified Files: plugin.xml Log Message: Making correction assistant on Ctrl+1 Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** plugin.xml 23 Sep 2004 18:03:20 -0000 1.42 --- plugin.xml 23 Sep 2004 18:06:31 -0000 1.43 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.9.7c" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.9.8" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> *************** *** 22,28 **** <import plugin="org.eclipse.ui.workbench.texteditor"/> <import plugin="org.eclipse.jface.text"/> - <import plugin="org.eclipse.jdt"/> - <import plugin="org.eclipse.jdt.core"/> - <import plugin="org.eclipse.jdt.ui"/> </requires> --- 22,25 ---- |
From: Fabio Z. <fa...@us...> - 2004-09-23 18:03:34
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6092 Modified Files: plugin.xml Log Message: Making correction assistant on Ctrl+1 Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** plugin.xml 22 Sep 2004 16:32:41 -0000 1.41 --- plugin.xml 23 Sep 2004 18:03:20 -0000 1.42 *************** *** 22,25 **** --- 22,28 ---- <import plugin="org.eclipse.ui.workbench.texteditor"/> <import plugin="org.eclipse.jface.text"/> + <import plugin="org.eclipse.jdt"/> + <import plugin="org.eclipse.jdt.core"/> + <import plugin="org.eclipse.jdt.ui"/> </requires> *************** *** 742,745 **** --- 745,757 ---- </perspectiveExtension> </extension> + <extension + point="org.eclipse.ui.ide.markerResolution"> + <markerResolutionGenerator + class="org.python.pydev.editor.markers.PyQuickFix" + markerType="org.eclipse.core.resources.problemmarker"/> + <markerResolutionGenerator + markerType="org.python.pydev.editor.markers.pycontentgeneratormarker" + class="org.python.pydev.editor.markers.PyContentGenerator"/> + </extension> </plugin> |
From: Fabio Z. <fa...@us...> - 2004-09-23 18:03:31
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6092/PySrc Modified Files: test_simpleTipper.py Log Message: Making correction assistant on Ctrl+1 Index: test_simpleTipper.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/test_simpleTipper.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** test_simpleTipper.py 22 Sep 2004 12:04:30 -0000 1.8 --- test_simpleTipper.py 23 Sep 2004 18:03:19 -0000 1.9 *************** *** 14,17 **** --- 14,18 ---- def tearDown(self): unittest.TestCase.tearDown(self) + def getDoc1(self): |
From: Fabio Z. <fa...@us...> - 2004-09-23 18:00:40
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5252/src/org/python/pydev/editor/codefolding Modified Files: PyEditProjection.java Added Files: PySourceViewer.java Log Message: Making correction assistant on Ctrl+1 --- NEW FILE: PySourceViewer.java --- /* * Created on Sep 23, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.codefolding; import org.eclipse.jface.text.source.IOverviewRuler; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.SourceViewerConfiguration; import org.eclipse.jface.text.source.projection.ProjectionViewer; import org.eclipse.swt.widgets.Composite; import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.PyEditConfiguration; import org.python.pydev.editor.correctionassist.PyCorrectionAssistant; public class PySourceViewer extends ProjectionViewer { private PyEditProjection projection; private PyCorrectionAssistant fCorrectionAssistant; public PySourceViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles, PyEditProjection projection) { super(parent, ruler, overviewRuler, showsAnnotationOverview, styles); this.projection = projection; } public void configure(SourceViewerConfiguration configuration) { super.configure(configuration); if (configuration instanceof PyEditConfiguration) { PyEditConfiguration pyConfiguration = (PyEditConfiguration) configuration; fCorrectionAssistant = pyConfiguration.getCorrectionAssistant(this); fCorrectionAssistant.install(this); } } /* (non-Javadoc) } * @see org.eclipse.jface.text.source.projection.ProjectionViewer#canDoOperation(int) */ public boolean canDoOperation(int operation) { if(operation == PyEdit.CORRECTIONASSIST_PROPOSALS){ return true; } return super.canDoOperation(operation); } /* (non-Javadoc) * @see org.eclipse.jface.text.source.projection.ProjectionViewer#doOperation(int) */ public void doOperation(int operation) { super.doOperation(operation); if (getTextWidget() == null) return; switch (operation) { case PyEdit.CORRECTIONASSIST_PROPOSALS: String msg= fCorrectionAssistant.showPossibleCompletions(); projection.setStatusLineErrorMessage(msg); return; } } } Index: PyEditProjection.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding/PyEditProjection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyEditProjection.java 22 Jul 2004 13:27:31 -0000 1.4 --- PyEditProjection.java 23 Sep 2004 17:59:58 -0000 1.5 *************** *** 9,12 **** --- 9,13 ---- import org.eclipse.jface.text.IInformationControl; import org.eclipse.jface.text.IInformationControlCreator; + import org.eclipse.jface.text.source.IOverviewRuler; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRuler; *************** *** 16,19 **** --- 17,22 ---- import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.editors.text.TextEditor; + import org.eclipse.ui.texteditor.IEditorStatusLine; + import org.python.pydev.editor.correctionassist.PyCorrectionAssistant; import org.python.pydev.parser.IParserListener; import org.python.pydev.plugin.PydevPrefs; *************** *** 30,33 **** --- 33,37 ---- private ProjectionSupport fProjectionSupport; + private PyCorrectionAssistant fCorrectionAssistant; public static final int PROP_FOLDING_CHANGED = -999; *************** *** 42,47 **** protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { ! return new ProjectionViewer(parent, ruler, getOverviewRuler(), true, ! styles); } --- 46,50 ---- protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { ! return new PySourceViewer(parent, ruler, getOverviewRuler(), true, styles, this); } *************** *** 95,98 **** --- 98,112 ---- } + /** + * Sets the given message as error message to this editor's status line. + * + * @param msg message to be set + */ + public void setStatusLineErrorMessage(String msg) { + IEditorStatusLine statusLine= (IEditorStatusLine) getAdapter(IEditorStatusLine.class); + if (statusLine != null) + statusLine.setMessage(true, msg, null); + } + } \ No newline at end of file |
From: Fabio Z. <fa...@us...> - 2004-09-23 18:00:13
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5252/src/org/python/pydev/editor Modified Files: PyEditConfiguration.java PyEdit.java Log Message: Making correction assistant on Ctrl+1 Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PyEditConfiguration.java 13 Sep 2004 17:11:53 -0000 1.19 --- PyEditConfiguration.java 23 Sep 2004 18:00:00 -0000 1.20 *************** *** 45,48 **** --- 45,50 ---- import org.python.pydev.editor.codecompletion.PyContentAssistant; import org.python.pydev.editor.codecompletion.PythonCompletionProcessor; + import org.python.pydev.editor.correctionassist.PyCorrectionAssistant; + import org.python.pydev.editor.correctionassist.PythonCorrectionProcessor; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.PydevPrefs; *************** *** 281,285 **** } ! /* (non-Javadoc) * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(org.eclipse.jface.text.source.ISourceViewer) --- 283,288 ---- } ! ! /* (non-Javadoc) * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(org.eclipse.jface.text.source.ISourceViewer) *************** *** 305,312 **** --- 308,343 ---- Color bgColor = colorCache.getColor(new RGB(230,255,230)); assistant.setProposalSelectorBackground(bgColor); + return assistant; } + /* (non-Javadoc) + * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(org.eclipse.jface.text.source.ISourceViewer) + */ + public PyCorrectionAssistant getCorrectionAssistant(ISourceViewer sourceViewer) { + final String PY_SINGLELINE_STRING = "__python_singleline_string"; + final String PY_MULTILINE_STRING = "__python_multiline_string"; + + // create a content assistant: + PyCorrectionAssistant assistant = new PyCorrectionAssistant(); + + // next create a content assistant processor to populate the completions window + IContentAssistProcessor processor = new PythonCorrectionProcessor(this.getEdit()); + + // No code completion in strings + assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_SINGLELINE_STRING ); + assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_MULTILINE_STRING ); + assistant.setContentAssistProcessor(processor,IDocument.DEFAULT_CONTENT_TYPE ); + assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); + + //delay and auto activate set on PyContentAssistant constructor. + + Color bgColor = colorCache.getColor(new RGB(230,255,230)); + assistant.setProposalSelectorBackground(bgColor); + + return assistant; + } + // The presenter instance for the information window private static final DefaultInformationControl.IInformationPresenter presenter = Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** PyEdit.java 16 Sep 2004 15:33:33 -0000 1.23 --- PyEdit.java 23 Sep 2004 18:00:00 -0000 1.24 *************** *** 58,120 **** import org.python.pydev.ui.ColorCache; - /** * The TextWidget. * ! * <p>Ties together all the main classes in this plugin. ! * <li>The {@link org.python.pydev.editor.PyEditConfiguration PyEditConfiguration} does preliminary partitioning. ! * <li>The {@link org.python.pydev.parser.PyParser PyParser} does a lazy validating python parse. ! * <li>The {@link org.python.pydev.outline.PyOutlinePage PyOutlinePage} shows the outline * ! * <p>Listens to the parser's events, and displays error markers from the parser. * ! * <p>General notes: ! * <p>TextWidget creates SourceViewer, an SWT control ! * @see <a href="http://dev.eclipse.org/newslists/news.eclipse.tools/msg61594.html">This eclipse article was an inspiration</a> * */ public class PyEdit extends PyEditProjection { ! static public String EDITOR_ID = "org.python.pydev.editor.PythonEditor"; ! static public String ACTION_OPEN = "OpenEditor"; ! ! /** color cache */ ! private ColorCache colorCache; ! /** lexical parser that continuously reparses the document on a thread */ ! private PyParser parser; ! // Listener waits for tab/spaces preferences that affect sourceViewer ! private Preferences.IPropertyChangeListener prefListener; ! /** need it to support GUESS_TAB_SUBSTITUTION preference */ ! private PyAutoIndentStrategy indentStrategy; ! /** need to hold onto it to support indentPrefix change through preferences */ ! PyEditConfiguration editConfiguration; ! /** Python model */ ! AbstractNode pythonModel; ! /** Hyperlinking listener */ ! Hyperlink fMouseListener; ! /** listeners that get notified of model changes */ ! ArrayList modelListeners; ! public PyEdit() { ! super(); ! modelListeners = new ArrayList(); ! colorCache = new ColorCache(PydevPrefs.getPreferences()); ! if (getDocumentProvider() == null) { ! setDocumentProvider(new PyDocumentProvider()); ! } ! editConfiguration = new PyEditConfiguration(colorCache,this); ! setSourceViewerConfiguration(editConfiguration); ! indentStrategy = (PyAutoIndentStrategy)editConfiguration.getAutoIndentStrategy(null, IDocument.DEFAULT_CONTENT_TYPE); ! setRangeIndicator(new DefaultRangeIndicator()); // enables standard vertical ruler ! //Added to set the code folding. CodeFoldingSetter codeFoldingSetter = new CodeFoldingSetter(this); this.addModelListener(codeFoldingSetter); this.addPropertyListener(codeFoldingSetter); ! //we also want to initialize our shells... //we use 2: one for refactoring and one for code completion. ! new Thread(){ ! public void run(){ try { try { --- 58,140 ---- import org.python.pydev.ui.ColorCache; /** * The TextWidget. * ! * <p> ! * Ties together all the main classes in this plugin. ! * <li>The ! * {@link org.python.pydev.editor.PyEditConfiguration PyEditConfiguration}does ! * preliminary partitioning. ! * <li>The {@link org.python.pydev.parser.PyParser PyParser}does a lazy ! * validating python parse. ! * <li>The {@link org.python.pydev.outline.PyOutlinePage PyOutlinePage}shows ! * the outline * ! * <p> ! * Listens to the parser's events, and displays error markers from the parser. * ! * <p> ! * General notes: ! * <p> ! * TextWidget creates SourceViewer, an SWT control * + * @see <a + * href="http://dev.eclipse.org/newslists/news.eclipse.tools/msg61594.html">This + * eclipse article was an inspiration </a> + * */ public class PyEdit extends PyEditProjection { ! static public String EDITOR_ID = "org.python.pydev.editor.PythonEditor"; ! static public String ACTION_OPEN = "OpenEditor"; ! /** color cache */ ! private ColorCache colorCache; ! ! /** lexical parser that continuously reparses the document on a thread */ ! private PyParser parser; ! ! // Listener waits for tab/spaces preferences that affect sourceViewer ! private Preferences.IPropertyChangeListener prefListener; ! ! /** need it to support GUESS_TAB_SUBSTITUTION preference */ ! private PyAutoIndentStrategy indentStrategy; ! ! /** need to hold onto it to support indentPrefix change through preferences */ ! PyEditConfiguration editConfiguration; ! ! /** Python model */ ! AbstractNode pythonModel; ! ! /** Hyperlinking listener */ ! Hyperlink fMouseListener; ! ! /** listeners that get notified of model changes */ ! ArrayList modelListeners; ! ! public PyEdit() { ! super(); ! modelListeners = new ArrayList(); ! colorCache = new ColorCache(PydevPrefs.getPreferences()); ! if (getDocumentProvider() == null) { ! setDocumentProvider(new PyDocumentProvider()); ! } ! editConfiguration = new PyEditConfiguration(colorCache, this); ! setSourceViewerConfiguration(editConfiguration); ! indentStrategy = (PyAutoIndentStrategy) editConfiguration.getAutoIndentStrategy(null, ! IDocument.DEFAULT_CONTENT_TYPE); ! setRangeIndicator(new DefaultRangeIndicator()); // enables standard ! // vertical ruler ! ! //Added to set the code folding. CodeFoldingSetter codeFoldingSetter = new CodeFoldingSetter(this); this.addModelListener(codeFoldingSetter); this.addPropertyListener(codeFoldingSetter); ! //we also want to initialize our shells... //we use 2: one for refactoring and one for code completion. ! new Thread() { ! public void run() { try { try { *************** *** 128,510 **** } catch (Exception e) { } ! ! } }.start(); - - } - - /** - * Sets the forceTabs preference for auto-indentation. - * - * <p>This is the preference that overrides "use spaces" preference - * when file contains tabs (like mine do). - * <p>If the first indented line starts with a tab, - * then tabs override spaces. - */ - private void resetForceTabs() { - IDocument doc = getDocumentProvider().getDocument(getEditorInput()); - if (doc == null) - return; - if ( !PydevPrefs.getPreferences().getBoolean(PydevPrefs.GUESS_TAB_SUBSTITUTION)) { - indentStrategy.setForceTabs(false); - return; - } ! int lines = doc.getNumberOfLines(); ! boolean forceTabs = false; ! int i = 0; ! // look for the first line that starts with ' ', or '\t' ! while (i<lines) { ! try { ! IRegion r = doc.getLineInformation(i); ! String text = doc.get(r.getOffset(), r.getLength()); ! if (text != null) ! if (text.startsWith("\t")) { ! forceTabs = true; ! break; ! } ! else if (text.startsWith(" ")) { ! forceTabs = false; ! break; ! } ! } catch (BadLocationException e) { ! PydevPlugin.log(IStatus.ERROR, "Unexpected error forcing tabs", e); ! break; ! } ! i++; ! } ! indentStrategy.setForceTabs(forceTabs); ! editConfiguration.resetIndentPrefixes(); ! // display a message in the status line ! if (forceTabs) { ! IEditorStatusLine statusLine = (IEditorStatusLine)getAdapter(IEditorStatusLine.class); ! if (statusLine != null) ! statusLine.setMessage(false, "Pydev: forcing tabs", null); ! } ! } ! ! /** ! * Initializes everyone that needs document access ! * ! */ ! public void init(final IEditorSite site, final IEditorInput input) throws PartInitException { ! super.init(site, input); ! parser = new PyParser(this); ! parser.addParseListener(this); ! parser.setDocument(getDocumentProvider().getDocument(input)); ! ! // listen to changes in TAB_WIDTH preference ! prefListener = new Preferences.IPropertyChangeListener() { ! public void propertyChange(Preferences.PropertyChangeEvent event) { ! String property= event.getProperty(); ! if (property.equals(PydevPrefs.TAB_WIDTH)) { ! ISourceViewer sourceViewer= getSourceViewer(); ! if (sourceViewer == null) ! return; ! sourceViewer.getTextWidget().setTabs(PydevPlugin.getDefault().getPluginPreferences().getInt(PydevPrefs.TAB_WIDTH)); ! } ! else if (property.equals(PydevPrefs.GUESS_TAB_SUBSTITUTION)) { ! resetForceTabs(); ! } ! } ! }; ! resetForceTabs(); ! PydevPrefs.getPreferences().addPropertyChangeListener(prefListener); ! } ! /** ! * @return ! * */ public File getEditorFile() { File f = null; ! IEditorInput editorInput = this.getEditorInput(); ! if (editorInput instanceof FileEditorInput){ ! IFile file = (IFile) ((FileEditorInput)editorInput).getAdapter(IFile.class); ! ! IPath path = file.getLocation().makeAbsolute(); ! f = path.toFile(); ! } ! return f; } // cleanup ! public void dispose() { ! PydevPrefs.getPreferences().removePropertyChangeListener(prefListener); ! parser.dispose(); ! colorCache.dispose(); ! super.dispose(); ! } ! private static final String CONTENTASSIST_PROPOSAL_ID = ! "org.python.pydev.editors.PyEdit.ContentAssistProposal"; ! private static final String TEMPLATE_PROPOSALS= "org.python.pydev.editors.PyEdit.TemplateProposalsAction"; - /* (non-Javadoc) - * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions() - */ - protected void createActions() { - super.createActions(); ! // This action will fire a CONTENTASSIST_PROPOSALS operation ! // when executed ! IAction action= new TextOperationAction( ! PydevPlugin.getDefault().getResourceBundle(), ! "ContentAssistProposal", ! this, ! SourceViewer.CONTENTASSIST_PROPOSALS); ! ! action.setActionDefinitionId(CONTENTASSIST_PROPOSAL_ID); ! // Tell the editor about this new action ! setAction(CONTENTASSIST_PROPOSAL_ID, action); ! // Tell the editor to execute this action ! // when Ctrl+Spacebar is pressed ! setActionActivationCode(CONTENTASSIST_PROPOSAL_ID,' ', -1, SWT.CTRL); ! ! //template proposals ! action= new TextOperationAction( ! PydevPlugin.getDefault().getResourceBundle(), ! "ContentTemplateProposal", ! this, ! ISourceViewer.CONTENTASSIST_PROPOSALS); ! ! action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); ! setAction(TEMPLATE_PROPOSALS, action); ! markAsStateDependentAction(TEMPLATE_PROPOSALS, true); ! ! IAction openAction = new PyOpenAction(); ! setAction(ACTION_OPEN, openAction); ! enableBrowserLikeLinks(); ! } protected void initializeKeyBindingScopes() { ! setKeyBindingScopes(new String[] { "org.python.pydev.ui.editor.scope" }); //$NON-NLS-1$ ! } ! public PyParser getParser() { ! return parser; ! } ! ! public AbstractNode getPythonModel() { ! return pythonModel; ! } ! ! /** ! * @return an outline view ! */ ! public Object getAdapter(Class adapter) { ! if (IContentOutlinePage.class.equals(adapter)) ! return new PyOutlinePage(this); ! else ! return super.getAdapter(adapter); ! } ! ! /** ! * implementation copied from ! * org.eclipse.ui.externaltools.internal.ant.editor.PlantyEditor#setSelection ! */ ! public void setSelection(int offset, int length) { ! ISourceViewer sourceViewer= getSourceViewer(); ! sourceViewer.setSelectedRange(offset, length); ! sourceViewer.revealRange(offset, length); ! } ! ! /** ! * Selects & reveals the model node ! */ ! public void revealModelNode(AbstractNode node) { ! if (node == null) ! return; // nothing to see here ! boolean wholeLine = false; ! Location start = node.getStart(); ! Location end = node.getEnd(); ! IDocument document = getDocumentProvider().getDocument(getEditorInput()); ! int offset, length; ! try { ! if (wholeLine) { ! IRegion r; ! r = document.getLineInformation(start.line); ! offset = r.getOffset(); ! length = r.getLength(); ! } else { ! offset = start.toOffset(document); ! length = end.toOffset(document) - offset; ! } ! } catch (BadLocationException e) { ! PydevPlugin.log(IStatus.WARNING, "error trying to revealModelItem" + node.toString(), e); ! return; ! } ! setSelection(offset, length); ! } ! ! /** ! * this event comes when document was parsed without errors ! * ! * Removes all the error markers ! */ ! public void parserChanged(SimpleNode root) { ! // Remove all the error markers ! IEditorInput input = getEditorInput(); ! IPath filePath = null; ! if (input instanceof IFileEditorInput) { ! IFile file = ((IFileEditorInput)input).getFile(); ! filePath = file.getLocation(); ! } ! else if (input instanceof IStorageEditorInput) ! try { ! filePath = ((IStorageEditorInput)input).getStorage().getFullPath(); ! filePath = filePath.makeAbsolute(); ! } catch (CoreException e2) { ! PydevPlugin.log(IStatus.ERROR, "unexpected error getting path", e2); ! } ! else if (input instanceof ILocationProvider) { ! filePath = ((ILocationProvider)input).getPath(input); ! filePath = filePath.makeAbsolute(); ! } ! else ! PydevPlugin.log(IStatus.ERROR, "unexpected type of editor input " + input.getClass().toString(), null); ! ! try { ! IResource res = (IResource) input.getAdapter(IResource.class); ! if (res != null) ! res.deleteMarkers(IMarker.PROBLEM, false, 1); ! } catch (CoreException e) { ! // What bad can come from removing markers? Ignore this exception ! PydevPlugin.log(IStatus.WARNING, "Unexpected error removing markers", e); ! } ! IDocument document = getDocumentProvider().getDocument(input); ! int lastLine = document.getNumberOfLines(); ! IRegion r; ! try { ! r = document.getLineInformation(lastLine-1); ! pythonModel = ModelMaker.createModel(root, document, filePath); ! fireModelChanged(pythonModel); ! } catch (BadLocationException e1) { ! PydevPlugin.log(IStatus.WARNING, "Unexpected error getting document length. No model!", e1); ! } ! } ! /** ! * this event comes when parse ended in an error ! * ! * generates an error marker on the document ! */ ! public void parserError(Throwable error) { ! IEditorInput input = getEditorInput(); ! IFile original= (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; ! if (original == null) ! return; ! try { ! IDocument document = getDocumentProvider().getDocument(getEditorInput()); ! original.deleteMarkers(IMarker.PROBLEM, false, 1); ! int errorStart; ! int errorEnd; ! int errorLine; ! String message; ! if (error instanceof ParseException) { ! ParseException.verboseExceptions = true; ! ParseException parseErr = (ParseException)error; ! // Figure out where the error is in the document, and create a marker for it ! Token errorToken = ! parseErr.currentToken.next != null ! ? parseErr.currentToken.next ! : parseErr.currentToken; ! IRegion startLine = ! document.getLineInformation(errorToken.beginLine - 1); ! IRegion endLine; ! if (errorToken.endLine == 0) ! endLine = startLine; ! else ! endLine = document.getLineInformation(errorToken.endLine - 1); ! errorStart = startLine.getOffset() + errorToken.beginColumn - 1; ! errorEnd = endLine.getOffset() + errorToken.endColumn; ! errorLine = errorToken.beginLine; ! message = parseErr.getMessage(); ! } else { ! TokenMgrError tokenErr = (TokenMgrError)error; ! IRegion startLine = ! document.getLineInformation(tokenErr.errorLine - 1); ! errorStart = startLine.getOffset(); ! errorEnd = startLine.getOffset() + tokenErr.errorColumn; ! errorLine = tokenErr.errorLine; ! message = tokenErr.getMessage(); ! } ! // map.put(IMarker.LOCATION, "Whassup?"); this is the location field in task manager ! if (message != null) { // prettyprint ! message = message.replaceAll("\\r\\n", " "); ! message = message.replaceAll("\\r", " "); ! message = message.replaceAll("\\n", " "); ! } ! MarkerAttributeMap map = new MarkerAttributeMap(); ! map.put(IMarker.MESSAGE, message); ! map.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); ! map.put(IMarker.LINE_NUMBER, new Integer(errorLine)); ! map.put(IMarker.CHAR_START, new Integer(errorStart)); ! map.put(IMarker.CHAR_END, new Integer(errorEnd)); ! map.put(IMarker.TRANSIENT, Boolean.valueOf(true)); ! MarkerUtilities.createMarker(original, map, IMarker.PROBLEM); ! } catch (CoreException e1) { ! // Whatever, could not create a marker. Swallow this one ! e1.printStackTrace(); ! } catch (BadLocationException e2) { ! // Whatever, could not create a marker. Swallow this one ! e2.printStackTrace(); ! } ! } ! ! private void enableBrowserLikeLinks() { ! if (fMouseListener == null) { ! fMouseListener= new Hyperlink(getSourceViewer(), this, colorCache); ! fMouseListener.install(); ! } ! } ! ! /** ! * Disables browser like links. ! */ ! private void disableBrowserLikeLinks() { ! if (fMouseListener != null) { ! fMouseListener.uninstall(); ! fMouseListener= null; ! } ! } ! /** stock listener implementation */ ! public void addModelListener(IModelListener listener) { ! Assert.isNotNull(listener); ! if (! modelListeners.contains(listener)) ! modelListeners.add(listener); ! } ! ! /** stock listener implementation */ ! public void removeModelListener(IModelListener listener) { ! Assert.isNotNull(listener); ! modelListeners.remove(listener); ! } ! /** ! * stock listener implementation ! * event is fired whenever we get a new root ! */ ! protected void fireModelChanged(AbstractNode root) { ! if (modelListeners.size() > 0) { ! ArrayList list= new ArrayList(modelListeners); ! Iterator e= list.iterator(); ! while (e.hasNext()) { ! IModelListener l= (IModelListener) e.next(); ! l.modelChanged(root); ! } ! } ! } } --- 148,533 ---- } catch (Exception e) { } ! } }.start(); ! } ! /** ! * Sets the forceTabs preference for auto-indentation. ! * ! * <p> ! * This is the preference that overrides "use spaces" preference when file ! * contains tabs (like mine do). ! * <p> ! * If the first indented line starts with a tab, then tabs override spaces. ! */ ! private void resetForceTabs() { ! IDocument doc = getDocumentProvider().getDocument(getEditorInput()); ! if (doc == null) ! return; ! if (!PydevPrefs.getPreferences().getBoolean(PydevPrefs.GUESS_TAB_SUBSTITUTION)) { ! indentStrategy.setForceTabs(false); ! return; ! } + int lines = doc.getNumberOfLines(); + boolean forceTabs = false; + int i = 0; + // look for the first line that starts with ' ', or '\t' + while (i < lines) { + try { + IRegion r = doc.getLineInformation(i); + String text = doc.get(r.getOffset(), r.getLength()); + if (text != null) + if (text.startsWith("\t")) { + forceTabs = true; + break; + } else if (text.startsWith(" ")) { + forceTabs = false; + break; + } + } catch (BadLocationException e) { + PydevPlugin.log(IStatus.ERROR, "Unexpected error forcing tabs", e); + break; + } + i++; + } + indentStrategy.setForceTabs(forceTabs); + editConfiguration.resetIndentPrefixes(); + // display a message in the status line + if (forceTabs) { + IEditorStatusLine statusLine = (IEditorStatusLine) getAdapter(IEditorStatusLine.class); + if (statusLine != null) + statusLine.setMessage(false, "Pydev: forcing tabs", null); + } + } ! /** ! * Initializes everyone that needs document access ! * ! */ ! public void init(final IEditorSite site, final IEditorInput input) throws PartInitException { ! super.init(site, input); ! parser = new PyParser(this); ! parser.addParseListener(this); ! parser.setDocument(getDocumentProvider().getDocument(input)); ! ! // listen to changes in TAB_WIDTH preference ! prefListener = new Preferences.IPropertyChangeListener() { ! public void propertyChange(Preferences.PropertyChangeEvent event) { ! String property = event.getProperty(); ! if (property.equals(PydevPrefs.TAB_WIDTH)) { ! ISourceViewer sourceViewer = getSourceViewer(); ! if (sourceViewer == null) ! return; ! sourceViewer.getTextWidget().setTabs( ! PydevPlugin.getDefault().getPluginPreferences().getInt(PydevPrefs.TAB_WIDTH)); ! } else if (property.equals(PydevPrefs.GUESS_TAB_SUBSTITUTION)) { ! resetForceTabs(); ! } ! } ! }; ! resetForceTabs(); ! PydevPrefs.getPreferences().addPropertyChangeListener(prefListener); ! ! } ! ! /** ! * @return ! * */ public File getEditorFile() { File f = null; ! IEditorInput editorInput = this.getEditorInput(); ! if (editorInput instanceof FileEditorInput) { ! IFile file = (IFile) ((FileEditorInput) editorInput).getAdapter(IFile.class); ! ! IPath path = file.getLocation().makeAbsolute(); ! f = path.toFile(); ! } ! return f; } // cleanup ! public void dispose() { ! PydevPrefs.getPreferences().removePropertyChangeListener(prefListener); ! parser.dispose(); ! colorCache.dispose(); ! super.dispose(); ! } ! private static final String TEMPLATE_PROPOSALS_ID = "org.python.pydev.editors.PyEdit.TemplateProposals"; ! private static final String CONTENTASSIST_PROPOSAL_ID = "org.python.pydev.editors.PyEdit.ContentAssistProposal"; ! private static final String CORRECTIONASSIST_PROPOSAL_ID = "org.python.pydev.editors.PyEdit.CorrectionAssist"; + public static final int CORRECTIONASSIST_PROPOSALS = 999777; + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions() + */ + protected void createActions() { + super.createActions(); + + //quick fix in editor. + IAction action = new TextOperationAction(PydevPlugin.getDefault().getResourceBundle(), + "CorrectionAssist", this, CORRECTIONASSIST_PROPOSALS); //$NON-NLS-1$ + + action.setActionDefinitionId(CORRECTIONASSIST_PROPOSAL_ID); + setAction(CORRECTIONASSIST_PROPOSAL_ID, action); //$NON-NLS-1$ + markAsStateDependentAction(CORRECTIONASSIST_PROPOSAL_ID, true); //$NON-NLS-1$ + setActionActivationCode(CORRECTIONASSIST_PROPOSAL_ID, '1', -1, SWT.CTRL); + + + // This action will fire a CONTENTASSIST_PROPOSALS operation + // when executed + // ------------------------------------------------------------------------------------- + action = new TextOperationAction(PydevPlugin.getDefault().getResourceBundle(), + "ContentAssistProposal", this, SourceViewer.CONTENTASSIST_PROPOSALS); + + action.setActionDefinitionId(CONTENTASSIST_PROPOSAL_ID); + // Tell the editor about this new action + setAction(CONTENTASSIST_PROPOSAL_ID, action); + // Tell the editor to execute this action + // when Ctrl+Spacebar is pressed + setActionActivationCode(CONTENTASSIST_PROPOSAL_ID, ' ', -1, SWT.CTRL); + + //template proposals + // --------------------------------------------------------------------------------- + action = new TextOperationAction(PydevPlugin.getDefault().getResourceBundle(), + "TemplateProposals", this, ISourceViewer.CONTENTASSIST_PROPOSALS); + + action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); + setAction(TEMPLATE_PROPOSALS_ID, action); + markAsStateDependentAction(TEMPLATE_PROPOSALS_ID, true); + + //open action + // ---------------------------------------------------------------------------------------- + IAction openAction = new PyOpenAction(); + setAction(ACTION_OPEN, openAction); + enableBrowserLikeLinks(); + } protected void initializeKeyBindingScopes() { ! setKeyBindingScopes(new String[] { "org.python.pydev.ui.editor.scope" }); //$NON-NLS-1$ ! } ! public PyParser getParser() { ! return parser; ! } ! public AbstractNode getPythonModel() { ! return pythonModel; ! } ! /** ! * @return an outline view ! */ ! public Object getAdapter(Class adapter) { ! if (IContentOutlinePage.class.equals(adapter)) ! return new PyOutlinePage(this); ! else ! return super.getAdapter(adapter); ! } ! /** ! * implementation copied from ! * org.eclipse.ui.externaltools.internal.ant.editor.PlantyEditor#setSelection ! */ ! public void setSelection(int offset, int length) { ! ISourceViewer sourceViewer = getSourceViewer(); ! sourceViewer.setSelectedRange(offset, length); ! sourceViewer.revealRange(offset, length); ! } ! /** ! * Selects & reveals the model node ! */ ! public void revealModelNode(AbstractNode node) { ! if (node == null) ! return; // nothing to see here ! boolean wholeLine = false; ! Location start = node.getStart(); ! Location end = node.getEnd(); ! IDocument document = getDocumentProvider().getDocument(getEditorInput()); ! int offset, length; ! try { ! if (wholeLine) { ! IRegion r; ! r = document.getLineInformation(start.line); ! offset = r.getOffset(); ! length = r.getLength(); ! } else { ! offset = start.toOffset(document); ! length = end.toOffset(document) - offset; ! } ! } catch (BadLocationException e) { ! PydevPlugin.log(IStatus.WARNING, "error trying to revealModelItem" + node.toString(), e); ! return; ! } ! setSelection(offset, length); ! } ! /** ! * this event comes when document was parsed without errors ! * ! * Removes all the error markers ! */ ! public void parserChanged(SimpleNode root) { ! // Remove all the error markers ! IEditorInput input = getEditorInput(); ! IPath filePath = null; ! if (input instanceof IFileEditorInput) { ! IFile file = ((IFileEditorInput) input).getFile(); ! filePath = file.getLocation(); ! } else if (input instanceof IStorageEditorInput) ! try { ! filePath = ((IStorageEditorInput) input).getStorage().getFullPath(); ! filePath = filePath.makeAbsolute(); ! } catch (CoreException e2) { ! PydevPlugin.log(IStatus.ERROR, "unexpected error getting path", e2); ! } ! else if (input instanceof ILocationProvider) { ! filePath = ((ILocationProvider) input).getPath(input); ! filePath = filePath.makeAbsolute(); ! } else ! PydevPlugin.log(IStatus.ERROR, "unexpected type of editor input " + input.getClass().toString(), ! null); ! try { ! IResource res = (IResource) input.getAdapter(IResource.class); ! if (res != null) ! res.deleteMarkers(IMarker.PROBLEM, false, 1); ! } catch (CoreException e) { ! // What bad can come from removing markers? Ignore this exception ! PydevPlugin.log(IStatus.WARNING, "Unexpected error removing markers", e); ! } ! IDocument document = getDocumentProvider().getDocument(input); ! int lastLine = document.getNumberOfLines(); ! IRegion r; ! try { ! r = document.getLineInformation(lastLine - 1); ! pythonModel = ModelMaker.createModel(root, document, filePath); ! fireModelChanged(pythonModel); ! } catch (BadLocationException e1) { ! PydevPlugin.log(IStatus.WARNING, "Unexpected error getting document length. No model!", e1); ! } ! } ! /** ! * this event comes when parse ended in an error ! * ! * generates an error marker on the document ! */ ! public void parserError(Throwable error) { ! IEditorInput input = getEditorInput(); ! IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; ! if (original == null) ! return; ! try { ! IDocument document = getDocumentProvider().getDocument(getEditorInput()); ! original.deleteMarkers(IMarker.PROBLEM, false, 1); ! int errorStart; ! int errorEnd; ! int errorLine; ! String message; ! if (error instanceof ParseException) { ! ParseException.verboseExceptions = true; ! ParseException parseErr = (ParseException) error; ! // Figure out where the error is in the document, and create a ! // marker for it ! Token errorToken = parseErr.currentToken.next != null ? parseErr.currentToken.next ! : parseErr.currentToken; ! IRegion startLine = document.getLineInformation(errorToken.beginLine - 1); ! IRegion endLine; ! if (errorToken.endLine == 0) ! endLine = startLine; ! else ! endLine = document.getLineInformation(errorToken.endLine - 1); ! errorStart = startLine.getOffset() + errorToken.beginColumn - 1; ! errorEnd = endLine.getOffset() + errorToken.endColumn; ! errorLine = errorToken.beginLine; ! message = parseErr.getMessage(); ! } else { ! TokenMgrError tokenErr = (TokenMgrError) error; ! IRegion startLine = document.getLineInformation(tokenErr.errorLine - 1); ! errorStart = startLine.getOffset(); ! errorEnd = startLine.getOffset() + tokenErr.errorColumn; ! errorLine = tokenErr.errorLine; ! message = tokenErr.getMessage(); ! } ! // map.put(IMarker.LOCATION, "Whassup?"); this is the location field ! // in task manager ! if (message != null) { // prettyprint ! message = message.replaceAll("\\r\\n", " "); ! message = message.replaceAll("\\r", " "); ! message = message.replaceAll("\\n", " "); ! } ! MarkerAttributeMap map = new MarkerAttributeMap(); ! map.put(IMarker.MESSAGE, message); ! map.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR)); ! map.put(IMarker.LINE_NUMBER, new Integer(errorLine)); ! map.put(IMarker.CHAR_START, new Integer(errorStart)); ! map.put(IMarker.CHAR_END, new Integer(errorEnd)); ! map.put(IMarker.TRANSIENT, Boolean.valueOf(true)); ! MarkerUtilities.createMarker(original, map, IMarker.PROBLEM); + } catch (CoreException e1) { + // Whatever, could not create a marker. Swallow this one + e1.printStackTrace(); + } catch (BadLocationException e2) { + // Whatever, could not create a marker. Swallow this one + e2.printStackTrace(); + } + } + + private void enableBrowserLikeLinks() { + if (fMouseListener == null) { + fMouseListener = new Hyperlink(getSourceViewer(), this, colorCache); + fMouseListener.install(); + } + } + + /** + * Disables browser like links. + */ + private void disableBrowserLikeLinks() { + if (fMouseListener != null) { + fMouseListener.uninstall(); + fMouseListener = null; + } + } + + /** stock listener implementation */ + public void addModelListener(IModelListener listener) { + Assert.isNotNull(listener); + if (!modelListeners.contains(listener)) + modelListeners.add(listener); + } + + /** stock listener implementation */ + public void removeModelListener(IModelListener listener) { + Assert.isNotNull(listener); + modelListeners.remove(listener); + } + + /** + * stock listener implementation event is fired whenever we get a new root + */ + protected void fireModelChanged(AbstractNode root) { + if (modelListeners.size() > 0) { + ArrayList list = new ArrayList(modelListeners); + Iterator e = list.iterator(); + while (e.hasNext()) { + IModelListener l = (IModelListener) e.next(); + l.modelChanged(root); + } + } + } } |
From: Fabio Z. <fa...@us...> - 2004-09-23 18:00:12
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5252/src/org/python/pydev/editor/actions Modified Files: PyAction.java PySelection.java Log Message: Making correction assistant on Ctrl+1 Index: PySelection.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PySelection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PySelection.java 15 Sep 2004 17:36:09 -0000 1.4 --- PySelection.java 23 Sep 2004 17:59:59 -0000 1.5 *************** *** 187,191 **** // Grab the selected text into our string ! selection = doc.get ( initialPos, selLength ); } // Otherwise we'll modify the whole document, if asked to --- 187,191 ---- // Grab the selected text into our string ! selection = doc.get ( getITextSelection().getOffset(), getITextSelection().getLength() ); } // Otherwise we'll modify the whole document, if asked to Index: PyAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAction.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyAction.java 4 Aug 2004 13:18:43 -0000 1.8 --- PyAction.java 23 Sep 2004 17:59:59 -0000 1.9 *************** *** 136,140 **** * @throws BadLocationException */ ! protected int getFirstCharPosition(IDocument doc, int cursorOffset) throws BadLocationException { IRegion region; --- 136,140 ---- * @throws BadLocationException */ ! public static int getFirstCharPosition(IDocument doc, int cursorOffset) throws BadLocationException { IRegion region; |
From: Fabio Z. <fa...@us...> - 2004-09-23 18:00:12
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5252/src/org/python/pydev/editor/codecompletion Modified Files: PythonCompletionProcessor.java Log Message: Making correction assistant on Ctrl+1 Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PythonCompletionProcessor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PythonCompletionProcessor.java 22 Sep 2004 12:04:31 -0000 1.7 --- PythonCompletionProcessor.java 23 Sep 2004 18:00:01 -0000 1.8 *************** *** 146,154 **** java.lang.String qualifier, List allProposals) { List propList = new ArrayList(); ! if (activationToken.trim().equals("") == false || qualifier.trim().equals("") == false) { ! //templates proposals are added here. ! this.templatesCompletion.addTemplateProposals(viewer, documentOffset, propList); ! ! } return propList; } --- 146,150 ---- java.lang.String qualifier, List allProposals) { List propList = new ArrayList(); ! this.templatesCompletion.addTemplateProposals(viewer, documentOffset, propList); return propList; } |
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5252/src/org/python/pydev/editor/correctionassist Added Files: PythonCorrectionProcessor.java PyQuickFix.java MarkerResolution.java PyCorrectionAssistant.java Log Message: Making correction assistant on Ctrl+1 --- NEW FILE: PyQuickFix.java --- package org.python.pydev.editor.correctionassist; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.ui.IMarkerResolution; import org.eclipse.ui.IMarkerResolutionGenerator; /** * This class can later be used to make quick fixes. * * * @author Fabio Zadrozny */ public class PyQuickFix implements IMarkerResolutionGenerator { public static String CONTENT_GENERATOR_MARKER = "org.python.pydev.editor.markers.pycontentgeneratormarker"; public IMarkerResolution[] getResolutions(IMarker mk) { try { Object problem = mk.getAttribute("WhatsUp"); return new IMarkerResolution[] { // new MarkerResolution("Fix #1 for "+problem), // new MarkerResolution("Fix #2 for "+problem), }; } catch (CoreException e) { return new IMarkerResolution[0]; } } } --- NEW FILE: PythonCorrectionProcessor.java --- /* * Created on Sep 23, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.correctionassist; import java.util.ArrayList; import java.util.List; import org.eclipse.jdt.internal.corext.util.Strings; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.CompletionProposal; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.actions.PyAction; import org.python.pydev.editor.actions.PySelection; /** * /** This class should be used to give context help * - Help depending on context (Ctrl+1): * * class A: pass * * class C: * * def __init__(self, param): self.newMethod() <- create new method on class C <- * assign result to new local variable <- assign result to new field a = A() * a.newMethod() <- create new method on class A <- assign result to new local * variable <- assign result to new field * * param. <- don't show anything. * * self.a1 = A() self.a1.newMethod() <- create new method on class A <- assign * result to new local variable <- assign result to new field * * def m(self): self.a1.newMethod() <- create new method on class A <- assign * result to new local variable <- assign result to new field * * * @author Fabio Zadrozny */ public class PythonCorrectionProcessor implements IContentAssistProcessor { private PyEdit edit; /** * @param edit */ public PythonCorrectionProcessor(PyEdit edit) { this.edit = edit; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, * int) */ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) { PySelection ps = new PySelection(edit, false); List results = getAssignToResults(ps); results.addAll(getCreations(ps)); return (ICompletionProposal[]) results.toArray(new ICompletionProposal[0]); } /** * @param ps * @return */ private List getCreations(PySelection ps) { List l = new ArrayList(); if (ps.selection.trim().length() == 0) { return l; } //here, any callable can be used to create a new method or class. //we have to parse it, because we have to discover the parameters for the new class. return l; } /** * @param ps */ private List getAssignToResults(PySelection ps) { List l = new ArrayList(); if (ps.selection.trim().length() == 0) { return l; } //first thing: check were we are and check that no single '=' exists. // '==' may happen. if (ps.selection.replaceAll("==", "").indexOf("=") == -1) { //second: go on and make the suggestion. // //if we have a method call, eg.: // e.methodCall()| would result in the following suggestions: // // methodCall = e.methodCall() // self.methodCall = e.methodCall() // // NewClass()| would result in // // newClass = NewClass() // self.newClass = NewClass() // //now, if we don't have a method call, eg.: // 1+1| would result in // // |result| = 1+1 // self.|result| = 1+1 String string = ps.selection.replaceAll("\\(*\\)", "()"); try { int firstCharPosition = PyAction.getFirstCharPosition(ps.doc, ps.absoluteCursorOffset); int i; String callName = "result"; if ((i = string.indexOf("()")) != -1) { callName = ""; for (int j = i-1; j >= 0 && stillInTok(string, j); j--) { callName = string.charAt(j) + callName; } if(callName.length()>0){ //all that just to change first char to lower case. char[] ds = callName.toCharArray(); ds[0] = (""+ds[0]).toLowerCase().charAt(0); callName = new String(ds); } } callName += " = "; l.add(new CompletionProposal(callName, firstCharPosition, 0, 0, null, "Assign to new local variable", null, null)); l.add(new CompletionProposal("self." + callName, firstCharPosition, 0, 0, null, "Assign to new field", null, null)); } catch (BadLocationException e) { e.printStackTrace(); } } return l; } /** * @param string * @param j * @return */ private boolean stillInTok(String string, int j) { char c = string.charAt(j); return c != '\n' && c != '\r' && c != ' ' && c != '.' && c != '(' && c != ')'; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, * int) */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() */ public char[] getCompletionProposalAutoActivationCharacters() { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() */ public char[] getContextInformationAutoActivationCharacters() { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() */ public String getErrorMessage() { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator() */ public IContextInformationValidator getContextInformationValidator() { // TODO Auto-generated method stub return null; } } --- NEW FILE: MarkerResolution.java --- /* * Created on Sep 22, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.correctionassist; import org.eclipse.core.resources.IMarker; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.ui.IMarkerResolution; /** * @author Fabio Zadrozny */ public class MarkerResolution implements IMarkerResolution { private String label; /** * @param string */ public MarkerResolution(String string) { this.label = string; } /* (non-Javadoc) * @see org.eclipse.ui.IMarkerResolution#getLabel() */ public String getLabel() { // TODO Auto-generated method stub return label; } public void run(IMarker marker) { MessageDialog.openInformation(null, "QuickFix Demo", "This quick-fix is not yet implemented"); } } --- NEW FILE: PyCorrectionAssistant.java --- /* * Created on Sep 23, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.correctionassist; import org.eclipse.jface.text.contentassist.ContentAssistant; /** * * The PyCorrectionAssistant was based on org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor * assistant. (after many hour of exploration)... * * @author Fabio Zadrozny */ public class PyCorrectionAssistant extends ContentAssistant{ } |
From: Fabio Z. <fa...@us...> - 2004-09-23 17:59:55
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5209/src/org/python/pydev/editor/correctionassist Log Message: Directory /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist added to the repository |
From: Fabio Z. <fa...@us...> - 2004-09-22 16:32:50
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8307/src/org/python/pydev/editor/codecompletion Modified Files: PyCodeCompletion.java CompletionCache.java Log Message: Changes to PyParser. Now it tries to parse one more time if a parser error occurs, substituting the error line for a pass, so that we have more changes of getting the class and method definition tokens on ModelUtils. Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PyCodeCompletion.java 22 Sep 2004 12:04:31 -0000 1.9 --- PyCodeCompletion.java 22 Sep 2004 16:32:41 -0000 1.10 *************** *** 175,188 **** * @return */ ! public String getDocToParse(IDocument doc, int documentOffset) { String wholeDoc = doc.get(); String newDoc = ""; try { - int lineOfOffset = doc.getLineOfOffset(documentOffset); IRegion lineInformation = doc.getLineInformation(lineOfOffset); int docLength = doc.getLength(); ! String src = doc.get(lineInformation.getOffset(), documentOffset ! - lineInformation.getOffset()); String spaces = ""; --- 175,206 ---- * @return */ ! public static String getDocToParse(IDocument doc, int documentOffset) { ! int lineOfOffset = -1; ! try { ! lineOfOffset = doc.getLineOfOffset(documentOffset); ! } catch (BadLocationException e) { ! e.printStackTrace(); ! } ! ! if(lineOfOffset!=-1) ! return "\n"+getDocToParseFromLine(doc, lineOfOffset); ! else ! return ""; ! } ! ! /** ! * @param doc ! * @param documentOffset ! * @param lineOfOffset ! * @return ! */ ! public static String getDocToParseFromLine(IDocument doc, int lineOfOffset) { String wholeDoc = doc.get(); String newDoc = ""; try { IRegion lineInformation = doc.getLineInformation(lineOfOffset); int docLength = doc.getLength(); ! String src = doc.get(lineInformation.getOffset(), lineInformation.getLength()); String spaces = ""; *************** *** 195,199 **** newDoc = wholeDoc.substring(0, lineInformation.getOffset()); ! newDoc += spaces + "pass\n"; newDoc += wholeDoc.substring(lineInformation.getOffset() + lineInformation.getLength(), docLength); --- 213,217 ---- newDoc = wholeDoc.substring(0, lineInformation.getOffset()); ! newDoc += spaces + "pass"; newDoc += wholeDoc.substring(lineInformation.getOffset() + lineInformation.getLength(), docLength); *************** *** 202,206 **** e1.printStackTrace(); } ! return "\n"+newDoc; } --- 220,224 ---- e1.printStackTrace(); } ! return newDoc; } Index: CompletionCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/CompletionCache.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CompletionCache.java 22 Sep 2004 12:04:31 -0000 1.4 --- CompletionCache.java 22 Sep 2004 16:32:41 -0000 1.5 *************** *** 47,51 **** partialDoc = importsTipperStr; }else{ ! partialDoc = codeCompletion.getDocToParse(doc, documentOffset); partialDoc += activationToken; } --- 47,51 ---- partialDoc = importsTipperStr; }else{ ! partialDoc = PyCodeCompletion.getDocToParse(doc, documentOffset); partialDoc += activationToken; } |
From: Fabio Z. <fa...@us...> - 2004-09-22 16:32:50
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8307/src/org/python/pydev/parser Modified Files: PyParser.java Log Message: Changes to PyParser. Now it tries to parse one more time if a parser error occurs, substituting the error line for a pass, so that we have more changes of getting the class and method definition tokens on ModelUtils. Index: PyParser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser/PyParser.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PyParser.java 22 Jul 2004 16:14:53 -0000 1.9 --- PyParser.java 22 Sep 2004 16:32:41 -0000 1.10 *************** *** 26,29 **** --- 26,30 ---- import org.python.parser.TokenMgrError; import org.python.pydev.editor.PyEdit; + import org.python.pydev.editor.codecompletion.PyCodeCompletion; /** *************** *** 53,56 **** --- 54,58 ---- boolean parseNow = false; // synchronized access by ParsingThread + /* * counter how to parse. 0 means do not parse, > 0 means wait this many *************** *** 100,103 **** --- 102,106 ---- final PyParser parser = this; documentListener = new IDocumentListener() { + public void documentChanged(DocumentEvent event) { if (event == null || event.getText() == null || event.getText().indexOf("\n") == -1) { *************** *** 167,174 **** StringReader inString = new StringReader(document.get()); ReaderCharStream in = new ReaderCharStream(inString); IParserHost host = new CompilerAPI(); ! PythonGrammar g1 = new PythonGrammar((CharStream) null, ! (IParserHost) null); PythonGrammar grammar = new PythonGrammar(in, host); --- 170,189 ---- StringReader inString = new StringReader(document.get()); ReaderCharStream in = new ReaderCharStream(inString); + reparseDocument(in, true); + } + + /** + * + * @param in char stream to read + * @param reparseIfErrorFound boolean indicating that another reparse should + * be attempted, changing the current text line for a 'pass', so that we can + * give outline and some feedback. + * (Maybe a good idea would be a fast parser that is error aware and that finds + * the information we need, as class and function definitions). + */ + private void reparseDocument(ReaderCharStream in, boolean reparseIfErrorFound) { IParserHost host = new CompilerAPI(); ! PythonGrammar g1 = new PythonGrammar((CharStream) null, (IParserHost) null); PythonGrammar grammar = new PythonGrammar(in, host); *************** *** 177,192 **** if (input == null) return; ! IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input) ! .getFile() ! : null; try { SimpleNode newRoot = grammar.file_input(); // parses the file ! if (original != null) original.deleteMarkers(IMarker.PROBLEM, false, 1); fireParserChanged(newRoot); } catch (ParseException parseErr) { ! fireParserError(parseErr); } catch (TokenMgrError tokenErr) { ! fireParserError(tokenErr); } catch (Exception e) { System.err.println("Unexpected parse error"); --- 192,211 ---- if (input == null) return; ! IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; try { SimpleNode newRoot = grammar.file_input(); // parses the file ! ! if (original != null && reparseIfErrorFound) original.deleteMarkers(IMarker.PROBLEM, false, 1); + fireParserChanged(newRoot); } catch (ParseException parseErr) { ! if (reparseIfErrorFound) ! tryReparseAgain(parseErr); ! } catch (TokenMgrError tokenErr) { ! if (reparseIfErrorFound) ! tryReparseAgain(tokenErr); ! } catch (Exception e) { System.err.println("Unexpected parse error"); *************** *** 194,197 **** --- 213,265 ---- } } + + /** + * @param tokenErr + */ + private void tryReparseAgain(TokenMgrError tokenErr) { + int line = tokenErr.errorLine; + + tryReparseChangingLine(line); + + fireParserError(tokenErr); //in this on + } + + /** + * This method tries to reparse the code again, changing the current line to + * a 'pass' + * + * Any new errors are ignored, and the error passed as a parameter is fired + * anyway, so, the utility of this function is trying to make a real model + * without any problems, so that we can update the outline and ModelUtils + * with a good aproximation of the code. + * + * @param tokenErr + */ + private void tryReparseAgain(ParseException tokenErr) { + int line = 0; + if(tokenErr.currentToken.image.equals(".") || tokenErr.currentToken.image.equals("(")){ + line = tokenErr.currentToken.beginLine-1; + }else{ + line = tokenErr.currentToken.beginLine; + } + + + tryReparseChangingLine(line); + + fireParserError(tokenErr); + } + + /** + * @param line + * + */ + private void tryReparseChangingLine(int line) { + String docToParse = PyCodeCompletion.getDocToParseFromLine(document, line); + + // create a stream with document's data + StringReader inString = new StringReader(docToParse); + ReaderCharStream in = new ReaderCharStream(inString); + reparseDocument(in, false); + } } *************** *** 210,214 **** private static ArrayList parsers = new ArrayList(); // synchronized access ! // only private boolean done = false; --- 278,283 ---- private static ArrayList parsers = new ArrayList(); // synchronized access ! ! // only private boolean done = false; |
From: Fabio Z. <fa...@us...> - 2004-09-22 16:32:50
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8307 Modified Files: plugin.xml Log Message: Changes to PyParser. Now it tries to parse one more time if a parser error occurs, substituting the error line for a pass, so that we have more changes of getting the class and method definition tokens on ModelUtils. Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** plugin.xml 21 Sep 2004 13:18:45 -0000 1.40 --- plugin.xml 22 Sep 2004 16:32:41 -0000 1.41 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.9.7b" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.9.7c" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> |
From: Fabio Z. <fa...@us...> - 2004-09-22 12:04:45
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14761/PySrc Modified Files: importsTipper.py test_refactoring.py test_simpleTipper.py Log Message: Cache changes. Index: test_simpleTipper.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/test_simpleTipper.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_simpleTipper.py 20 Sep 2004 19:28:41 -0000 1.7 --- test_simpleTipper.py 22 Sep 2004 12:04:30 -0000 1.8 *************** *** 3,7 **** ''' ! from coilib import unittest import simpleTipper import importsTipper --- 3,7 ---- ''' ! import unittest import simpleTipper import importsTipper *************** *** 97,102 **** def testImports(self): ! importsTipper.GenerateTip('qt.') ! importsTipper.GenerateTip('scbr.') importsTipper.GenerateImportsTip(['scbr']) importsTipper.GenerateImportsTip([ ] ) --- 97,105 ---- def testImports(self): ! ''' ! You can print the results to check... ! ''' ! importsTipper.GenerateTip('inspect.') ! importsTipper.GenerateTip('compiler.') importsTipper.GenerateImportsTip(['scbr']) importsTipper.GenerateImportsTip([ ] ) *************** *** 104,109 **** importsTipper.GenerateImportsTip(['os','path']) importsTipper.GenerateImportsTip(['unittest']) ! importsTipper.GenerateImportsTip(['scbr', 'app', 'actions', 'db']) ! importsTipper.GenerateImportsTip(['scbr', 'app', 'actions', 'db', 'EditCont']) --- 107,112 ---- importsTipper.GenerateImportsTip(['os','path']) importsTipper.GenerateImportsTip(['unittest']) ! importsTipper.GenerateImportsTip(['compiler', 'ast']) ! importsTipper.GenerateImportsTip(['compiler', 'ast', 'Node']) *************** *** 127,132 **** if __name__ == '__main__': - from coilib import unittest - # unittest.TestMethod(Test, 'Test.testEnv3') unittest.main() --- 130,133 ---- Index: test_refactoring.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/test_refactoring.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_refactoring.py 20 Sep 2004 19:08:41 -0000 1.3 --- test_refactoring.py 22 Sep 2004 12:04:30 -0000 1.4 *************** *** 3,7 **** ''' ! from coilib import unittest import refactoring import os --- 3,7 ---- ''' ! import unittest import refactoring import os *************** *** 94,100 **** self.assertEquals(self.getRefactoredFile(), contents) ! def testRename(self): r = refactoring.Refactoring() ! s = r.renameByCoordinates(FILE, 1+1, 6, 'G') f = file(FILE, 'r') --- 94,110 ---- self.assertEquals(self.getRefactoredFile(), contents) ! # def testRename(self): ! # r = refactoring.Refactoring() ! # s = r.renameByCoordinates(FILE, 1+1, 6, 'G') ! # ! # f = file(FILE, 'r') ! # contents = f.read() ! # f.close() ! # ! # self.assertEquals(getRenameRefactored(), contents) ! ! def testRename2(self): r = refactoring.Refactoring() ! s = r.renameByCoordinates(FILE, 7+1, 4, 'G') f = file(FILE, 'r') *************** *** 132,137 **** if __name__ == '__main__': ! # unittest.main() ! unittest.TestMethod(Test, 'Test.testFind') --- 142,146 ---- if __name__ == '__main__': ! unittest.main() Index: importsTipper.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/importsTipper.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** importsTipper.py 17 Sep 2004 19:22:04 -0000 1.3 --- importsTipper.py 22 Sep 2004 12:04:30 -0000 1.4 *************** *** 33,36 **** --- 33,45 ---- m = stripExtension(f, ret, '.pyc') + if f.endswith('.pyd'): + m = stripExtension(f, ret, '.pyd') + + if f.endswith('.dll'): + m = stripExtension(f, ret, '.dll') + + if f.endswith('.pyo'): + m = stripExtension(f, ret, '.pyo') + if m is not None and isModuleWithinList(m, ret) is None: ret.append((m,absolute)) |
From: Fabio Z. <fa...@us...> - 2004-09-22 12:04:45
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14761/src/org/python/pydev/editor/codecompletion Modified Files: PythonCompletionProcessor.java PyCodeCompletion.java CompletionCache.java Log Message: Cache changes. Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyCodeCompletion.java 20 Sep 2004 13:18:05 -0000 1.8 --- PyCodeCompletion.java 22 Sep 2004 12:04:31 -0000 1.9 *************** *** 68,81 **** public List autoComplete(PyEdit edit, IDocument doc, int documentOffset, java.lang.String theActivationToken) { - return serverCompletion(theActivationToken, edit, doc, documentOffset); - } - - /** - * @param edit - * @param doc - * @param documentOffset - */ - private List serverCompletion(String theActivationToken, PyEdit edit, - IDocument doc, int documentOffset) { List theList = new ArrayList(); PythonShell serverShell = null; --- 68,71 ---- *************** *** 85,96 **** throw new RuntimeException(e); } ! String docToParse = getDocToParse(doc, documentOffset); ! String trimmed = theActivationToken.replace('.', ' ').trim(); ! ! String importsTipper = useImportsTipper(theActivationToken, edit, doc, documentOffset); if (importsTipper.length()!=0) { //may be space. ! List completions = serverShell.getImportCompletions(importsTipper); theList.addAll(completions); --- 75,86 ---- throw new RuntimeException(e); } ! String docToParse = getDocToParse(doc, documentOffset); ! String trimmed = theActivationToken.replace('.', ' ').trim(); ! ! String importsTipper = getImportsTipperStr(theActivationToken, edit, doc, documentOffset); if (importsTipper.length()!=0) { //may be space. ! List completions = serverShell.getImportCompletions(importsTipper); theList.addAll(completions); *************** *** 98,102 **** } else if (trimmed.equals("") == false && theActivationToken.indexOf('.') != -1) { ! List completions; if (trimmed.equals("self")) { --- 88,92 ---- } else if (trimmed.equals("") == false && theActivationToken.indexOf('.') != -1) { ! List completions; if (trimmed.equals("self")) { *************** *** 104,116 **** AbstractNode closest = ModelUtils.getLessOrEqualNode(edit .getPythonModel(), loc); ! if(closest == null){ completions = serverShell.getTokenCompletions(trimmed, docToParse); }else{ ! Scope scope = closest.getScope().findContainingClass(); ! String token = scope.getStartNode().getName(); ! completions = serverShell ! .getClassCompletions(token, docToParse); } } else { --- 94,106 ---- AbstractNode closest = ModelUtils.getLessOrEqualNode(edit .getPythonModel(), loc); ! if(closest == null){ completions = serverShell.getTokenCompletions(trimmed, docToParse); }else{ ! Scope scope = closest.getScope().findContainingClass(); ! String token = scope.getStartNode().getName(); ! completions = serverShell ! .getClassCompletions(token, docToParse); } } else { *************** *** 119,132 **** } theList.addAll(completions); ! } else { //go to globals List completions = serverShell.getGlobalCompletions(docToParse); theList.addAll(completions); ! } return theList; - } /** * @param theActivationToken --- 109,122 ---- } theList.addAll(completions); ! } else { //go to globals List completions = serverShell.getGlobalCompletions(docToParse); theList.addAll(completions); ! } return theList; } + /** * @param theActivationToken *************** *** 136,140 **** * @return */ ! private String useImportsTipper(String theActivationToken, PyEdit edit, IDocument doc, int documentOffset) { String importMsg = ""; --- 126,130 ---- * @return */ ! public String getImportsTipperStr(String theActivationToken, PyEdit edit, IDocument doc, int documentOffset) { String importMsg = ""; *************** *** 145,148 **** --- 135,139 ---- int fromIndex = string.indexOf("from"); int importIndex = string.indexOf("import"); + if(fromIndex != -1 || importIndex != -1){ string = string.replaceAll("#.*", ""); //remove comments *************** *** 184,188 **** * @return */ ! private String getDocToParse(IDocument doc, int documentOffset) { String wholeDoc = doc.get(); String newDoc = ""; --- 175,179 ---- * @return */ ! public String getDocToParse(IDocument doc, int documentOffset) { String wholeDoc = doc.get(); String newDoc = ""; Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/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 15 Sep 2004 17:36:09 -0000 1.6 --- PythonCompletionProcessor.java 22 Sep 2004 12:04:31 -0000 1.7 *************** *** 54,108 **** } ! public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, ! int documentOffset) { ! IDocument doc = viewer.getDocument(); - Point selectedRange = viewer.getSelectedRange(); // there may not be a selected range ! java.lang.String theDoc = doc.get(); ! codeCompletion.calcDocBoundary(theDoc, documentOffset); ! String activationToken = codeCompletion.getActivationToken(theDoc, ! documentOffset); java.lang.String qualifier = ""; ! ! //we complete on '.' and '('. //' ' gets globals //and any other char gets globals on token and templates. //we have to get the qualifier. e.g. bla.foo = foo is the qualifier. ! if(activationToken.indexOf('.')!= -1){ ! while (endsWithSomeChar(new char[]{'.'}, activationToken) == false ! && activationToken.length() > 0) { ! ! qualifier = activationToken.charAt(activationToken.length() - 1) ! + qualifier; ! activationToken = activationToken.substring(0, activationToken ! .length() - 1); ! } ! }else{ //everything is a part of the qualifier. qualifier = activationToken.trim(); activationToken = ""; } - theDoc = codeCompletion.partialDocument(theDoc, documentOffset); - int qlen = qualifier.length(); - theDoc += "\n" + activationToken; - try { PythonShell.getServerShell().sendGoToDirMsg(edit.getEditorFile()); } catch (Exception e) { ! //if we don't suceed, we don't have to fail... just go on and try to complete... e.printStackTrace(); ! } ! ! List pythonProposals = getPythonProposals(documentOffset, doc, theDoc, activationToken, qlen); ! List templateProposals = getTemplateProposals(viewer, documentOffset, activationToken, qualifier, pythonProposals); ArrayList pythonAndTemplateProposals = new ArrayList(); --- 54,100 ---- } ! public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { ! IDocument doc = viewer.getDocument(); Point selectedRange = viewer.getSelectedRange(); // there may not be a selected range ! java.lang.String completeDoc = doc.get(); ! codeCompletion.calcDocBoundary(completeDoc, documentOffset); ! String activationToken = codeCompletion.getActivationToken(completeDoc, documentOffset); java.lang.String qualifier = ""; ! ! //we complete on '.' and '('. //' ' gets globals //and any other char gets globals on token and templates. //we have to get the qualifier. e.g. bla.foo = foo is the qualifier. ! if (activationToken.indexOf('.') != -1) { ! while (endsWithSomeChar(new char[] { '.' }, activationToken) == false ! && activationToken.length() > 0) { ! ! qualifier = activationToken.charAt(activationToken.length() - 1) + qualifier; ! activationToken = activationToken.substring(0, activationToken.length() - 1); ! } ! } else { //everything is a part of the qualifier. qualifier = activationToken.trim(); activationToken = ""; } int qlen = qualifier.length(); try { PythonShell.getServerShell().sendGoToDirMsg(edit.getEditorFile()); } catch (Exception e) { ! //if we don't suceed, we don't have to fail... just go on and try ! // to complete... e.printStackTrace(); ! } ! List pythonProposals = getPythonProposals(documentOffset, doc, activationToken, qlen); ! List templateProposals = getTemplateProposals(viewer, documentOffset, activationToken, qualifier, ! pythonProposals); ArrayList pythonAndTemplateProposals = new ArrayList(); *************** *** 111,115 **** ArrayList returnProposals = new ArrayList(); ! for (Iterator iter = pythonAndTemplateProposals.iterator(); iter.hasNext();) { ICompletionProposal proposal = (ICompletionProposal) iter.next(); --- 103,107 ---- ArrayList returnProposals = new ArrayList(); ! for (Iterator iter = pythonAndTemplateProposals.iterator(); iter.hasNext();) { ICompletionProposal proposal = (ICompletionProposal) iter.next(); *************** *** 123,127 **** // and fill with list elements returnProposals.toArray(proposals); ! Arrays.sort(proposals, proposalsComparator); // Return the proposals --- 115,119 ---- // and fill with list elements returnProposals.toArray(proposals); ! Arrays.sort(proposals, proposalsComparator); // Return the proposals *************** *** 138,144 **** * @return */ ! private List getPythonProposals(int documentOffset, IDocument doc, java.lang.String theDoc, String activationToken, int qlen) { ! List allProposals = this.completionCache.getAllProposals(edit, doc, theDoc, ! activationToken, documentOffset, qlen, codeCompletion); return allProposals; } --- 130,136 ---- * @return */ ! private List getPythonProposals(int documentOffset, IDocument doc, String activationToken, int qlen) { ! List allProposals = this.completionCache.getAllProposals(edit, doc, activationToken, documentOffset, ! qlen, codeCompletion); return allProposals; } *************** *** 151,161 **** * @param allProposals */ ! private List getTemplateProposals(ITextViewer viewer, int documentOffset, String activationToken, java.lang.String qualifier, List allProposals) { List propList = new ArrayList(); ! if(activationToken.trim().equals("") == false || qualifier.trim().equals("") == false){ //templates proposals are added here. ! this.templatesCompletion.addTemplateProposals(viewer, documentOffset, ! propList); ! } return propList; --- 143,153 ---- * @param allProposals */ ! private List getTemplateProposals(ITextViewer viewer, int documentOffset, String activationToken, ! java.lang.String qualifier, List allProposals) { List propList = new ArrayList(); ! if (activationToken.trim().equals("") == false || qualifier.trim().equals("") == false) { //templates proposals are added here. ! this.templatesCompletion.addTemplateProposals(viewer, documentOffset, propList); ! } return propList; *************** *** 168,173 **** * int) */ ! public IContextInformation[] computeContextInformation(ITextViewer viewer, ! int documentOffset) { return null; } --- 160,164 ---- * int) */ ! public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { return null; } Index: CompletionCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/CompletionCache.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CompletionCache.java 14 Sep 2004 17:42:14 -0000 1.3 --- CompletionCache.java 22 Sep 2004 12:04:31 -0000 1.4 *************** *** 37,44 **** * @return */ ! public List getAllProposals(PyEdit edit, IDocument doc, String partialDoc, String activationToken, int documentOffset, int qlen, PyCodeCompletion codeCompletion) { List allProposals = getCacheProposals(partialDoc, documentOffset, qlen); --- 37,54 ---- * @return */ ! public List getAllProposals(PyEdit edit, IDocument doc, String activationToken, int documentOffset, int qlen, PyCodeCompletion codeCompletion) { + String importsTipperStr = codeCompletion.getImportsTipperStr(activationToken, edit, doc, documentOffset); + + String partialDoc = ""; + if (importsTipperStr.length() != 0){ + partialDoc = importsTipperStr; + }else{ + partialDoc = codeCompletion.getDocToParse(doc, documentOffset); + partialDoc += activationToken; + } + List allProposals = getCacheProposals(partialDoc, documentOffset, qlen); *************** *** 66,69 **** --- 76,89 ---- */ private void addProposalsToCache(String partialDoc, List allProposals) { + for (Iterator iter = allProposals.iterator(); iter.hasNext();) { + CompletionProposal element = (CompletionProposal) iter.next(); + + String displayString = element.getDisplayString(); + //we don't add to cache if there is an error here... + if(displayString.startsWith("ERROR") || displayString.startsWith("SERVER_ERROR")){ + return; + } + } + cacheEntries.add(partialDoc); cache.put(partialDoc, allProposals); |
From: Fabio Z. <fa...@us...> - 2004-09-22 12:04:45
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14761/src/org/python/pydev/editor/actions/refactoring Modified Files: PyRefactorAction.java PyRename.java Log Message: Cache changes. Index: PyRename.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring/PyRename.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyRename.java 20 Sep 2004 19:08:42 -0000 1.3 --- PyRename.java 22 Sep 2004 12:04:30 -0000 1.4 *************** *** 39,42 **** --- 39,48 ---- } + /** + * @return + */ + protected String getDefaultValue() { + return ps.textSelection.getText(); + } Index: PyRefactorAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring/PyRefactorAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyRefactorAction.java 20 Sep 2004 19:08:42 -0000 1.3 --- PyRefactorAction.java 22 Sep 2004 12:04:30 -0000 1.4 *************** *** 79,83 **** protected String getInput(PyEdit edit, String msg) { InputDialog d = new InputDialog(getPyEditShell(), "Refactoring", msg, ! "", null); int retCode = d.open(); if (retCode == InputDialog.OK) { --- 79,85 ---- protected String getInput(PyEdit edit, String msg) { InputDialog d = new InputDialog(getPyEditShell(), "Refactoring", msg, ! getDefaultValue(), null); ! ! int retCode = d.open(); if (retCode == InputDialog.OK) { *************** *** 87,90 **** --- 89,99 ---- } + /** + * @return + */ + protected String getDefaultValue() { + return ""; + } + private void refreshEditor(PyEdit edit) throws CoreException { IFile file = (IFile) ((FileEditorInput) edit.getEditorInput()) |
From: Fabio Z. <fa...@us...> - 2004-09-21 17:07:59
|
Update of /cvsroot/pydev/org.python.pydev/PySrc/aRefactoring In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3475/PySrc/aRefactoring Removed Files: Refactoring.py MatchesForm.ui MatchesForm.py MatchesDialog.py __init__.py Log Message: Minor bug fixes. --- MatchesForm.py DELETED --- --- MatchesDialog.py DELETED --- --- MatchesForm.ui DELETED --- --- __init__.py DELETED --- --- Refactoring.py DELETED --- |
From: Fabio Z. <fa...@us...> - 2004-09-21 17:07:59
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3475/PySrc Modified Files: simpleTipper.py Log Message: Minor bug fixes. Index: simpleTipper.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/simpleTipper.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** simpleTipper.py 20 Sep 2004 12:46:07 -0000 1.6 --- simpleTipper.py 21 Sep 2004 17:07:50 -0000 1.7 *************** *** 98,103 **** for n in node.getChildNodes(): if isinstance(n,compiler.ast.AssAttr): ! if n.expr.name == 'self': ! self.selfAttribs.append((n.attrname,'Instance attribute')) --- 98,106 ---- for n in node.getChildNodes(): if isinstance(n,compiler.ast.AssAttr): ! try: ! if n.expr.name == 'self' and (n.attrname,'Instance attribute') not in self.selfAttribs: ! self.selfAttribs.append((n.attrname,'Instance attribute')) ! except: ! pass |
From: Fabio Z. <fa...@us...> - 2004-09-21 13:18:54
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20028 Modified Files: plugin.xml Log Message: Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** plugin.xml 20 Sep 2004 19:08:43 -0000 1.39 --- plugin.xml 21 Sep 2004 13:18:45 -0000 1.40 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.9.7" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.9.7b" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> |
From: Fabio Z. <fa...@us...> - 2004-09-21 13:18:27
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19881/src/org/python/pydev/editor/codecompletion Modified Files: PyCodeCompletionPreferencesPage.java Log Message: Removed server choice. Index: PyCodeCompletionPreferencesPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PyCodeCompletionPreferencesPage.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyCodeCompletionPreferencesPage.java 13 Sep 2004 18:23:09 -0000 1.3 --- PyCodeCompletionPreferencesPage.java 21 Sep 2004 13:18:03 -0000 1.4 *************** *** 36,42 **** public static final boolean DEFAULT_AUTOCOMPLETE_ON_PAR = false; - public static final String USE_SERVER_TIP = "USE_SERVER_TIP"; - public static final boolean DEFAULT_USE_SERVER_TIP = false; - /** */ --- 36,39 ---- *************** *** 66,71 **** AUTOCOMPLETE_ON_PAR, "Autocomplete on '('?", p)); - addField(new BooleanFieldEditor( - USE_SERVER_TIP, "Use server tipper enviroment (otherwise console is used)?", p)); } --- 63,66 ---- *************** *** 76,80 **** */ public void init(IWorkbench workbench) { - // TODO Auto-generated method stub PydevPrefs.getPreferences().addPropertyChangeListener(this); } --- 71,74 ---- *************** *** 87,91 **** prefs.setDefault(AUTOCOMPLETE_DELAY, DEFAULT_AUTOCOMPLETE_DELAY); prefs.setDefault(AUTOCOMPLETE_ON_PAR, DEFAULT_AUTOCOMPLETE_ON_PAR); - prefs.setDefault(USE_SERVER_TIP, DEFAULT_USE_SERVER_TIP); } --- 81,84 ---- *************** *** 106,112 **** } - public static boolean useServerTipEnviroment() { - return PydevPrefs.getPreferences().getBoolean(PyCodeCompletionPreferencesPage.USE_SERVER_TIP); - } /* (non-Javadoc) --- 99,102 ---- |
From: Fabio Z. <fa...@us...> - 2004-09-20 19:28:50
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15482/PySrc Modified Files: test_simpleTipper.py Log Message: Index: test_simpleTipper.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/test_simpleTipper.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_simpleTipper.py 20 Sep 2004 12:46:07 -0000 1.6 --- test_simpleTipper.py 20 Sep 2004 19:28:41 -0000 1.7 *************** *** 124,144 **** return s - def testEnv4(self): - comps = simpleTipper.GenerateTip(self.getDoc4(), None, False) - - def getDoc4(self): - s = \ - '''import test - - - class KKKK(object): - pass - - f = KKKK() - - d = test.LL() - d.vv() - ''' - return s if __name__ == '__main__': --- 124,127 ---- |
From: Fabio Z. <fa...@us...> - 2004-09-20 19:28:35
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15432/PySrc Modified Files: simpleinspect.py Log Message: Index: simpleinspect.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/simpleinspect.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** simpleinspect.py 20 Sep 2004 19:08:41 -0000 1.4 --- simpleinspect.py 20 Sep 2004 19:28:25 -0000 1.5 *************** *** 7,11 **** d = dict() d['__eraseThisTips'] = [] ! dGlobals = dict() #we don't want the globals ! exec __eraseThisV in dGlobals, d return d['__eraseThisTips'] --- 7,10 ---- d = dict() d['__eraseThisTips'] = [] ! exec __eraseThisV in d return d['__eraseThisTips'] |
From: Fabio Z. <fa...@us...> - 2004-09-20 19:09:36
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11446/PySrc Modified Files: test_pyserver.py pycompletionserver.py refactoring.py simpleinspect.py test_refactoring.py Log Message: Changed search for bicycle repair man search and added a refactor view to show which files are modified. Index: pycompletionserver.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/pycompletionserver.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** pycompletionserver.py 17 Sep 2004 19:22:04 -0000 1.10 --- pycompletionserver.py 20 Sep 2004 19:08:41 -0000 1.11 *************** *** 22,26 **** MSG_CHANGE_DIR = '@@CHANGE_DIR:' MSG_OK = '@@MSG_OK_END@@' ! MSG_REFACTOR = '@@REFACTOR' MSG_PROCESSING = '@@PROCESSING_END@@' MSG_PROCESSING_PROGRESS = '@@PROCESSING:%sEND@@' --- 22,26 ---- MSG_CHANGE_DIR = '@@CHANGE_DIR:' MSG_OK = '@@MSG_OK_END@@' ! MSG_BIKE = '@@BIKE' MSG_PROCESSING = '@@PROCESSING_END@@' MSG_PROCESSING_PROGRESS = '@@PROCESSING:%sEND@@' *************** *** 179,184 **** returnMsg = MSG_OK ! elif data.startswith(MSG_REFACTOR): ! data = data.replace(MSG_REFACTOR, '') data = urllib.unquote_plus(data) returnMsg = refactoring.HandleRefactorMessage(data, keepAliveThread) --- 179,184 ---- returnMsg = MSG_OK ! elif data.startswith(MSG_BIKE): ! data = data.replace(MSG_BIKE, '') data = urllib.unquote_plus(data) returnMsg = refactoring.HandleRefactorMessage(data, keepAliveThread) Index: simpleinspect.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/simpleinspect.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** simpleinspect.py 20 Sep 2004 12:46:07 -0000 1.3 --- simpleinspect.py 20 Sep 2004 19:08:41 -0000 1.4 *************** *** 7,10 **** d = dict() d['__eraseThisTips'] = [] ! exec __eraseThisV in d return d['__eraseThisTips'] --- 7,11 ---- d = dict() d['__eraseThisTips'] = [] ! dGlobals = dict() #we don't want the globals ! exec __eraseThisV in dGlobals, d return d['__eraseThisTips'] Index: test_refactoring.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/test_refactoring.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_refactoring.py 16 Sep 2004 15:27:25 -0000 1.2 --- test_refactoring.py 20 Sep 2004 19:08:41 -0000 1.3 *************** *** 104,111 **** self.assertEquals(getRenameRefactored(), contents) ! if __name__ == '__main__': ! unittest.main() --- 104,137 ---- self.assertEquals(getRenameRefactored(), contents) + def testFind(self): + r = refactoring.Refactoring() + s = r.findDefinition(FILE, 7+1, 4) ! s = s.replace('[(','').replace(')]','').split(',') ! self.assert_( s[0].endswith('temporary_file.py')) ! self.assertEquals('2', s[1]) #line ! self.assertEquals('6', s[2]) #col ! self.assertEquals('100', s[3]) #accuracy ! ! createFile(FILE, getFindFile()) ! s = r.findDefinition(FILE, 5+1, 2) ! s1 = r.findDefinition(FILE, 5+1, 3) ! s2 = r.findDefinition(FILE, 5+1, 4) ! self.assert_(s == s1 == s2) + def getFindFile(): + s = \ + ''' + class C: + def aaa(self): + return 0 + c = C() + c.aaa() + ''' + return s + + if __name__ == '__main__': + # unittest.main() + unittest.TestMethod(Test, 'Test.testFind') Index: test_pyserver.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/test_pyserver.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_pyserver.py 17 Sep 2004 17:35:55 -0000 1.7 --- test_pyserver.py 20 Sep 2004 19:08:41 -0000 1.8 *************** *** 71,80 **** #now that we have the connections all set up, check the code completion messages. ! msg = urllib.quote('import math\n') sToWrite.send('@@GLOBALS:%sEND@@'%msg) #only 1 global should be returned: math itself. completions = self.readMsg() ! msg = urllib.quote('This module is always available. It provides access to the\n'\ 'mathematical functions defined by the C standard.') self.assertEquals('@@COMPLETIONS((math,%s))END@@'%msg, --- 71,80 ---- #now that we have the connections all set up, check the code completion messages. ! msg = urllib.quote_plus('import math\n') sToWrite.send('@@GLOBALS:%sEND@@'%msg) #only 1 global should be returned: math itself. completions = self.readMsg() ! msg = urllib.quote_plus('This module is always available. It provides access to the\n'\ 'mathematical functions defined by the C standard.') self.assertEquals('@@COMPLETIONS((math,%s))END@@'%msg, *************** *** 82,91 **** ! msg1 = urllib.quote('math') ! msg2 = urllib.quote('import math\n') #check token msg. sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' % (msg1, msg2)) completions = self.readMsg() - self.assert_('@@COMPLETIONS' in completions) --- 82,90 ---- ! msg1 = urllib.quote_plus('math') ! msg2 = urllib.quote_plus('import math\n') #check token msg. sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' % (msg1, msg2)) completions = self.readMsg() self.assert_('@@COMPLETIONS' in completions) *************** *** 109,113 **** pass ''' ! msg = urllib.quote(s) sToWrite.send('@@TOKEN_GLOBALS(C):%s\nEND@@'%s) --- 108,112 ---- pass ''' ! msg = urllib.quote_plus(s) sToWrite.send('@@TOKEN_GLOBALS(C):%s\nEND@@'%s) *************** *** 137,147 **** self.assert_(newDir != None) ! newDir = urllib.quote(newDir) sToWrite.send('@@CHANGE_DIR:%sEND@@'%newDir) ok = self.readMsg() self.assertEquals('@@MSG_OK_END@@' , ok) ! msg1 = urllib.quote('math.acos') #with point ! msg2 = urllib.quote('import math\n') sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' %(msg1, msg2)) completions = self.readMsg() --- 136,146 ---- self.assert_(newDir != None) ! newDir = urllib.quote_plus(newDir) sToWrite.send('@@CHANGE_DIR:%sEND@@'%newDir) ok = self.readMsg() self.assertEquals('@@MSG_OK_END@@' , ok) ! msg1 = urllib.quote_plus('math.acos') #with point ! msg2 = urllib.quote_plus('import math\n') sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' %(msg1, msg2)) completions = self.readMsg() *************** *** 149,154 **** self.assert_('END@@' in completions) ! msg1 = urllib.quote('math acos') #with space ! msg2 = urllib.quote('import math\n') sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' %(msg1, msg2)) completions2 = self.readMsg() --- 148,153 ---- self.assert_('END@@' in completions) ! msg1 = urllib.quote_plus('math acos') #with space ! msg2 = urllib.quote_plus('import math\n') sToWrite.send('@@TOKEN_GLOBALS(%s):%sEND@@' %(msg1, msg2)) completions2 = self.readMsg() *************** *** 177,183 **** createFile(FILE, getInitialFile()) ! sToWrite.send('@@REFACTORrenameByCoordinates %s %s %s %sEND@@'%(FILE, 1+1, 6, 'G')) result = self.readMsg() ! print 'result', result self.sendKillMsg(sToWrite) --- 176,186 ---- createFile(FILE, getInitialFile()) ! sToWrite.send('@@BIKEfindDefinition %s %s %sEND@@'%(FILE, 7+1, 4)) result = self.readMsg() ! self.assert_('BIKE_OK:' in result) ! ! sToWrite.send('@@BIKErenameByCoordinates %s %s %s %sEND@@'%(FILE, 1+1, 6, 'G')) ! result = self.readMsg() ! self.assert_('BIKE_OK:' in result) self.sendKillMsg(sToWrite) Index: refactoring.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/refactoring.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** refactoring.py 17 Sep 2004 19:22:04 -0000 1.5 --- refactoring.py 20 Sep 2004 19:08:41 -0000 1.6 *************** *** 78,81 **** --- 78,93 ---- return str(savedfiles) + + def findDefinition(self, filename, line, column): + defns = self.brmctx.findDefinitionByCoordinates(filename, int(line), int(column)) + + ret = '' + + for ref in defns: + ret += '(%s)'%str(ref) + + return '[%s]' % ret + + __Refactoring = None *************** *** 87,96 **** return __Refactoring ! def releaseRefactorerBuffers(): ! GetRefactorer().warning.close() ! GetRefactorer().progress.close() ! GetRefactorer().warning.__init__() ! GetRefactorer().progress.__init__() def restartRefactorer(): --- 99,109 ---- return __Refactoring ! def restartRefactorerBuffer(): ! r = GetRefactorer() ! r.warning.close() ! r.progress.close() ! r.warning.__init__() ! r.progress.__init__() def restartRefactorer(): *************** *** 113,119 **** try: f = func(*msgSplit) ! releaseRefactorerBuffers() s = urllib.quote_plus(f) ! return 'REFACTOR_OK:%s\nEND@@'%(s) except: import sys --- 126,132 ---- try: f = func(*msgSplit) ! restartRefactorerBuffer() s = urllib.quote_plus(f) ! return 'BIKE_OK:%s\nEND@@'%(s) except: import sys *************** *** 132,136 **** traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file = s) ! releaseRefactorerBuffers() restartRefactorer() s = urllib.quote_plus(s.getvalue()) --- 145,149 ---- traceback.print_exception(exc_info[0], exc_info[1], exc_info[2], limit=None, file = s) ! restartRefactorerBuffer() restartRefactorer() s = urllib.quote_plus(s.getvalue()) |