Anonymous avatar Anonymous committed 56737f4

Added PyName.get_definition_location

Comments (0)

Files changed (7)

 
 Features added in this release:
 
-* Proposing base class attributes
-* Auto-completing "self."s
-* Auto completion after "."s for modules and classes
+* 
 
 You can use <Alt-/> for auto-completion.  The letter before the actual
 proposal in the code assist proposals dialog indicates the type of
 T: template. Some basic templates are added. You can use 'main', 'test_case',
 'hash', 'eq' and 'super' templates while coding.
 
-Right now, you can't complete as you type but that will be probably
-implemented before 0.2 release.  Lots of interesting features are
-planned to be added before 0.3 release like quick outline, show pydoc,
-goto definition and a bit of type inferencing.  Keep waiting!
-
 
 Keybinding
 ==========
 C-x k          close active editor
 C-x C-c        exit
 C-F11          run active editor
-
+-------------  --------------------------
+C-f            forward character
+C-b            backward character
+C-n            next line
+C-p            previous line
+M-f            next word
+M-b            previous word
+C-v            next page
+M-v            previous page
 C-s            start searching
 C-x C-u        undo
 C-x C-r        redo
 ---------------
 One of the basic features of modern IDEs is the availability of auto-completion.
 Some Python IDEs have auto-completion support but in a limited form.  Since
-the type of many variables cannot be deduced from simple analysis of the source code.
-Auto-completing modules names, class names, static methods, class methods,
+the type of many variables cannot be deduced from simple analysis of the source
+code. Auto-completing modules names, class names, static methods, class methods,
 function names and variable names are easy.  But auto-completing the methods and
 attributes of an object is hard.  Because the IDE needs to know the type of
 the object that cannot be achieved easily most of the time in dynamic languages.
 ================
 
 The main motive for starting this project was the lack of good
-refactoring tools for python language.  Refactoring programs like "bicycle repair man"
-aren't reliable due to type inferencing problems discussed earlier and they
+refactoring tools for python language.  Refactoring programs like "bicycle repair
+man" aren't reliable due to type inferencing problems discussed earlier and they
 support a limited number of refactorings.
 
 
 ===========
 
 
+> Public release 0.2pre3 : June 18, 2006
+
+
 - Auto-completing "self."s : June 13, 2006
 
 
 * Rename function @ 2
 
 
-* Rename class @ 3
-
-
 * Move a class to another module @ 3
 
 
-* Local history @ 4
-
-
 * Find matching parens @ 1
 
 
   * Fixed places for StatusTexts
 
 
+* Having different strategies for selecting next/prev words @ 1
+
+
 * Enhancing auto indentation @ 1
   * Indenting a range of file
   * Removing extra spaces
 * Dynamic type inference @ 3
 
 
-* Rename local variable @ 2
-
-
 * Changing next/prev word to stop on underline and capital letters @ 1
 
 
 * Rename module refactoring @ 2
 
 
-* Formating Code @ 5
-  * Writing ASTs
-
-
-* Better multi-sequence key event handling @ 2
-
-
 * Enhancing editor @ 1
   * Clearing selection if something happens
   * Unifying builtin and emacs-style selections; if selection
 * Auto-completing inherited methods @ 2
 
 
+* Better multi-sequence key event handling @ 2
+
+
 * Optimizing StatementRangeFinder @ 1
   Add CachedLines and not starting from the start of the lines
 
   in codeassist
 
 
+* Local history @ 4
+
+
 * Open Type; C-T @ 3
 
 
   * Sorting proposals
 
 
+* We know the type of list and keyword args @ 1
+
+
 * Complete as you type @ 2
   Update proposal list while typing.
 
 * Show PyDoc @ 2
 
 
-* Go to definition; F3 @ 1
-  Not overwriting PyNames in pycore; Updating them.
+* Out of project modules @ 2
+  Using inspect on modules that cannot be found in the project and builtins
+
+
+* AssList and AssTuple assignments @ 1
+
+
+* Auto completion contexts; strings, comments, functions and ... @ 2
+
+
+* Rename class @ 3
+
+
+* Rename local variable @ 2
 
 
 > Public Release 0.2pre4 : July 2, 2006
 
 
-* Show quick outline; C-o @ 2
-
-
-* Out of project modules @ 2
-  Using inspect on modules that cannot be found in the project
-
-
-* AssList and AssTuple assignments @ 1
+* Formating Code @ 4
+  * Writing ASTs
 
 
 * Auto-completing function parameter names when calling @ 2
 
 
-* Auto completion contexts; strings, comments, functions and ... @ 2
+* Show quick outline; C-o @ 2
 
 
-> Public release 0.2pre3 : June 18, 2006
+* Go to definition; F3 @ 1
+  Not overwriting PyNames in pycore; Updating them.
 
 
 Remaining Stories

docs/workingon.txt

-Refactor CodeAssist and PyCore @ 2
-==================================
+Go to definition; F3 @ 1
+========================
+
+- What should be the value of lineno for unknowns; None
+
+* Imported names
+* Not overwriting PyNames in pycore; Updating them
 
 * Refactor _ScopeVisitor.visitFrom and visitImport
 ? Folders and change_observers
 ? Code-assist proposal name should not be so long
 * PyNames with None object
 ? Refactor pycore; So many kinds for Modules; eliminate checking module.is_package
-? Not accessing pyname.object in codeassist
 ? PyObject equality check; Value objects
 * Removing duplications in tests in codeassist and pycore scopes
-? Builtins and scopes
-? We know the type of list and keyword args
 ? Consider using StatementRangeFinder in highlight module
+? Updating editor when file changes at disk
 
 
 Before 0.2 Release
 
 class PyName(object):
 
-    def __init__(self, object_=None, is_defined_here=False):
+    def __init__(self, object_=None, is_defined_here=False, lineno=None):
         self.object = object_
         self.is_defined_here = is_defined_here
+        self.lineno = lineno
+        if self._has_block():
+            self.lineno = self._get_ast().lineno
 
     def get_attributes(self):
         if self.object:
             return self.object.get_attributes()
         else:
             return PyObject.get_base_type('Unknown').get_attributes()
-    
+
     def get_type(self):
         if self.object:
             return self.object.get_type()
         else:
             return PyObject.get_base_type('Unknown')
 
+    def get_definition_location(self):
+        return self.lineno
+
     def _has_block(self):
         return self.is_defined_here and isinstance(self.object,
                                                    PyDefinedObject)
         self.names[node.name] = PyName(pyobject, True)
 
     def visitAssName(self, node):
-        self.names[node.name] = PyName()
+        self.names[node.name] = PyName(lineno=node.lineno)
 
     def visitImport(self, node):
         for import_pair in node.names:

ropetest/pycoretest.py

 from rope.pycore import PyObject, ModuleNotFoundException, PythonFileRunner
 from rope.project import Project
 
-class PyElementHierarchyTest(unittest.TestCase):
+class PyCoreTest(unittest.TestCase):
 
     def setUp(self):
-        super(PyElementHierarchyTest, self).setUp()
+        super(PyCoreTest, self).setUp()
         self.project_root = 'sample_project'
         testutils.remove_recursively(self.project_root)
         self.project = Project(self.project_root)
 
     def tearDown(self):
         testutils.remove_recursively(self.project_root)
-        super(PyElementHierarchyTest, self).tearDown()
+        super(PyCoreTest, self).tearDown()
 
     def test_simple_module(self):
         self.pycore.create_module(self.project.get_root_folder(), 'mod')
         self.assertTrue(self.project.get_root_folder() in source_folders and \
                         src in source_folders)
 
+    def test_get_pyname_definition_location(self):
+        mod = self.pycore.get_string_module('a_var = 20\n')
+        a_var = mod.get_attributes()['a_var']
+        self.assertEquals(1, a_var.get_definition_location())
+
+    def test_get_pyname_definition_location_functions(self):
+        mod = self.pycore.get_string_module('def a_func():\n    pass\n')
+        a_func = mod.get_attributes()['a_func']
+        self.assertEquals(1, a_func.get_definition_location())
+
+    def test_get_pyname_definition_location_class(self):
+        mod = self.pycore.get_string_module('class AClass(object):\n    pass\n\n')
+        a_class = mod.get_attributes()['AClass']
+        self.assertEquals(1, a_class.get_definition_location())
+
+    def test_get_pyname_definition_location_local_variables(self):
+        mod = self.pycore.get_string_module('def a_func():\n    a_var = 10\n')
+        a_func_scope = mod.get_scope().get_scopes()[0]
+        a_var = a_func_scope.get_names()['a_var']
+        self.assertEquals(2, a_var.get_definition_location())
+
 
 class PyCoreInProjectsTest(unittest.TestCase):
 
 
 def suite():
     result = unittest.TestSuite()
-    result.addTests(unittest.makeSuite(PyElementHierarchyTest))
+    result.addTests(unittest.makeSuite(PyCoreTest))
     result.addTests(unittest.makeSuite(PyCoreInProjectsTest))
     result.addTests(unittest.makeSuite(PyCoreScopesTest))
     result.addTests(unittest.makeSuite(PythonFileRunnerTest))
 from distutils.core import setup
 
 setup(name='rope',
-      version='0.2pre3',
+      version='0.2pre4',
       description='A Python IDE ...',
       author='Ali Gholami Rudi',
       author_email='aligrudi@users.sourceforge.net',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.