Anonymous avatar Anonymous committed 3a2aaac

Using Proposals.completions in editor

Comments (0)

Files changed (4)

docs/workingon.txt

 *** Proposing templates in auto-completion proposals @ 1 ***
 
-* Machanisms for getting and editing and setting template variables
-
-- Multiple variables
-- substitute
-- Underlined variables
-- $$
-- ${name}${age}
-- The same variable many times
-- ${cursor}
-- [^$]$[^{$] in template
-- get_cursor_location
-- What if templates does not have ${cursor}
+* Showing templates in completion dialog
 ? Defaults for templates
-
-* Showing templates in completion dialog
 * Builtin templates
 
 ?? Ignoring string contents while indenting

rope/codeassist.py

 class TemplateProposal(CodeAssistProposal):
     """A template proposal"""
 
-    def __init__(self, name, definition):
+    def __init__(self, name, template):
         super(TemplateProposal, self).__init__(name)
-        self.definition = definition
+        self.template = template
 
 
 class Template(object):
         return (last_non_space - current_pos - 1) / self.indentation_length
 
     def add_template(self, name, definition):
-        self.templates.append(TemplateProposal(name, definition))
+        self.templates.append(TemplateProposal(name, Template(definition)))
 
     def _get_template_proposals(self, starting):
         result = []
                 self.text.delete('0.0 +%dc' % result.start_offset,
                                  '0.0 +%dc' % result.end_offset)
                 self.text.insert('0.0 +%dc' % result.start_offset,
-                                 result.proposals[selected].completion)
+                                 result.completions[selected].completion)
                 toplevel.destroy()
         def cancel():
             toplevel.destroy()

ropetest/codeassisttest.py

 
     def test_get_cursor_location(self):
         template = Template('My name is ${name}${cursor}.')
-        self.assertEquals('My name is Ali.', template.substitute({'name': 'Ali'}))
         self.assertEquals(14, template.get_cursor_location({'name': 'Ali'}))
 
     def test_get_cursor_location_with_no_cursor(self):
         template = Template('My name is ${name}.')
-        self.assertEquals('My name is Ali.', template.substitute({'name': 'Ali'}))
         self.assertEquals(15, template.get_cursor_location({'name': 'Ali'}))
 
 
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.