pydev-cvs Mailing List for PyDev for Eclipse (Page 316)
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-04-22 10:35:33
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14105/src/org/python/pydev/ui Modified Files: InterpreterEditor.java Log Message: Lots of minor changes: double-clicking, more hyperlink navigation, making editor more useable. Moved some files here from debug, and pruned some obsolete ones. Index: InterpreterEditor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/InterpreterEditor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** InterpreterEditor.java 15 Apr 2004 23:19:22 -0000 1.1 --- InterpreterEditor.java 22 Apr 2004 10:35:23 -0000 1.2 *************** *** 137,147 **** return executable.toLowerCase().indexOf("jython") != -1; } ! /** * returns true if interpreter was launched successfully */ public static boolean validateInterpreterPath(String executable) { boolean retVal = true; - try { String versionOption = " -V"; --- 137,152 ---- return executable.toLowerCase().indexOf("jython") != -1; } ! /** * returns true if interpreter was launched successfully */ + static String cachedExecutable = null; + static boolean cachedExecutableValid = false; public static boolean validateInterpreterPath(String executable) { + // we cache the last query because this gets called a lot + // i do not want to launch + if (cachedExecutable != null && cachedExecutable.equals(executable)) + return cachedExecutableValid; boolean retVal = true; try { String versionOption = " -V"; *************** *** 166,169 **** --- 171,176 ---- retVal = false; } + cachedExecutable = executable; + cachedExecutableValid = retVal; return retVal; } |
From: Aleksandar T. <at...@us...> - 2004-04-22 10:34:40
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13928 Modified Files: plugin.xml Log Message: Lots of minor changes: double-clicking, more hyperlink navigation, making editor more useable. Moved some files here from debug, and pruned some obsolete ones. Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** plugin.xml 15 Apr 2004 23:19:21 -0000 1.11 --- plugin.xml 22 Apr 2004 10:34:32 -0000 1.12 *************** *** 3,7 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.3.0" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 3,7 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.4.0" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> |
From: Fabio Z. <fa...@us...> - 2004-04-20 14:42:14
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10367/src/org/python/pydev/editor/actions Modified Files: PyAddBlockComment.java Log Message: Comment block now goes to right position. Index: PyAddBlockComment.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAddBlockComment.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyAddBlockComment.java 10 Apr 2004 01:48:14 -0000 1.3 --- PyAddBlockComment.java 20 Apr 2004 14:42:05 -0000 1.4 *************** *** 21,25 **** /** - * Hi. * Insert a comment block. * #===... --- 21,24 ---- *************** *** 40,65 **** .getSelection(); IRegion startLine = null; int startLineIndex = selection.getStartLine(); ! String endLineDelim = getDelimiter(doc, startLineIndex); startLine = doc.getLineInformation(startLineIndex); IRegion line = doc.getLineInformation(startLineIndex); int pos = line.getOffset(); StringBuffer strBuf = new StringBuffer(); strBuf.append(endLineDelim); ! strBuf.append( ! "#==============================================================================="); strBuf.append(endLineDelim); strBuf.append("# "); strBuf.append(endLineDelim); ! strBuf.append( ! "#==============================================================================="); ! strBuf.append(endLineDelim); strBuf.append(endLineDelim); ! ! doc.replace(pos, 0, strBuf.toString()); } catch (Exception e) { --- 39,77 ---- .getSelection(); + //strange things happen when we try to get the line information on the last line of the + //document (it doesn't return the end line delimiter correctly), so we always get on position + //0 and check to see if we are not in the last line. + if (doc.getNumberOfLines() <= 1) + return; + IRegion startLine = null; int startLineIndex = selection.getStartLine(); ! String endLineDelim = getDelimiter(doc, 0); startLine = doc.getLineInformation(startLineIndex); IRegion line = doc.getLineInformation(startLineIndex); + int lineLenght = line.getLength(); int pos = line.getOffset(); + + String content = doc.get(pos, lineLenght); + String comment = getFullCommentLine(); + StringBuffer strBuf = new StringBuffer(); + strBuf.append(endLineDelim); ! strBuf.append(comment); //#=========... strBuf.append(endLineDelim); + strBuf.append("# "); + strBuf.append(content); + strBuf.append(endLineDelim); ! strBuf.append(comment); //#=========... strBuf.append(endLineDelim); ! ! doc.replace(pos, lineLenght, strBuf.toString()); ! textEditor.selectAndReveal(pos+strBuf.length()-comment.length()-4,0); } catch (Exception e) { *************** *** 67,69 **** --- 79,85 ---- } } + + private String getFullCommentLine(){ + return "#==============================================================================="; + } } |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:24:59
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17142/src/org/python/pydev/debug/ui/launching Modified Files: PythonRunner.java PythonRunnerConfig.java LaunchShortcut.java PythonLaunchConfigurationDelegate.java Removed Files: PythonDebugTabGroup.java PythonTab.java Log Message: Removed the duplicate Tab definitions Index: PythonRunner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonRunner.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonRunner.java 29 Mar 2004 17:07:25 -0000 1.1 --- PythonRunner.java 15 Apr 2004 23:24:49 -0000 1.2 *************** *** 72,83 **** } ! /** ! * launches the debug configuration ! * @param config ! * @param launch ! * @param monitor ! * @throws CoreException ! */ ! public void run(PythonRunnerConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException, IOException { if (monitor == null) monitor = new NullProgressMonitor(); --- 72,76 ---- } ! public void runDebug(PythonRunnerConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException, IOException { if (monitor == null) monitor = new NullProgressMonitor(); *************** *** 97,111 **** Process p = DebugPlugin.exec(cmdLine, config.workingDirectory); if (p == null) - // TODO this might not be an error throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Could not execute python process. Was it cancelled?", null)); // Register the process with the debug plugin subMonitor.worked(2); subMonitor.subTask("Starting debugger..."); - HashMap processAttributes = new HashMap(); - processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); - processAttributes.put(IProcess.ATTR_CMDLINE, config.getCommandLineAsString()); - IProcess process = DebugPlugin.newProcess(launch,p, config.file.lastSegment(), processAttributes); - // Launch the debug listener on a thread, and wait until it completes while (connectThread.isAlive()) { --- 90,100 ---- Process p = DebugPlugin.exec(cmdLine, config.workingDirectory); if (p == null) throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Could not execute python process. Was it cancelled?", null)); + + IProcess process = registerWithDebugPlugin(config, launch, p); // Register the process with the debug plugin subMonitor.worked(2); subMonitor.subTask("Starting debugger..."); // Launch the debug listener on a thread, and wait until it completes while (connectThread.isAlive()) { *************** *** 149,152 **** --- 138,184 ---- dt.start(); } + + /** + * launches the debug configuration + * @param config + * @param launch + * @param monitor + * @throws CoreException + */ + public void run(PythonRunnerConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException, IOException { + if (config.isDebug) { + runDebug(config, launch, monitor); + return; + } + if (monitor == null) + monitor = new NullProgressMonitor(); + IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 5); + subMonitor.beginTask("Launching python", 1); + + // Launch & connect to the debugger + subMonitor.subTask("Constructing command_line..."); + String[] cmdLine = config.getCommandLine(); + subMonitor.worked(1); + + subMonitor.subTask("Exec..."); + Process p = DebugPlugin.exec(cmdLine, config.workingDirectory); + if (p == null) + throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Could not execute python process. Was it cancelled?", null)); + + // Register the process with the debug plugin + subMonitor.worked(2); + subMonitor.subTask("Done"); + registerWithDebugPlugin(config, launch, p); + } + + /** + * TODO document + */ + private IProcess registerWithDebugPlugin(PythonRunnerConfig config, ILaunch launch, Process p) { + HashMap processAttributes = new HashMap(); + processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); + processAttributes.put(IProcess.ATTR_CMDLINE, config.getCommandLineAsString()); + return DebugPlugin.newProcess(launch,p, config.file.lastSegment(), processAttributes); + } protected void checkErrorMessage(IProcess process) throws CoreException { Index: PythonLaunchConfigurationDelegate.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonLaunchConfigurationDelegate.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PythonLaunchConfigurationDelegate.java 29 Mar 2004 17:07:25 -0000 1.4 --- PythonLaunchConfigurationDelegate.java 15 Apr 2004 23:24:49 -0000 1.5 *************** *** 29,33 **** * <p>I would have subclassed, but ProgramLaunchDelegate hides important internals * ! * @see org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate */ public class PythonLaunchConfigurationDelegate implements ILaunchConfigurationDelegate --- 29,33 ---- * <p>I would have subclassed, but ProgramLaunchDelegate hides important internals * ! * Based on org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate */ public class PythonLaunchConfigurationDelegate implements ILaunchConfigurationDelegate --- PythonDebugTabGroup.java DELETED --- --- PythonTab.java DELETED --- Index: LaunchShortcut.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/LaunchShortcut.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LaunchShortcut.java 29 Mar 2004 17:07:25 -0000 1.3 --- LaunchShortcut.java 15 Apr 2004 23:24:49 -0000 1.4 *************** *** 32,35 **** --- 32,36 ---- import org.eclipse.ui.dialogs.ElementListSelectionDialog; import org.python.pydev.debug.core.*; + import org.python.pydev.plugin.PydevPrefs; /** *************** *** 39,43 **** * <p>Launches the "Run python..." window * <p>code almost all copied from AntLaunchShortcut: ! * @see org.eclipse.ui.externaltools.internal.ant.launchConfigurations.AntLaunchShortcut */ public class LaunchShortcut implements ILaunchShortcut { --- 40,44 ---- * <p>Launches the "Run python..." window * <p>code almost all copied from AntLaunchShortcut: ! * Based on org.eclipse.ui.externaltools.internal.ant.launchConfigurations.AntLaunchShortcut */ public class LaunchShortcut implements ILaunchShortcut { *************** *** 154,158 **** String baseDirectory = file.getRawLocation().removeLastSegments(1).toString(); String arguments = ""; ! String interpreter = PydevDebugPlugin.getDefault().getInterpreters()[0]; workingCopy.setAttribute(Constants.ATTR_LOCATION,location); workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY,baseDirectory); --- 155,159 ---- String baseDirectory = file.getRawLocation().removeLastSegments(1).toString(); String arguments = ""; ! String interpreter = PydevPrefs.getInterpreters()[0]; workingCopy.setAttribute(Constants.ATTR_LOCATION,location); workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY,baseDirectory); Index: PythonRunnerConfig.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonRunnerConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonRunnerConfig.java 29 Mar 2004 17:07:25 -0000 1.1 --- PythonRunnerConfig.java 15 Apr 2004 23:24:49 -0000 1.2 *************** *** 21,25 **** import org.python.pydev.debug.core.Constants; import org.python.pydev.debug.core.PydevDebugPlugin; - import org.python.pydev.debug.ui.InterpreterEditor; /** --- 21,24 ---- *************** *** 108,112 **** cmdArgs.add(interpreter); // Next option is for unbuffered stdout, otherwise Eclipse will not see any output until done ! cmdArgs.add(InterpreterEditor.isJython(interpreter) ? "-i" : "-u"); if (isDebug) { // rpdb cmdArgs.add(debugScript); --- 107,111 ---- cmdArgs.add(interpreter); // Next option is for unbuffered stdout, otherwise Eclipse will not see any output until done ! cmdArgs.add(org.python.pydev.ui.InterpreterEditor.isJython(interpreter) ? "-i" : "-u"); if (isDebug) { // rpdb cmdArgs.add(debugScript); |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:24:59
|
Update of /cvsroot/pydev/org.python.pydev.debug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17142 Modified Files: .project plugin.xml Added Files: Changes.txt Log Message: Removed the duplicate Tab definitions Index: .project =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/.project,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .project 10 Jan 2004 03:13:04 -0000 1.2 --- .project 15 Apr 2004 23:24:50 -0000 1.3 *************** *** 4,7 **** --- 4,11 ---- <comment></comment> <projects> + <project>org.apache.xerces</project> + <project>org.eclipse.core.boot</project> + <project>org.eclipse.core.resources</project> + <project>org.eclipse.core.runtime</project> <project>org.python.pydev</project> </projects> --- NEW FILE: Changes.txt --- ChangeLog org.python.pydev.debug Extension points: org.eclipse.debug.ui.debugModelPresentations allows tools to handle presentation aspects of a debug model org.eclipse.cdt.debug.internal.ui.CDTDebugModelPresentation is a big class implementing this org.eclipse.cdt.launch.internal.LocalCLaunchConfigurationDelegate launches a debugged C program Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/plugin.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** plugin.xml 30 Mar 2004 20:02:58 -0000 1.5 --- plugin.xml 15 Apr 2004 23:24:50 -0000 1.6 *************** *** 32,39 **** name="Python" delegate="org.python.pydev.debug.ui.launching.PythonLaunchConfigurationDelegate" ! category="org.python.pydev.debug" ! modes="run, debug" id="org.python.pydev.debug.launchConfigurationType"> </launchConfigurationType> </extension> <!--- the launcher icon --> --- 32,39 ---- name="Python" delegate="org.python.pydev.debug.ui.launching.PythonLaunchConfigurationDelegate" ! modes="run, debug" id="org.python.pydev.debug.launchConfigurationType"> </launchConfigurationType> + <!--- set category="org.python.pydev.debug" to disable display in debug window--> </extension> <!--- the launcher icon --> *************** *** 103,116 **** </objectContribution> </extension> - <!-- preference page --> - <extension - point="org.eclipse.ui.preferencePages"> - <page - name="Debug" - category="org.python.pydev.prefs" - class="org.python.pydev.debug.ui.DebugPrefsPage" - id="org.python.pydev.prefs.debugPage"> - </page> - </extension> <!--- launch groups for python --> <extension --- 103,106 ---- *************** *** 166,217 **** </attribute> </extension> - - <!-- Begin Run->Run... extensions --> - <extension - point="org.eclipse.debug.core.launchConfigurationTypes"> - <launchConfigurationType - name="Python" - delegate="org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate" - modes="run" - id="org.python.pydev.debug.ui.launching.launchConfigurationType1"> - <fileExtension - extension="py"> - </fileExtension> - <fileExtension - extension="pyc"> - </fileExtension> - </launchConfigurationType> - </extension> - <extension - point="org.eclipse.debug.ui.launchConfigurationTabGroups"> - <launchConfigurationTabGroup - type="org.python.pydev.debug.ui.launching.launchConfigurationType1" - helpContextId="foo" - class="org.python.pydev.debug.ui.launching.PythonDebugTabGroup" - id="org.python.pydev.debug.ui.launching.PythonDebugTabGroup"> - </launchConfigurationTabGroup> - </extension> - <extension - id="org.python.debug.ui.image" - point="org.eclipse.debug.ui.launchConfigurationTypeImages"> - <launchConfigurationTypeImage - icon="icons/python.gif" - configTypeID="org.python.pydev.debug.ui.launching.launchConfigurationType1" - id="org.python.pydev.debug.ui.launching.launchConfigurationTypeImage1"> - </launchConfigurationTypeImage> - </extension> - <extension - id="org.python.debug.ui.lineTracker" - point="org.eclipse.debug.ui.consoleLineTrackers"> - <consoleLineTracker - class="org.python.pydev.debug.ui.PythonConsoleLineTracker" - processType="python" - id="org.python.pydev.debug.ui.PythonConsoleLineTracker"> - </consoleLineTracker> - </extension> - <!-- End Run->Run... extensions --> - - - - </plugin> --- 156,158 ---- |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:24:59
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17142/src/org/python/pydev/debug/core Modified Files: PydevDebugPlugin.java Constants.java Log Message: Removed the duplicate Tab definitions Index: PydevDebugPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core/PydevDebugPlugin.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PydevDebugPlugin.java 29 Mar 2004 17:07:25 -0000 1.1 --- PydevDebugPlugin.java 15 Apr 2004 23:24:50 -0000 1.2 *************** *** 5,10 **** import org.eclipse.core.runtime.*; import org.eclipse.core.resources.*; - import org.python.pydev.debug.ui.InterpreterEditor; - /** * The main plugin for Python Debugger. --- 5,8 ---- *************** *** 40,48 **** } - public String[] getInterpreters() { - String interpreters = getPreferenceStore().getString(Constants.PREF_INTERPRETER_PATH); - return InterpreterEditor.getInterpreterList(interpreters); - } - /** * @param errorLevel IStatus.[OK|INFO|WARNING|ERROR] --- 38,41 ---- Index: Constants.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core/Constants.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Constants.java 8 Jan 2004 22:47:21 -0000 1.1 --- Constants.java 15 Apr 2004 23:24:50 -0000 1.2 *************** *** 28,33 **** static final String ATTR_INTERPRETER = PLUGIN_ID + ".ATTR_INTERPRETER"; - // Preferences - public static final String PREF_INTERPRETER_PATH = "INTERPRETER_PATH"; } --- 28,31 ---- |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:24:59
|
Update of /cvsroot/pydev/org.python.pydev.debug/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17142/docs Modified Files: notes.txt Log Message: Removed the duplicate Tab definitions Index: notes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/docs/notes.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** notes.txt 8 Jan 2004 22:47:20 -0000 1.1 --- notes.txt 15 Apr 2004 23:24:50 -0000 1.2 *************** *** 5,6 **** --- 5,10 ---- http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/JavaAppletLaunchConfigurationDelegate.java?rev=HEAD&content-type=text/vnd.viewcvs-markup + org.eclipse.cdt.debug.core.CDebugModel + * Provides utility methods for creating debug sessions, targets and + * breakpoints specific to the CDI debug model. + \ No newline at end of file |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:24:58
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17142/src/org/python/pydev/debug/ui Modified Files: PythonMainTab.java PythonConsoleLineTracker.java Removed Files: DebugPrefsPage.java InterpreterEditor.java StreamConsumer.java Log Message: Removed the duplicate Tab definitions --- StreamConsumer.java DELETED --- Index: PythonConsoleLineTracker.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/PythonConsoleLineTracker.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PythonConsoleLineTracker.java 29 Mar 2004 17:07:25 -0000 1.2 --- PythonConsoleLineTracker.java 15 Apr 2004 23:24:49 -0000 1.3 *************** *** 38,42 **** * Hyperlink error lines to the editor. * ! * @see org.eclipse.debug.ui.console.IConsoleLineTracker#lineAppended(org.eclipse.jface.text.IRegion) */ public void lineAppended(IRegion line) { --- 38,42 ---- * Hyperlink error lines to the editor. * ! * Based on org.eclipse.debug.ui.console.IConsoleLineTracker#lineAppended(org.eclipse.jface.text.IRegion) */ public void lineAppended(IRegion line) { --- DebugPrefsPage.java DELETED --- Index: PythonMainTab.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/PythonMainTab.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PythonMainTab.java 29 Mar 2004 17:07:25 -0000 1.4 --- PythonMainTab.java 15 Apr 2004 23:24:49 -0000 1.5 *************** *** 23,26 **** --- 23,28 ---- import org.eclipse.swt.widgets.*; import org.python.pydev.debug.core.*; + import org.python.pydev.plugin.PydevPrefs; + import org.python.pydev.ui.InterpreterEditor; /** *************** *** 106,110 **** interpreterField = new Combo (comp, SWT.DROP_DOWN); ! interpreterField.setItems (PydevDebugPlugin.getDefault().getInterpreters()); interpreterField.select(0); data = new GridData (); --- 108,112 ---- interpreterField = new Combo (comp, SWT.DROP_DOWN); ! interpreterField.setItems (PydevPrefs.getInterpreters()); interpreterField.select(0); data = new GridData (); --- InterpreterEditor.java DELETED --- |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:19:32
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16009/src/org/python/pydev/editor/model Modified Files: AbstractNode.java NameEqualsMainNode.java LocalNode.java ModelUtils.java ModuleNode.java ImportNode.java FunctionCallNode.java ClassNode.java FunctionNode.java Scope.java ModelMaker.java LengthEstimator.java ImportFromNode.java ImportAlias.java Added Files: ItemPointer.java AttributeNode.java Log Message: More model code. Hyperlinks on function calls and imports now work. had to pull interpreter editor from PydevDebug plugin into this one since we needed interpreter locaiton for include paths. Model got extensive changes. Scopes are now used in the code. General code cleanup everywehre. Added findFunctionDefinition functionality with hyperlinks Added the ability to open external files (for external hyperlinks) Index: ModelMaker.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ModelMaker.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ModelMaker.java 10 Apr 2004 01:48:13 -0000 1.1 --- ModelMaker.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 6,10 **** --- 6,14 ---- package org.python.pydev.editor.model; + import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IStatus; + import org.eclipse.jface.text.BadLocationException; + import org.eclipse.jface.text.IDocument; + import org.eclipse.jface.text.IRegion; import org.python.parser.SimpleNode; import org.python.parser.ast.*; *************** *** 13,16 **** --- 17,21 ---- /** * Creates the model from the AST tree. + * uses PopulateModel visitor pattern to create the tree. */ public class ModelMaker { *************** *** 21,27 **** * */ ! public static ModuleNode createModel(SimpleNode root, int lines, int cols) { ! ModuleNode n = new ModuleNode(null, lines, cols); ! PopulateModel populator = new PopulateModel(root, n); try { root.accept(populator); --- 26,40 ---- * */ ! public static ModuleNode createModel(SimpleNode root, IDocument doc, IFile file) { ! int lastLine = doc.getNumberOfLines(); ! int lineLength = 255; ! try { ! IRegion r = doc.getLineInformation(lastLine-1); ! lineLength = r.getLength(); ! } catch (BadLocationException e1) { ! PydevPlugin.log(IStatus.ERROR, "Unexpected error getting last line", e1); ! } ! ModuleNode n = new ModuleNode(file, lastLine, lineLength); ! PopulateModel populator = new PopulateModel(root, n, doc); try { root.accept(populator); *************** *** 34,43 **** /** ! * Problems this class is trying to solve: ! * ! * - figuring out the end position of the node. AST only has starting position, ! * so we need to heuristically find the end of it ! * * */ static class PopulateModel extends VisitorBase { --- 47,55 ---- /** ! * Create the model by traversing AST tree. * + * visit* functions are required by visitor patters. + * When the pattern finds something interesting, it calls process* which + * create the model. */ static class PopulateModel extends VisitorBase { *************** *** 45,61 **** SimpleNode root; AbstractNode parent; ! public PopulateModel(SimpleNode root, AbstractNode parent) { this.root = root; this.parent = parent; } void processAliases(AbstractNode parent, aliasType[] nodes) { for (int i=0; i<nodes.length; i++) ! new ImportAlias(parent, nodes[i]); } void processImport(Import node) { ! ImportNode newNode = new ImportNode(parent, node); // have to traverse children manually to find all imports processAliases(newNode, node.names); --- 57,89 ---- SimpleNode root; AbstractNode parent; + IDocument doc; ! public PopulateModel(SimpleNode root, AbstractNode parent, IDocument doc) { this.root = root; this.parent = parent; + this.doc = doc; + } + + private String getLineText(SimpleNode node) { + try { + IRegion lineInfo = doc.getLineInformation(node.beginLine -1); + return doc.get(lineInfo.getOffset(), lineInfo.getLength()); + } catch (BadLocationException e) { + PydevPlugin.log(IStatus.ERROR, "Unexpected getLineText error", e); + } + return ""; } + /** + * processAliases creates Import tokens. + * import os, sys would create 2 aliases + */ void processAliases(AbstractNode parent, aliasType[] nodes) { for (int i=0; i<nodes.length; i++) ! new ImportAlias(parent, nodes[i], getLineText(nodes[i])); } void processImport(Import node) { ! ImportNode newNode = new ImportNode(parent, node, getLineText(node)); // have to traverse children manually to find all imports processAliases(newNode, node.names); *************** *** 63,67 **** void processImportFrom(ImportFrom node) { ! ImportFromNode newNode = new ImportFromNode(parent, node); // have to traverse children manually to find all imports processAliases(newNode, node.names); --- 91,95 ---- void processImportFrom(ImportFrom node) { ! ImportFromNode newNode = new ImportFromNode(parent, node, getLineText(node)); // have to traverse children manually to find all imports processAliases(newNode, node.names); *************** *** 71,75 **** ClassNode newNode = new ClassNode(parent, node); // traverse inside the class definition ! PopulateModel populator = new PopulateModel(node, newNode); try { node.traverse(populator); --- 99,103 ---- ClassNode newNode = new ClassNode(parent, node); // traverse inside the class definition ! PopulateModel populator = new PopulateModel(node, newNode, doc); try { node.traverse(populator); *************** *** 81,87 **** void processFunctionDef(FunctionDef node) { ! FunctionNode newNode = new FunctionNode(parent, node); // traverse inside the function definition ! PopulateModel populator = new PopulateModel(node, newNode); try { node.traverse(populator); --- 109,115 ---- void processFunctionDef(FunctionDef node) { ! FunctionNode newNode = new FunctionNode(parent, node, getLineText(node)); // traverse inside the function definition ! PopulateModel populator = new PopulateModel(node, newNode, doc); try { node.traverse(populator); *************** *** 94,103 **** void processLocal(Name node) { if (!LocalNode.isBuiltin(node.id)) ! new LocalNode(parent, node); } void processFunctionCall(Call node) { ! FunctionCallNode newNode = new FunctionCallNode(parent, node); ! PopulateModel populator = new PopulateModel(node, newNode); try { node.traverse(populator); --- 122,131 ---- void processLocal(Name node) { if (!LocalNode.isBuiltin(node.id)) ! new LocalNode(parent, node, getLineText(node)); } void processFunctionCall(Call node) { ! FunctionCallNode newNode = new FunctionCallNode(parent, node, getLineText(node)); ! PopulateModel populator = new PopulateModel(node, newNode, doc); try { node.traverse(populator); *************** *** 108,115 **** void processMain(If node) { ! NameEqualsMainNode newNode = new NameEqualsMainNode(parent, node); } protected Object unhandled_node(SimpleNode node) throws Exception { return null; } --- 136,148 ---- void processMain(If node) { ! new NameEqualsMainNode(parent, node); ! } ! ! private void processAttribute(Attribute node) { ! new AttributeNode(parent, node, getLineText(node)); } protected Object unhandled_node(SimpleNode node) throws Exception { + // System.err.println("Unhandled: " + node.getClass().toString() + " L:" + Integer.toString(node.beginLine)); return null; } *************** *** 166,173 **** && ((Str)compareNode.comparators[0]).s.equals("__main__")) processMain(node); - return null; } return super.visitIf(node); } } } --- 199,211 ---- && ((Str)compareNode.comparators[0]).s.equals("__main__")) processMain(node); } return super.visitIf(node); } + + public Object visitAttribute(Attribute node) throws Exception { + processAttribute(node); + super.visitAttribute(node); + return null; // do not want to visit its children? + } } } Index: ModelUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ModelUtils.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ModelUtils.java 10 Apr 2004 01:48:13 -0000 1.1 --- ModelUtils.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 6,12 **** --- 6,15 ---- package org.python.pydev.editor.model; + import java.io.File; import java.util.ArrayList; + import java.util.Comparator; import java.util.Iterator; + import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.text.BadLocationException; *************** *** 16,23 **** /** ! * Utility functions: querying/conversion */ public class ModelUtils { public static AbstractNode getElement(AbstractNode root, int offset, IDocument doc, int properties) { try { --- 19,42 ---- /** ! * Utility functions: querying/conversion of the model. ! * ! * The model is ordered by position in the file, and can be traversed ! * with {@link #getNextNode} and {@link #getPreviousNode}. ! * ! * The ordering looks like this: ! * <pre> ! * 0 ! * / \ ! * / \ ! * 1 4 ! * / \ /\ ! * 2 3 5 6 ! * </pre> */ public class ModelUtils { + /** + * See the getElement(AbstractNode root, Location loc, int properties) comment. + */ public static AbstractNode getElement(AbstractNode root, int offset, IDocument doc, int properties) { try { *************** *** 32,36 **** /** ! * Depth-first search for a node that spans given location * @param root: node to start the search with * @param loc: location we are looking for --- 51,55 ---- /** ! * Depth-first search for a node that spans given location. * @param root: node to start the search with * @param loc: location we are looking for *************** *** 145,148 **** --- 164,170 ---- } + /** + * Tree traversal, get next node. + */ public static AbstractNode getNextNode(AbstractNode node) { if (node == null) *************** *** 154,156 **** --- 176,213 ---- return getNextNodeHelper(node.getParent(), node); } + + /** + * Finds where the given node is defined. + * @return TRICKY: null if nothing found. Otherwise, an array list of + * If found first element is the IFile + * second element is start of the + */ + public static ArrayList findDefinition(AbstractNode node) { + IFile file; + ArrayList retVal = new ArrayList(); + // simple function calls + // ex: simpleCall() + if (node instanceof LocalNode && + node.getParent() instanceof FunctionCallNode) { + ArrayList funcCalls = node.getScope().findFunctionCalls(node.getName(), true, + new Comparator() { + public int compare(Object token, Object funcCall) { + return ((String)token).compareTo(((AbstractNode)funcCall).getName()); + } + }); + for (Iterator i = funcCalls.iterator(); i.hasNext();) { + FunctionNode funcNode = (FunctionNode)i.next(); + retVal.add(new ItemPointer(funcNode.getFile(), funcNode.getStart(), funcNode.getEnd())); + } + } else if (node instanceof ImportAlias) { + // imports: + // import sys + File myImport = node.getScope().findImport(node.getName(), node.getFile()); + if (myImport != null) + retVal.add(new ItemPointer(myImport)); + }else if (node instanceof AttributeNode) { + // method calls. ex: self.break_here() + } + return retVal; + } } Index: LengthEstimator.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/LengthEstimator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LengthEstimator.java 10 Apr 2004 01:48:13 -0000 1.1 --- LengthEstimator.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 68,72 **** public Object visitBinOp(BinOp node) throws Exception { ! System.out.println("lenVisitBinOp:" + node.toString("")); return null; } --- 68,72 ---- public Object visitBinOp(BinOp node) throws Exception { ! // System.out.println("lenVisitBinOp:" + node.toString("")); return null; } *************** *** 216,220 **** public Object visitNum(Num node) throws Exception { ! System.out.println("lenVisitNum:" + node.toString("")); return null; } --- 216,220 ---- public Object visitNum(Num node) throws Exception { ! // System.out.println("lenVisitNum:" + node.toString("")); return null; } *************** *** 258,262 **** public Object visitStr(Str node) throws Exception { ! System.out.println("lenVisitStr:" + node.toString("")); return null; } --- 258,262 ---- public Object visitStr(Str node) throws Exception { ! // System.out.println("lenVisitStr:" + node.toString("")); return null; } *************** *** 264,268 **** public Object visitSubscript(Subscript node) throws Exception { ! System.out.println("lenVisitSubscript:" + node.toString("")); return null; } --- 264,268 ---- public Object visitSubscript(Subscript node) throws Exception { ! // System.out.println("lenVisitSubscript:" + node.toString("")); return null; } *************** *** 288,292 **** public Object visitTuple(Tuple node) throws Exception { ! System.out.println("lenVisitTuple:" + node.toString("")); return null; } --- 288,292 ---- public Object visitTuple(Tuple node) throws Exception { ! // System.out.println("lenVisitTuple:" + node.toString("")); return null; } Index: ImportAlias.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ImportAlias.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImportAlias.java 10 Apr 2004 01:48:13 -0000 1.1 --- ImportAlias.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 17,26 **** aliasType astNode; ! public ImportAlias(AbstractNode parent, aliasType astNode) { super(parent); this.astNode = astNode; setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 1)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn - 1 + astNode.name.length())); properties = PROP_CLICKABLE; } } --- 17,32 ---- aliasType astNode; ! public ImportAlias(AbstractNode parent, aliasType astNode, String lineText) { super(parent); this.astNode = astNode; setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 1)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn - 1 + astNode.name.length())); + fixColumnLocation(start, lineText); + fixColumnLocation(end, lineText); properties = PROP_CLICKABLE; } + + public String getName() { + return astNode.name; + } } Index: FunctionCallNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/FunctionCallNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FunctionCallNode.java 10 Apr 2004 01:48:13 -0000 1.1 --- FunctionCallNode.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 19,26 **** * @param parent */ ! public FunctionCallNode(AbstractNode parent, Call astNode) { super(parent); this.astNode = astNode; ! this.setStart(new Location(astNode.beginLine - 1, astNode.beginColumn)); LengthEstimator estimate = new LengthEstimator(); try { --- 19,26 ---- * @param parent */ ! public FunctionCallNode(AbstractNode parent, Call astNode, String lineText) { super(parent); this.astNode = astNode; ! this.setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 1)); LengthEstimator estimate = new LengthEstimator(); try { *************** *** 31,35 **** --- 31,41 ---- this.setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn + estimate.getLength())); + fixColumnLocation(start, lineText); + fixColumnLocation(end, lineText); properties = PROP_CLICKABLE; } + + public String getName() { + return null; + } } Index: LocalNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/LocalNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LocalNode.java 10 Apr 2004 01:48:13 -0000 1.1 --- LocalNode.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 25,42 **** * @param parent */ ! public LocalNode(AbstractNode parent, Name astNode) { super(parent); this.astNode = astNode; ! this.setStart(new Location(astNode.beginLine - 1, astNode.beginColumn)); ! this.setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn + astNode.id.length())); parent.getScope().addLocalDefinition(this); properties = PROP_CLICKABLE; } public String toString() { return super.toString() + astNode.id; } - - public class PredefinedNameException extends Exception { - } } --- 25,45 ---- * @param parent */ ! public LocalNode(AbstractNode parent, Name astNode, String lineText) { super(parent); this.astNode = astNode; ! this.setStart(new Location(astNode.beginLine - 1, astNode.beginColumn-1)); ! this.setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn -1+ astNode.id.length())); ! fixColumnLocation(start, lineText); ! fixColumnLocation(end, lineText); parent.getScope().addLocalDefinition(this); properties = PROP_CLICKABLE; } + public String getName() { + return astNode.id; + } + public String toString() { return super.toString() + astNode.id; } } Index: ImportNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ImportNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImportNode.java 10 Apr 2004 01:48:13 -0000 1.1 --- ImportNode.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 15,19 **** public Import astNode; ! public ImportNode(AbstractNode parent, Import astNode) { super(parent); this.astNode = astNode; --- 15,19 ---- public Import astNode; ! public ImportNode(AbstractNode parent, Import astNode, String lineText) { super(parent); this.astNode = astNode; *************** *** 21,26 **** setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 8)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn - 2)); } ! } --- 21,30 ---- setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 8)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn - 2)); + fixColumnLocation(start, lineText); + fixColumnLocation(end, lineText); } ! public String getName() { ! return "Import has a list of ImportAliases as its children"; ! } } Index: ModuleNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ModuleNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ModuleNode.java 10 Apr 2004 01:48:13 -0000 1.1 --- ModuleNode.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 6,9 **** --- 6,11 ---- package org.python.pydev.editor.model; + import org.eclipse.core.resources.IFile; + /** * Top-level node representing a python module. *************** *** 14,25 **** Scope scope; ! public ModuleNode(AbstractNode parent, int lines, int cols) { ! super(parent); scope = new Scope(this); // FileNode always spans the entire file this.start = Location.MIN_LOCATION; this.end = new Location(lines, cols); } public Scope getScope() { --- 16,38 ---- Scope scope; + IFile file; ! public ModuleNode(IFile file, int lines, int cols) { ! super(null); scope = new Scope(this); // FileNode always spans the entire file + this.file = file; this.start = Location.MIN_LOCATION; this.end = new Location(lines, cols); } + + public String getName() { + // TODO module needs a name, probably a file it comes from + return "module"; + } + + public IFile getFile() { + return file; + } public Scope getScope() { Index: ImportFromNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ImportFromNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ImportFromNode.java 10 Apr 2004 01:48:13 -0000 1.1 --- ImportFromNode.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 17,26 **** public ImportFrom astNode; ! public ImportFromNode(AbstractNode parent, ImportFrom astNode) { super(parent); this.astNode = astNode; setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 1)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn -1 + astNode.module.length())); properties = PROP_CLICKABLE; } } --- 17,32 ---- public ImportFrom astNode; ! public ImportFromNode(AbstractNode parent, ImportFrom astNode, String lineText) { super(parent); this.astNode = astNode; setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 1)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn -1 + astNode.module.length())); + fixColumnLocation(start, lineText); + fixColumnLocation(end, lineText); properties = PROP_CLICKABLE; } + + public String getName() { + return astNode.module; + } } --- NEW FILE: AttributeNode.java --- /* * Author: atotic * Created on Apr 14, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.python.parser.ast.Attribute; /** * self.a.b.c.d => a,b,c & d are attributes. */ public class AttributeNode extends AbstractNode { public Attribute astNode; public AttributeNode(AbstractNode parent, Attribute astNode, String lineText) { super(parent); this.astNode = astNode; this.setStart(new Location(astNode.beginLine - 1, astNode.beginColumn-1)); this.setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn -1 + astNode.attr.length())); fixColumnLocation(start, lineText); fixColumnLocation(end, lineText); // HACK alert // For the final attribute the location produced by AST is wrong (probably intentionally) // So I'll resort to desperate measure of doing a text search to find a matching string // this will work sometimes. if (astNode.beginColumn <= astNode.value.beginColumn) { Location temp = new Location(0, astNode.value.beginColumn -1); fixColumnLocation(temp, lineText); int grep = lineText.indexOf(astNode.attr, temp.column+1); if (grep != -1 && grep > start.column) { start.column = grep; end.column = start.column + astNode.attr.length(); } } properties = PROP_CLICKABLE; } public String getName() { return astNode.attr; } public String toString() { return super.toString()+ astNode.attr; } } Index: FunctionNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/FunctionNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FunctionNode.java 10 Apr 2004 01:48:13 -0000 1.1 --- FunctionNode.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 16,28 **** Scope scope; ! public FunctionNode(AbstractNode parent, FunctionDef node) { super(parent); this.astNode = node; scope = new Scope(this); setStart(new Location(astNode.beginLine - 1, astNode.beginColumn + 3)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn + 3 + astNode.name.length())); properties = PROP_CLICKABLE; } public Scope getScope() { return scope; --- 16,36 ---- Scope scope; ! public FunctionNode(AbstractNode parent, FunctionDef node, String lineText) { super(parent); this.astNode = node; scope = new Scope(this); + parent.getScope().addFunctionDefinition(this); + setStart(new Location(astNode.beginLine - 1, astNode.beginColumn + 3)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn + 3 + astNode.name.length())); + fixColumnLocation(start, lineText); + fixColumnLocation(end, lineText); properties = PROP_CLICKABLE; } + public String getName() { + return astNode.name; + } + public Scope getScope() { return scope; Index: NameEqualsMainNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/NameEqualsMainNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NameEqualsMainNode.java 10 Apr 2004 01:48:13 -0000 1.1 --- NameEqualsMainNode.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 21,23 **** --- 21,27 ---- this.setEnd(new Location(astNode.beginLine, astNode.beginColumn + 22)); } + + public String getName() { + return "if __name__ equals main"; + } } Index: Scope.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/Scope.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Scope.java 10 Apr 2004 01:48:13 -0000 1.1 --- Scope.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 6,14 **** package org.python.pydev.editor.model; import java.util.ArrayList; import java.util.Iterator; /** ! * Scope represents scope where local variables belong to. * * There is a scope hierarchy: --- 6,22 ---- package org.python.pydev.editor.model; + import java.io.File; import java.util.ArrayList; + import java.util.Comparator; import java.util.Iterator; + import org.eclipse.core.resources.IFile; + import org.eclipse.core.runtime.IPath; + import org.python.pydev.plugin.PydevPrefs; + + /** ! * Scope is where definitions of locals/classes/functions go in a namespace. ! * Every AbstractNode has a scope. * * There is a scope hierarchy: *************** *** 23,27 **** private AbstractNode end; private Scope parent; ! private ArrayList children; public Scope(AbstractNode start) { --- 31,38 ---- private AbstractNode end; private Scope parent; ! ! // Lists of elements defined inside this this scope. ! private ArrayList children; // array of LocalNodes ! private ArrayList functions; // array of FunctionCallNodes public Scope(AbstractNode start) { *************** *** 62,65 **** --- 73,82 ---- } + void addFunctionDefinition(FunctionNode newDef) { + if (functions == null) + functions = new ArrayList(); + functions.add(newDef); + } + public Location getStart() { return start.getStart(); *************** *** 86,88 **** --- 103,177 ---- this.end = trueEndNode; } + + /** + * @param name: function name + * @param c: comparator to test for. + * @return an ArrayList of ItemPointers to the function definitions. + * each returned item will test as equal in c.compare(token, item); + * null is never returned, there will be an empty array if none were found. + * + * Usage: + scope.findFunctionCalls("FunctionName", true, + new Comparator() { + public int compare(Object token, Object funcCall) { + return ((String)token).compareTo(((AbstractNode)funcCall).getName()); + + */ + + public ArrayList findFunctionCalls(Object token, boolean recursive, Comparator c) { + ArrayList retVal = new ArrayList(); + // traverse our definitions + if (functions != null) { + Iterator i = functions.iterator(); + while (i.hasNext()) { + Object item = i.next(); + if (c.compare(token, item) == 0) + retVal.add(item); + } + } + // now traverse parents + ArrayList ancestors = null; + if (recursive) + if (parent != null) + ancestors = parent.findFunctionCalls(token, recursive, c); + if (ancestors != null) + retVal.addAll(ancestors); + return retVal; + } + + /** + * get all the import files + * @param startingPoint: a file to start searching from + * @return an ordered ArrayList of File of all import paths for the project. + */ + private ArrayList getImportPaths(IFile startingPoint) { + ArrayList retVal = new ArrayList(); + // 1) the directory where the file is + if (startingPoint != null) { + IPath fileDir = startingPoint.getLocation().removeLastSegments(1); + retVal.add(fileDir.toFile()); + } + // 2) interpreter/Lib + String interpreter = PydevPrefs.getInterpreters()[0]; + File interpreterFile = new File(interpreter); + String parent = interpreterFile.getParent(); + if (parent != null) + retVal.add(new File(parent, "Lib")); + return retVal; + } + + /** + * Find a file "name.py", searching the import include path + * @return ArrayList of File objects that match. + */ + public File findImport(String name, IFile startAt) { + ArrayList importPaths = getImportPaths(startAt); + for (Iterator i= importPaths.iterator();i.hasNext();) { + File dir = (File)i.next(); + File testFile = new File(dir, name + ".py"); + if (testFile.exists()) + return testFile; + } + return null; + } } --- NEW FILE: ItemPointer.java --- /* * Author: atotic * Created on Apr 14, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; /** * * TODO Comment this class */ public class ItemPointer { public Object file; // IFile or File... public Location start; public Location end; public ItemPointer(Object file) { this(file, new Location(), new Location()); } public ItemPointer(Object file, Location start, Location end) { this.file = file; this.start = start; this.end = end; } } Index: ClassNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ClassNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ClassNode.java 10 Apr 2004 01:48:13 -0000 1.1 --- ClassNode.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 25,28 **** --- 25,32 ---- } + public String getName() { + return astNode.name; + } + public Scope getScope() { return scope; Index: AbstractNode.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/AbstractNode.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractNode.java 10 Apr 2004 01:48:13 -0000 1.1 --- AbstractNode.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 8,11 **** --- 8,15 ---- import java.util.ArrayList; + import org.eclipse.core.resources.IFile; + import org.eclipse.core.runtime.IStatus; + import org.python.pydev.plugin.PydevPlugin; + /** * ModelNode is a superclass of all nodes. *************** *** 15,19 **** * For example, clickable nodes have PROP_CLICKABLE set. */ ! public class AbstractNode { static ArrayList emptyChildList = new ArrayList(); // we keep an empty list around for efficiency --- 19,23 ---- * For example, clickable nodes have PROP_CLICKABLE set. */ ! public abstract class AbstractNode { static ArrayList emptyChildList = new ArrayList(); // we keep an empty list around for efficiency *************** *** 91,93 **** --- 95,135 ---- return getClass().toString() + " " + start.toString() + end.toString(); } + + /** + * Subclasses should override. This gets the python string. + */ + public abstract String getName(); + + public IFile getFile() { + return parent.getFile(); + } + + /** + * This function is a heuristic solution for the way jython & TextEditor + * deal with column numbers. + * + * jython's parser converts tabs to spaces internally. + * When it reports the column, it reports the column after the spaces + * have been converted to tabs. So in "\tFunc()", func starts in column + * 5 according to jython's parser, and in column 1 according to text editor. + * + * This fix tries to convert jython's column numbers to those that work for editor. + * To do this, we get the whole line where location was defined, and + * substract the spaces assumed by jython (8 per tab). + */ + public void fixColumnLocation(Location loc, String lineText) { + int where = 0; + int tabCount = 0; + where = lineText.indexOf("\t", where); + while (where != -1 && where <= loc.column) { + where = lineText.indexOf("\t", where+1); + tabCount++; + } + if (tabCount > 0) + loc.column = loc.column - tabCount * 7; + if (loc.column < 0) { + loc.column = 0; + PydevPlugin.log(IStatus.ERROR, "Unexpected columnFixLocation error", null); + } + } } |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:19:30
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16009/src/org/python/pydev/ui Modified Files: ProjectProperties.java Added Files: InterpreterEditor.java StreamConsumer.java Log Message: More model code. Hyperlinks on function calls and imports now work. had to pull interpreter editor from PydevDebug plugin into this one since we needed interpreter locaiton for include paths. Model got extensive changes. Scopes are now used in the code. General code cleanup everywehre. Added findFunctionDefinition functionality with hyperlinks Added the ability to open external files (for external hyperlinks) --- NEW FILE: StreamConsumer.java --- package org.python.pydev.ui; import java.io.*; import org.eclipse.core.runtime.IStatus; import org.python.pydev.plugin.PydevPlugin; /** * Used to receive output from processes. * * Copied from Ant code, and used by InterpreterEditor */ public class StreamConsumer extends Thread { BufferedReader bReader; private String lastLine; public StreamConsumer(InputStream inputStream) { super(); setDaemon(true); bReader = new BufferedReader(new InputStreamReader(inputStream)); } public void run() { try { String line; while (null != (line = bReader.readLine())) { lastLine = line; // DebugPlugin.log(line); } bReader.close(); } catch (IOException ioe) { PydevPlugin.log(IStatus.ERROR, "Error in stream consumer", ioe); } } /** * @return last line obtained, can be null */ public String getLastLine() { return lastLine; } } Index: ProjectProperties.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/ProjectProperties.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ProjectProperties.java 12 Mar 2004 00:18:40 -0000 1.1 --- ProjectProperties.java 15 Apr 2004 23:19:22 -0000 1.2 *************** *** 27,31 **** Text pathText; ! public static QualifiedName INCLUDE_PATH_PROP = new QualifiedName("test", "INCLUDE_PATH"); /** --- 27,31 ---- Text pathText; ! public static QualifiedName SRC_PATH_PROP = new QualifiedName(PydevPlugin.getPluginID(), "SOURCE_PATH"); /** *************** *** 61,65 **** if (project != null) { try { ! project.setPersistentProperty(INCLUDE_PATH_PROP, pathText.getText()); } catch (CoreException e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error setting project properties", e); --- 61,65 ---- if (project != null) { try { ! project.setPersistentProperty(SRC_PATH_PROP, pathText.getText()); } catch (CoreException e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error setting project properties", e); --- NEW FILE: InterpreterEditor.java --- /* * Author: atotic * Created: Sep 8, 2003 * License: Common Public License v1.0 */ package org.python.pydev.ui; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.StringTokenizer; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.preference.ListEditor; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.FileDialog; import org.python.pydev.plugin.PydevPlugin; /** * Field editor for a list of python interpreter with executable verifier. * * <p>heavily inspired by org.eclipse.jface.preference.PathEditor * <p>Tries to run python binary to make sure it exists */ public class InterpreterEditor extends ListEditor { /** * The last path, or <code>null</code> if none. */ private String lastPath; /** * Creates a path field editor. * * @param name the name of the preference this field editor works on * @param labelText the label text of the field editor * @param parent the parent of the field editor's control */ public InterpreterEditor( String name, String labelText, Composite parent) { init(name, labelText); createControl(parent); } /* * Creates a single string of paths from a list of items */ protected String createList(String[] items) { StringBuffer path = new StringBuffer(""); for (int i = 0; i < items.length; i++) { path.append(items[i]); path.append(File.pathSeparator); } return path.toString(); } /* * Method declared on ListEditor. * Creates a new path element by means of a file dialog. */ protected String getNewInputObject() { FileDialog dialog = new FileDialog(getShell(), SWT.OPEN); if (System.getProperty("os.name").startsWith("Win")) dialog.setFilterExtensions(new String[] {"*.exe", "*.*"}); else ; // TODO right file dialog executable filters for unix/mac? if (lastPath != null) { if (new File(lastPath).exists()) dialog.setFilterPath(lastPath); } String file = dialog.open(); if (file != null) { file = file.trim(); if (file.length() == 0) return null; lastPath = file; } return file; } public static String[] getInterpreterList(String stringList) { if (stringList == null) { PydevPlugin.log(IStatus.WARNING, "No python interpreters specified", (Throwable)null); return new String[] {"python"}; } StringTokenizer st = new StringTokenizer(stringList, File.pathSeparator + "\n\r"); //$NON-NLS-1$ ArrayList v = new ArrayList(); while (st.hasMoreElements()) { v.add(st.nextElement()); } if (v.size() == 0) v.add("python"); return (String[])v.toArray(new String[v.size()]); } /** * Lifted from org.eclipse.help.internal.browser.MozillaFactory * On some OSes 0 is always returned by "which" command * it is necessary to examine ouput to find out failure. * @param outputs * @param errors * @return true if there are errors * @throws InterruptedException */ static private boolean errorsInOutput( String executable, StreamConsumer outputs, StreamConsumer errors) { try { outputs.join(1000); if (outputs.getLastLine() != null && outputs.getLastLine().indexOf("no " + executable + " in") >= 0) { return true; } errors.join(1000); if (errors.getLastLine() != null && errors.getLastLine().indexOf("no " + executable + " in") >= 0) { return true; } } catch (InterruptedException ie) { // ignore } return false; } /** * true if executable is jython. A hack, */ static public boolean isJython(String executable) { return executable.toLowerCase().indexOf("jython") != -1; } /** * returns true if interpreter was launched successfully */ public static boolean validateInterpreterPath(String executable) { boolean retVal = true; try { String versionOption = " -V"; // Jython command line option is --version, not -V if (isJython(executable)) versionOption = " --version"; Process pr = Runtime.getRuntime().exec(executable + versionOption); StreamConsumer outputs = new StreamConsumer(pr.getInputStream()); outputs.start(); StreamConsumer errors = new StreamConsumer(pr.getErrorStream()); errors.start(); pr.waitFor(); int ret = pr.exitValue(); if (ret == 0) retVal = !errorsInOutput(executable, outputs, errors); else retVal = false; } catch (InterruptedException e) { retVal = false; } catch (IOException e) { // launching which failed, assume browser executable is present retVal = false; } return retVal; } /* (non-Javadoc) * Method declared on ListEditor. */ protected String[] parseString(String stringList) { return getInterpreterList(stringList); } } |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:19:30
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16009/src/org/python/pydev/plugin Modified Files: PydevPrefs.java Added Files: DebugPrefsPage.java ExternalEditorInput.java FileStorage.java Log Message: More model code. Hyperlinks on function calls and imports now work. had to pull interpreter editor from PydevDebug plugin into this one since we needed interpreter locaiton for include paths. Model got extensive changes. Scopes are now used in the code. General code cleanup everywehre. Added findFunctionDefinition functionality with hyperlinks Added the ability to open external files (for external hyperlinks) --- NEW FILE: ExternalEditorInput.java --- /* Copied by atotic from Eclipse's bugzilla. The bug talked about opening external files */ package org.python.pydev.plugin; /* * (c) Copyright QNX Software Systems Ltd. 2002. * All Rights Reserved. */ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.core.resources.IStorage; import org.eclipse.ui.IEditorRegistry; import org.eclipse.ui.IPersistableElement; import org.eclipse.ui.IStorageEditorInput; import org.eclipse.ui.PlatformUI; /** * An EditorInput for an external file. */ public class ExternalEditorInput implements IStorageEditorInput { IStorage externalFile; /** * Two ExternalEditorInputs are equal if their IStorage's are equal. * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof ExternalEditorInput)) return false; ExternalEditorInput other = (ExternalEditorInput)obj; return externalFile.equals(other.externalFile); } /* * @see IEditorInput#exists() */ public boolean exists() { // External file ca not be deleted return true; } /* * @see IAdaptable#getAdapter(Class) */ public Object getAdapter(Class adapter) { return null; } /* * @see IEditorInput#getContentType() */ public String getContentType() { return externalFile.getFullPath().getFileExtension(); } /* * @see IEditorInput#getFullPath() */ public String getFullPath() { return externalFile.getFullPath().toString(); } /* * @see IEditorInput#getImageDescriptor() */ public ImageDescriptor getImageDescriptor() { IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry(); return registry.getImageDescriptor(externalFile.getFullPath().getFileExtension()); } /* * @see IEditorInput#getName() */ public String getName() { return externalFile.getName(); } /* * @see IEditorInput#getPersistable() */ public IPersistableElement getPersistable() { return null; } /* * see IStorageEditorInput#getStorage() */ public IStorage getStorage() { return externalFile; } /* * @see IEditorInput#getToolTipText() */ public String getToolTipText() { return externalFile.getFullPath().toString(); } public ExternalEditorInput(IStorage exFile) { externalFile = exFile; } } --- NEW FILE: DebugPrefsPage.java --- /* * Author: atotic * Created: Jun 23, 2003 * License: Common Public License v1.0 */ package org.python.pydev.plugin; import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.python.pydev.ui.InterpreterEditor; /** * Debug preferences. * * <p>Simple 1 page debug preferences page. * <p>Prefeernce constants are defined in Constants.java */ public class DebugPrefsPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage{ /** * Initializer sets the preference store */ public DebugPrefsPage() { super(GRID); setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); } public void init(IWorkbench workbench) { String interpreterPath = getPreferenceStore().getString(PydevPrefs.INTERPRETER_PATH); // If the interpreter path is empty, always try to come up with something if (interpreterPath == null || interpreterPath.length() == 0) { getPreferenceStore().setDefault(PydevPrefs.INTERPRETER_PATH, getDefaultInterpreterPath()); getPreferenceStore().setToDefault(PydevPrefs.INTERPRETER_PATH); } } /** * Creates the editors */ protected void createFieldEditors() { Composite p = getFieldEditorParent(); InterpreterEditor pathEditor = new InterpreterEditor ( PydevPrefs.INTERPRETER_PATH, "Python interpreters (for example python.exe)", p); addField(pathEditor); } /** * Return the default python executable * I tried making this smarter, but you can't do much without getenv(PATH) */ private String getDefaultInterpreterPath() { String executable = "python"; return executable; // ideally, I'd search the system path here, but getenv has been disabled // some code on finding the binary // java.util.Properties p = System.getProperties(); // java.util.Enumeration keys = p.keys(); // while( keys.hasMoreElements() ) { // System.out.println( keys.nextElement() ); // } // StringBuffer retVal = new StringBuffer(); // String sysPath = System.getProperty("sys.path"); // if (sysPath == null) // sysPath = System.getenv("PATH"); // if (sysPath != null) { // StringTokenizer st = new StringTokenizer(sysPath, File.pathSeparator + "\n\r"); // while (st.hasMoreElements()) { // String path =st.nextToken(); // System.out.println(path); // } // } // return retVal.toString(); } /** * Sets default preference values */ protected void initializeDefaultPreferences(Preferences prefs) { prefs.setDefault(PydevPrefs.INTERPRETER_PATH, getDefaultInterpreterPath()); } } Index: PydevPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPrefs.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PydevPrefs.java 8 Jan 2004 22:41:15 -0000 1.4 --- PydevPrefs.java 15 Apr 2004 23:19:22 -0000 1.5 *************** *** 16,19 **** --- 16,20 ---- import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; + import org.python.pydev.ui.InterpreterEditor; /** *************** *** 45,48 **** --- 46,51 ---- public static final String COMMENT_COLOR = "COMMENT_COLOR"; private static final RGB DEFAULT_COMMENT_COLOR = new RGB(178, 34, 34); + public static final String INTERPRETER_PATH = "INTERPRETER_PATH"; + protected static final String DEFAULT_INTERPRETER_PATH = "python"; /** *************** *** 58,61 **** --- 61,69 ---- } + public static String[] getInterpreters() { + String interpreters = getPreferences().getString(PydevPrefs.INTERPRETER_PATH); + return InterpreterEditor.getInterpreterList(interpreters); + } + public void init(IWorkbench workbench) { } --- NEW FILE: FileStorage.java --- /* Copied by atotic from Eclipse's bugzilla. The bug talked about opening external files */ package org.python.pydev.plugin; /* * (c) Copyright QNX Software Systems Ltd. 2002. * All Rights Reserved. */ import java.io.InputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import org.eclipse.core.resources.IStorage; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.IStatus; /** * * @see IStorage */ public class FileStorage extends PlatformObject implements IStorage { IPath path; InputStream in = null; /** * Two FileStorages are equal if their IPaths are equal. * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof FileStorage)) return false; FileStorage other = (FileStorage)obj; return path.equals(other.path); } /** * @see org.eclipse.core.resources.IStorage#getContents() */ public InputStream getContents() throws CoreException { if (in == null) { try { return new FileInputStream(path.toFile()); } catch (FileNotFoundException e) { throw new CoreException(new Status(IStatus.ERROR, "FileStorage unknown string", IStatus.ERROR, e.toString(), e)); } } else { return in; } } /** * @see IStorage#getFullPath */ public IPath getFullPath() { return this.path; } /** * @see IStorage#getName */ public String getName() { return this.path.lastSegment(); } /** * @see IStorage#isReadOnly() */ public boolean isReadOnly() { return true; } /** * Method FileStorage. * @param path */ public FileStorage(IPath path){ this.path = path; } /** * Method FileStorage. * @param in * @param path */ public FileStorage(InputStream in, IPath path){ this.path = path; this.in = in; } /** * @see IStorage#isReadOnly() */ public String toString() { return path.toOSString(); } } |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:19:30
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16009/src/org/python/pydev/parser Modified Files: PyParser.java Log Message: More model code. Hyperlinks on function calls and imports now work. had to pull interpreter editor from PydevDebug plugin into this one since we needed interpreter locaiton for include paths. Model got extensive changes. Scopes are now used in the code. General code cleanup everywehre. Added findFunctionDefinition functionality with hyperlinks Added the ability to open external files (for external hyperlinks) Index: PyParser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser/PyParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyParser.java 10 Apr 2004 01:48:14 -0000 1.6 --- PyParser.java 15 Apr 2004 23:19:22 -0000 1.7 *************** *** 169,173 **** try { SimpleNode newRoot = grammar.file_input(); // parses the file ! original.deleteMarkers(IMarker.PROBLEM, false, 1); fireParserChanged(newRoot); } catch (ParseException parseErr) { --- 169,174 ---- try { SimpleNode newRoot = grammar.file_input(); // parses the file ! if (original != null) ! original.deleteMarkers(IMarker.PROBLEM, false, 1); fireParserChanged(newRoot); } catch (ParseException parseErr) { *************** *** 249,253 **** } } ! Iterator i = parseUs.iterator(); while (i.hasNext()) { --- 250,255 ---- } } ! ! // Now parse the queue Iterator i = parseUs.iterator(); while (i.hasNext()) { *************** *** 255,258 **** --- 257,261 ---- if (p.parseNow) { p.parseNow = false; + p.parseLater = 0; p.reparseDocument(); } |
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16009/src/org/python/pydev/editor Modified Files: Hyperlink.java PyEdit.java PyEditConfiguration.java Added Files: PyDoubleClickStrategy.java Removed Files: PyContentAssistProcessor.java PyContentAssistant.java Log Message: More model code. Hyperlinks on function calls and imports now work. had to pull interpreter editor from PydevDebug plugin into this one since we needed interpreter locaiton for include paths. Model got extensive changes. Scopes are now used in the code. General code cleanup everywehre. Added findFunctionDefinition functionality with hyperlinks Added the ability to open external files (for external hyperlinks) Index: Hyperlink.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/Hyperlink.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Hyperlink.java 10 Apr 2004 01:48:14 -0000 1.1 --- Hyperlink.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 6,9 **** --- 6,10 ---- package org.python.pydev.editor; + import java.util.ArrayList; import java.util.StringTokenizer; *************** *** 47,51 **** --- 48,55 ---- import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; + import org.eclipse.ui.PlatformUI; + import org.python.pydev.editor.actions.PyOpenAction; import org.python.pydev.editor.model.AbstractNode; + import org.python.pydev.editor.model.ItemPointer; import org.python.pydev.editor.model.ModelUtils; import org.python.pydev.plugin.PydevPlugin; *************** *** 79,82 **** --- 83,87 ---- private ISourceViewer fSourceViewer; private PyEdit fEditor; + private AbstractNode fClickedNode; public Hyperlink(ISourceViewer sourceViewer, PyEdit editor) { *************** *** 334,341 **** if (offset == -1) return null; ! ! AbstractNode node = ModelUtils.getElement(fEditor.getPythonModel(), offset, viewer.getDocument(), AbstractNode.PROP_CLICKABLE); ! if (node == null) return null; --- 339,345 ---- if (offset == -1) return null; ! fClickedNode = ModelUtils.getElement(fEditor.getPythonModel(), offset, viewer.getDocument(), AbstractNode.PROP_CLICKABLE); ! if (fClickedNode == null) return null; *************** *** 526,530 **** if (wasActive) { ! System.out.println("Clicked for action"); // IAction action= getAction("OpenEditor"); //$NON-NLS-1$ // if (action != null) --- 530,539 ---- if (wasActive) { ! PyOpenAction action = (PyOpenAction)fEditor.getAction(PyEdit.ACTION_OPEN); ! ArrayList where = ModelUtils.findDefinition(fClickedNode); ! if (where.size() > 0) ! action.run((ItemPointer)where.get(0)); ! else ! PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay().beep(); // IAction action= getAction("OpenEditor"); //$NON-NLS-1$ // if (action != null) --- NEW FILE: PyDoubleClickStrategy.java --- /* * Author: atotic * Created on Apr 14, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor; import org.eclipse.jdt.internal.ui.text.JavaPairMatcher; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextDoubleClickStrategy; import org.eclipse.jface.text.ITextViewer; /** * Our double-click implementation. * * Copied org.eclipse.jdt.internal.ui.text.java.JavaDoubleClickStrategy. */ public class PyDoubleClickStrategy implements ITextDoubleClickStrategy { protected static final char[] BRACKETS = { '{', '}', '(', ')', '[', ']' }; protected JavaPairMatcher fPairMatcher = new JavaPairMatcher(BRACKETS); /** * @see ITextDoubleClickStrategy#doubleClicked */ public void doubleClicked(ITextViewer textViewer) { int offset = textViewer.getSelectedRange().x; if (offset < 0) return; IDocument document = textViewer.getDocument(); IRegion region = fPairMatcher.match(document, offset); if (region != null && region.getLength() >= 2) textViewer.setSelectedRange( region.getOffset() + 1, region.getLength() - 2); else selectWord(textViewer, document, offset); } protected void selectWord( ITextViewer textViewer, IDocument document, int anchor) { try { int offset = anchor; char c; while (offset >= 0) { c = document.getChar(offset); if (!Character.isJavaIdentifierPart(c)) break; --offset; } int start = offset; offset = anchor; int length = document.getLength(); while (offset < length) { c = document.getChar(offset); if (!Character.isJavaIdentifierPart(c)) break; ++offset; } int end = offset; if (start == end) textViewer.setSelectedRange(start, 0); else textViewer.setSelectedRange(start + 1, end - start - 1); } catch (BadLocationException x) { } } } --- PyContentAssistProcessor.java DELETED --- Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyEditConfiguration.java 2 Apr 2004 18:07:50 -0000 1.7 --- PyEditConfiguration.java 15 Apr 2004 23:19:21 -0000 1.8 *************** *** 136,141 **** ISourceViewer sourceViewer, String contentType) { ! // TODO Implement smarter double-click strategy ! return super.getDoubleClickStrategy(sourceViewer, contentType); } --- 136,143 ---- ISourceViewer sourceViewer, String contentType) { ! if (contentType.equals(IDocument.DEFAULT_CONTENT_TYPE)) ! return new PyDoubleClickStrategy(); ! else ! return super.getDoubleClickStrategy(sourceViewer, contentType); } Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PyEdit.java 10 Apr 2004 01:48:14 -0000 1.11 --- PyEdit.java 15 Apr 2004 23:19:21 -0000 1.12 *************** *** 37,40 **** --- 37,41 ---- import org.python.parser.TokenMgrError; import org.python.pydev.plugin.*; + import org.python.pydev.editor.actions.PyOpenAction; import org.python.pydev.editor.model.AbstractNode; import org.python.pydev.editor.model.IModelListener; *************** *** 65,68 **** --- 66,71 ---- public class PyEdit extends TextEditor implements IParserListener { + static public String ACTION_OPEN = "OpenEditor"; + /** color cache */ private ColorCache colorCache; *************** *** 190,196 **** 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); --- 193,199 ---- 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); *************** *** 202,205 **** --- 205,210 ---- setActionActivationCode(CONTENTASSIST_PROPOSAL_ID,' ', -1, SWT.CTRL); + IAction openAction = new PyOpenAction(); + setAction(ACTION_OPEN, openAction); enableBrowserLikeLinks(); } *************** *** 290,294 **** try { r = document.getLineInformation(lastLine-1); ! pythonModel = ModelMaker.createModel(root, lastLine , r.getLength()); fireModelChanged(pythonModel); } catch (BadLocationException e1) { --- 295,299 ---- try { r = document.getLineInformation(lastLine-1); ! pythonModel = ModelMaker.createModel(root, document, original); fireModelChanged(pythonModel); } catch (BadLocationException e1) { *************** *** 325,330 **** IRegion startLine = document.getLineInformation(errorToken.beginLine - 1); ! IRegion endLine = ! document.getLineInformation(errorToken.endLine - 1); errorStart = startLine.getOffset() + errorToken.beginColumn - 1; errorEnd = endLine.getOffset() + errorToken.endColumn; --- 330,338 ---- 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; *************** *** 352,356 **** map.put(IMarker.CHAR_START, new Integer(errorStart)); map.put(IMarker.CHAR_END, new Integer(errorEnd)); ! map.put(IMarker.TRANSIENT, new Boolean(true)); MarkerUtilities.createMarker(original, map, IMarker.PROBLEM); --- 360,364 ---- 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); --- PyContentAssistant.java DELETED --- |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:19:30
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16009/src/org/python/pydev/editor/actions Modified Files: PyComment.java Added Files: PyOpenAction.java Log Message: More model code. Hyperlinks on function calls and imports now work. had to pull interpreter editor from PydevDebug plugin into this one since we needed interpreter locaiton for include paths. Model got extensive changes. Scopes are now used in the code. General code cleanup everywehre. Added findFunctionDefinition functionality with hyperlinks Added the ability to open external files (for external hyperlinks) --- NEW FILE: PyOpenAction.java --- /* * Author: atotic * Created on Apr 12, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.actions; import java.io.File; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IStorage; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.jface.action.Action; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.TextSelection; import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorRegistry; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.ITextEditor; import org.python.pydev.editor.model.ItemPointer; import org.python.pydev.editor.model.Location; import org.python.pydev.plugin.ExternalEditorInput; import org.python.pydev.plugin.FileStorage; import org.python.pydev.plugin.PydevPlugin; /** * Opens an editor and selects text in it. * * Inspired by {@link org.eclipse.jdt.ui.actions.OpenAction}, but simplifies * traversal of functions. */ public class PyOpenAction extends Action { public PyOpenAction() { } /** * Opens the file, and sets the selection. * @param start: ok if null, won't set selection * @param end */ private void openInFile(IFile file, Location start, Location end) { if (file == null) return; IWorkbenchPage p = PydevPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IEditorPart editorPart= p.openEditor(file, null, true); if (start != null && editorPart instanceof ITextEditor) { ITextEditor textEdit = (ITextEditor)editorPart; showInEditor(textEdit, start, end); } } catch (PartInitException e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error opening file", e); } catch (BadLocationException e1) { PydevPlugin.log(IStatus.ERROR, "Error setting selection", e1); } } private void openInExternalFile(IPath path, Location start, Location end) { IStorage storage = new FileStorage(path); IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor desc = registry.getDefaultEditor(path.lastSegment()); if (desc == null) desc = registry.getDefaultEditor(); IEditorInput input = new ExternalEditorInput(storage); IWorkbenchPage p = PydevPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { IEditorPart editor = p.openEditor(input, desc.getId()); } catch (PartInitException e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error opening external file", e); } } private void showInEditor(ITextEditor textEdit, Location start, Location end) throws BadLocationException { IDocument doc = textEdit.getDocumentProvider().getDocument(textEdit.getEditorInput()); int s; s = start.toOffset(doc); int e = end == null ? s : end.toOffset(doc); TextSelection sel = new TextSelection(s, e - s); textEdit.getSelectionProvider().setSelection(sel); } public void run(ItemPointer p) { if (p.file instanceof IFile) openInFile((IFile)p.file, p.start, p.end); else if (p.file instanceof File) { IPath path = new Path(((File)p.file).getAbsolutePath()); IWorkspace w = ResourcesPlugin.getWorkspace(); IFile file = w.getRoot().getFileForLocation(path); if (file != null && file.exists()) openInFile(file, p.start, p.end); else { openInExternalFile(path, p.start, p.end); } // I wrote a plugin that does something like this; see the Fileopen plugin at // www.eclipsepowered.org (open source on sourceforge). Since you don't want to // save the file it's even easier, see the sample code posted for // https://bugs.eclipse.org/bugs/show_bug.cgi?id=2869 . Basically it's the same // idea used by the CVS plugin to view source code on an arbitrary revision, so // that's another place to look. HTH. } else { PydevPlugin.log(IStatus.ERROR, "Unknown ItemPointer file format", null); } } } Index: PyComment.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyComment.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyComment.java 28 Feb 2004 05:13:16 -0000 1.1 --- PyComment.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 54,58 **** endLine = doc.getLineInformation(endLineIndex); ! String str = new String(doc.get(initialPos, length)); str = replaceStr(str, endLineDelim); --- 54,58 ---- endLine = doc.getLineInformation(endLineIndex); ! String str = doc.get(initialPos, length); str = replaceStr(str, endLineDelim); |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:19:29
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16009/src/org/python/parser Modified Files: JJTPythonGrammarState.java Log Message: More model code. Hyperlinks on function calls and imports now work. had to pull interpreter editor from PydevDebug plugin into this one since we needed interpreter locaiton for include paths. Model got extensive changes. Scopes are now used in the code. General code cleanup everywehre. Added findFunctionDefinition functionality with hyperlinks Added the ability to open external files (for external hyperlinks) Index: JJTPythonGrammarState.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/parser/JJTPythonGrammarState.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** JJTPythonGrammarState.java 17 Aug 2003 04:44:22 -0000 1.1 --- JJTPythonGrammarState.java 15 Apr 2004 23:19:21 -0000 1.2 *************** *** 85,88 **** --- 85,89 ---- n.beginLine = lines.pop(); n.beginColumn = columns.pop(); + // System.out.println(n.getClass().toString() + " L:" + Integer.toString(n.beginLine) + " C:" + Integer.toString(n.beginColumn)); } |
From: Aleksandar T. <at...@us...> - 2004-04-15 23:19:29
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16009 Modified Files: plugin.xml Changes.txt Log Message: More model code. Hyperlinks on function calls and imports now work. had to pull interpreter editor from PydevDebug plugin into this one since we needed interpreter locaiton for include paths. Model got extensive changes. Scopes are now used in the code. General code cleanup everywehre. Added findFunctionDefinition functionality with hyperlinks Added the ability to open external files (for external hyperlinks) Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Changes.txt 10 Apr 2004 02:06:27 -0000 1.2 --- Changes.txt 15 Apr 2004 23:19:21 -0000 1.3 *************** *** 14,18 **** - Parsing now happens either immediately on return, or a second after the last typing. This makes error notifications nicer and more predictable ! Bug fixes: - Moved parsing so that all pydev parsers use single thread --- 14,21 ---- - Parsing now happens either immediately on return, or a second after the last typing. This makes error notifications nicer and more predictable ! - New double-clicking strategy, copied from Java ! - Moved debug preferences into main plugin. We need them for import paths parsing ! - Hyperlinks on simple imports now work. For them to find system includes, you'll need to ! set up the python interpreter in the preferences Bug fixes: - Moved parsing so that all pydev parsers use single thread Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** plugin.xml 10 Apr 2004 02:06:27 -0000 1.10 --- plugin.xml 15 Apr 2004 23:19:21 -0000 1.11 *************** *** 75,80 **** id="org.python.pydev.prefs"> </page> </extension> ! <!-- Editor menus --> <extension point="org.eclipse.ui.editorActions"> --- 75,86 ---- id="org.python.pydev.prefs"> </page> + <page + name="Debug" + category="org.python.pydev.prefs" + class="org.python.pydev.plugin.DebugPrefsPage" + id="org.python.pydev.prefs.debugPage"> + </page> </extension> ! <!-- Editor menus --> <extension point="org.eclipse.ui.editorActions"> |
From: Aleksandar T. <at...@us...> - 2004-04-10 02:19:52
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3977 Modified Files: .project .classpath Changes.txt plugin.xml Added Files: javadoc.xml Log Message: Checking in the rest of the project --- NEW FILE: javadoc.xml --- <?xml version="1.0" encoding="UTF-8"?> <project name="org.python.pydev" default="javadoc"> <property name="bootclasspath" value=""/> <path id="project.class.path"> <pathelement location="bin"/> <fileset dir="D:\eclipse\plugins\"> <include name="**/*.jar"/> </fileset> </path> <target name="javadoc"> <javadoc destdir="doc/javadoc" access="private" use="true" notree="false" nonavbar="false" noindex="false" splitindex="false" author="true" version="true" nodeprecatedlist="false" nodeprecated="false" classpathref="project.class.path" overview="src\overview.html" stylesheetfile="doc\javadoc.css" doctitle="Pydev javadoc" additionalparam="-quiet -link "http://help.eclipse.org/help21/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api""> <packageset dir="src"> </packageset> <packageset dir="../org.python.pydev.debug/src"> </packageset> </javadoc> </target> </project> Index: .project =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/.project,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** .project 17 Aug 2003 04:44:22 -0000 1.1 --- .project 10 Apr 2004 02:06:27 -0000 1.2 *************** *** 4,7 **** --- 4,11 ---- <comment></comment> <projects> + <project>org.eclipse.core.boot</project> + <project>org.eclipse.core.resources</project> + <project>org.eclipse.core.runtime</project> + <project>org.eclipse.jdt.ui</project> </projects> <buildSpec> Index: Changes.txt =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/Changes.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Changes.txt 12 Mar 2004 00:16:01 -0000 1.1 --- Changes.txt 10 Apr 2004 02:06:27 -0000 1.2 *************** *** 10,13 **** --- 10,19 ---- that opens a python editor. - Added Python properties to projects that have Python nature + - Editor now has a python icon. Icon is ugly, help! + - .pyc files are filtered in the resource view + - Parsing now happens either immediately on return, or a second after the last typing. + This makes error notifications nicer and more predictable Bug fixes: + - Moved parsing so that all pydev parsers use single thread + - \ No newline at end of file Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** plugin.xml 12 Mar 2004 00:19:05 -0000 1.9 --- plugin.xml 10 Apr 2004 02:06:27 -0000 1.10 *************** *** 1,307 **** <?xml version="1.0" encoding="UTF-8"?> <plugin ! id="org.python.pydev" ! name="Pydev - Python Development Environment" ! version="0.3.0" ! provider-name="AleksTotic" ! class="org.python.pydev.plugin.PydevPlugin"> ! <runtime> ! <library name="pydev.jar"/> ! </runtime> ! <requires> ! <import plugin="org.eclipse.core.resources"/> ! <import plugin="org.eclipse.core.runtime"/> ! <import plugin="org.eclipse.ui"/> ! <import plugin="org.eclipse.ui.editors"/> ! <import plugin="org.eclipse.ui.views"/> ! <import plugin="org.eclipse.ui.workbench.texteditor"/> ! <import plugin="org.eclipse.jface.text"/> ! </requires> <!-- Python editor --> ! <extension point="org.eclipse.ui.editors"> ! <editor ! name="Python Editor" ! icon="icons/sample.gif" ! extensions="py" ! contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor" ! class="org.python.pydev.editor.PyEdit" ! id="org.python.pydev.editor.PythonEditor"> ! </editor> ! </extension> ! <!-- Python nature --> ! <extension point="org.eclipse.core.resources.natures" ! id="pythonNature" ! name="Python Nature"> ! <runtime> ! <run class="org.python.pydev.plugin.PythonNature"/> ! </runtime> ! </extension> ! ! <extension point="org.eclipse.ui.projectNatureImages"> ! <image ! icon="icons/pythonNature.gif" ! natureId="org.python.pydev.pythonNature" ! id="org.python.pydev.ui.projectNatureImage"> ! </image> ! </extension> ! <!-- Python project properties --> ! <extension point="org.eclipse.ui.propertyPages"> ! <page ! objectClass="org.eclipse.core.resources.IProject" ! name="Python" ! class="org.python.pydev.ui.ProjectProperties" ! id="org.python.pydev.ui.projectProperties"> ! <filter ! name="projectNature" ! value="org.python.pydev.pythonNature"> ! </filter> ! </page> ! </extension> ! <!-- Preference page --> ! <extension ! point="org.eclipse.ui.preferencePages"> ! <page ! name="Pydev" ! class="org.python.pydev.plugin.PydevPrefs" ! id="org.python.pydev.prefs"> ! </page> ! </extension> ! <!-- Editor menus --> ! <extension ! point="org.eclipse.ui.editorActions"> ! <editorContribution ! targetID="org.python.pydev.editor.PythonEditor" ! id="org.python.pydev.editor.editorContribution"> ! <menu ! label="Source" ! path="edit" ! id="org.python.pydev.editor.actions.sourceMenu"> ! <separator ! name="editGroup"> ! </separator> ! <separator ! name="addGroup"> ! </separator> ! </menu> ! <action ! definitionId="org.python.pydev.editor.actions.firstChar" ! label="Goto first char" ! class="org.python.pydev.editor.actions.FirstCharAction" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/editGroup" ! id="org.python.pydev.editor.actions.firstChar"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.uncomment" ! label="Uncomment" ! class="org.python.pydev.editor.actions.PyUncomment" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/editGroup" ! id="org.python.pydev.editor.actions.uncomment"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.comment" ! label="Comment" ! class="org.python.pydev.editor.actions.PyComment" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/editGroup" ! id="org.python.pydev.editor.actions.comment"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.addBlockComment" ! label="Add comment block" ! class="org.python.pydev.editor.actions.PyAddBlockComment" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" ! id="org.python.pydev.editor.actions.addBlockComment"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.navigation.nextMethod" ! label="Goto next method or class" ! class="org.python.pydev.editor.actions.navigation.PyNextMethod" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" ! id="org.python.pydev.editor.actions.navigation.nextMethod"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.navigation.previousMethod" ! label="Goto previous method or class" ! class="org.python.pydev.editor.actions.navigation.PyPreviousMethod" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" ! id="org.python.pydev.editor.actions.navigation.previousMethod"> ! </action> ! </editorContribution> ! </extension> ! <!-- NOTE: EditorContext part of the targetID was deduced, that is just what Eclipse expects --> <!-- Editor popup menus--> ! <extension ! point="org.eclipse.ui.popupMenus"> ! <viewerContribution ! targetID="org.python.pydev.editor.PythonEditor.EditorContext" ! id="org.python.pydev.editor.popup"> ! <menu ! label="Source" ! id="org.python.pydev.editor.actions.editorPopup"> ! <separator ! name="editGroup"> ! </separator> ! <separator ! name="addGroup"> ! </separator> ! </menu> ! <action ! label="Uncomment" ! class="org.python.pydev.editor.actions.PyUncomment" ! menubarPath="org.python.pydev.editor.actions.editorPopup/editGroup" ! id="org.python.pydev.editor.actions.uncomment"> ! </action> ! <action ! label="Comment" ! class="org.python.pydev.editor.actions.PyComment" ! menubarPath="org.python.pydev.editor.actions.editorPopup/editGroup" ! id="org.python.pydev.editor.actions.comment"> ! </action> ! <action ! label="Add comment block" ! class="org.python.pydev.editor.actions.PyAddBlockComment" ! menubarPath="org.python.pydev.editor.actions.editorPopup/addGroup" ! id="org.python.pydev.editor.actions.addBlockComment"> ! </action> ! <action ! label="Navigate to next method / class" ! class="org.python.pydev.editor.actions.navigation.PyNextMethod" ! menubarPath="org.python.pydev.editor.actions.editorPopup/addGroup" ! id="org.python.pydev.editor.actions.navigation.nextMethod"> ! </action> ! <action ! label="Navigate to previous method / class" ! class="org.python.pydev.editor.actions.navigation.PyPreviousMethod" ! menubarPath="org.python.pydev.editor.actions.editorPopup/addGroup" ! id="org.python.pydev.editor.actions.navigation.previousMethod"> ! </action> ! </viewerContribution> ! </extension> ! <!-- associates commands with keyboard shortcuts --> <!-- Commands --> ! <extension ! point="org.eclipse.ui.commands"> ! <scope ! name="Pydev editor scope" ! parent="org.eclipse.ui.textEditorScope" ! description="Pydev commands" ! id="org.python.pydev.ui.editor.scope"> ! </scope> ! <category ! name="Pydev editor commands" ! description="Pydev editor category" ! id="org.python.pydev.ui.category.source"> ! </category> <!-- command: next method / class--> ! <command ! name="First char" ! description="Goes to the first non space char or first char of the line depending on the cursor position." ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.firstChar"> ! </command> ! <keyBinding ! string="Home" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.firstChar" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: next method / class--> ! <command ! name="Next Method or Class" ! description="Navigates to the next method or class declaration" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.navigation.nextMethod"> ! </command> ! <keyBinding ! string="Ctrl+Shift+Arrow_Down" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.navigation.nextMethod" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: previous method / class--> ! <command ! name="Previous Method or Class" ! description="Navigates to the previous method or class declaration" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.navigation.previousMethod"> ! </command> ! <keyBinding ! string="Ctrl+Shift+Arrow_Up" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.navigation.previousMethod" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: block--> ! <command ! name="Add Comment Block" ! description="Creates a python comment block" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.addBlockComment"> ! </command> ! <keyBinding ! string="Ctrl+4" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.addBlockComment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: uncomment--> ! <command ! name="Python Uncomment" ! description="Uncomments a python line (Removes # from the beggining of the line)" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.uncomment"> ! </command> ! <keyBinding ! string="Ctrl+\" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.uncomment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> ! <keyBinding ! string="Ctrl+Shift+3" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.uncomment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: comment--> ! <command ! name="Python Comment" ! description="Comments a python line (Adds # to beggining of the line)" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.comment"> ! </command> ! <keyBinding ! string="Ctrl+/" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.comment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> ! <keyBinding ! string="Ctrl+3" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.comment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> ! </extension> <!-- file type extensions for the team (CVS) --> ! <extension ! point="org.eclipse.team.core.fileTypes"> ! <fileTypes ! type="text" ! extension="py"> ! </fileTypes> ! </extension> ! <extension ! point="org.eclipse.team.core.ignore"> ! <ignore ! enabled="true" ! pattern="*.pyc"> ! </ignore> ! </extension> </plugin> --- 1,318 ---- <?xml version="1.0" encoding="UTF-8"?> <plugin ! id="org.python.pydev" ! name="Pydev - Python Development Environment" ! version="0.3.0" ! provider-name="AleksTotic" ! class="org.python.pydev.plugin.PydevPlugin"> ! <runtime> ! <library name="pydev.jar"/> ! </runtime> ! <requires> ! <import plugin="org.eclipse.core.resources"/> ! <import plugin="org.eclipse.core.runtime"/> ! <import plugin="org.eclipse.ui"/> ! <import plugin="org.eclipse.ui.editors"/> ! <import plugin="org.eclipse.ui.views"/> ! <import plugin="org.eclipse.ui.workbench.texteditor"/> ! <import plugin="org.eclipse.jface.text"/> ! <import plugin="org.eclipse.jdt.ui"/> ! </requires> <!-- Python editor --> ! <extension ! point="org.eclipse.ui.editors"> ! <editor ! name="Python Editor" ! icon="icons/python.gif" ! extensions="py" ! contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor" ! class="org.python.pydev.editor.PyEdit" ! id="org.python.pydev.editor.PythonEditor"> ! </editor> ! </extension> <!-- Python nature --> ! <extension ! id="pythonNature" ! name="Python Nature" ! point="org.eclipse.core.resources.natures"> ! <runtime> ! <run ! class="org.python.pydev.plugin.PythonNature"> ! </run> ! </runtime> ! </extension> ! <extension ! point="org.eclipse.ui.projectNatureImages"> ! <image ! icon="icons/pythonNature.gif" ! natureId="org.python.pydev.pythonNature" ! id="org.python.pydev.ui.projectNatureImage"> ! </image> ! </extension> <!-- Python project properties --> ! <extension ! point="org.eclipse.ui.propertyPages"> ! <page ! objectClass="org.eclipse.core.resources.IProject" ! name="Python" ! class="org.python.pydev.ui.ProjectProperties" ! id="org.python.pydev.ui.projectProperties"> ! <filter ! name="projectNature" ! value="org.python.pydev.pythonNature"> ! </filter> ! </page> ! </extension> <!-- Preference page --> ! <extension ! point="org.eclipse.ui.preferencePages"> ! <page ! name="Pydev" ! class="org.python.pydev.plugin.PydevPrefs" ! id="org.python.pydev.prefs"> ! </page> ! </extension> <!-- Editor menus --> ! <extension ! point="org.eclipse.ui.editorActions"> ! <editorContribution ! targetID="org.python.pydev.editor.PythonEditor" ! id="org.python.pydev.editor.editorContribution"> ! <menu ! label="Source" ! path="edit" ! id="org.python.pydev.editor.actions.sourceMenu"> ! <separator ! name="editGroup"> ! </separator> ! <separator ! name="addGroup"> ! </separator> ! </menu> ! <action ! definitionId="org.python.pydev.editor.actions.firstChar" ! label="Goto first char" ! class="org.python.pydev.editor.actions.FirstCharAction" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/editGroup" ! id="org.python.pydev.editor.actions.firstChar"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.uncomment" ! label="Uncomment" ! class="org.python.pydev.editor.actions.PyUncomment" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/editGroup" ! id="org.python.pydev.editor.actions.uncomment"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.comment" ! label="Comment" ! class="org.python.pydev.editor.actions.PyComment" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/editGroup" ! id="org.python.pydev.editor.actions.comment"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.addBlockComment" ! label="Add comment block" ! class="org.python.pydev.editor.actions.PyAddBlockComment" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" ! id="org.python.pydev.editor.actions.addBlockComment"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.navigation.nextMethod" ! label="Goto next method or class" ! class="org.python.pydev.editor.actions.navigation.PyNextMethod" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" ! id="org.python.pydev.editor.actions.navigation.nextMethod"> ! </action> ! <action ! definitionId="org.python.pydev.editor.actions.navigation.previousMethod" ! label="Goto previous method or class" ! class="org.python.pydev.editor.actions.navigation.PyPreviousMethod" ! menubarPath="org.python.pydev.editor.actions.sourceMenu/addGroup" ! id="org.python.pydev.editor.actions.navigation.previousMethod"> ! </action> ! </editorContribution> ! </extension> <!-- Editor popup menus--> ! <!-- NOTE: EditorContext part of the targetID was deduced, that is just what Eclipse expects --> ! <extension ! point="org.eclipse.ui.popupMenus"> ! <viewerContribution ! targetID="org.python.pydev.editor.PythonEditor.EditorContext" ! id="org.python.pydev.editor.popup"> ! <menu ! label="Source" ! id="org.python.pydev.editor.actions.editorPopup"> ! <separator ! name="editGroup"> ! </separator> ! <separator ! name="addGroup"> ! </separator> ! </menu> ! <action ! label="Uncomment" ! class="org.python.pydev.editor.actions.PyUncomment" ! menubarPath="org.python.pydev.editor.actions.editorPopup/editGroup" ! id="org.python.pydev.editor.actions.uncomment"> ! </action> ! <action ! label="Comment" ! class="org.python.pydev.editor.actions.PyComment" ! menubarPath="org.python.pydev.editor.actions.editorPopup/editGroup" ! id="org.python.pydev.editor.actions.comment"> ! </action> ! <action ! label="Add comment block" ! class="org.python.pydev.editor.actions.PyAddBlockComment" ! menubarPath="org.python.pydev.editor.actions.editorPopup/addGroup" ! id="org.python.pydev.editor.actions.addBlockComment"> ! </action> ! <action ! label="Navigate to next method / class" ! class="org.python.pydev.editor.actions.navigation.PyNextMethod" ! menubarPath="org.python.pydev.editor.actions.editorPopup/addGroup" ! id="org.python.pydev.editor.actions.navigation.nextMethod"> ! </action> ! <action ! label="Navigate to previous method / class" ! class="org.python.pydev.editor.actions.navigation.PyPreviousMethod" ! menubarPath="org.python.pydev.editor.actions.editorPopup/addGroup" ! id="org.python.pydev.editor.actions.navigation.previousMethod"> ! </action> ! </viewerContribution> ! </extension> <!-- Commands --> ! <!-- associates commands with keyboard shortcuts --> ! <extension ! point="org.eclipse.ui.commands"> ! <scope ! name="Pydev editor scope" ! parent="org.eclipse.ui.textEditorScope" ! description="Pydev commands" ! id="org.python.pydev.ui.editor.scope"> ! </scope> ! <category ! name="Pydev editor commands" ! description="Pydev editor category" ! id="org.python.pydev.ui.category.source"> ! </category> <!-- command: next method / class--> ! <command ! name="First char" ! description="Goes to the first non space char or first char of the line depending on the cursor position." ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.firstChar"> ! </command> ! <keyBinding ! string="Home" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.firstChar" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: next method / class--> ! <command ! name="Next Method or Class" ! description="Navigates to the next method or class declaration" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.navigation.nextMethod"> ! </command> ! <keyBinding ! string="Ctrl+Shift+Arrow_Down" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.navigation.nextMethod" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: previous method / class--> ! <command ! name="Previous Method or Class" ! description="Navigates to the previous method or class declaration" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.navigation.previousMethod"> ! </command> ! <keyBinding ! string="Ctrl+Shift+Arrow_Up" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.navigation.previousMethod" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: block--> ! <command ! name="Add Comment Block" ! description="Creates a python comment block" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.addBlockComment"> ! </command> ! <keyBinding ! string="Ctrl+4" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.addBlockComment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: uncomment--> ! <command ! name="Python Uncomment" ! description="Uncomments a python line (Removes # from the beggining of the line)" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.uncomment"> ! </command> ! <keyBinding ! string="Ctrl+\" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.uncomment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> ! <keyBinding ! string="Ctrl+Shift+3" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.uncomment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> <!-- command: comment--> ! <command ! name="Python Comment" ! description="Comments a python line (Adds # to beggining of the line)" ! category="org.python.pydev.ui.category.source" ! id="org.python.pydev.editor.actions.comment"> ! </command> ! <keyBinding ! string="Ctrl+/" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.comment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> ! <keyBinding ! string="Ctrl+3" ! scope="org.python.pydev.ui.editor.scope" ! command="org.python.pydev.editor.actions.comment" ! configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> ! </keyBinding> ! </extension> <!-- file type extensions for the team (CVS) --> ! <extension ! point="org.eclipse.team.core.fileTypes"> ! <fileTypes ! type="text" ! extension="py"> ! </fileTypes> ! </extension> ! <extension ! point="org.eclipse.team.core.ignore"> ! <ignore ! enabled="true" ! pattern="*.pyc"> ! </ignore> ! </extension> ! <!-- filter out .pyc files in the navigation view --> ! <extension ! point="org.eclipse.ui.resourceFilters"> ! <filter ! selected="True" ! pattern="*.pyc"> ! </filter> ! </extension> ! </plugin> Index: .classpath =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/.classpath,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** .classpath 12 Mar 2004 00:15:03 -0000 1.5 --- .classpath 10 Apr 2004 02:06:27 -0000 1.6 *************** *** 1,6 **** <?xml version="1.0" encoding="UTF-8"?> <classpath> ! <classpathentry kind="src" path="src/"/> ! <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> --- 1,6 ---- <?xml version="1.0" encoding="UTF-8"?> <classpath> ! <classpathentry kind="src" path="src/"/> ! <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> |
From: Aleksandar T. <at...@us...> - 2004-04-10 02:19:51
|
Update of /cvsroot/pydev/org.python.pydev/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3977/doc Added Files: python.bnf Log Message: Checking in the rest of the project --- NEW FILE: python.bnf --- identifier ::= (letter|"_") (letter | digit | "_")* letter ::= lowercase | uppercase lowercase ::= "a"..."z" uppercase ::= "A"..."Z" digit ::= "0"..."9" stringliteral ::= [stringprefix](shortstring | longstring) stringprefix ::= "r" | "u" | "ur" | "R" | "U" | "UR" | "Ur" | "uR" shortstring ::= "'" shortstringitem* "'" | '"' shortstringitem* '"' longstring ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""' shortstringitem ::= shortstringchar | escapeseq longstringitem ::= longstringchar | escapeseq shortstringchar ::= <any ASCII character except "\" or newline or the quote> longstringchar ::= <any ASCII character except "\"> escapeseq ::= "\" <any ASCII character> longinteger ::= integer ("l" | "L") integer ::= decimalinteger | octinteger | hexinteger decimalinteger ::= nonzerodigit digit* | "0" octinteger ::= "0" octdigit+ hexinteger ::= "0" ("x" | "X") hexdigit+ nonzerodigit ::= "1"..."9" octdigit ::= "0"..."7" hexdigit ::= digit | "a"..."f" | "A"..."F" floatnumber ::= pointfloat | exponentfloat pointfloat ::= [intpart] fraction | intpart "." exponentfloat ::= (intpart | pointfloat) exponent intpart ::= digit+ fraction ::= "." digit+ exponent ::= ("e" | "E") ["+" | "-"] digit+ imagnumber ::= (floatnumber | intpart) ("j" | "J") atom ::= identifier | literal | enclosure enclosure ::= parenth_form | list_display | dict_display | string_conversion literal ::= stringliteral | integer | longinteger | floatnumber | imagnumber parenth_form ::= "(" [expression_list] ")" list_display ::= "[" [listmaker] "]" listmaker ::= expression ( list_for | ( "," expression)* [","] ) list_iter ::= list_for | list_if list_for ::= "for" expression_list "in" testlist [list_iter] list_if ::= "if" test [list_iter] dict_display ::= "\{" [key_datum_list] "\}" key_datum_list ::= key_datum ("," key_datum)* [","] key_datum ::= expression ":" expression string_conversion ::= "`" expression_list "`" primary ::= atom | attributeref | subscription | slicing | call attributeref ::= primary "." identifier subscription ::= primary "[" expression_list "]" slicing ::= simple_slicing | extended_slicing simple_slicing ::= primary "[" short_slice "]" extended_slicing ::= primary "[" slice_list "]" slice_list ::= slice_item ("," slice_item)* [","] slice_item ::= expression | proper_slice | ellipsis proper_slice ::= short_slice | long_slice short_slice ::= [lower_bound] ":" [upper_bound] long_slice ::= short_slice ":" [stride] lower_bound ::= expression upper_bound ::= expression stride ::= expression ellipsis ::= "..." call ::= primary "(" [argument_list [","]] ")" argument_list ::= positional_arguments ["," keyword_arguments ["," "*" expression ["," "**" expression]]] | keyword_arguments ["," "*" expression ["," "**" expression]] | "*" expression ["," "**" expression] | "**" expression positional_arguments ::= expression ("," expression)* keyword_arguments ::= keyword_item ("," keyword_item)* keyword_item ::= identifier "=" expression power ::= primary ["**" u_expr] u_expr ::= power | "-" u_expr | "+" u_expr | "\~" u_expr m_expr ::= u_expr | m_expr "*" u_expr | m_expr "/" u_expr | m_expr "\%" u_expr a_expr ::= m_expr | aexpr "+" m_expr | aexpr "-" m_expr shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr and_expr ::= shift_expr | and_expr "\;SPMamp;" shift_expr xor_expr ::= and_expr | xor_expr "\textasciicircum" and_expr or_expr ::= xor_expr | or_expr "|" xor_expr comparison ::= or_expr ( comp_operator or_expr )* comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "<>" | "!=" | "is" ["not"] | ["not"] "in" expression ::= or_test | lambda_form or_test ::= and_test | or_test "or" and_test and_test ::= not_test | and_test "and" not_test not_test ::= comparison | "not" not_test # XXX Had to fix lambda_form ::= "lambda" [parameter_list] expression expression_list ::= expression ( "," expression )* [","] simple_stmt ::= expression_stmt | assert_stmt | assignment_stmt | augmented_assignment_stmt | pass_stmt | del_stmt | print_stmt | return_stmt | yield_stmt | raise_stmt | break_stmt | continue_stmt | import_stmt | global_stmt | exec_stmt expression_stmt ::= expression_list assert_statement ::= "assert" expression ["," expression] assignment_stmt ::= (target_list "=")+ expression_list target_list ::= target ("," target)* [","] target ::= identifier | "(" target_list ")" | "[" target_list "]" | attributeref | subscription | slicing augmented_assignment_stmt ::= target augop expression_list augop ::= "+=" | "-=" | "*=" | "/=" | "\%=" | "**=" | ">>=" | "<<=" | "\&=" | "\textasciicircum=" | "|=" pass_stmt ::= "pass" del_stmt ::= "del" target_list print_stmt ::= "print" ( \optionalexpression ("," expression)* \optional"," | ">\code>" expression \optional("," expression)+ \optional"," ) return_stmt ::= "return" [expression_list] yield_stmt ::= "yield" expression_list raise_stmt ::= "raise" [expression ["," expression ["," expression]]] break_stmt ::= "break" continue_stmt ::= "continue" import_stmt ::= "import" module ["as" name] ( "," module ["as" name] )* | "from" module "import" identifier ["as" name] ( "," identifier ["as" name] )* | "from" module "import" "*" module ::= (identifier ".")* identifier global_stmt ::= "global" identifier ("," identifier)* exec_stmt ::= "exec" expression ["in" expression ["," expression]] compound_stmt ::= if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT statement ::= stmt_list NEWLINE | compound_stmt stmt_list ::= simple_stmt (";" simple_stmt)* [";"] if_stmt ::= "if" expression ":" suite ( "elif" expression ":" suite )* ["else" ":" suite] while_stmt ::= "while" expression ":" suite ["else" ":" suite] for_stmt ::= "for" target_list "in" expression_list ":" suite ["else" ":" suite] try_stmt ::= try_exc_stmt | try_fin_stmt try_exc_stmt ::= "try" ":" suite ("except" [expression ["," target]] ":" suite)+ ["else" ":" suite] try_fin_stmt ::= "try" ":" suite "finally" ":" suite funcdef ::= "def" funcname "(" [parameter_list] ")" ":" suite # XXX Fixed this parameter_list ::= (defparameter ",")* ("*" identifier ["," "**" identifier] | "**" identifier | defparameter [","]) defparameter ::= parameter ["=" expression] sublist ::= parameter ("," parameter)* [","] parameter ::= identifier | "(" sublist ")" funcname ::= identifier classdef ::= "class" classname [inheritance] ":" suite inheritance ::= "(" [expression_list] ")" classname ::= identifier file_input ::= (NEWLINE | statement)* interactive_input ::= [stmt_list] NEWLINE | compound_stmt NEWLINE eval_input ::= expression_list NEWLINE* input_input ::= expression_list NEWLINE |
From: Aleksandar T. <at...@us...> - 2004-04-10 02:01:41
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv649/src/org/python/pydev/editor Modified Files: PyEdit.java package.html Added Files: Hyperlink.java Log Message: Huge code rewrite. I've implemented a Python model. Model is based in AST tree, but should be simpler to use. No more visitor pattern. OutlineView and Navigation actions have been reworked to use new model, instead of traversing AST. Added Hyperlinking capability, but goto is not implemetned yet. Index: package.html =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/package.html,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** package.html 30 Mar 2004 01:03:37 -0000 1.2 --- package.html 10 Apr 2004 01:48:14 -0000 1.3 *************** *** 37,43 **** Find an innermost vocabulary containing current selection. Then quiz it for whatever is needed - - Questions: - can vocabularies be overlapping? That would make things hard. </pre> --- 37,40 ---- Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PyEdit.java 2 Apr 2004 18:17:44 -0000 1.10 --- PyEdit.java 10 Apr 2004 01:48:14 -0000 1.11 *************** *** 6,9 **** --- 6,12 ---- package org.python.pydev.editor; + import java.util.ArrayList; + import java.util.Iterator; + import org.eclipse.core.internal.resources.MarkerAttributeMap; import org.eclipse.core.resources.IFile; *************** *** 12,15 **** --- 15,19 ---- import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Preferences; + import org.eclipse.jface.text.Assert; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; *************** *** 24,28 **** import org.eclipse.ui.editors.text.TextEditor; import org.eclipse.ui.texteditor.DefaultRangeIndicator; - import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.MarkerUtilities; --- 28,31 ---- *************** *** 33,41 **** import org.python.parser.Token; import org.python.parser.TokenMgrError; ! import org.python.pydev.plugin.PydevPlugin; ! import org.python.pydev.plugin.PydevPrefs; ! import org.python.pydev.editor.dictionary.PyDEditorItem; import org.python.pydev.outline.PyOutlinePage; - import org.python.pydev.outline.SelectionPosition; import org.python.pydev.parser.IParserListener; import org.python.pydev.parser.PyParser; --- 36,45 ---- import org.python.parser.Token; import org.python.parser.TokenMgrError; ! import org.python.pydev.plugin.*; ! import org.python.pydev.editor.model.AbstractNode; ! import org.python.pydev.editor.model.IModelListener; ! import org.python.pydev.editor.model.Location; ! import org.python.pydev.editor.model.ModelMaker; import org.python.pydev.outline.PyOutlinePage; import org.python.pydev.parser.IParserListener; import org.python.pydev.parser.PyParser; *************** *** 71,79 **** /** need to hold onto it to support indentPrefix change through preferences */ PyEditConfiguration editConfiguration; ! /** top-level dictionary */ ! PyDEditorItem dictionaryRoot; ! public PyEdit() { super(); colorCache = new ColorCache(PydevPrefs.getPreferences()); if (getDocumentProvider() == null) { --- 75,88 ---- /** 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) { *************** *** 147,152 **** parser.setDocument(getDocumentProvider().getDocument(input)); - dictionaryRoot = new PyDEditorItem(parser); - // listen to changes in TAB_WIDTH preference prefListener = new Preferences.IPropertyChangeListener() { --- 156,159 ---- *************** *** 194,197 **** --- 201,206 ---- // when Ctrl+Spacebar is pressed setActionActivationCode(CONTENTASSIST_PROPOSAL_ID,' ', -1, SWT.CTRL); + + enableBrowserLikeLinks(); } *************** *** 205,208 **** --- 214,221 ---- } + public AbstractNode getPythonModel() { + return pythonModel; + } + /** * @return an outline view *************** *** 217,221 **** /** * implementation copied from ! * @see org.eclipse.ui.externaltools.internal.ant.editor.PlantyEditor#setSelection */ public void setSelection(int offset, int length) { --- 230,234 ---- /** * implementation copied from ! * org.eclipse.ui.externaltools.internal.ant.editor.PlantyEditor#setSelection */ public void setSelection(int offset, int length) { *************** *** 226,251 **** /** ! * Reveals the selection */ ! public void setSelection(SelectionPosition newSel) { ! if (newSel.r != null) { ! setSelection(newSel.r.getOffset(), newSel.r.getLength()); ! } ! else { ! IDocumentProvider provider = getDocumentProvider(); ! IDocument document = provider.getDocument(getEditorInput()); ! try { ! IRegion r = document.getLineInformation(newSel.line - 1); ! // if selecting the whole line, just use the information ! if (newSel.column == SelectionPosition.WHOLE_LINE) { ! newSel.column = 0; ! newSel.length = r.getLength(); ! } ! setSelection(r.getOffset() + newSel.column, newSel.length); ! } catch (BadLocationException e) { ! e.printStackTrace(); } } } /** --- 239,271 ---- /** ! * Selects & reveals the model node */ ! public void revealModelNode(AbstractNode node) { ! if (node == null) ! return; // nothing to see here ! boolean wholeLine = false; ! // if (node instanceof ImportNode) ! // wholeLine = true; ! 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); } + /** *************** *** 263,267 **** } catch (CoreException e) { // What bad can come from removing markers? Ignore this exception ! e.printStackTrace(); } } --- 283,297 ---- } 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(getEditorInput()); ! int lastLine = document.getNumberOfLines(); ! IRegion r; ! try { ! r = document.getLineInformation(lastLine-1); ! pythonModel = ModelMaker.createModel(root, lastLine , r.getLength()); ! fireModelChanged(pythonModel); ! } catch (BadLocationException e1) { ! PydevPlugin.log(IStatus.WARNING, "Unexpected error getting document length. No model!", e1); } } *************** *** 333,337 **** --- 363,411 ---- } } + + private void enableBrowserLikeLinks() { + if (fMouseListener == null) { + fMouseListener= new Hyperlink(getSourceViewer(), this); + 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); + } + } + } --- NEW FILE: Hyperlink.java --- /* * Author: atotic * Created on Mar 31, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor; import java.util.StringTokenizer; import org.eclipse.core.runtime.IStatus; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jface.action.Action; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocumentListener; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextInputListener; import org.eclipse.jface.text.ITextViewerExtension2; import org.eclipse.jface.text.ITextViewerExtension3; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.python.pydev.editor.model.AbstractNode; import org.python.pydev.editor.model.ModelUtils; import org.python.pydev.plugin.PydevPlugin; /** * Hyperlink is a "Mouse highlight on ctrl". * The code here has been copied from JavaEditor::MouseClick. * I've just modified Python-specific code. */ public class Hyperlink implements KeyListener, MouseListener, MouseMoveListener, FocusListener, PaintListener, IPropertyChangeListener, IDocumentListener, ITextInputListener { /** The session is active. */ private boolean fActive; /** The currently active style range. */ private IRegion fActiveRegion; /** The currently active style range as position. */ private Position fRememberedPosition; /** The hand cursor. */ private Cursor fCursor; /** The link color. */ private Color fColor; /** The key modifier mask. */ private int fKeyModifierMask; /************ * ALEKS ADDITIONS */ private ISourceViewer fSourceViewer; private PyEdit fEditor; public Hyperlink(ISourceViewer sourceViewer, PyEdit editor) { fSourceViewer = sourceViewer; fEditor = editor; } private ISourceViewer getSourceViewer() { return fSourceViewer; } IPreferenceStore fPrefStore = null; public IPreferenceStore getPreferenceStore() { if (fPrefStore == null) fPrefStore = JavaPlugin.getDefault().getPreferenceStore(); return fPrefStore; } public void deactivate() { deactivate(false); } public void deactivate(boolean redrawAll) { if (!fActive) return; repairRepresentation(redrawAll); fActive= false; } public void install() { ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return; StyledText text= sourceViewer.getTextWidget(); if (text == null || text.isDisposed()) return; updateColor(sourceViewer); sourceViewer.addTextInputListener(this); IDocument document= sourceViewer.getDocument(); if (document != null) document.addDocumentListener(this); text.addKeyListener(this); text.addMouseListener(this); text.addMouseMoveListener(this); text.addFocusListener(this); text.addPaintListener(this); updateKeyModifierMask(); IPreferenceStore preferenceStore= getPreferenceStore(); preferenceStore.addPropertyChangeListener(this); } private void updateKeyModifierMask() { String modifiers= getPreferenceStore().getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK); fKeyModifierMask= computeStateMask(modifiers); if (fKeyModifierMask == -1) { // Fallback to stored state mask fKeyModifierMask= getPreferenceStore().getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK); }; } private int computeStateMask(String modifiers) { if (modifiers == null) return -1; if (modifiers.length() == 0) return SWT.NONE; int stateMask= 0; StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$ while (modifierTokenizer.hasMoreTokens()) { int modifier= EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken()); if (modifier == 0 || (stateMask & modifier) == modifier) return -1; stateMask= stateMask | modifier; } return stateMask; } public void uninstall() { if (fColor != null) { fColor.dispose(); fColor= null; } if (fCursor != null) { fCursor.dispose(); fCursor= null; } ISourceViewer sourceViewer= getSourceViewer(); if (sourceViewer == null) return; sourceViewer.removeTextInputListener(this); IDocument document= sourceViewer.getDocument(); if (document != null) document.removeDocumentListener(this); IPreferenceStore preferenceStore= getPreferenceStore(); if (preferenceStore != null) preferenceStore.removePropertyChangeListener(this); StyledText text= sourceViewer.getTextWidget(); if (text == null || text.isDisposed()) return; text.removeKeyListener(this); text.removeMouseListener(this); text.removeMouseMoveListener(this); text.removeFocusListener(this); text.removePaintListener(this); } /* * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(PreferenceConstants.EDITOR_LINK_COLOR)) { ISourceViewer viewer= getSourceViewer(); if (viewer != null) updateColor(viewer); } else if (event.getProperty().equals(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) { updateKeyModifierMask(); } } private void updateColor(ISourceViewer viewer) { if (fColor != null) fColor.dispose(); StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return; Display display= text.getDisplay(); fColor= createColor(getPreferenceStore(), PreferenceConstants.EDITOR_LINK_COLOR, display); } /** * Creates a color from the information stored in the given preference store. * Returns <code>null</code> if there is no such information available. */ private Color createColor(IPreferenceStore store, String key, Display display) { RGB rgb= null; if (store.contains(key)) { if (store.isDefault(key)) rgb= PreferenceConverter.getDefaultColor(store, key); else rgb= PreferenceConverter.getColor(store, key); if (rgb != null) return new Color(display, rgb); } return null; } private void repairRepresentation() { repairRepresentation(false); } private void repairRepresentation(boolean redrawAll) { if (fActiveRegion == null) return; ISourceViewer viewer= getSourceViewer(); if (viewer != null) { resetCursor(viewer); int offset= fActiveRegion.getOffset(); int length= fActiveRegion.getLength(); // remove style if (!redrawAll && viewer instanceof ITextViewerExtension2) ((ITextViewerExtension2) viewer).invalidateTextPresentation(offset, length); else viewer.invalidateTextPresentation(); // remove underline if (viewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) viewer; offset= extension.modelOffset2WidgetOffset(offset); } else { offset -= viewer.getVisibleRegion().getOffset(); } StyledText text= viewer.getTextWidget(); try { text.redrawRange(offset, length, true); } catch (IllegalArgumentException x) { PydevPlugin.log(IStatus.ERROR, "Unexpected error in Hyperlink code", x); } } fActiveRegion= null; } // will eventually be replaced by a method provided by jdt.core private IRegion selectWord(IDocument document, int anchor) { try { int offset= anchor; char c; while (offset >= 0) { c= document.getChar(offset); if (!Character.isJavaIdentifierPart(c)) break; --offset; } int start= offset; offset= anchor; int length= document.getLength(); while (offset < length) { c= document.getChar(offset); if (!Character.isJavaIdentifierPart(c)) break; ++offset; } int end= offset; if (start == end) return new Region(start, 0); else return new Region(start + 1, end - start - 1); } catch (BadLocationException x) { return null; } } IRegion getCurrentTextRegion(ISourceViewer viewer) { int offset= getCurrentTextOffset(viewer); if (offset == -1) return null; AbstractNode node = ModelUtils.getElement(fEditor.getPythonModel(), offset, viewer.getDocument(), AbstractNode.PROP_CLICKABLE); if (node == null) return null; // try { // // IJavaElement[] elements= null; // synchronized (input) { // elements= ((ICodeAssist) input).codeSelect(offset, 0); // } // // if (elements == null || elements.length == 0) // return null; // return selectWord(viewer.getDocument(), offset); return selectWord(viewer.getDocument(), offset); // } catch (JavaModelException e) { // return null; // } } private int getCurrentTextOffset(ISourceViewer viewer) { try { StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return -1; Display display= text.getDisplay(); Point absolutePosition= display.getCursorLocation(); Point relativePosition= text.toControl(absolutePosition); int widgetOffset= text.getOffsetAtLocation(relativePosition); if (viewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) viewer; return extension.widgetOffset2ModelOffset(widgetOffset); } else { return widgetOffset + viewer.getVisibleRegion().getOffset(); } } catch (IllegalArgumentException e) { return -1; } } private void highlightRegion(ISourceViewer viewer, IRegion region) { if (region.equals(fActiveRegion)) return; repairRepresentation(); StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return; // highlight region int offset= 0; int length= 0; if (viewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) viewer; IRegion widgetRange= extension.modelRange2WidgetRange(region); if (widgetRange == null) return; offset= widgetRange.getOffset(); length= widgetRange.getLength(); } else { offset= region.getOffset() - viewer.getVisibleRegion().getOffset(); length= region.getLength(); } StyleRange oldStyleRange= text.getStyleRangeAtOffset(offset); Color foregroundColor= fColor; Color backgroundColor= oldStyleRange == null ? text.getBackground() : oldStyleRange.background; StyleRange styleRange= new StyleRange(offset, length, foregroundColor, backgroundColor); text.setStyleRange(styleRange); // underline text.redrawRange(offset, length, true); fActiveRegion= region; } private void activateCursor(ISourceViewer viewer) { StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return; Display display= text.getDisplay(); if (fCursor == null) fCursor= new Cursor(display, SWT.CURSOR_HAND); text.setCursor(fCursor); } private void resetCursor(ISourceViewer viewer) { StyledText text= viewer.getTextWidget(); if (text != null && !text.isDisposed()) text.setCursor(null); if (fCursor != null) { fCursor.dispose(); fCursor= null; } } /* * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent) */ public void keyPressed(KeyEvent event) { if (fActive) { deactivate(); return; } if (event.keyCode != fKeyModifierMask) { deactivate(); return; } fActive= true; // removed for #25871 // // ISourceViewer viewer= getSourceViewer(); // if (viewer == null) // return; // // IRegion region= getCurrentTextRegion(viewer); // if (region == null) // return; // // highlightRegion(viewer, region); // activateCursor(viewer); } /* * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent) */ public void keyReleased(KeyEvent event) { if (!fActive) return; deactivate(); } /* * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) */ public void mouseDoubleClick(MouseEvent e) {} /* * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) */ public void mouseDown(MouseEvent event) { if (!fActive) return; if (event.stateMask != fKeyModifierMask) { deactivate(); return; } if (event.button != 1) { deactivate(); return; } } /* * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) */ public void mouseUp(MouseEvent e) { if (!fActive) return; if (e.button != 1) { deactivate(); return; } boolean wasActive= fCursor != null; deactivate(); if (wasActive) { System.out.println("Clicked for action"); // IAction action= getAction("OpenEditor"); //$NON-NLS-1$ // if (action != null) // action.run(); } } /* * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent) */ public void mouseMove(MouseEvent event) { if (event.widget instanceof Control && !((Control) event.widget).isFocusControl()) { deactivate(); return; } if (!fActive) { if (event.stateMask != fKeyModifierMask) return; // modifier was already pressed fActive= true; } ISourceViewer viewer= getSourceViewer(); if (viewer == null) { deactivate(); return; } StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) { deactivate(); return; } if ((event.stateMask & SWT.BUTTON1) != 0 && text.getSelectionCount() != 0) { deactivate(); return; } IRegion region= getCurrentTextRegion(viewer); if (region == null || region.getLength() == 0) { repairRepresentation(); return; } highlightRegion(viewer, region); activateCursor(viewer); } /* * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent) */ public void focusGained(FocusEvent e) {} /* * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent) */ public void focusLost(FocusEvent event) { deactivate(); } /* * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) */ public void documentAboutToBeChanged(DocumentEvent event) { if (fActive && fActiveRegion != null) { fRememberedPosition= new Position(fActiveRegion.getOffset(), fActiveRegion.getLength()); try { event.getDocument().addPosition(fRememberedPosition); } catch (BadLocationException x) { fRememberedPosition= null; } } } /* * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) */ public void documentChanged(DocumentEvent event) { if (fRememberedPosition != null && !fRememberedPosition.isDeleted()) { event.getDocument().removePosition(fRememberedPosition); fActiveRegion= new Region(fRememberedPosition.getOffset(), fRememberedPosition.getLength()); } fRememberedPosition= null; ISourceViewer viewer= getSourceViewer(); if (viewer != null) { StyledText widget= viewer.getTextWidget(); if (widget != null && !widget.isDisposed()) { widget.getDisplay().asyncExec(new Runnable() { public void run() { deactivate(); } }); } } } /* * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) */ public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { if (oldInput == null) return; deactivate(); oldInput.removeDocumentListener(this); } /* * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) */ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { if (newInput == null) return; newInput.addDocumentListener(this); } /* * @see PaintListener#paintControl(PaintEvent) */ public void paintControl(PaintEvent event) { if (fActiveRegion == null) return; ISourceViewer viewer= getSourceViewer(); if (viewer == null) return; StyledText text= viewer.getTextWidget(); if (text == null || text.isDisposed()) return; int offset= 0; int length= 0; if (viewer instanceof ITextViewerExtension3) { ITextViewerExtension3 extension= (ITextViewerExtension3) viewer; IRegion widgetRange= extension.modelRange2WidgetRange(new Region(offset, length)); if (widgetRange == null) return; offset= widgetRange.getOffset(); length= widgetRange.getLength(); } else { IRegion region= viewer.getVisibleRegion(); if (!includes(region, fActiveRegion)) return; offset= fActiveRegion.getOffset() - region.getOffset(); length= fActiveRegion.getLength(); } // support for bidi Point minLocation= getMinimumLocation(text, offset, length); Point maxLocation= getMaximumLocation(text, offset, length); int x1= minLocation.x; int x2= minLocation.x + maxLocation.x - minLocation.x - 1; int y= minLocation.y + text.getLineHeight() - 1; GC gc= event.gc; if (fColor != null && !fColor.isDisposed()) gc.setForeground(fColor); gc.drawLine(x1, y, x2, y); } private boolean includes(IRegion region, IRegion position) { return position.getOffset() >= region.getOffset() && position.getOffset() + position.getLength() <= region.getOffset() + region.getLength(); } private Point getMinimumLocation(StyledText text, int offset, int length) { Point minLocation= new Point(Integer.MAX_VALUE, Integer.MAX_VALUE); for (int i= 0; i <= length; i++) { Point location= text.getLocationAtOffset(offset + i); if (location.x < minLocation.x) minLocation.x= location.x; if (location.y < minLocation.y) minLocation.y= location.y; } return minLocation; } private Point getMaximumLocation(StyledText text, int offset, int length) { Point maxLocation= new Point(Integer.MIN_VALUE, Integer.MIN_VALUE); for (int i= 0; i <= length; i++) { Point location= text.getLocationAtOffset(offset + i); if (location.x > maxLocation.x) maxLocation.x= location.x; if (location.y > maxLocation.y) maxLocation.y= location.y; } return maxLocation; } } class EditorUtility { /** * Maps the localized modifier name to a code in the same * manner as #findModifier. * * @return the SWT modifier bit, or <code>0</code> if no match was found * @see findModifier * @since 2.1.1 */ public static int findLocalizedModifier(String token) { if (token == null) return 0; if (token.equalsIgnoreCase(Action.findModifierString(SWT.CTRL))) return SWT.CTRL; if (token.equalsIgnoreCase(Action.findModifierString(SWT.SHIFT))) return SWT.SHIFT; if (token.equalsIgnoreCase(Action.findModifierString(SWT.ALT))) return SWT.ALT; if (token.equalsIgnoreCase(Action.findModifierString(SWT.COMMAND))) return SWT.COMMAND; return 0; } } |
From: Aleksandar T. <at...@us...> - 2004-04-10 02:01:40
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv649/src/org/python/pydev/editor/actions Modified Files: PyAddBlockComment.java PyAction.java Log Message: Huge code rewrite. I've implemented a Python model. Model is based in AST tree, but should be simpler to use. No more visitor pattern. OutlineView and Navigation actions have been reworked to use new model, instead of traversing AST. Added Hyperlinking capability, but goto is not implemetned yet. Index: PyAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyAction.java 5 Mar 2004 22:04:44 -0000 1.3 --- PyAction.java 10 Apr 2004 01:48:14 -0000 1.4 *************** *** 81,86 **** /** ! * This function returns the python editor. ! * @return */ protected PyEdit getPyEdit() { --- 81,85 ---- /** ! * @return python editor. */ protected PyEdit getPyEdit() { Index: PyAddBlockComment.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAddBlockComment.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyAddBlockComment.java 5 Mar 2004 22:04:44 -0000 1.2 --- PyAddBlockComment.java 10 Apr 2004 01:48:14 -0000 1.3 *************** *** 21,24 **** --- 21,25 ---- /** + * Hi. * Insert a comment block. * #===... |
From: Aleksandar T. <at...@us...> - 2004-04-10 02:01:39
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv649/src/org/python/pydev/outline Modified Files: ParsedModel.java ParsedItem.java ParsedLabelProvider.java PyOutlinePage.java IOutlineModel.java RawPartitionModel.java Removed Files: SelectionPosition.java Log Message: Huge code rewrite. I've implemented a Python model. Model is based in AST tree, but should be simpler to use. No more visitor pattern. OutlineView and Navigation actions have been reworked to use new model, instead of traversing AST. Added Hyperlinking capability, but goto is not implemetned yet. Index: PyOutlinePage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/PyOutlinePage.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyOutlinePage.java 5 Mar 2004 22:07:04 -0000 1.6 --- PyOutlinePage.java 10 Apr 2004 01:48:12 -0000 1.7 *************** *** 25,28 **** --- 25,29 ---- import org.eclipse.ui.views.contentoutline.ContentOutlinePage; import org.python.pydev.editor.PyEdit; + import org.python.pydev.editor.model.AbstractNode; import org.python.pydev.ui.ImageCache; import org.python.pydev.ui.UIConstants; *************** *** 109,113 **** */ public ParsedModel getParsedModel() { ! return new ParsedModel(this, editorView.getParser()); } --- 110,114 ---- */ public ParsedModel getParsedModel() { ! return new ParsedModel(this, editorView); } *************** *** 205,212 **** public void selectionChanged(SelectionChangedEvent event) { StructuredSelection sel = (StructuredSelection)tree.getSelection(); ! SelectionPosition newSel = model.getSelectionPosition(sel); ! if (newSel == null) ! return; ! editorView.setSelection(newSel); } }; --- 206,211 ---- public void selectionChanged(SelectionChangedEvent event) { StructuredSelection sel = (StructuredSelection)tree.getSelection(); ! AbstractNode node = model.getSelectionPosition(sel); ! editorView.revealModelNode(node); } }; --- SelectionPosition.java DELETED --- Index: ParsedItem.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/ParsedItem.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ParsedItem.java 5 Mar 2004 22:04:44 -0000 1.6 --- ParsedItem.java 10 Apr 2004 01:48:12 -0000 1.7 *************** *** 7,104 **** import java.util.ArrayList; - import org.python.parser.SimpleNode; - import org.python.parser.ast.ClassDef; - import org.python.parser.ast.Compare; - import org.python.parser.ast.FunctionDef; - import org.python.parser.ast.If; - import org.python.parser.ast.Import; import org.python.parser.ast.ImportFrom; - import org.python.parser.ast.Name; - import org.python.parser.ast.Str; - import org.python.parser.ast.VisitorBase; import org.python.parser.ast.aliasType; /** * ParsedModel is composed of ParsedItems. * ! * <p>The model gets an AST (Abstract Syntax Tree) from jython's parser ! * and this is then converted to a tree of ParsedItems */ public class ParsedItem { ParsedItem parent; ParsedItem[] children = null; // array of modTypes ! SimpleNode token; // parser token that this node represents ! ! /** ! * Traverses the parsed tree. ! * ! * <p>Fills the array list with the items we are interested in. ! */ ! static class Visitor extends VisitorBase { ! ! ArrayList fill; ! ParsedItem parent; ! ! boolean hasImports; ! ParsedItem imports; ! ! public Visitor(ParsedItem parent, ArrayList fill) { ! this.parent = parent; ! this.fill = fill; ! } ! ! protected Object unhandled_node(SimpleNode node) throws Exception { ! return null; ! } ! ! public void traverse(SimpleNode node) throws Exception {} ! ! public Object visitClassDef(ClassDef node) throws Exception { ! fill.add(new ParsedItem(parent, node)); ! return null; ! } ! ! public Object visitImport(Import node) throws Exception { ! fill.add(new ParsedItem(parent, node)); ! return null; ! } ! ! public Object visitImportFrom(ImportFrom node) throws Exception { ! fill.add(new ParsedItem(parent, node)); ! return null; ! } ! ! public Object visitFunctionDef(FunctionDef node) throws Exception { ! fill.add(new ParsedItem(parent, node)); ! return null; ! } ! ! // On if statements, we are looking to tag if __name__ == 'main' idiom ! public Object visitIf(If node) throws Exception { ! if (node.test instanceof Compare) { ! Compare compareNode = (Compare)node.test; ! // handcrafted structure walking ! if (compareNode.left instanceof Name ! && ((Name)compareNode.left).id.equals("__name__") ! && compareNode.ops != null ! && compareNode.ops.length == 1 ! && compareNode.ops[0] == Compare.Eq) ! if ( true ! && compareNode.comparators != null ! && compareNode.comparators.length == 1 ! && compareNode.comparators[0] instanceof Str ! && ((Str)compareNode.comparators[0]).s.equals("__main__")) ! fill.add(new ParsedItem(parent, node)); ! } ! return super.visitIf(node); ! } ! } ! public ParsedItem(ParsedItem parent, SimpleNode token) { this.parent = parent; this.token = token; } ! public SimpleNode getToken() { return token; } --- 7,32 ---- import java.util.ArrayList; + import java.util.Iterator; import org.python.parser.ast.ImportFrom; import org.python.parser.ast.aliasType; + import org.python.pydev.editor.model.*; /** * ParsedModel is composed of ParsedItems. * ! * <p>The model traverses Python model to get a tree of items for display. ! * We have to deal with token */ public class ParsedItem { ParsedItem parent; ParsedItem[] children = null; // array of modTypes ! AbstractNode token; // parser token that this node represents. Can be null! ! public ParsedItem(ParsedItem parent, AbstractNode token) { this.parent = parent; this.token = token; } ! public AbstractNode getToken() { return token; } *************** *** 108,143 **** } ! /* ! * @return where in the document is this item located ! */ ! public SelectionPosition getPosition() { ! return getPosition(token); ! } ! ! /* ! * @return where in the document is this item located */ ! public static SelectionPosition getPosition(SimpleNode token) { ! int startOffset = 0; ! boolean wholeLine = false; ! if (token instanceof ClassDef) { ! startOffset = 5; ! } ! else if (token instanceof FunctionDef) { ! startOffset = 3; ! } ! else if (token instanceof Import) { ! startOffset = -1; ! } ! else { ! // for others, just select the whole line, since the syntax tree -> document position calculation can be painful ! wholeLine = true; } - - SelectionPosition position = new SelectionPosition(token.beginLine, token.beginColumn+startOffset, toString(token).length()); - - if (wholeLine) - position.column = SelectionPosition.WHOLE_LINE; - return position; } --- 36,59 ---- } ! /** ! * Traverses AST model, and puts its children into our tree */ ! private void adoptChildrenOfNode(AbstractNode node, ArrayList children) { ! if (node == null) ! return; ! Iterator i = node.getChildren().iterator(); ! while (i.hasNext()) { ! AbstractNode child = (AbstractNode)i.next(); ! // these are the nodes we display ! if (child instanceof ClassNode || ! child instanceof FunctionNode || ! child instanceof ImportNode || ! child instanceof ImportFromNode || ! child instanceof NameEqualsMainNode) ! children.add(new ParsedItem(this, child)); ! if (! (child instanceof ClassNode) && !(child instanceof FunctionNode)) ! // functions & class will have their own children, do not traverse now ! adoptChildrenOfNode(child, children); } } *************** *** 145,158 **** if (children == null) { ArrayList allMyChildren = new ArrayList(); ! Visitor v = new Visitor(this, allMyChildren); ! try { ! if (token != null) ! token.traverse(v); // traversal fills in the children ! children = new ParsedItem[allMyChildren.size()]; ! for (int i=0; i<allMyChildren.size();i++) ! children[i] = (ParsedItem)allMyChildren.get(i); ! } catch (Exception e) { ! e.printStackTrace(); ! } } return children; --- 61,68 ---- if (children == null) { ArrayList allMyChildren = new ArrayList(); ! adoptChildrenOfNode(token, allMyChildren); ! children = new ParsedItem[allMyChildren.size()]; ! for (int i=0; i<allMyChildren.size();i++) ! children[i] = (ParsedItem)allMyChildren.get(i); } return children; *************** *** 164,176 **** } ! public static String toString(SimpleNode token) { ! if (token instanceof ClassDef) { ! return ((ClassDef)token).name; } ! else if (token instanceof FunctionDef) { ! return ((FunctionDef)token).name; } ! else if (token instanceof Import) { ! aliasType[] imports = ((Import)token).names; StringBuffer retVal = new StringBuffer(); for (int i=0; i<imports.length; i++) { --- 74,88 ---- } ! public static String toString(AbstractNode token) { ! if (token == null) ! return "null"; ! if (token instanceof ClassNode) { ! return ((ClassNode)token).astNode.name; } ! else if (token instanceof FunctionNode) { ! return ((FunctionNode)token).astNode.name; } ! else if (token instanceof ImportNode) { ! aliasType[] imports = ((ImportNode)token).astNode.names; StringBuffer retVal = new StringBuffer(); for (int i=0; i<imports.length; i++) { *************** *** 181,187 **** return retVal.toString(); } ! else if (token instanceof ImportFrom) { // from wxPython.wx import * ! ImportFrom importToken = (ImportFrom)token; StringBuffer modules = new StringBuffer(); for (int i=0; i<importToken.names.length;i++) { --- 93,99 ---- return retVal.toString(); } ! else if (token instanceof ImportFromNode) { // from wxPython.wx import * ! ImportFrom importToken = ((ImportFromNode)token).astNode; StringBuffer modules = new StringBuffer(); for (int i=0; i<importToken.names.length;i++) { *************** *** 195,199 **** return importToken.module + ".(" + modules.toString() + ")"; } ! else if (token instanceof If) { return "__name__ == main"; } --- 107,111 ---- return importToken.module + ".(" + modules.toString() + ")"; } ! else if (token instanceof NameEqualsMainNode) { return "__name__ == main"; } *************** *** 209,221 **** public int getClassRanking() { int rank = 0; ! if (token instanceof Import) { rank = 0; ! } else if (token instanceof ImportFrom) { rank = 1; ! } else if (token instanceof ClassDef) { rank = 2; ! } else if (token instanceof FunctionDef) { rank = 3; ! } else if (token instanceof If) { rank = 10; } --- 121,133 ---- public int getClassRanking() { int rank = 0; ! if (token instanceof ImportFromNode) { rank = 0; ! } else if (token instanceof ImportNode) { rank = 1; ! } else if (token instanceof ClassNode) { rank = 2; ! } else if (token instanceof FunctionNode) { rank = 3; ! } else if (token instanceof NameEqualsMainNode) { rank = 10; } Index: ParsedLabelProvider.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/ParsedLabelProvider.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ParsedLabelProvider.java 17 Aug 2003 04:44:22 -0000 1.1 --- ParsedLabelProvider.java 10 Apr 2004 01:48:12 -0000 1.2 *************** *** 8,17 **** import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; ! import org.python.parser.SimpleNode; ! import org.python.parser.ast.ClassDef; ! import org.python.parser.ast.FunctionDef; ! import org.python.parser.ast.If; ! import org.python.parser.ast.Import; ! import org.python.parser.ast.ImportFrom; import org.python.pydev.ui.ImageCache; import org.python.pydev.ui.UIConstants; --- 8,12 ---- import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.swt.graphics.Image; ! import org.python.pydev.editor.model.*; import org.python.pydev.ui.ImageCache; import org.python.pydev.ui.UIConstants; *************** *** 35,44 **** // returns images based upon element type public Image getImage(Object element) { ! SimpleNode token = ((ParsedItem)element).getToken(); ! if (token instanceof ClassDef) { return imageCache.get(UIConstants.CLASS_ICON); } ! else if (token instanceof FunctionDef) { ! if (((FunctionDef)token).name.startsWith("_")) { return imageCache.get(UIConstants.PRIVATE_METHOD_ICON); } --- 30,39 ---- // returns images based upon element type public Image getImage(Object element) { ! AbstractNode token = ((ParsedItem)element).getToken(); ! if (token instanceof ClassNode) { return imageCache.get(UIConstants.CLASS_ICON); } ! else if (token instanceof FunctionNode) { ! if (((FunctionNode)token).astNode.name.startsWith("_")) { return imageCache.get(UIConstants.PRIVATE_METHOD_ICON); } *************** *** 46,56 **** return imageCache.get(UIConstants.PUBLIC_METHOD_ICON); } ! else if (token instanceof Import) { return imageCache.get(UIConstants.IMPORT_ICON); } ! else if (token instanceof ImportFrom) { return imageCache.get(UIConstants.IMPORT_ICON); } ! else if (token instanceof If) { return imageCache.get(UIConstants.MAIN_FUNCTION_ICON); } --- 41,51 ---- return imageCache.get(UIConstants.PUBLIC_METHOD_ICON); } ! else if (token instanceof ImportNode) { return imageCache.get(UIConstants.IMPORT_ICON); } ! else if (token instanceof ImportFromNode) { return imageCache.get(UIConstants.IMPORT_ICON); } ! else if (token instanceof NameEqualsMainNode) { return imageCache.get(UIConstants.MAIN_FUNCTION_ICON); } Index: RawPartitionModel.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/RawPartitionModel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RawPartitionModel.java 5 Mar 2004 22:04:44 -0000 1.3 --- RawPartitionModel.java 10 Apr 2004 01:48:12 -0000 1.4 *************** *** 13,19 **** import org.eclipse.jface.text.IDocumentPartitioningListener; import org.eclipse.jface.text.Position; - import org.eclipse.jface.text.Region; import org.eclipse.jface.text.rules.DefaultPartitioner; import org.eclipse.jface.viewers.StructuredSelection; --- 13,19 ---- import org.eclipse.jface.text.IDocumentPartitioningListener; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.rules.DefaultPartitioner; import org.eclipse.jface.viewers.StructuredSelection; + import org.python.pydev.editor.model.AbstractNode; *************** *** 113,123 **** // IOutlineModel API ! public SelectionPosition getSelectionPosition(StructuredSelection sel) { ! Region r = null; ! if(sel.size() == 1) { // only sync the editing view if it is a single-selection ! Position p = (Position)sel.getFirstElement(); ! r = new Region(p.offset, p.length); ! } ! return new SelectionPosition(r); } --- 113,120 ---- // IOutlineModel API ! public AbstractNode getSelectionPosition(StructuredSelection sel) { ! // we do not have it, broken in Outline rewrite ! System.err.println("RawOutlineModel can't navigate right now"); ! return null; } Index: ParsedModel.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/ParsedModel.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ParsedModel.java 5 Mar 2004 22:04:43 -0000 1.3 --- ParsedModel.java 10 Apr 2004 01:48:12 -0000 1.4 *************** *** 10,16 **** import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.widgets.Display; ! import org.python.parser.SimpleNode; ! import org.python.pydev.parser.IParserListener; ! import org.python.pydev.parser.PyParser; /** --- 10,16 ---- import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.widgets.Display; ! import org.python.pydev.editor.PyEdit; ! import org.python.pydev.editor.model.AbstractNode; ! import org.python.pydev.editor.model.IModelListener; /** *************** *** 20,26 **** public class ParsedModel implements IOutlineModel { ! PyParser parser; PyOutlinePage outline; ! IParserListener parserListener; ParsedItem root = null; // A list of top nodes in this document. Used as a tree root --- 20,26 ---- public class ParsedModel implements IOutlineModel { ! PyEdit editor; PyOutlinePage outline; ! IModelListener modelListener; ParsedItem root = null; // A list of top nodes in this document. Used as a tree root *************** *** 30,35 **** * @param parser */ ! public ParsedModel(PyOutlinePage outline, PyParser parser) { ! this.parser = parser; this.outline = outline; --- 30,35 ---- * @param parser */ ! public ParsedModel(PyOutlinePage outline, PyEdit editor) { ! this.editor = editor; this.outline = outline; *************** *** 38,44 **** // Tell parser that we want to know about all the changes // make sure that the changes are propagated on the main thread ! parserListener = new IParserListener() { ! public void parserChanged(SimpleNode pyRoot) { ! final SimpleNode myRoot = pyRoot; Display.getDefault().syncExec( new Runnable() { public void run() { --- 38,44 ---- // Tell parser that we want to know about all the changes // make sure that the changes are propagated on the main thread ! modelListener = new IModelListener() { ! public void modelChanged(AbstractNode root) { ! final AbstractNode myRoot = root; Display.getDefault().syncExec( new Runnable() { public void run() { *************** *** 46,68 **** setRoot(new ParsedItem(null, myRoot)); } ! }); ! } ! public void parserError(Throwable error) { ! final Throwable myError = error; ! Display.getDefault().syncExec(new Runnable() { ! public void run() { ! setError(myError); ! } ! }); ! setError(error); } }; ! parser.addParseListener(parserListener); ! ! root = new ParsedItem(null, parser.getRoot()); } public void dispose() { ! parser.removeParseListener(parserListener); } --- 46,58 ---- setRoot(new ParsedItem(null, myRoot)); } ! }); } }; ! root = new ParsedItem(null, editor.getPythonModel()); ! editor.addModelListener(modelListener); } public void dispose() { ! editor.removeModelListener(modelListener); } *************** *** 117,121 **** else { ! System.out.println("No old root in ParsedModel!"); } } --- 107,111 ---- else { ! System.out.println("No old model root?"); } } *************** *** 127,137 **** /* */ ! public SelectionPosition getSelectionPosition(StructuredSelection sel) { ! SelectionPosition position = null; if(sel.size() == 1) { // only sync the editing view if it is a single-selection ParsedItem p = (ParsedItem)sel.getFirstElement(); ! position = p.getPosition(); } ! return position; } --- 117,126 ---- /* */ ! public AbstractNode getSelectionPosition(StructuredSelection sel) { if(sel.size() == 1) { // only sync the editing view if it is a single-selection ParsedItem p = (ParsedItem)sel.getFirstElement(); ! return p.getToken(); } ! return null; } Index: IOutlineModel.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/IOutlineModel.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** IOutlineModel.java 5 Mar 2004 22:04:44 -0000 1.4 --- IOutlineModel.java 10 Apr 2004 01:48:12 -0000 1.5 *************** *** 7,10 **** --- 7,11 ---- import org.eclipse.jface.viewers.StructuredSelection; + import org.python.pydev.editor.model.AbstractNode; /** *************** *** 32,35 **** * @return Point that contains line/column, or item to be selected */ ! SelectionPosition getSelectionPosition(StructuredSelection sel); } --- 33,36 ---- * @return Point that contains line/column, or item to be selected */ ! AbstractNode getSelectionPosition(StructuredSelection sel); } |
From: Aleksandar T. <at...@us...> - 2004-04-10 02:01:39
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv649/src/org/python/pydev/parser Modified Files: PyParser.java Added Files: package.html Log Message: Huge code rewrite. I've implemented a Python model. Model is based in AST tree, but should be simpler to use. No more visitor pattern. OutlineView and Navigation actions have been reworked to use new model, instead of traversing AST. Added Hyperlinking capability, but goto is not implemetned yet. --- NEW FILE: package.html --- <body> Pydev interface to Python parser. <p>Every {@link org.python.pydev.editor.PyEdit PyEdit} has a PyParser associated with it. The parser continuously parses the input into AST (Abstract Syntax Tree). Listeners can register with PyParser to receive events when parse is complete. <p>PyParser is used by everyone who needs access to the underlying Python structure: {@link org.python.pydev.outline.ParsedModel outliner}, {@link org.python.pydev.editor.dictionary.PyDEditorItem dictionary}. </body> Index: PyParser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser/PyParser.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyParser.java 30 Mar 2004 01:03:38 -0000 1.5 --- PyParser.java 10 Apr 2004 01:48:14 -0000 1.6 *************** *** 42,65 **** IDocument document; PyEdit editorView; ! SimpleNode root = null; IDocumentListener documentListener; // listens to changes in the document ArrayList parserListeners; // listeners that get notified ! ! static final boolean parseOnThread = true; // can turn of thread parsing for debugging ! ParsingThread parsingThread; // thread that reparses the document ! public PyParser(PyEdit editorView) { this.editorView = editorView; parserListeners = new ArrayList(); ! parsingThread = new ParsingThread(this); ! parsingThread.setName("Pydev parsing thread"); } public void dispose() { // remove the listeners if (document != null) document.removeDocumentListener(documentListener); ! parsingThread.diePlease(); } --- 42,79 ---- IDocument document; PyEdit editorView; ! SimpleNode root = null; // Document root IDocumentListener documentListener; // listens to changes in the document ArrayList parserListeners; // listeners that get notified ! ! final static int PARSE_LATER_INTERVAL = 20; // 20 = 2 seconds ! ! boolean parseNow = false; // synchronized access by ParsingThread ! /* counter how to parse. ! * 0 means do not parse, > 0 means wait this many loops in main thread ! */ ! int parseLater = 0; // synchronized access by ParsingThread ! public PyParser(PyEdit editorView) { this.editorView = editorView; parserListeners = new ArrayList(); ! ParsingThread.getParsingThread().register(this); ! } ! ! public void parseNow() { ! parseNow = true; } + public void parseLater() { + parseNow = false; + parseLater = PARSE_LATER_INTERVAL; // delay of 1 second + } + public void dispose() { // remove the listeners if (document != null) document.removeDocumentListener(documentListener); ! parserListeners.clear(); ! ParsingThread.getParsingThread().unregister(this); } *************** *** 80,94 **** return; } documentListener = new IDocumentListener() { public void documentChanged(DocumentEvent event) { - if (parseOnThread == true) { if (event.getText().indexOf("\n") == -1) // carriage return in changed text means parse now, anything else means parse later ! parsingThread.parseLater(); else ! parsingThread.parseNow(); ! } ! else ! reparseDocument(); } public void documentAboutToBeChanged(DocumentEvent event) {} --- 94,105 ---- return; } + final PyParser parser = this; documentListener = new IDocumentListener() { public void documentChanged(DocumentEvent event) { if (event.getText().indexOf("\n") == -1) // carriage return in changed text means parse now, anything else means parse later ! parseLater(); else ! parseNow(); } public void documentAboutToBeChanged(DocumentEvent event) {} *************** *** 96,104 **** document.addDocumentListener(documentListener); // Reparse document on the initial set ! parsingThread.start(); ! if (parseOnThread == true) ! parsingThread.parseNow(); ! else ! reparseDocument(); } --- 107,111 ---- document.addDocumentListener(documentListener); // Reparse document on the initial set ! parseNow(); } *************** *** 179,182 **** --- 186,191 ---- * Utility thread that reparses document as needed. * + * Singleton. + * * Current algorithm is: * - if parseLater is called, parse 10 main loops later *************** *** 184,248 **** */ class ParsingThread extends Thread { - PyParser parser; - boolean stayingAlive = true; - boolean parseNow = false; - /* counter how to parse. - * 0 means do not parse, > 0 means wait this many loops in main thread - */ - int parseLater = 0; - - final static int PARSE_LATER_INTERVAL = 20; // 20 = 2 seconds - - ParsingThread(PyParser parser) { - this.parser = parser; - } - - /** - * - * @throws InterruptedException - */ - public synchronized void waitForChange() throws InterruptedException { - if (!parseNow && parseLater == 0) - wait(); - } ! public synchronized void parseNow() { ! parseNow = true; ! notify(); ! } ! public synchronized void parseLater() { ! parseLater = PARSE_LATER_INTERVAL; // delay of 1 second ! notify(); ! } ! public synchronized void doNotParse() { ! parseLater = 0; ! parseNow = false; } ! public synchronized void diePlease() { ! stayingAlive = false; ! notify(); } public void run() { // wait for document change, and reparse try { ! while (stayingAlive) { ! parseLater--; ! if (parseLater == 1) ! parseNow(); ! if (parseNow) { ! doNotParse(); ! if (stayingAlive) ! parser.reparseDocument(); } sleep(100); // sleep a bit, to avoid flicker - waitForChange(); } } catch (InterruptedException e) { ! return; ! } } } --- 193,268 ---- */ class ParsingThread extends Thread { ! private static ParsingThread thread = null; ! private static ArrayList parsers = new ArrayList(); // synchronized access only ! private boolean done = false; ! private ParsingThread() { ! setName("Pydev parsing thread"); } ! static public ParsingThread getParsingThread() { ! synchronized(ParsingThread.class) { ! if (thread == null) { ! thread = new ParsingThread(); ! thread.start(); ! } ! return thread; ! } } + public void register(PyParser parser) { + synchronized(parsers) { + parsers.add(parser); + } + } + + public void unregister(PyParser parser) { + synchronized(parsers) { + parser.parseNow = false; + parser.parseLater = 0; + parsers.remove(parser); + if (parsers.size() == 0) { + done = true; + thread = null; + } + } + } + public void run() { // wait for document change, and reparse try { ! while (!done) { ! ArrayList parseUs = new ArrayList(); ! ! // Populate the list of parsers waiting to be parsed ! synchronized(parsers) { ! Iterator i = parsers.iterator(); ! while (i.hasNext()) { ! PyParser p = (PyParser)i.next(); ! p.parseLater--; ! if (p.parseLater == 1) ! p.parseNow = true; ! if (p.parseNow) ! parseUs.add(p); ! } ! } ! ! Iterator i = parseUs.iterator(); ! while (i.hasNext()) { ! PyParser p = (PyParser)i.next(); ! if (p.parseNow) { ! p.parseNow = false; ! p.reparseDocument(); ! } } sleep(100); // sleep a bit, to avoid flicker } } catch (InterruptedException e) { ! } finally { ! if (thread == this) ! thread = null; ! } } } |
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv649/src/org/python/pydev/editor/model Added Files: AbstractNode.java NameEqualsMainNode.java ModelUtils.java LocalNode.java Location.java ModuleNode.java ImportNode.java FunctionCallNode.java IModelListener.java ClassNode.java FunctionNode.java package.html Scope.java ModelMaker.java LengthEstimator.java ImportFromNode.java ImportAlias.java Log Message: Huge code rewrite. I've implemented a Python model. Model is based in AST tree, but should be simpler to use. No more visitor pattern. OutlineView and Navigation actions have been reworked to use new model, instead of traversing AST. Added Hyperlinking capability, but goto is not implemetned yet. --- NEW FILE: ModelMaker.java --- /* * Author: atotic * Created on Apr 8, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.eclipse.core.runtime.IStatus; import org.python.parser.SimpleNode; import org.python.parser.ast.*; import org.python.pydev.plugin.PydevPlugin; /** * Creates the model from the AST tree. */ public class ModelMaker { /* algorithm: * Traverse the top node. * For each Item found, call foundItem. * */ public static ModuleNode createModel(SimpleNode root, int lines, int cols) { ModuleNode n = new ModuleNode(null, lines, cols); PopulateModel populator = new PopulateModel(root, n); try { root.accept(populator); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error populating model", e); } n.getScope().setEnd(n); return n; } /** * Problems this class is trying to solve: * * - figuring out the end position of the node. AST only has starting position, * so we need to heuristically find the end of it * * */ static class PopulateModel extends VisitorBase { SimpleNode root; AbstractNode parent; public PopulateModel(SimpleNode root, AbstractNode parent) { this.root = root; this.parent = parent; } void processAliases(AbstractNode parent, aliasType[] nodes) { for (int i=0; i<nodes.length; i++) new ImportAlias(parent, nodes[i]); } void processImport(Import node) { ImportNode newNode = new ImportNode(parent, node); // have to traverse children manually to find all imports processAliases(newNode, node.names); } void processImportFrom(ImportFrom node) { ImportFromNode newNode = new ImportFromNode(parent, node); // have to traverse children manually to find all imports processAliases(newNode, node.names); } void processClassDef(ClassDef node) { ClassNode newNode = new ClassNode(parent, node); // traverse inside the class definition PopulateModel populator = new PopulateModel(node, newNode); try { node.traverse(populator); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error populating model", e); } newNode.getScope().setEnd(newNode); } void processFunctionDef(FunctionDef node) { FunctionNode newNode = new FunctionNode(parent, node); // traverse inside the function definition PopulateModel populator = new PopulateModel(node, newNode); try { node.traverse(populator); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error populating model", e); } newNode.getScope().setEnd(newNode); } void processLocal(Name node) { if (!LocalNode.isBuiltin(node.id)) new LocalNode(parent, node); } void processFunctionCall(Call node) { FunctionCallNode newNode = new FunctionCallNode(parent, node); PopulateModel populator = new PopulateModel(node, newNode); try { node.traverse(populator); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error populating model", e); } } void processMain(If node) { NameEqualsMainNode newNode = new NameEqualsMainNode(parent, node); } protected Object unhandled_node(SimpleNode node) throws Exception { return null; } public void traverse(SimpleNode node) throws Exception { node.traverse(this); } public Object visitClassDef(ClassDef node) throws Exception { processClassDef(node); return null; } public Object visitFunctionDef(FunctionDef node) throws Exception { processFunctionDef(node); return null; } public Object visitImport(Import node) throws Exception { processImport(node); return null; } public Object visitImportFrom(ImportFrom node) throws Exception { processImportFrom(node); return null; } /* Is every name a local? */ public Object visitName(Name node) throws Exception { processLocal(node); return null; } public Object visitCall(Call node) throws Exception { processFunctionCall(node); return null; } public Object visitIf(If node) throws Exception { if (node.test instanceof Compare) { Compare compareNode = (Compare)node.test; // handcrafted structure walking if (compareNode.left instanceof Name && ((Name)compareNode.left).id.equals("__name__") && compareNode.ops != null && compareNode.ops.length == 1 && compareNode.ops[0] == Compare.Eq) if ( true && compareNode.comparators != null && compareNode.comparators.length == 1 && compareNode.comparators[0] instanceof Str && ((Str)compareNode.comparators[0]).s.equals("__main__")) processMain(node); return null; } return super.visitIf(node); } } } --- NEW FILE: ModelUtils.java --- /* * Author: atotic * Created on Apr 8, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import java.util.ArrayList; import java.util.Iterator; import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.python.pydev.plugin.PydevPlugin; /** * Utility functions: querying/conversion */ public class ModelUtils { public static AbstractNode getElement(AbstractNode root, int offset, IDocument doc, int properties) { try { int line = doc.getLineOfOffset(offset); IRegion r = doc.getLineInformation(line); return getElement(root, new Location(line, offset - r.getOffset()), properties); } catch (BadLocationException e) { PydevPlugin.log(IStatus.WARNING, "getElementByOffset failed", e); } return null; } /** * Depth-first search for a node that spans given location * @param root: node to start the search with * @param loc: location we are looking for * @param properties: properties node must match. Pass in PROP_ANY for all nodes * @return */ public static AbstractNode getElement(AbstractNode root, Location loc, int properties) { if (root == null) return null; Iterator i = root.getChildren().iterator(); while (i.hasNext()) { AbstractNode next = (AbstractNode)i.next(); AbstractNode retVal = getElement(next, loc, properties); if (retVal != null) return retVal; } if (loc.contained(root.getStart(), root.getEnd()) && ((root.getProperties() & properties) == properties)) { System.out.println(root.toString()); return root; } return null; } /** * @return the closest node whose node.start() <= offset */ public static AbstractNode getLessOrEqualNode(AbstractNode root, int offset, IDocument doc) { try { int line = doc.getLineOfOffset(offset); IRegion r = doc.getLineInformation(line); return getLessOrEqualNode(root, new Location(line, offset - r.getOffset())); } catch (BadLocationException e) { PydevPlugin.log(IStatus.WARNING, "getScopeByOffset failed", e); } return null; } /** * @return the closest node whose node.start() <= location */ public static AbstractNode getLessOrEqualNode(AbstractNode root, Location loc) { AbstractNode smallestSoFar = null; AbstractNode current = root; boolean greater = false; while (current != null && !greater) { if (current.getStart().compareTo(loc) <= 0) smallestSoFar = current; else greater = true; current = getNextNode(current); } return smallestSoFar; } /** * Gets the largest child of my ancestor that is smaller than me. */ private static AbstractNode getPreviousNodeHelper(AbstractNode node) { if (node == null) return null; ArrayList children = node.getChildren(); if (children.size() == 0) return node; else return getPreviousNodeHelper((AbstractNode)children.get(children.size() -1)); } /** * This gets the previous node by position. The nodes are ordered, * and each parent is smaller than its children. * The siblings after me are greater, the ones before are smaller * @return */ public static AbstractNode getPreviousNode(AbstractNode node) { if (node == null) return null; AbstractNode parent = node.getParent(); if (parent == null) return null; ArrayList children = parent.getChildren(); int pos = children.indexOf(node); if (pos == -1) { PydevPlugin.log(IStatus.ERROR, "Error traversing model tree", null); return null; } else if (pos > 0) return getPreviousNodeHelper((AbstractNode)children.get(pos-1)); else return parent; } /** * gets the smallest child of my ancestor that larger than me */ private static AbstractNode getNextNodeHelper(AbstractNode parent, AbstractNode child) { if (parent == null) return null; ArrayList children = parent.getChildren(); int pos = children.indexOf(child); if (pos == -1) { PydevPlugin.log(IStatus.ERROR, "Error traversing model tree", null); return null; } else if (pos == children.size() - 1) // last element, must traverse my parents // /\ return getNextNodeHelper(parent.getParent(), parent); else { return (AbstractNode)children.get(pos + 1); } } public static AbstractNode getNextNode(AbstractNode node) { if (node == null) return null; ArrayList children = node.getChildren(); if (children.size() > 0) return (AbstractNode)children.get(0); else return getNextNodeHelper(node.getParent(), node); } } --- NEW FILE: LengthEstimator.java --- /* * Author: atotic * Created on Apr 8, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.python.parser.SimpleNode; import org.python.parser.ast.*; /** * LengthEstimator estimates a lenght of a node in characters. * * We need this to properly determine length of Nodes in the model. * Jython's parser only gives us the start of the node. * The estimates in this file are heuristic. */ public class LengthEstimator extends VisitorBase { int length = 0; int getLength() { return length; } protected Object unhandled_node(SimpleNode node) throws Exception { return null; } public void traverse(SimpleNode node) throws Exception { node.traverse(this); } public Object visitName(Name node) throws Exception { length += node.id.length(); return null; } public Object visitAttribute(Attribute node) throws Exception { length += node.attr.length() + 1; // +1 for '.' node.traverse(this); return null; } public Object visitCall(Call node) throws Exception { LengthEstimator e2 = new LengthEstimator(); node.traverse(e2); length += e2.getLength(); return null; } public Object visitAssert(Assert node) throws Exception { System.out.println("lenVisitAssert:" + node.toString("")); return null; } public Object visitAssign(Assign node) throws Exception { System.out.println("lenVisitAssign:" + node.toString("")); return null; } public Object visitAugAssign(AugAssign node) throws Exception { System.out.println("lenVisitAugAssign:" + node.toString("")); return null; } public Object visitBinOp(BinOp node) throws Exception { System.out.println("lenVisitBinOp:" + node.toString("")); return null; } public Object visitBoolOp(BoolOp node) throws Exception { System.out.println("lenVisitBoolOp:" + node.toString("")); return null; } public Object visitBreak(Break node) throws Exception { System.out.println("lenVisitBreak:" + node.toString("")); return null; } public Object visitClassDef(ClassDef node) throws Exception { System.out.println("lenVisitClassDef:" + node.name); return null; } public Object visitCompare(Compare node) throws Exception { System.out.println("lenVisitCompare:" + node.toString("")); return null; } public Object visitContinue(Continue node) throws Exception { System.out.println("lenVisitContinue:" + node.toString("")); return null; } public Object visitDelete(Delete node) throws Exception { System.out.println("lenVisitDelete:" + node.toString("")); return null; } public Object visitDict(Dict node) throws Exception { System.out.println("lenVisitDict:" + node.toString("")); return null; } public Object visitEllipsis(Ellipsis node) throws Exception { System.out.println("lenVisitEllipsis:" + node.toString("")); return null; } public Object visitExec(Exec node) throws Exception { System.out.println("lenVisitExec:" + node.toString("")); return null; } public Object visitExpr(Expr node) throws Exception { System.out.println("lenVisitExpr:" + node.toString("")); return null; } public Object visitExpression(Expression node) throws Exception { System.out.println("lenVisitExpression:" + node.toString("")); return null; } public Object visitExtSlice(ExtSlice node) throws Exception { System.out.println("lenVisitExtSlice:" + node.toString("")); return null; } public Object visitFor(For node) throws Exception { System.out.println("lenVisitFor:" + node.toString("")); return null; } public Object visitFunctionDef(FunctionDef node) throws Exception { System.out.println("lenVisitFunctionDef:" + node.toString("")); return null; } public Object visitGlobal(Global node) throws Exception { System.out.println("lenVisitGlobal:" + node.toString("")); return null; } public Object visitIf(If node) throws Exception { System.out.println("lenVisitIf:" + node.toString("")); return null; } public Object visitImport(Import node) throws Exception { System.out.println("lenVisitImport:" + node.toString("")); return null; } public Object visitImportFrom(ImportFrom node) throws Exception { System.out.println("lenVisitImportFrom:" + node.toString("")); return null; } public Object visitIndex(Index node) throws Exception { System.out.println("lenVisitIndex:" + node.toString("")); return null; } public Object visitInteractive(Interactive node) throws Exception { System.out.println("lenVisitInteractive:" + node.toString("")); return null; } public Object visitLambda(Lambda node) throws Exception { System.out.println("lenVisitLambda:" + node.toString("")); return null; } public Object visitList(List node) throws Exception { System.out.println("lenVisitList:" + node.toString("")); return null; } public Object visitListComp(ListComp node) throws Exception { System.out.println("lenVisitListComp:" + node.toString("")); return null; } public Object visitModule(Module node) throws Exception { System.out.println("lenVisitModule:" + node.toString("")); return null; } public Object visitNum(Num node) throws Exception { System.out.println("lenVisitNum:" + node.toString("")); return null; } public Object visitPass(Pass node) throws Exception { System.out.println("lenVisitPass:" + node.toString("")); return null; } public Object visitPrint(Print node) throws Exception { System.out.println("lenVisitPrint:" + node.toString("")); return null; } public Object visitRaise(Raise node) throws Exception { System.out.println("lenVisitRaise:" + node.toString("")); return null; } public Object visitRepr(Repr node) throws Exception { System.out.println("lenVisitRepr:" + node.toString("")); return null; } public Object visitReturn(Return node) throws Exception { System.out.println("lenVisitReturn:" + node.toString("")); return null; } public Object visitSlice(Slice node) throws Exception { System.out.println("lenVisitSlice:" + node.toString("")); return null; } public Object visitStr(Str node) throws Exception { System.out.println("lenVisitStr:" + node.toString("")); return null; } public Object visitSubscript(Subscript node) throws Exception { System.out.println("lenVisitSubscript:" + node.toString("")); return null; } public Object visitSuite(Suite node) throws Exception { System.out.println("lenVisitSuite:" + node.toString("")); return null; } public Object visitTryExcept(TryExcept node) throws Exception { System.out.println("lenVisitTryExcept:" + node.toString("")); return null; } public Object visitTryFinally(TryFinally node) throws Exception { System.out.println("lenVisitTryFinally:" + node.toString("")); return null; } public Object visitTuple(Tuple node) throws Exception { System.out.println("lenVisitTuple:" + node.toString("")); return null; } public Object visitUnaryOp(UnaryOp node) throws Exception { System.out.println("lenVisitUnaryOp:" + node.toString("")); return null; } public Object visitWhile(While node) throws Exception { System.out.println("lenVisitWhile:" + node.toString("")); return null; } public Object visitYield(Yield node) throws Exception { System.out.println("lenVisitYield:" + node.toString("")); return null; } } --- NEW FILE: ImportAlias.java --- /* * Author: atotic * Created on Apr 9, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.python.parser.ast.aliasType; /** * ImportAlias represents individual imports. * * For example "import os,sys,network" generates 3 alias nodes. */ public class ImportAlias extends AbstractNode { aliasType astNode; public ImportAlias(AbstractNode parent, aliasType astNode) { super(parent); this.astNode = astNode; setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 1)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn - 1 + astNode.name.length())); properties = PROP_CLICKABLE; } } --- NEW FILE: FunctionCallNode.java --- /* * Author: atotic * Created on Apr 8, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.eclipse.core.runtime.IStatus; import org.python.parser.ast.Call; import org.python.pydev.plugin.PydevPlugin; /** * Represents a function call. */ public class FunctionCallNode extends AbstractNode { Call astNode; /** * @param parent */ public FunctionCallNode(AbstractNode parent, Call astNode) { super(parent); this.astNode = astNode; this.setStart(new Location(astNode.beginLine - 1, astNode.beginColumn)); LengthEstimator estimate = new LengthEstimator(); try { astNode.traverse(estimate); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error estimating length of function call", e); } this.setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn + estimate.getLength())); properties = PROP_CLICKABLE; } } --- NEW FILE: LocalNode.java --- /* * Author: atotic * Created on Apr 8, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.python.parser.ast.Name; /** * Local nodes represent locals variables. * A LocalNode is generated for every mention of the variable. * First mention is considered a declaration, and is stored inside Scope. */ public class LocalNode extends AbstractNode { // True if local is a builtin public static boolean isBuiltin(String name) { return (name.equals("None")); } Name astNode; /** * @param parent */ public LocalNode(AbstractNode parent, Name astNode) { super(parent); this.astNode = astNode; this.setStart(new Location(astNode.beginLine - 1, astNode.beginColumn)); this.setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn + astNode.id.length())); parent.getScope().addLocalDefinition(this); properties = PROP_CLICKABLE; } public String toString() { return super.toString() + astNode.id; } public class PredefinedNameException extends Exception { } } --- NEW FILE: ImportNode.java --- /* * Author: atotic * Created on Apr 8, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.python.parser.ast.Import; /** * Represents import & import as statements */ public class ImportNode extends AbstractNode { public Import astNode; public ImportNode(AbstractNode parent, Import astNode) { super(parent); this.astNode = astNode; // instead of trying to calculate its arguments, just span the "import" keyword setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 8)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn - 2)); } } --- NEW FILE: ModuleNode.java --- /* * Author: atotic * Created on Apr 7, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; /** * Top-level node representing a python module. * * I also think of it as a file. */ public class ModuleNode extends AbstractNode { Scope scope; public ModuleNode(AbstractNode parent, int lines, int cols) { super(parent); scope = new Scope(this); // FileNode always spans the entire file this.start = Location.MIN_LOCATION; this.end = new Location(lines, cols); } public Scope getScope() { return scope; } } --- NEW FILE: ImportFromNode.java --- /* * Author: atotic * Created on Apr 9, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.python.parser.ast.ImportFrom; /** * ImportFrom node spans first argument of "from import" statement. * * from repr import Repr, this node would span "repr". */ public class ImportFromNode extends AbstractNode { public ImportFrom astNode; public ImportFromNode(AbstractNode parent, ImportFrom astNode) { super(parent); this.astNode = astNode; setStart(new Location(astNode.beginLine - 1, astNode.beginColumn - 1)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn -1 + astNode.module.length())); properties = PROP_CLICKABLE; } } --- NEW FILE: package.html --- <body> The model represents the structure of the python file. <p>{@link org.python.pydev.model.ModelMaker ModelMaker} creates the model from AST by traversing the tree. <p>{@link org.python.pydev.model.ModelUtils ModelUtils} have various utility functions for model traversal, etc. <p>{@link org.python.pydev.model.AbstractNode AbstractNode} is the main node API. Subclasses modify it as needed. See ClassNode, FunctionCallNode, etc... <p>The definitions of local variables are inferred. The first mention of every local variable (implicit definition) is stored inside Scope. Scope is intended for repository of inferred data. <p>We still need to work on processing of the include modules. </body> --- NEW FILE: FunctionNode.java --- /* * Author: atotic * Created on Apr 8, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.python.parser.ast.FunctionDef; /** * Represents a function definition. */ public class FunctionNode extends AbstractNode { public FunctionDef astNode; Scope scope; public FunctionNode(AbstractNode parent, FunctionDef node) { super(parent); this.astNode = node; scope = new Scope(this); setStart(new Location(astNode.beginLine - 1, astNode.beginColumn + 3)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn + 3 + astNode.name.length())); properties = PROP_CLICKABLE; } public Scope getScope() { return scope; } } --- NEW FILE: NameEqualsMainNode.java --- /* * Author: atotic * Created on Apr 9, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.python.parser.ast.If; /** * if __name__ == 'main' Node. */ public class NameEqualsMainNode extends AbstractNode { If astNode; public NameEqualsMainNode(AbstractNode parent, If astNode) { super(parent); this.astNode = astNode; this.setStart(new Location(astNode.beginLine, astNode.beginColumn-1)); this.setEnd(new Location(astNode.beginLine, astNode.beginColumn + 22)); } } --- NEW FILE: Scope.java --- /* * Author: atotic * Created on Apr 8, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import java.util.ArrayList; import java.util.Iterator; /** * Scope represents scope where local variables belong to. * * There is a scope hierarchy: * ModuleNode scope * Function scope * Class scope * Function scope */ public class Scope { private ArrayList locals; private AbstractNode start; private AbstractNode end; private Scope parent; private ArrayList children; public Scope(AbstractNode start) { this.start = start; AbstractNode startParent = start.getParent(); if (startParent != null) { parent = startParent.getScope(); parent.addChild(this); } children = new ArrayList(); } private void addChild(Scope scope) { children.add(scope); } public ArrayList getChildren() { return children; } public LocalNode getLocalByName(String name) { if (locals == null) return null; Iterator i = locals.iterator(); while (i.hasNext()) { LocalNode l = (LocalNode)i.next(); if (l.toString().equals(name)) return l; } return null; } void addLocalDefinition(LocalNode newLocal) { if (locals == null) locals = new ArrayList(); if (getLocalByName(newLocal.toString()) == null) locals.add(newLocal); } public Location getStart() { return start.getStart(); } public AbstractNode getStartNode() { return start; } public Scope getParent() { return parent; } public Location getEnd() { return end.getEnd(); } /** * Computes where the last child of the node ends */ public void setEnd(AbstractNode end) { ArrayList children = end.getChildren(); int size = children.size(); AbstractNode trueEndNode = size > 0 ? (AbstractNode)children.get(size-1) : end; this.end = trueEndNode; } } --- NEW FILE: ClassNode.java --- /* * Author: atotic * Created on Apr 8, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.python.parser.ast.ClassDef; /** * Represents a class definition. */ public class ClassNode extends AbstractNode { public ClassDef astNode; Scope scope; public ClassNode(AbstractNode parent, ClassDef astNode) { super(parent); this.astNode = astNode; scope = new Scope(this); setStart(new Location(astNode.beginLine - 1, astNode.beginColumn + 5)); setEnd(new Location(astNode.beginLine - 1, astNode.beginColumn + 5 + astNode.name.length())); properties = PROP_CLICKABLE; } public Scope getScope() { return scope; } } --- NEW FILE: Location.java --- /* * Author: atotic * Created on Apr 7, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; /** * Struct class, holds line/column information. * * Has static utility functions for Location->offset/line conversions */ public class Location { public int line; public int column; static Location MIN_LOCATION = new Location(0,0); static Location MAX_LOCATION = new Location(Integer.MAX_VALUE, Integer.MAX_VALUE); public Location() { line = column = 0; } public Location(int line, int column) { this.line = line; this.column = column; } /** * Conversion to document coordinates. */ public int toOffset(IDocument document) throws BadLocationException { return document.getLineOffset(line) + column; } /** * @param location * @param location2 * @return */ public boolean contained(Location start, Location end) { boolean startOk = (line > start.line || line == start.line && column >= start.column); boolean endOk = startOk ? (line < end.line || line == end.line && column <= end.column): false; return startOk && endOk; } public String toString() { return "L:" + Integer.toString(line) + " C:" + Integer.toString(column); } /** * standard compare * @return 1 means I win, -1 means argument wins, 0 means equal */ public int compareTo(Location l) { if (line > l.line) return 1; if (line < l.line) return -1; if (column > l.column) return 1; if (column < l.column) return -1; return 0; } /** * Utility: Converts document's offset to Location * @return Location */ static public Location offsetToLocation(IDocument document, int offset) { try { int line = document.getLineOfOffset(offset); int line_start = document.getLineOffset(line); return new Location(line, offset - line_start); } catch (BadLocationException e) { return new Location(); } } } --- NEW FILE: IModelListener.java --- /* * Author: atotic * Created on Apr 9, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; /** * PyEdit will broadcast model changes to IModelListeners. * * modelChanged is generated every time document is parsed successfully */ public interface IModelListener { /** * every time document gets parsed, it generates a new parse tree * @param root - the root of the new model */ void modelChanged(AbstractNode root); } --- NEW FILE: AbstractNode.java --- /* * Author: atotic * Created on Apr 7, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.model; import java.util.ArrayList; /** * ModelNode is a superclass of all nodes. * It knows its location, parent & children. * * Nodes can have properties that are useful when querying * For example, clickable nodes have PROP_CLICKABLE set. */ public class AbstractNode { static ArrayList emptyChildList = new ArrayList(); // we keep an empty list around for efficiency public static int PROP_CLICKABLE = 1; // if the node can be hyperlinked public static int PROP_ANY = 0; // all properties protected Location start; // line/offset start of the text that defines this node protected Location end; // end of node text protected AbstractNode parent; protected ArrayList children; int properties = 0; // a multi-valued integer, can be PROP_CLICKABLE, or others later // properties should be set in the initializer /** * @param parent can be null */ public AbstractNode(AbstractNode parent) { this.parent = parent; if (parent != null) parent.addChild(this); } public Location getStart() { return start; } public void setStart(Location start) { this.start = start; } public Location getEnd() { return end; } public void setEnd(Location end) { this.end = end; } /** * @return an unmodifiable list of children. * It is UNMODIFIABLE because if list is empty, we return a static empty list * to save memory/speed. */ public ArrayList getChildren() { if (children == null) return emptyChildList; return children; } public void addChild(AbstractNode child) { if (children == null) children = new ArrayList(); children.add(child); } public AbstractNode getParent() { return parent; } /** * Scope is where the local variables are. Module/Class/Functions have scope, * all others inherit from the parent. */ public Scope getScope() { if (parent != null) return parent.getScope(); return null; } public int getProperties() { return properties; } public String toString() { return getClass().toString() + " " + start.toString() + end.toString(); } } |
From: Aleksandar T. <at...@us...> - 2004-04-10 02:01:39
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/navigation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv649/src/org/python/pydev/editor/actions/navigation Modified Files: PyPreviousMethod.java PyNextMethod.java PyMethodNavigation.java Added Files: package.html Log Message: Huge code rewrite. I've implemented a Python model. Model is based in AST tree, but should be simpler to use. No more visitor pattern. OutlineView and Navigation actions have been reworked to use new model, instead of traversing AST. Added Hyperlinking capability, but goto is not implemetned yet. Index: PyPreviousMethod.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/navigation/PyPreviousMethod.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyPreviousMethod.java 5 Mar 2004 22:04:44 -0000 1.2 --- PyPreviousMethod.java 10 Apr 2004 01:48:13 -0000 1.3 *************** *** 7,24 **** package org.python.pydev.editor.actions.navigation; ! import org.python.pydev.outline.ParsedItem; ! import org.python.pydev.outline.SelectionPosition; /** * @author Fabio Zadrozny */ ! public class PyPreviousMethod extends PyMethodNavigation{ ! public SelectionPosition getSelect(Visitor v) { ! if (v.prevNode != null){ ! return ParsedItem.getPosition(v.prevNode); ! } ! return null; } - } --- 7,26 ---- package org.python.pydev.editor.actions.navigation; ! import org.python.pydev.editor.model.*; ! /** * @author Fabio Zadrozny */ ! public class PyPreviousMethod extends PyMethodNavigation { ! // me is the last node w ! public AbstractNode getSelect(AbstractNode me) { ! AbstractNode current = ModelUtils.getPreviousNode(me); ! while (current != null && ! !(current instanceof FunctionNode) && ! !(current instanceof ClassNode)) ! current = ModelUtils.getPreviousNode(current); ! return current; } } --- NEW FILE: package.html --- <body> Editor navigation actions. </body> Index: PyNextMethod.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/navigation/PyNextMethod.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyNextMethod.java 5 Mar 2004 22:04:44 -0000 1.2 --- PyNextMethod.java 10 Apr 2004 01:48:13 -0000 1.3 *************** *** 7,23 **** package org.python.pydev.editor.actions.navigation; ! import org.python.pydev.outline.ParsedItem; ! import org.python.pydev.outline.SelectionPosition; /** ! * @author Fabio Zadrozny */ public class PyNextMethod extends PyMethodNavigation{ ! public SelectionPosition getSelect(Visitor v) { ! if (v.nextNode != null){ ! return ParsedItem.getPosition(v.nextNode); ! } ! return null; } } --- 7,27 ---- package org.python.pydev.editor.actions.navigation; ! import org.python.pydev.editor.model.*; /** ! * One-trick pony, finds the next method. */ public class PyNextMethod extends PyMethodNavigation{ ! /** ! * Gets the next method/class definition ! */ ! public AbstractNode getSelect(AbstractNode me ) { ! AbstractNode current = ModelUtils.getNextNode(me); ! while (current != null && ! !(current instanceof FunctionNode) && ! !(current instanceof ClassNode)) ! current = ModelUtils.getNextNode(current); ! return current; } } Index: PyMethodNavigation.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/navigation/PyMethodNavigation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyMethodNavigation.java 5 Mar 2004 22:07:04 -0000 1.3 --- PyMethodNavigation.java 10 Apr 2004 01:48:13 -0000 1.4 *************** *** 10,22 **** import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextSelection; - import org.python.parser.SimpleNode; - import org.python.parser.ast.ClassDef; - import org.python.parser.ast.FunctionDef; - import org.python.parser.ast.VisitorBase; import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.actions.PyAction; ! import org.python.pydev.outline.ParsedItem; ! import org.python.pydev.outline.ParsedModel; ! import org.python.pydev.outline.SelectionPosition; /** --- 10,16 ---- import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextSelection; import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.actions.PyAction; ! import org.python.pydev.editor.model.*; /** *************** *** 30,107 **** /** - * This class is interested in knowing where are we... - * - * @author Fabio Zadrozny - * - */ - class Visitor extends VisitorBase { - - /** - * The initial line starts in 0 - */ - public int initialLine; - - /** - * This is the previous node. - */ - public SimpleNode prevNode = null; - - /** - * This is the current node. (Its begin line - * starts at 1 and not 0). - */ - public SimpleNode currentNode = null; - - /** - * This is the next found node. - */ - public SimpleNode nextNode = null; - - /** - * We have to know the initialLine, so that we can know where we are. - * @param initialLine - */ - public Visitor(int initialLine) { - this.initialLine = initialLine; - } - - /** - * Marks the current, previous and next node... - * @param node - */ - private void mark(SimpleNode node) { - if (this.initialLine >= node.beginLine - 1) { - if (this.currentNode != null) { - this.prevNode = this.currentNode; - } - this.currentNode = node; - } else if (nextNode == null) { //only sets the next node once... - nextNode = node; - } - } - - public Object visitClassDef(ClassDef node) throws Exception { - // print("visiting...visitClassDef"); - mark(node); - node.traverse(this); - return null; - } - - public Object visitFunctionDef(FunctionDef node) throws Exception { - // print("visiting...visitFunctionDef"); - mark(node); - return null; - } - - protected Object unhandled_node(SimpleNode node) throws Exception { - return null; - } - - public void traverse(SimpleNode node) throws Exception { - } - - } - - /** * This method gets the parsed model, discovers where we are in the * document (through the visitor), and asks the implementing class --- 24,27 ---- *************** *** 110,154 **** public void run(IAction action) { PyEdit pyEdit = getPyEdit(); ! IDocument doc = ! pyEdit.getDocumentProvider().getDocument(pyEdit.getEditorInput()); ITextSelection selection = (ITextSelection) pyEdit.getSelectionProvider().getSelection(); - - ParsedModel model = new ParsedModel(null, pyEdit.getParser()); - ParsedItem item = (ParsedItem)model.getRoot(); - SimpleNode node = item.getToken(); - - if (node == null) - return; ! int startLine = selection.getStartLine(); ! Visitor v = whereAmI(startLine, node); ! ! // print (v.nextNode); ! SelectionPosition select = getSelect(v); ! // print("select = " + select); ! if (select != null) { ! pyEdit.setSelection(select); ! } ! model.dispose(); ! } ! ! /** ! * Returns a visitor that knows where we are and the nodes next to me... ! * ! * @param startLine ! * @param root ! * @return ! */ ! public Visitor whereAmI(int startLine, SimpleNode root) { ! Visitor v = new Visitor(startLine); ! try { ! synchronized (v) { ! root.traverse(v); ! } ! } catch (Exception e) { ! e.printStackTrace(); ! } ! return v; } --- 30,42 ---- public void run(IAction action) { PyEdit pyEdit = getPyEdit(); ! IDocument doc = pyEdit.getDocumentProvider().getDocument(pyEdit.getEditorInput()); ITextSelection selection = (ITextSelection) pyEdit.getSelectionProvider().getSelection(); ! Location loc = Location.offsetToLocation(doc, selection.getOffset()); ! AbstractNode closest = ModelUtils.getLessOrEqualNode(pyEdit.getPythonModel(),loc); ! ! AbstractNode goHere = getSelect(closest); ! pyEdit.revealModelNode(goHere); } *************** *** 159,165 **** * * @param v ! * @return */ ! public abstract SelectionPosition getSelect(Visitor v); } --- 47,53 ---- * * @param v ! * @return where we should go depending on visitor */ ! public abstract AbstractNode getSelect(AbstractNode v); } |
From: Aleksandar T. <at...@us...> - 2004-04-10 02:01:37
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv649/src/org/python/pydev/editor/dictionary Added Files: package.html Removed Files: PyDFunctionItem.java PyDEditorItem.java PopulateDictionary.java PyDictionary.java PyDClassItem.java DebugVisitor.java PyDictionaryItem.java PyDLocalItem.java Log Message: Huge code rewrite. I've implemented a Python model. Model is based in AST tree, but should be simpler to use. No more visitor pattern. OutlineView and Navigation actions have been reworked to use new model, instead of traversing AST. Added Hyperlinking capability, but goto is not implemetned yet. --- DebugVisitor.java DELETED --- --- NEW FILE: package.html --- <body> This package is obsolete, it has been replaced by org.python.pydev.editor.model. </body> --- PopulateDictionary.java DELETED --- --- PyDictionaryItem.java DELETED --- --- PyDLocalItem.java DELETED --- --- PyDClassItem.java DELETED --- --- PyDEditorItem.java DELETED --- --- PyDictionary.java DELETED --- --- PyDFunctionItem.java DELETED --- |