pydev-cvs Mailing List for PyDev for Eclipse (Page 307)
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: Fabio Z. <fa...@us...> - 2004-08-25 17:25:51
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17214/src/org/python/pydev/editor/codecompletion Modified Files: PythonCompletionProcessor.java Log Message: Added code completion page. Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PythonCompletionProcessor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PythonCompletionProcessor.java 11 Aug 2004 17:45:05 -0000 1.2 --- PythonCompletionProcessor.java 25 Aug 2004 17:25:41 -0000 1.3 *************** *** 19,33 **** /** * @author Dmoore ! * @author Fabio Zadrozny * * This class is responsible for code completion / template completion. */ ! public class PythonCompletionProcessor ! implements IContentAssistProcessor { ! private PyTemplateCompletion templatesCompletion = new PyTemplateCompletion(); private PyCodeCompletion codeCompletion = new PyCodeCompletion(); private CompletionCache completionCache = new CompletionCache(); public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, --- 19,43 ---- /** * @author Dmoore ! * @author Fabio Zadrozny * * This class is responsible for code completion / template completion. */ ! public class PythonCompletionProcessor implements IContentAssistProcessor { ! private PyTemplateCompletion templatesCompletion = new PyTemplateCompletion(); + private PyCodeCompletion codeCompletion = new PyCodeCompletion(); + private CompletionCache completionCache = new CompletionCache(); + private boolean endsWithSomeChar(char cs[], String activationToken) { + for (int i = 0; i < cs.length; i++) { + if (activationToken.endsWith(cs[i] + "")) { + return true; + } + } + return false; + + } public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, *************** *** 40,69 **** java.lang.String theDoc = doc.get(); codeCompletion.calcDocBoundary(theDoc, documentOffset); ! ! String activationToken = codeCompletion ! .getActivationToken(theDoc, documentOffset); ! // System.out.println("DBG:PythonCompletionProcessor:activationToken:"+activationToken); java.lang.String qualifier = ""; ! while( ! (activationToken.endsWith(".") ||activationToken.endsWith("(")) ! == false && activationToken.length() > 0){ ! qualifier = activationToken.charAt(activationToken.length()-1) + qualifier; ! activationToken = activationToken.substring(0, activationToken.length()-1); } theDoc = codeCompletion.partialDocument(theDoc, documentOffset); ! ! int qlen = qualifier.length(); theDoc += "\n" + activationToken; ! List allProposals = this.completionCache.getAllProposals(theDoc, activationToken, documentOffset, qlen, codeCompletion); //templates proposals are added here. ! this.templatesCompletion.addTemplateProposals(viewer, documentOffset, propList); for (Iterator iter = allProposals.iterator(); iter.hasNext();) { ICompletionProposal proposal = (ICompletionProposal) iter.next(); ! if(proposal.getDisplayString().startsWith(qualifier)){ propList.add(proposal); } --- 50,84 ---- java.lang.String theDoc = doc.get(); codeCompletion.calcDocBoundary(theDoc, documentOffset); ! ! String activationToken = codeCompletion.getActivationToken(theDoc, ! documentOffset); ! java.lang.String qualifier = ""; ! char[] cs = getCompletionProposalAutoActivationCharacters(); ! ! while (endsWithSomeChar(cs, activationToken) == false ! && activationToken.length() > 0) { ! ! qualifier = activationToken.charAt(activationToken.length() - 1) ! + qualifier; ! activationToken = activationToken.substring(0, activationToken ! .length() - 1); } theDoc = codeCompletion.partialDocument(theDoc, documentOffset); ! int qlen = qualifier.length(); theDoc += "\n" + activationToken; ! List allProposals = this.completionCache.getAllProposals(theDoc, ! activationToken, documentOffset, qlen, codeCompletion); //templates proposals are added here. ! this.templatesCompletion.addTemplateProposals(viewer, documentOffset, ! propList); for (Iterator iter = allProposals.iterator(); iter.hasNext();) { ICompletionProposal proposal = (ICompletionProposal) iter.next(); ! if (proposal.getDisplayString().startsWith(qualifier)) { propList.add(proposal); } *************** *** 79,87 **** } - - - - - /* * (non-Javadoc) --- 94,97 ---- *************** *** 92,96 **** public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { - // TODO Auto-generated method stub return null; } --- 102,105 ---- *************** *** 102,107 **** */ public char[] getCompletionProposalAutoActivationCharacters() { ! //System.out.println("DBG:getCompletionProposalAutoActivationCharacters called"); ! return new char[] { '.', '(', /*'['*/ }; } --- 111,135 ---- */ public char[] getCompletionProposalAutoActivationCharacters() { ! char[] c = new char[0]; ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnDot()) { ! c = addChar(c, '.'); ! } ! if (PyCodeCompletionPreferencesPage.isToAutocompleteOnPar()) { ! c = addChar(c, '('); ! } ! return c; ! } ! ! private char[] addChar(char[] c, char toAdd) { ! char[] c1 = new char[c.length + 1]; ! ! int i; ! ! for (i = 0; i < c.length; i++) { ! c1[i] = c[i]; ! } ! c1[i] = toAdd; ! return c1; ! } *************** *** 112,117 **** */ public char[] getContextInformationAutoActivationCharacters() { ! // is this _really_ what we want to use?? ! return new char[] { '.' }; } --- 140,144 ---- */ public char[] getContextInformationAutoActivationCharacters() { ! return new char[] {}; } |
From: Fabio Z. <fa...@us...> - 2004-08-25 17:25:33
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17128/src/org/python/pydev/plugin Modified Files: PydevPlugin.java Log Message: Added code completion page. Index: PydevPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPlugin.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PydevPlugin.java 10 Aug 2004 01:16:13 -0000 1.11 --- PydevPlugin.java 25 Aug 2004 17:25:23 -0000 1.12 *************** *** 27,30 **** --- 27,31 ---- import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; + import org.python.pydev.editor.codecompletion.PyCodeCompletionPreferencesPage; import org.python.pydev.editor.templates.PyContextType; *************** *** 110,113 **** --- 111,115 ---- protected void initializeDefaultPluginPreferences() { PydevPrefs.initializeDefaultPreferences(getPluginPreferences()); + PyCodeCompletionPreferencesPage.initializeDefaultPreferences(getPluginPreferences()); } |
From: Fabio Z. <fa...@us...> - 2004-08-25 17:25:32
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17128/src/org/python/pydev/editor/codecompletion Added Files: PyContentAssistant.java PyCodeCompletionPreferencesPage.java Log Message: Added code completion page. --- NEW FILE: PyCodeCompletionPreferencesPage.java --- /* * Created on Aug 25, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.codecompletion; import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IntegerFieldEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.PydevPrefs; /** * @author Fabio Zadrozny */ public class PyCodeCompletionPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage , Preferences.IPropertyChangeListener { public static final String AUTOCOMPLETE_ON_DOT = "AUTOCOMPLETE_ON_DOT"; public static final boolean DEFAULT_AUTOCOMPLETE_ON_DOT = true; public static final String USE_AUTOCOMPLETE = "USE_AUTOCOMPLETE"; public static final boolean DEFAULT_USE_AUTOCOMPLETE = true; public static final String AUTOCOMPLETE_DELAY = "AUTOCOMPLETE_DELAY"; public static final int DEFAULT_AUTOCOMPLETE_DELAY = 250; public static final String AUTOCOMPLETE_ON_PAR = "AUTOCOMPLETE_ON_PAR"; public static final boolean DEFAULT_AUTOCOMPLETE_ON_PAR = false; /** */ public PyCodeCompletionPreferencesPage() { super(GRID); setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); } /* * (non-Javadoc) * * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() */ protected void createFieldEditors() { Composite p = getFieldEditorParent(); addField(new BooleanFieldEditor( USE_AUTOCOMPLETE, "Use autocompletion?", p)); addField(new IntegerFieldEditor( AUTOCOMPLETE_DELAY, "Autocompletion delay: ", p)); addField(new BooleanFieldEditor( AUTOCOMPLETE_ON_DOT, "Autocomplete on '.'?", p)); addField(new BooleanFieldEditor( AUTOCOMPLETE_ON_PAR, "Autocomplete on '('?", p)); } /* * (non-Javadoc) * * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ public void init(IWorkbench workbench) { // TODO Auto-generated method stub PydevPrefs.getPreferences().addPropertyChangeListener(this); } /** * Sets default preference values */ public static void initializeDefaultPreferences(Preferences prefs) { prefs.setDefault(AUTOCOMPLETE_ON_DOT, DEFAULT_AUTOCOMPLETE_ON_DOT); prefs.setDefault(USE_AUTOCOMPLETE, DEFAULT_USE_AUTOCOMPLETE); prefs.setDefault(AUTOCOMPLETE_DELAY, DEFAULT_AUTOCOMPLETE_DELAY); prefs.setDefault(AUTOCOMPLETE_ON_PAR, DEFAULT_AUTOCOMPLETE_ON_PAR); } public static boolean isToAutocompleteOnDot() { return PydevPrefs.getPreferences().getBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_DOT); } public static boolean isToAutocompleteOnPar() { return PydevPrefs.getPreferences().getBoolean(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_ON_PAR); } public static boolean useAutocomplete() { return PydevPrefs.getPreferences().getBoolean(PyCodeCompletionPreferencesPage.USE_AUTOCOMPLETE); } public static int getAutocompleteDelay() { return PydevPrefs.getPreferences().getInt(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_DELAY); } /* (non-Javadoc) * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { // System.out.println( event.getProperty() // + "\n\told setting: " // + event.getOldValue() // + "\n\tnew setting: " // + event.getNewValue()); } } --- NEW FILE: PyContentAssistant.java --- /* * Created on Aug 25, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.codecompletion; import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Preferences.PropertyChangeEvent; import org.eclipse.jface.text.contentassist.ContentAssistant; import org.python.pydev.plugin.PydevPrefs; /** * @author Fabio Zadrozny */ public class PyContentAssistant extends ContentAssistant implements Preferences.IPropertyChangeListener{ public PyContentAssistant(){ PydevPrefs.getPreferences().addPropertyChangeListener(this); enableAutoActivation(PyCodeCompletionPreferencesPage.useAutocomplete()); setAutoActivationDelay(PyCodeCompletionPreferencesPage.getAutocompleteDelay()); } /* (non-Javadoc) * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if(event.getProperty().equals(PyCodeCompletionPreferencesPage.USE_AUTOCOMPLETE)){ this.enableAutoActivation( ((Boolean)event.getNewValue()).booleanValue() ); } if(event.getProperty().equals(PyCodeCompletionPreferencesPage.AUTOCOMPLETE_DELAY)){ this.setAutoActivationDelay( ((Integer)event.getNewValue()).intValue() ); } } } |
From: Fabio Z. <fa...@us...> - 2004-08-25 17:24:32
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16869 Modified Files: plugin.xml Log Message: Added code completion page. Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** plugin.xml 16 Aug 2004 18:55:22 -0000 1.33 --- plugin.xml 25 Aug 2004 17:24:23 -0000 1.34 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.8.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.1" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> *************** *** 89,92 **** --- 89,97 ---- name="Templates" id="org.python.pydev.prefs.template"/> + <page + class="org.python.pydev.editor.codecompletion.PyCodeCompletionPreferencesPage" + category="org.python.pydev.prefs" + name="Code Completion" + id="org.python.pydev.prefs.PyCodeCompletionPage"/> </extension> <!-- Editor menus --> *************** *** 589,593 **** name="stderr" icon="icons/template.gif" ! description="Prints to sys.stdout" contextTypeId="org.python.pydev.editor.templates.python" id="org.python.pydev.editor.templates.python.stderr"> --- 594,598 ---- name="stderr" icon="icons/template.gif" ! description="Prints to sys.stderr" contextTypeId="org.python.pydev.editor.templates.python" id="org.python.pydev.editor.templates.python.stderr"> |
From: Fabio Z. <fa...@us...> - 2004-08-19 17:50:57
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20637/src/org/python/pydev/editor/codefolding Modified Files: CodeFoldingSetter.java Log Message: Modified position when it changes (was trying to add marker again). Index: CodeFoldingSetter.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding/CodeFoldingSetter.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CodeFoldingSetter.java 16 Aug 2004 13:31:00 -0000 1.5 --- CodeFoldingSetter.java 19 Aug 2004 17:50:46 -0000 1.6 *************** *** 13,17 **** import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Position; ! import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.projection.ProjectionAnnotation; import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; --- 13,17 ---- import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Position; ! import org.eclipse.jface.text.source.Annotation; import org.eclipse.jface.text.source.projection.ProjectionAnnotation; import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel; *************** *** 44,48 **** */ public synchronized void modelChanged(AbstractNode root) { ! IAnnotationModel model = (IAnnotationModel) editor .getAdapter(ProjectionAnnotationModel.class); --- 44,48 ---- */ public synchronized void modelChanged(AbstractNode root) { ! ProjectionAnnotationModel model = (ProjectionAnnotationModel) editor .getAdapter(ProjectionAnnotationModel.class); *************** *** 54,60 **** new Thread(){ public void run(){ ! IAnnotationModel modelT = null; for(int i=0 ; i < 10 && modelT == null; i++){ ! modelT = (IAnnotationModel) editor .getAdapter(ProjectionAnnotationModel.class); try { --- 54,60 ---- new Thread(){ public void run(){ ! ProjectionAnnotationModel modelT = null; for(int i=0 ; i < 10 && modelT == null; i++){ ! modelT = (ProjectionAnnotationModel) editor .getAdapter(ProjectionAnnotationModel.class); try { *************** *** 79,83 **** * @param model */ ! private void addMarksToModel(AbstractNode root, IAnnotationModel model) { try{ if (model != null) { --- 79,83 ---- * @param model */ ! private void addMarksToModel(AbstractNode root, ProjectionAnnotationModel model) { try{ if (model != null) { *************** *** 131,135 **** * @param model */ ! private void addMarks(ArrayList nodes, IAnnotationModel model, ArrayList collapsed) { int i=0; --- 131,135 ---- * @param model */ ! private void addMarks(ArrayList nodes, ProjectionAnnotationModel model, ArrayList collapsed) { int i=0; *************** *** 215,219 **** * @throws BadLocationException */ ! private void addFoldingMark(AbstractNode node, int start, int end, IAnnotationModel model, ArrayList collapsed) throws BadLocationException { try { --- 215,219 ---- * @throws BadLocationException */ ! private void addFoldingMark(AbstractNode node, int start, int end, ProjectionAnnotationModel model, ArrayList collapsed) throws BadLocationException { try { *************** *** 225,229 **** ! model.addAnnotation(getAnnotationToAdd(position, node, model, collapsed), position); --- 225,234 ---- ! Annotation anottation = getAnnotationToAdd(position, node, model, collapsed); ! if(model.getPosition(anottation)!= null && model.getPosition(anottation).equals(position) == false){ ! model.modifyAnnotationPosition(anottation, position); ! }else{ ! model.addAnnotation(anottation, position); ! } *************** *** 243,247 **** * @return */ ! private ProjectionAnnotation getAnnotationToAdd(Position position, AbstractNode node, IAnnotationModel model, ArrayList collapsed){ for (Iterator iter = collapsed.iterator(); iter.hasNext();) { PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next(); --- 248,252 ---- * @return */ ! private ProjectionAnnotation getAnnotationToAdd(Position position, AbstractNode node, ProjectionAnnotationModel model, ArrayList collapsed){ for (Iterator iter = collapsed.iterator(); iter.hasNext();) { PyProjectionAnnotation element = (PyProjectionAnnotation) iter.next(); |
From: Fabio Z. <fa...@us...> - 2004-08-16 20:55:45
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31791/src/org/python/pydev/editor/codecompletion Modified Files: PyCodeCompletion.java Log Message: Now we don't write/ read the file anymore. Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyCodeCompletion.java 11 Aug 2004 17:44:16 -0000 1.2 --- PyCodeCompletion.java 16 Aug 2004 20:55:31 -0000 1.3 *************** *** 7,16 **** import java.io.BufferedReader; - import java.io.BufferedWriter; import java.io.File; - import java.io.FileWriter; import java.io.IOException; - import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; --- 7,14 ---- import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; + import java.io.OutputStreamWriter; import java.net.URL; import java.util.ArrayList; *************** *** 64,73 **** java.lang.String theActivationToken) { List theList = new ArrayList(); ! String s = new String(); ! File tmp = null; ! // System.out.println("DBG:autoComplete:theActivationToken: "+theActivationToken); try { ! // get the inspect.py file from the package: ! s = getAutoCompleteScript(); } catch (CoreException e) { --- 62,69 ---- java.lang.String theActivationToken) { List theList = new ArrayList(); ! File tipperFile=null; ! try { ! tipperFile = getAutoCompleteScript(); } catch (CoreException e) { *************** *** 77,99 **** try { ! //We actually write a file with all of our code to a temporary location, ! //so that we can get its code completion from the typper.py script. ! // ! //TODO: there must be a faster strategy... ! // ! tmp = bufferContent(theCode); ! ! if (tmp == null) { ! System.out.println("DBG:bufferContent() null. No tip for you!!"); ! return theList; ! } ! String ss = new String("python " + s + " " + tmp.getAbsolutePath()); ! ! Process p = Runtime.getRuntime().exec(ss); BufferedReader in = new BufferedReader(new InputStreamReader(p .getInputStream())); String str; ! while ((str = in.readLine()) != null) { if (!str.startsWith("tip: ")){ continue; --- 73,107 ---- try { ! Process p = Runtime.getRuntime().exec(new String[]{"python"}); ! //we have the process... ! OutputStreamWriter writer = new OutputStreamWriter(p.getOutputStream()); BufferedReader in = new BufferedReader(new InputStreamReader(p .getInputStream())); + BufferedReader eIn = new BufferedReader(new InputStreamReader( + p.getErrorStream())); + + //we have to put the tipper in sys.path + writer.write("import sys\n"); + writer.write("sys.path.insert(0,r'"+tipperFile.getParent()+"')\n"); + + //now we have it in the modules... import and call tipper with the code... + writer.write("from tipper import GenerateTip\n"); + + theCode = theCode.replaceAll("\r",""); + theCode = theCode.replaceAll("\n","\\\\n"); + + theCode = theCode.replaceAll("'","@l@l@*"); //TODO: that's a really bad way to do it... + + writer.write("s = '"+theCode+"'\n"); + writer.write("s = s.replace('@l@l@*', '\\'')\n"); + + writer.write("GenerateTip(s)\n\n\n"); + + writer.flush(); + writer.close(); + String str; ! while ((str = in.readLine()) != null) { if (!str.startsWith("tip: ")){ continue; *************** *** 105,115 **** } in.close(); - InputStream eInput = p.getErrorStream(); - BufferedReader eIn = new BufferedReader(new InputStreamReader( - eInput)); while ((str = eIn.readLine()) != null) { ! //System.out.println("error output: " + str); } p.waitFor(); } catch (IOException e) { --- 113,121 ---- } in.close(); while ((str = eIn.readLine()) != null) { ! // System.out.println("error output: " + str); } + eIn.close(); p.waitFor(); } catch (IOException e) { *************** *** 123,150 **** } - /** - * We actually write a file with all of our code to a temporary location, - * so that we can get its code completion from the typper.py script. - * - * @param theCode code to be written to file. - */ - private File bufferContent(java.lang.String theCode) { - // - try { - // Create temp file. - File temp = File.createTempFile("PyDev", ".tmp"); - - // Delete temp file when program exits. - temp.deleteOnExit(); - - // Write to temp file - BufferedWriter out = new BufferedWriter(new FileWriter(temp)); - out.write(theCode); - out.close(); - return temp; - } catch (IOException e) { - return null; - } - } /** --- 129,132 ---- *************** *** 154,158 **** * @throws CoreException */ ! public static String getAutoCompleteScript() throws CoreException { String targetExec = "tipper.py"; --- 136,140 ---- * @throws CoreException */ ! public static File getAutoCompleteScript() throws CoreException { String targetExec = "tipper.py"; *************** *** 166,172 **** try { fileURL = Platform.asLocalURL(bundleURL); ! String filePath = new File(fileURL.getPath()).getAbsolutePath(); ! return filePath; } catch (IOException e) { throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, --- 148,154 ---- try { fileURL = Platform.asLocalURL(bundleURL); ! File f = new File(fileURL.getPath()); ! return f; } catch (IOException e) { throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, |
From: Dana M. <dan...@us...> - 2004-08-16 18:55:31
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7322 Modified Files: plugin.xml Log Message: adds a couple new (possibly useful??) templates: {debbuger, dbg. stderr, stdout}, and corrects one other (main) Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** plugin.xml 11 Aug 2004 17:57:16 -0000 1.32 --- plugin.xml 16 Aug 2004 18:55:22 -0000 1.33 *************** *** 335,338 **** --- 335,339 ---- configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> </keyBinding> + <!-- command: next method / class--> <command *************** *** 561,568 **** name="main" icon="icons/template.gif" ! description="main" contextTypeId="org.python.pydev.editor.templates.python" ! id="org.python.pydev.editor.templates.python.pdb"> ! <pattern>if __name__ == 'main':</pattern> </template> <template --- 562,572 ---- name="main" icon="icons/template.gif" ! description="main function pattern. Season to taste" contextTypeId="org.python.pydev.editor.templates.python" ! id="org.python.pydev.editor.templates.python.main"> ! <pattern> ! if __name__ == '__main__': ! ${cursor}${Run)() ! </pattern> </template> <template *************** *** 575,578 **** --- 579,598 ---- </template> <template + name="stdout" + icon="icons/template.gif" + description="Prints to sys.stdout" + contextTypeId="org.python.pydev.editor.templates.python" + id="org.python.pydev.editor.templates.python.stdout"> + <pattern>print >> sys.stdout, ${cursor}${data}</pattern> + </template> + <template + name="stderr" + icon="icons/template.gif" + description="Prints to sys.stdout" + contextTypeId="org.python.pydev.editor.templates.python" + id="org.python.pydev.editor.templates.python.stderr"> + <pattern>print >> sys.stderr, ${cursor}${data}</pattern> + </template> + <template name="eq" icon="icons/template.gif" *************** *** 614,618 **** </pattern> </template> ! </extension> --- 634,662 ---- </pattern> </template> ! <template ! name="debugger" ! icon="icons/template.gif" ! description="Creates an in-module debugger" ! contextTypeId="org.python.pydev.editor.templates.python" ! id="org.python.pydev.editor.templates.python.debug"> ! <pattern> ! import sys ! debugToggle = 1 ! def debug(*values): ! if debugToggle == 0: return ! print >> sys.stderr, "DBG>", ! for v in values: print >> sys.stderr, v, ! print >> sys.stderr, '.' ! ${cursor} ! </pattern> ! </template> ! <template ! name="dbg" ! icon="icons/template.gif" ! description="print a debug line.(use the debugger macro to define an in-module global debug method first!)" ! contextTypeId="org.python.pydev.editor.templates.python" ! id="org.python.pydev.editor.templates.python.dbg"> ! <pattern>debug('==>', ${cursor}${data})</pattern> ! </template> </extension> |
From: Aleksandar T. <at...@us...> - 2004-08-13 20:47:27
|
Update of /cvsroot/pydev/org.python.pydev.help/pydev.sf.net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8647/pydev.sf.net Removed Files: debug.html screenshot.jpg Log Message: Added press references --- debug.html DELETED --- --- screenshot.jpg DELETED --- |
From: Aleksandar T. <at...@us...> - 2004-08-13 20:47:27
|
Update of /cvsroot/pydev/org.python.pydev.help/pydev.sf.net/images In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8647/pydev.sf.net/images Removed Files: debug_dialog.gif debug_console.gif ed_prefs.gif db_prefs.gif debug_menu.gif Log Message: Added press references --- debug_dialog.gif DELETED --- --- debug_console.gif DELETED --- --- ed_prefs.gif DELETED --- --- db_prefs.gif DELETED --- --- debug_menu.gif DELETED --- |
From: Dana M. <dan...@us...> - 2004-08-11 17:57:29
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14096 Modified Files: plugin.xml Log Message: adds a couple new (possibly useful??) templates Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** plugin.xml 11 Aug 2004 13:04:14 -0000 1.31 --- plugin.xml 11 Aug 2004 17:57:16 -0000 1.32 *************** *** 591,594 **** --- 591,616 ---- return not self == o </pattern> + + </template> + + <template + name="iff" + icon="icons/template.gif" + description="Normal 'if' test" + contextTypeId="org.python.pydev.editor.templates.python" + id="org.python.pydev.editor.templates.python.iff"> + <pattern> + if ${cursor}${condition}: True + </pattern> + </template> + <template + name="def" + icon="icons/template.gif" + description="global method definition" + contextTypeId="org.python.pydev.editor.templates.python" + id="org.python.pydev.editor.templates.python.def"> + <pattern> + def ${cursor}${method}(): True + </pattern> </template> |
From: Dana M. <dan...@us...> - 2004-08-11 17:45:14
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11934/src/org/python/pydev/editor/codecompletion Modified Files: PythonCompletionProcessor.java Log Message: re-adds autoactivation for '(' Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PythonCompletionProcessor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonCompletionProcessor.java 11 Aug 2004 13:04:13 -0000 1.1 --- PythonCompletionProcessor.java 11 Aug 2004 17:45:05 -0000 1.2 *************** *** 43,50 **** String activationToken = codeCompletion .getActivationToken(theDoc, documentOffset); ! java.lang.String qualifier = ""; ! ! while(activationToken.endsWith(".") == false && activationToken.length() > 0){ qualifier = activationToken.charAt(activationToken.length()-1) + qualifier; activationToken = activationToken.substring(0, activationToken.length()-1); --- 43,51 ---- String activationToken = codeCompletion .getActivationToken(theDoc, documentOffset); ! // System.out.println("DBG:PythonCompletionProcessor:activationToken:"+activationToken); java.lang.String qualifier = ""; ! while( ! (activationToken.endsWith(".") ||activationToken.endsWith("(")) ! == false && activationToken.length() > 0){ qualifier = activationToken.charAt(activationToken.length()-1) + qualifier; activationToken = activationToken.substring(0, activationToken.length()-1); *************** *** 101,105 **** */ public char[] getCompletionProposalAutoActivationCharacters() { ! return new char[] { '.'/*, '(', '['*/ }; } --- 102,107 ---- */ public char[] getCompletionProposalAutoActivationCharacters() { ! //System.out.println("DBG:getCompletionProposalAutoActivationCharacters called"); ! return new char[] { '.', '(', /*'['*/ }; } |
From: Dana M. <dan...@us...> - 2004-08-11 17:44:25
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11789/src/org/python/pydev/editor/codecompletion Modified Files: PyCodeCompletion.java Log Message: re-adds autoactivation for '(' Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyCodeCompletion.java 11 Aug 2004 13:04:13 -0000 1.1 --- PyCodeCompletion.java 11 Aug 2004 17:44:16 -0000 1.2 *************** *** 66,70 **** String s = new String(); File tmp = null; ! try { // get the inspect.py file from the package: --- 66,70 ---- String s = new String(); File tmp = null; ! // System.out.println("DBG:autoComplete:theActivationToken: "+theActivationToken); try { // get the inspect.py file from the package: *************** *** 85,90 **** if (tmp == null) { ! System.out ! .println("DBG:bufferContent() null. No tip for you!!"); return theList; } --- 85,89 ---- if (tmp == null) { ! System.out.println("DBG:bufferContent() null. No tip for you!!"); return theList; } *************** *** 96,101 **** .getInputStream())); String str; ! while ((str = in.readLine()) != null) { ! if (!str.startsWith("tip: ")){ continue; --- 95,99 ---- .getInputStream())); String str; ! while ((str = in.readLine()) != null) { if (!str.startsWith("tip: ")){ continue; |
From: Dana M. <dan...@us...> - 2004-08-11 17:40:38
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11076/src/org/python/pydev/editor Modified Files: PyEditConfiguration.java Log Message: shortens autoactivation latency Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PyEditConfiguration.java 11 Aug 2004 13:04:13 -0000 1.16 --- PyEditConfiguration.java 11 Aug 2004 17:40:20 -0000 1.17 *************** *** 299,303 **** // Allow automatic activation after 500 msec assistant.enableAutoActivation(true); ! assistant.setAutoActivationDelay(500); Color bgColor = colorCache.getColor(new RGB(230,255,230)); assistant.setProposalSelectorBackground(bgColor); --- 299,303 ---- // Allow automatic activation after 500 msec assistant.enableAutoActivation(true); ! assistant.setAutoActivationDelay(250); Color bgColor = colorCache.getColor(new RGB(230,255,230)); assistant.setProposalSelectorBackground(bgColor); |
From: Fabio Z. <fa...@us...> - 2004-08-11 13:04:24
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21162 Modified Files: plugin.xml Log Message: Refactored code completion. Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** plugin.xml 10 Aug 2004 16:10:38 -0000 1.30 --- plugin.xml 11 Aug 2004 13:04:14 -0000 1.31 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.8.5" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.8.7" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> *************** *** 564,568 **** contextTypeId="org.python.pydev.editor.templates.python" id="org.python.pydev.editor.templates.python.pdb"> ! <pattern>if __name __ == 'main':</pattern> </template> <template --- 564,568 ---- contextTypeId="org.python.pydev.editor.templates.python" id="org.python.pydev.editor.templates.python.pdb"> ! <pattern>if __name__ == 'main':</pattern> </template> <template |
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21162/src/org/python/pydev/editor/codecompletion Added Files: PyTemplateCompletion.java PythonCompletionProcessor.java PyCodeCompletion.java CompletionCache.java Log Message: Refactored code completion. --- NEW FILE: PyTemplateCompletion.java --- /* * Created on Aug 11, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.codecompletion; import java.util.List; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.templates.Template; import org.eclipse.jface.text.templates.TemplateCompletionProcessor; import org.eclipse.jface.text.templates.TemplateContextType; import org.eclipse.swt.graphics.Image; import org.python.pydev.editor.templates.PyContextType; import org.python.pydev.plugin.PydevPlugin; /** * @author Fabio Zadrozny */ public class PyTemplateCompletion extends TemplateCompletionProcessor{ /* * (non-Javadoc) * * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getTemplates(java.lang.String) */ protected Template[] getTemplates(String contextTypeId) { return PydevPlugin.getDefault().getTemplateStore().getTemplates(); } /* * (non-Javadoc) * * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextType(org.eclipse.jface.text.ITextViewer, * org.eclipse.jface.text.IRegion) */ protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { return PydevPlugin.getDefault().getContextTypeRegistry() .getContextType(PyContextType.PY_CONTEXT_TYPE); } /* * (non-Javadoc) * * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getImage(org.eclipse.jface.text.templates.Template) */ protected Image getImage(Template template) { // TODO Auto-generated method stub return null; } /** * @param viewer * @param documentOffset * @param propList * */ protected void addTemplateProposals(ITextViewer viewer, int documentOffset, List propList) { String str = extractPrefix(viewer, documentOffset); ICompletionProposal[] templateProposals = computeCompletionProposals(viewer, documentOffset); for (int j = 0; j < templateProposals.length; j++) { if ( templateProposals[j].getDisplayString().startsWith(str)){ propList.add(templateProposals[j]); } } } public String extractPrefix(ITextViewer viewer, int offset) { String str =""; int i = offset - 1; if (i == -1){ return ""; } char c; try { c = viewer.getDocument().getChar(i); while (c != ' ' && c != '\n' && c != '\r') { str = c + str; i--; if(i < 0){ break; }else{ c = viewer.getDocument().getChar(i); } } } catch (BadLocationException e) { e.printStackTrace(); } return str; } } --- NEW FILE: PyCodeCompletion.java --- /* * Created on Aug 11, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.codecompletion; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; import org.python.pydev.plugin.PydevPlugin; /** * @author Dmoore * @author Fabio Zadrozny */ public class PyCodeCompletion { /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, * int) */ int docBoundary = -1; // the document prior to the activation token /** * @param theDoc: the whole document as a string. * @param documentOffset: the cursor position */ String partialDocument(String theDoc, int documentOffset) { if (this.docBoundary < 0) { calcDocBoundary(theDoc, documentOffset); } if(this.docBoundary != -1){ String before = theDoc.substring(0, this.docBoundary); return before; } return ""; } /** * Returns a list with the tokens to use for autocompletion. * * @param theCode * @param theActivationToken * @return */ public List autoComplete(java.lang.String theCode, java.lang.String theActivationToken) { List theList = new ArrayList(); String s = new String(); File tmp = null; try { // get the inspect.py file from the package: s = getAutoCompleteScript(); } catch (CoreException e) { e.printStackTrace(); } try { //We actually write a file with all of our code to a temporary location, //so that we can get its code completion from the typper.py script. // //TODO: there must be a faster strategy... // tmp = bufferContent(theCode); if (tmp == null) { System.out .println("DBG:bufferContent() null. No tip for you!!"); return theList; } String ss = new String("python " + s + " " + tmp.getAbsolutePath()); Process p = Runtime.getRuntime().exec(ss); BufferedReader in = new BufferedReader(new InputStreamReader(p .getInputStream())); String str; while ((str = in.readLine()) != null) { if (!str.startsWith("tip: ")){ continue; } str = str.substring(5); theList.add(str); } in.close(); InputStream eInput = p.getErrorStream(); BufferedReader eIn = new BufferedReader(new InputStreamReader( eInput)); while ((str = eIn.readLine()) != null) { //System.out.println("error output: " + str); } p.waitFor(); } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } return theList; } /** * We actually write a file with all of our code to a temporary location, * so that we can get its code completion from the typper.py script. * * @param theCode code to be written to file. */ private File bufferContent(java.lang.String theCode) { // try { // Create temp file. File temp = File.createTempFile("PyDev", ".tmp"); // Delete temp file when program exits. temp.deleteOnExit(); // Write to temp file BufferedWriter out = new BufferedWriter(new FileWriter(temp)); out.write(theCode); out.close(); return temp; } catch (IOException e) { return null; } } /** * * @return the script to get the variables. * * @throws CoreException */ public static String getAutoCompleteScript() throws CoreException { String targetExec = "tipper.py"; IPath relative = new Path("PySrc").addTrailingSeparator().append( targetExec); Bundle bundle = PydevPlugin.getDefault().getBundle(); URL bundleURL = Platform.find(bundle, relative); URL fileURL; try { fileURL = Platform.asLocalURL(bundleURL); String filePath = new File(fileURL.getPath()).getAbsolutePath(); return filePath; } catch (IOException e) { throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, "Can't find python debug script", null)); } } /** * The docBoundary should get until the last line before the one * we are editing. * * @param qualifier * @param documentOffset * @param proposals */ public void calcDocBoundary(String theDoc, int documentOffset) { this.docBoundary = theDoc.substring(0, documentOffset) .lastIndexOf('\n'); } /** * Returns the activation token. * * @param theDoc * @param documentOffset * @return */ public String getActivationToken(String theDoc, int documentOffset) { if (this.docBoundary < 0) { calcDocBoundary(theDoc, documentOffset); } return theDoc.substring(this.docBoundary + 1, documentOffset); } } --- NEW FILE: PythonCompletionProcessor.java --- /* * Created on Mar 29, 2004 * */ package org.python.pydev.editor.codecompletion; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; 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.eclipse.swt.graphics.Point; /** * @author Dmoore * @author Fabio Zadrozny * * This class is responsible for code completion / template completion. */ public class PythonCompletionProcessor implements IContentAssistProcessor { private PyTemplateCompletion templatesCompletion = new PyTemplateCompletion(); private PyCodeCompletion codeCompletion = new PyCodeCompletion(); private CompletionCache completionCache = new CompletionCache(); public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { List propList = new ArrayList(); 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 = ""; while(activationToken.endsWith(".") == false && activationToken.length() > 0){ qualifier = activationToken.charAt(activationToken.length()-1) + qualifier; activationToken = activationToken.substring(0, activationToken.length()-1); } theDoc = codeCompletion.partialDocument(theDoc, documentOffset); int qlen = qualifier.length(); theDoc += "\n" + activationToken; List allProposals = this.completionCache.getAllProposals(theDoc, activationToken, documentOffset, qlen, codeCompletion); //templates proposals are added here. this.templatesCompletion.addTemplateProposals(viewer, documentOffset, propList); for (Iterator iter = allProposals.iterator(); iter.hasNext();) { ICompletionProposal proposal = (ICompletionProposal) iter.next(); if(proposal.getDisplayString().startsWith(qualifier)){ propList.add(proposal); } } ICompletionProposal[] proposals = new ICompletionProposal[propList .size()]; // and fill with list elements propList.toArray(proposals); // Return the proposals return proposals; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, * int) */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { // TODO Auto-generated method stub return null; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() */ public char[] getCompletionProposalAutoActivationCharacters() { return new char[] { '.'/*, '(', '['*/ }; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() */ public char[] getContextInformationAutoActivationCharacters() { // is this _really_ what we want to use?? return new char[] { '.' }; } /* * (non-Javadoc) * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() */ public java.lang.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: CompletionCache.java --- /* * Created on Aug 11, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.codecompletion; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.jface.text.contentassist.CompletionProposal; /** * @author Fabio Zadrozny */ public class CompletionCache { private Map cache = new HashMap(); private List cacheEntries = new ArrayList(); public List getAllProposals(String theDoc, String activationToken, int documentOffset, int qlen, PyCodeCompletion codeCompletion) { List allProposals = null; if (cache.containsKey(theDoc)) { //if it is in the cache, we can just get the proposals, //the only thing here, is that we have to change its size depending //on the new qlen. allProposals = new ArrayList(); List proposals = (List) cache.get(theDoc); for (Iterator iter = proposals.iterator(); iter.hasNext();) { CompletionProposal prop = (CompletionProposal) iter.next(); String displayString = prop.getDisplayString(); allProposals.add(new CompletionProposal(displayString, documentOffset - qlen, qlen, displayString.length())); } } else { List theList = codeCompletion.autoComplete(theDoc, activationToken); allProposals = new ArrayList(); for (Iterator iter = theList.iterator(); iter.hasNext();) { String element = (String) iter.next(); CompletionProposal proposal = new CompletionProposal(element, documentOffset - qlen, qlen, element.length()); allProposals.add(proposal); } cacheEntries.add(theDoc); cache.put(theDoc, allProposals); //we don't want this the get huge... if (cacheEntries.size() > 20) { Object entry = cacheEntries.remove(0); cache.remove(entry); } } return allProposals; } } |
From: Fabio Z. <fa...@us...> - 2004-08-11 13:04:21
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21162/src/org/python/pydev/editor Modified Files: PyEditConfiguration.java Removed Files: PythonCompletionProcessor.java Log Message: Refactored code completion. Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PyEditConfiguration.java 9 Aug 2004 22:30:58 -0000 1.15 --- PyEditConfiguration.java 11 Aug 2004 13:04:13 -0000 1.16 *************** *** 43,46 **** --- 43,47 ---- import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; + import org.python.pydev.editor.codecompletion.PythonCompletionProcessor; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.PydevPrefs; --- PythonCompletionProcessor.java DELETED --- |
From: Fabio Z. <fa...@us...> - 2004-08-11 13:03:59
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21142/src/org/python/pydev/editor/codecompletion Log Message: Directory /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion added to the repository |
From: Fabio Z. <fa...@us...> - 2004-08-10 16:17:55
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7593/src/org/python/pydev/editor Modified Files: PythonCompletionProcessor.java Log Message: Removed sysouts. Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PythonCompletionProcessor.java 10 Aug 2004 16:16:56 -0000 1.16 --- PythonCompletionProcessor.java 10 Aug 2004 16:17:46 -0000 1.17 *************** *** 114,119 **** activationToken = activationToken.substring(0, activationToken.length()-1); } - System.out.println("qualifier = "+qualifier); - System.out.println("activationToken = "+activationToken); theDoc = partialDocument(theDoc, documentOffset); --- 114,117 ---- |
From: Fabio Z. <fa...@us...> - 2004-08-10 16:17:05
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7324/src/org/python/pydev/editor Modified Files: PythonCompletionProcessor.java Log Message: ooooooppps Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PythonCompletionProcessor.java 10 Aug 2004 16:04:18 -0000 1.15 --- PythonCompletionProcessor.java 10 Aug 2004 16:16:56 -0000 1.16 *************** *** 110,119 **** java.lang.String qualifier = ""; - while(activationToken.endsWith(".") == false && activationToken.length() > 0){ ! qualifier += activationToken.charAt(activationToken.length()-1); activationToken = activationToken.substring(0, activationToken.length()-1); } ! theDoc = partialDocument(theDoc, documentOffset); --- 110,119 ---- java.lang.String qualifier = ""; while(activationToken.endsWith(".") == false && activationToken.length() > 0){ ! qualifier = activationToken.charAt(activationToken.length()-1) + qualifier; activationToken = activationToken.substring(0, activationToken.length()-1); } ! System.out.println("qualifier = "+qualifier); ! System.out.println("activationToken = "+activationToken); theDoc = partialDocument(theDoc, documentOffset); |
From: Fabio Z. <fa...@us...> - 2004-08-10 16:10:47
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6118 Modified Files: plugin.xml Log Message: Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** plugin.xml 10 Aug 2004 12:24:50 -0000 1.29 --- plugin.xml 10 Aug 2004 16:10:38 -0000 1.30 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.8.2" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.8.5" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> |
From: Fabio Z. <fa...@us...> - 2004-08-10 16:04:38
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4917/src/org/python/pydev/editor Modified Files: PythonCompletionProcessor.java Log Message: Cached results from code completion and removed completion for ( and [. Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PythonCompletionProcessor.java 10 Aug 2004 14:09:38 -0000 1.14 --- PythonCompletionProcessor.java 10 Aug 2004 16:04:18 -0000 1.15 *************** *** 14,20 **** import java.net.URL; import java.util.ArrayList; ! import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Vector; --- 14,21 ---- import java.net.URL; import java.util.ArrayList; ! import java.util.HashMap; import java.util.Iterator; import java.util.List; + import java.util.Map; import java.util.Vector; *************** *** 50,53 **** --- 51,58 ---- public class PythonCompletionProcessor extends TemplateCompletionProcessor implements IContentAssistProcessor { + + private Map cache = new HashMap(); + private List cacheEntries = new ArrayList(); + /* * (non-Javadoc) *************** *** 95,126 **** List propList = new ArrayList(); IDocument doc = viewer.getDocument(); ! //System.out.println("The document:"+doc.get()); Point selectedRange = viewer.getSelectedRange(); // there may not be a selected range java.lang.String theDoc = doc.get(); calcDocBoundary(theDoc, documentOffset); String activationToken = this .getActivationToken(theDoc, documentOffset); ! //System.out.println("DBG:theActivationToken: " + activationToken); theDoc = partialDocument(theDoc, documentOffset); ! java.lang.String qualifier = getQualifier(doc, documentOffset); int qlen = qualifier.length(); theDoc += "\n" + activationToken; - //System.out.println("Interpreted doc: " + theDoc); - //System.out.println("activationToken: " + activationToken); - Vector theList = autoComplete(theDoc, activationToken); - //System.out.println("DBG:vector:" + theList); ! for (Iterator iter = theList.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); ! ! CompletionProposal proposal = new CompletionProposal(element, ! documentOffset - qlen, qlen, element.length()); ! propList.add(proposal); } //templates proposals are added here. addTemplateProposals(viewer, documentOffset, propList); ICompletionProposal[] proposals = new ICompletionProposal[propList .size()]; --- 100,163 ---- List propList = new ArrayList(); IDocument doc = viewer.getDocument(); ! Point selectedRange = viewer.getSelectedRange(); // there may not be a selected range java.lang.String theDoc = doc.get(); calcDocBoundary(theDoc, documentOffset); + String activationToken = this .getActivationToken(theDoc, documentOffset); ! ! java.lang.String qualifier = ""; ! ! while(activationToken.endsWith(".") == false && activationToken.length() > 0){ ! qualifier += activationToken.charAt(activationToken.length()-1); ! activationToken = activationToken.substring(0, activationToken.length()-1); ! } ! ! theDoc = partialDocument(theDoc, documentOffset); ! ! int qlen = qualifier.length(); theDoc += "\n" + activationToken; ! //simple cache mechanism. ! List allProposals; ! if(cache.containsKey(theDoc)){ ! allProposals = (List) cache.get(theDoc); ! } ! else{ ! Vector theList = autoComplete(theDoc, activationToken); ! ! allProposals = new ArrayList(); ! ! for (Iterator iter = theList.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); ! CompletionProposal proposal = new CompletionProposal(element, ! documentOffset - qlen, qlen, element.length()); ! allProposals.add(proposal); ! } ! cacheEntries.add(theDoc); ! cache.put(theDoc, allProposals); ! //we don't want this the get huge... ! if(cacheEntries.size() > 20){ ! Object entry = cacheEntries.remove(0); ! cache.remove(entry); ! } } + //end cache mechanism. + //templates proposals are added here. addTemplateProposals(viewer, documentOffset, propList); + for (Iterator iter = allProposals.iterator(); iter.hasNext();) { + ICompletionProposal proposal = (ICompletionProposal) iter.next(); + if(proposal.getDisplayString().startsWith(qualifier)){ + propList.add(proposal); + } + } + ICompletionProposal[] proposals = new ICompletionProposal[propList .size()]; *************** *** 311,323 **** } - /** - * @param doc - * @param documentOffset - */ - private java.lang.String getQualifier(IDocument doc, int documentOffset) { - // this routine should return any partial entry after the activation - // character - return ""; - } /* --- 348,351 ---- *************** *** 339,343 **** */ public char[] getCompletionProposalAutoActivationCharacters() { ! return new char[] { '.', '(', '[' }; } --- 367,371 ---- */ public char[] getCompletionProposalAutoActivationCharacters() { ! return new char[] { '.'/*, '(', '['*/ }; } |
From: Fabio Z. <fa...@us...> - 2004-08-10 14:09:48
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14588/src/org/python/pydev/editor Modified Files: PythonCompletionProcessor.java Log Message: Extracting prefix to get only the template completions that start with the string in the prefix. Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PythonCompletionProcessor.java 10 Aug 2004 12:45:16 -0000 1.13 --- PythonCompletionProcessor.java 10 Aug 2004 14:09:38 -0000 1.14 *************** *** 140,171 **** protected void addTemplateProposals(ITextViewer viewer, int documentOffset, List propList) { ! String str = ""; ! int i = documentOffset - 1; ! if (i <= 0) ! return; char c; try { c = viewer.getDocument().getChar(i); ! while (c != ' ' && c != '\n' && c != '\r' && i > 0) { str = c + str; i--; ! c = viewer.getDocument().getChar(i); ! } ! char [] chars = getCompletionProposalAutoActivationCharacters(); ! ! //we don't want templates on autocompletion proposals. ! for (int j = 0; j < chars.length; j++) { ! if(str.endsWith(chars[j]+"")) ! return; } - - ICompletionProposal[] templateProposals = super - .computeCompletionProposals(viewer, documentOffset); - propList.addAll(Arrays.asList(templateProposals)); - } catch (BadLocationException e) { e.printStackTrace(); } } --- 140,179 ---- protected void addTemplateProposals(ITextViewer viewer, int documentOffset, List propList) { ! String str = extractPrefix(viewer, documentOffset); ! ! ICompletionProposal[] templateProposals = super ! .computeCompletionProposals(viewer, documentOffset); ! ! for (int j = 0; j < templateProposals.length; j++) { ! if ( templateProposals[j].getDisplayString().startsWith(str)){ ! propList.add(templateProposals[j]); ! } ! } ! ! } + protected String extractPrefix(ITextViewer viewer, int offset) { + String str =""; + int i = offset - 1; + if (i == -1){ + return ""; + } + char c; try { c = viewer.getDocument().getChar(i); ! while (c != ' ' && c != '\n' && c != '\r') { str = c + str; i--; ! if(i < 0){ ! break; ! }else{ ! c = viewer.getDocument().getChar(i); ! } } } catch (BadLocationException e) { e.printStackTrace(); } + return str; } *************** *** 295,301 **** calcDocBoundary(theDoc, documentOffset); } ! ! String before = theDoc.substring(0, this.docBoundary); ! return before; } --- 303,311 ---- calcDocBoundary(theDoc, documentOffset); } ! if(this.docBoundary != -1){ ! String before = theDoc.substring(0, this.docBoundary); ! return before; ! } ! return ""; } |
From: Fabio Z. <fa...@us...> - 2004-08-10 12:45:28
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32350/src/org/python/pydev/editor Modified Files: PythonCompletionProcessor.java Log Message: Template proposals not active on auto activation chars. Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PythonCompletionProcessor.java 10 Aug 2004 11:39:11 -0000 1.12 --- PythonCompletionProcessor.java 10 Aug 2004 12:45:16 -0000 1.13 *************** *** 24,27 **** --- 24,28 ---- import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; + import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; *************** *** 47,52 **** * This class is responsible for code completion / template completion. */ ! public class PythonCompletionProcessor extends TemplateCompletionProcessor implements IContentAssistProcessor { ! /* (non-Javadoc) * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getTemplates(java.lang.String) */ --- 48,56 ---- * This class is responsible for code completion / template completion. */ ! public class PythonCompletionProcessor extends TemplateCompletionProcessor ! implements IContentAssistProcessor { ! /* ! * (non-Javadoc) ! * * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getTemplates(java.lang.String) */ *************** *** 55,67 **** } ! /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextType(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) */ ! protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { ! return PydevPlugin.getDefault().getContextTypeRegistry().getContextType(PyContextType.PY_CONTEXT_TYPE); } ! ! /* (non-Javadoc) * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getImage(org.eclipse.jface.text.templates.Template) */ --- 59,77 ---- } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextType(org.eclipse.jface.text.ITextViewer, ! * org.eclipse.jface.text.IRegion) */ ! protected TemplateContextType getContextType(ITextViewer viewer, ! IRegion region) { ! return PydevPlugin.getDefault().getContextTypeRegistry() ! .getContextType(PyContextType.PY_CONTEXT_TYPE); } ! /* ! * (non-Javadoc) ! * * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getImage(org.eclipse.jface.text.templates.Template) */ *************** *** 71,316 **** } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, ! * int) ! */ ! int docBoundary = -1; // the document prior to the activation token ! int docBoundary2 = 0; ! public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, ! int documentOffset) { ! List propList = new ArrayList(); ! IDocument doc = viewer.getDocument(); ! //System.out.println("The document:"+doc.get()); ! Point selectedRange = viewer.getSelectedRange(); ! // there may not be a selected range ! java.lang.String theDoc = doc.get(); ! calcDocBoundary(theDoc, documentOffset); ! String activationToken = this ! .getActivationToken(theDoc, documentOffset); ! //System.out.println("DBG:theActivationToken: " + activationToken); ! theDoc = partialDocument(theDoc, documentOffset); ! java.lang.String qualifier = getQualifier(doc, documentOffset); ! int qlen = qualifier.length(); ! theDoc += "\n"+activationToken; ! //System.out.println("Interpreted doc: " + theDoc); ! //System.out.println("activationToken: " + activationToken); ! Vector theList = autoComplete(theDoc, activationToken); ! //System.out.println("DBG:vector:" + theList); ! for (Iterator iter = theList.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); ! CompletionProposal proposal = new CompletionProposal(element, ! documentOffset - qlen, qlen, element.length()); ! propList.add(proposal); ! } ! ! //templates proposals are added here. ! ICompletionProposal[] templateProposals = super.computeCompletionProposals(viewer, documentOffset); ! propList.addAll(Arrays.asList(templateProposals)); ! ! ! ICompletionProposal[] proposals = new ICompletionProposal[propList ! .size()]; ! // and fill with list elements ! propList.toArray(proposals); ! // Return the proposals ! return proposals; ! } ! private Vector autoComplete(java.lang.String theCode, ! java.lang.String theActivationToken) { ! Vector theList = new Vector(); ! String s = new String(); ! File tmp = null; ! //System.out.println("DBG:autoComplete"); ! try { ! // get the inspect.py file from the package: ! s = getAutoCompleteScript(); ! //System.out.println("DBG:getAutoCompleteScript() returns" + s); ! } catch (CoreException e) { ! //System.out.println("DBG:getAutoCompleteScript() fails " + e); ! e.printStackTrace(); ! } ! // ! try { ! tmp = bufferContent(theCode); ! if (tmp == null) { ! System.out ! .println("DBG:bufferContent() null. No tip for you!!"); ! return theList; ! } ! String ss = new String("python " + s + " " ! + tmp.getAbsolutePath()); ! //System.out.println("DBG:exec string " + ss); ! Process p = Runtime.getRuntime().exec(ss); ! BufferedReader in = new BufferedReader(new InputStreamReader(p ! .getInputStream())); ! String str; ! while ((str = in.readLine()) != null) { ! if(!str.startsWith("tip: ")) continue; ! str = str.substring(5); ! //System.out.println("DBG:autoComplete:output: " + str); ! theList.add(str); ! } ! in.close(); ! InputStream eInput = p.getErrorStream(); ! BufferedReader eIn = new BufferedReader(new InputStreamReader( ! eInput)); ! while ((str = eIn.readLine()) != null) { ! //System.out.println("error output: " + str); ! } ! p.waitFor(); ! } catch (IOException e) { ! // TODO Auto-generated catch block ! e.printStackTrace(); ! } catch (InterruptedException e) { ! // TODO Auto-generated catch block ! //System.out.println("Interrupted call: error output: "); ! e.printStackTrace(); ! } ! return theList; ! } ! /** ! * @param theCode ! */ ! private File bufferContent(java.lang.String theCode) { ! // ! try { ! // Create temp file. ! File temp = File.createTempFile("PyDev", ".tmp"); ! // Delete temp file when program exits. ! temp.deleteOnExit(); ! // Write to temp file ! BufferedWriter out = new BufferedWriter(new FileWriter(temp)); ! out.write(theCode); ! out.close(); ! return temp; ! } catch (IOException e) { ! return null; ! } ! } ! public static String getAutoCompleteScript() throws CoreException { ! String targetExec = "tipper.py"; ! //System.out.println("DBG:getAutoCompleteScript();"); ! IPath relative = new Path("PySrc").addTrailingSeparator().append( ! targetExec); ! //System.out.println("DBG:getAutoCompleteScript(); relative " + relative); ! Bundle bundle = PydevPlugin.getDefault().getBundle(); ! //System.out.println("DBG:getAutoCompleteScript(); bundle " + bundle); ! URL bundleURL = Platform.find(bundle, relative); ! URL fileURL; ! try { ! fileURL = Platform.asLocalURL(bundleURL); ! String filePath = new File(fileURL.getPath()).getAbsolutePath(); ! //System.out.println("DBG:getAutoCompleteScript();filePath " + filePath); ! return filePath; ! } catch (IOException e) { ! throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, ! "Can't find python debug script", null)); ! } ! } ! /** ! * @param qualifier ! * @param documentOffset ! * @param proposals ! */ ! public void calcDocBoundary(String theDoc, int documentOffset) { ! this.docBoundary = theDoc.substring(0, documentOffset) ! .lastIndexOf('\n'); ! } ! public String getActivationToken(String theDoc, int documentOffset) { ! if (this.docBoundary < 0) { ! calcDocBoundary(theDoc, documentOffset); ! } ! return theDoc.substring(this.docBoundary + 1, documentOffset); ! } ! /** ! * @param theDoc ! */ ! private String partialDocument(String theDoc, int documentOffset) { ! if (this.docBoundary < 0) { ! calcDocBoundary(theDoc, documentOffset); ! } ! String before = theDoc.substring(0, this.docBoundary); ! return before; ! } ! /** ! * @param doc ! * @param documentOffset ! */ ! private java.lang.String getQualifier(IDocument doc, int documentOffset) { ! // this routine should return any partial entry after the activation ! // character ! return ""; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, ! * int) ! */ ! public IContextInformation[] computeContextInformation(ITextViewer viewer, ! int documentOffset) { ! // TODO Auto-generated method stub ! return null; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() ! */ ! public char[] getCompletionProposalAutoActivationCharacters() { ! return new char[] { '.', '(', '[' }; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() ! */ ! public char[] getContextInformationAutoActivationCharacters() { ! // is this _really_ what we want to use?? ! return new char[] { '.' }; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() ! */ ! public java.lang.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; ! } } \ No newline at end of file --- 81,364 ---- } ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, ! * int) ! */ ! int docBoundary = -1; // the document prior to the activation token ! int docBoundary2 = 0; ! public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, ! int documentOffset) { ! List propList = new ArrayList(); ! IDocument doc = viewer.getDocument(); ! //System.out.println("The document:"+doc.get()); ! Point selectedRange = viewer.getSelectedRange(); ! // there may not be a selected range ! java.lang.String theDoc = doc.get(); ! calcDocBoundary(theDoc, documentOffset); ! String activationToken = this ! .getActivationToken(theDoc, documentOffset); ! //System.out.println("DBG:theActivationToken: " + activationToken); ! theDoc = partialDocument(theDoc, documentOffset); ! java.lang.String qualifier = getQualifier(doc, documentOffset); ! int qlen = qualifier.length(); ! theDoc += "\n" + activationToken; ! //System.out.println("Interpreted doc: " + theDoc); ! //System.out.println("activationToken: " + activationToken); ! Vector theList = autoComplete(theDoc, activationToken); ! //System.out.println("DBG:vector:" + theList); ! for (Iterator iter = theList.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); ! CompletionProposal proposal = new CompletionProposal(element, ! documentOffset - qlen, qlen, element.length()); ! propList.add(proposal); ! } ! //templates proposals are added here. ! addTemplateProposals(viewer, documentOffset, propList); ! ICompletionProposal[] proposals = new ICompletionProposal[propList ! .size()]; ! // and fill with list elements ! propList.toArray(proposals); ! // Return the proposals ! return proposals; ! } ! /** ! * @param viewer ! * @param documentOffset ! * @param propList ! * ! */ ! protected void addTemplateProposals(ITextViewer viewer, int documentOffset, ! List propList) { ! String str = ""; ! int i = documentOffset - 1; ! if (i <= 0) ! return; ! char c; ! try { ! c = viewer.getDocument().getChar(i); ! while (c != ' ' && c != '\n' && c != '\r' && i > 0) { ! str = c + str; ! i--; ! c = viewer.getDocument().getChar(i); ! } ! char [] chars = getCompletionProposalAutoActivationCharacters(); ! ! //we don't want templates on autocompletion proposals. ! for (int j = 0; j < chars.length; j++) { ! if(str.endsWith(chars[j]+"")) ! return; ! } ! ! ICompletionProposal[] templateProposals = super ! .computeCompletionProposals(viewer, documentOffset); ! propList.addAll(Arrays.asList(templateProposals)); ! } catch (BadLocationException e) { ! e.printStackTrace(); ! } ! } ! private Vector autoComplete(java.lang.String theCode, ! java.lang.String theActivationToken) { ! Vector theList = new Vector(); ! String s = new String(); ! File tmp = null; ! //System.out.println("DBG:autoComplete"); ! try { ! // get the inspect.py file from the package: ! s = getAutoCompleteScript(); ! //System.out.println("DBG:getAutoCompleteScript() returns" + s); ! } catch (CoreException e) { ! //System.out.println("DBG:getAutoCompleteScript() fails " + e); ! e.printStackTrace(); ! } ! // ! try { ! tmp = bufferContent(theCode); ! if (tmp == null) { ! System.out ! .println("DBG:bufferContent() null. No tip for you!!"); ! return theList; ! } ! String ss = new String("python " + s + " " + tmp.getAbsolutePath()); ! //System.out.println("DBG:exec string " + ss); ! Process p = Runtime.getRuntime().exec(ss); ! BufferedReader in = new BufferedReader(new InputStreamReader(p ! .getInputStream())); ! String str; ! while ((str = in.readLine()) != null) { ! if (!str.startsWith("tip: ")) ! continue; ! str = str.substring(5); ! //System.out.println("DBG:autoComplete:output: " + str); ! theList.add(str); ! } ! in.close(); ! InputStream eInput = p.getErrorStream(); ! BufferedReader eIn = new BufferedReader(new InputStreamReader( ! eInput)); ! while ((str = eIn.readLine()) != null) { ! //System.out.println("error output: " + str); ! } ! p.waitFor(); ! } catch (IOException e) { ! // TODO Auto-generated catch block ! e.printStackTrace(); ! } catch (InterruptedException e) { ! // TODO Auto-generated catch block ! //System.out.println("Interrupted call: error output: "); ! e.printStackTrace(); ! } ! return theList; ! } ! /** ! * @param theCode ! */ ! private File bufferContent(java.lang.String theCode) { ! // ! try { ! // Create temp file. ! File temp = File.createTempFile("PyDev", ".tmp"); ! // Delete temp file when program exits. ! temp.deleteOnExit(); ! // Write to temp file ! BufferedWriter out = new BufferedWriter(new FileWriter(temp)); ! out.write(theCode); ! out.close(); ! return temp; ! } catch (IOException e) { ! return null; ! } ! } ! public static String getAutoCompleteScript() throws CoreException { ! String targetExec = "tipper.py"; ! //System.out.println("DBG:getAutoCompleteScript();"); ! IPath relative = new Path("PySrc").addTrailingSeparator().append( ! targetExec); ! //System.out.println("DBG:getAutoCompleteScript(); relative " + ! // relative); ! Bundle bundle = PydevPlugin.getDefault().getBundle(); ! //System.out.println("DBG:getAutoCompleteScript(); bundle " + bundle); ! URL bundleURL = Platform.find(bundle, relative); ! URL fileURL; ! try { ! fileURL = Platform.asLocalURL(bundleURL); ! String filePath = new File(fileURL.getPath()).getAbsolutePath(); ! //System.out.println("DBG:getAutoCompleteScript();filePath " + ! // filePath); ! return filePath; ! } catch (IOException e) { ! throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, ! "Can't find python debug script", null)); ! } ! } ! /** ! * @param qualifier ! * @param documentOffset ! * @param proposals ! */ ! public void calcDocBoundary(String theDoc, int documentOffset) { ! this.docBoundary = theDoc.substring(0, documentOffset) ! .lastIndexOf('\n'); ! } ! public String getActivationToken(String theDoc, int documentOffset) { ! if (this.docBoundary < 0) { ! calcDocBoundary(theDoc, documentOffset); ! } ! return theDoc.substring(this.docBoundary + 1, documentOffset); ! } ! /** ! * @param theDoc ! */ ! private String partialDocument(String theDoc, int documentOffset) { ! if (this.docBoundary < 0) { ! calcDocBoundary(theDoc, documentOffset); ! } ! String before = theDoc.substring(0, this.docBoundary); ! return before; ! } ! /** ! * @param doc ! * @param documentOffset ! */ ! private java.lang.String getQualifier(IDocument doc, int documentOffset) { ! // this routine should return any partial entry after the activation ! // character ! return ""; ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, ! * int) ! */ ! public IContextInformation[] computeContextInformation(ITextViewer viewer, ! int documentOffset) { ! // TODO Auto-generated method stub ! return null; ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() ! */ ! public char[] getCompletionProposalAutoActivationCharacters() { ! return new char[] { '.', '(', '[' }; ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() ! */ ! public char[] getContextInformationAutoActivationCharacters() { ! // is this _really_ what we want to use?? ! return new char[] { '.' }; ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() ! */ ! public java.lang.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; ! } } \ No newline at end of file |
From: Fabio Z. <fa...@us...> - 2004-08-10 12:25:00
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29608 Modified Files: build.properties plugin.xml Log Message: Added the pySrc folder to the build. Index: build.properties =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/build.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** build.properties 17 May 2004 23:29:35 -0000 1.2 --- build.properties 10 Aug 2004 12:24:50 -0000 1.3 *************** *** 4,5 **** --- 4,10 ---- pydev.jar,\ icons/ + bin.includes = plugin.xml,\ + pydev.jar,\ + icons/,\ + PySrc/ + src.includes = PySrc/ Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** plugin.xml 10 Aug 2004 11:45:53 -0000 1.28 --- plugin.xml 10 Aug 2004 12:24:50 -0000 1.29 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.8" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.8.2" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> |
From: Fabio Z. <fa...@us...> - 2004-08-10 11:46:04
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23473 Modified Files: plugin.xml Log Message: Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** plugin.xml 10 Aug 2004 00:21:29 -0000 1.27 --- plugin.xml 10 Aug 2004 11:45:53 -0000 1.28 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.7.2" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.8" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> *************** *** 559,562 **** --- 559,570 ---- id="org.python.pydev.editor.templates.python"/> <template + name="main" + icon="icons/template.gif" + description="main" + contextTypeId="org.python.pydev.editor.templates.python" + id="org.python.pydev.editor.templates.python.pdb"> + <pattern>if __name __ == 'main':</pattern> + </template> + <template name="pd" icon="icons/template.gif" *************** *** 564,568 **** contextTypeId="org.python.pydev.editor.templates.python" id="org.python.pydev.editor.templates.python.pdb"> ! <pattern>import pdb;pdb.set_trace</pattern> </template> <template --- 572,576 ---- contextTypeId="org.python.pydev.editor.templates.python" id="org.python.pydev.editor.templates.python.pdb"> ! <pattern>import pdb;pdb.set_trace()</pattern> </template> <template *************** *** 584,588 **** </pattern> </template> ! </extension> --- 592,596 ---- </pattern> </template> ! </extension> |