mpourmpoulis / PythonVoiceCodingPlugin

Sublime Text 3 plugin for voice coding Python 3
https://pythonvoicecodingplugin.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
13 stars 3 forks source link

Problem with selecting decorators and base class #17

Closed mpourmpoulis closed 4 years ago

mpourmpoulis commented 4 years ago

Description

General Information

Plug-In Version: v0.1.2 , develop

Queries Affected

decorator and base class can sometimes be not selected at all! argument inside decorators can also not be selected unless we are already inside the decorator, dedicated subindexing commands work!

Response To Command

Context In Which It Appears

Does the problem seem to appear or disappear only some of the time? Does there seem to be

code snippet when things are working

@mark_as_snippet_grammar
class MarkdownSnippets(MappingRule):
    pronunciation = "sublime snippet"
    mapping = {
        "<snippet>":
            R(Snippet("%(snippet)s")),
        "<snippet_variants> [<n>]":
            R(Snippet("%(snippet_variants)s")),
    }

Code snippet where things are not working

@mark_as_snippet_grammar(big_big_stream = "beautiful")
class CppSnippetMoreExampleExperimental(MappingRule):
    pronunciation = "sublime snippet"
    mapping = {
        "<snippet>":
            R(Snippet("%(snippet)s")),
        "<snippet_variants> [<n>]":
            R(Snippet("%(snippet_variants)s")),
        "<big_big_stream> <thing> [<n>] [with <delimiter>]":
            R(Snippet(lambda stream,thing,n,delimiter:
                stream[0] + stream[1].format(delimiter).join([thing(x) for x in range(1,n + 1)]) + stream[2]
                ,remap_data = {"big_big_stream":"stream"})
            ),
    }

With a little bit of experimenting, it seems that removing the argument from the decorator has no effect where is removing the third dictionary value with the lambda solves the problem!

It should be noted, that for selecting the decorator or the base class positional description or point of origin seem to have no effect, whereas for argument queries, things are actually working if we are already within the function call! also dedicated sub index and commands work fine!

Error Message

Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\application\application.py", line 76, in respond_to_query
    s(view_information,query_description,extra)
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\queries\abstract\selection_query.py", line 80, in __call__
    self.result ,self.alternatives = self.handle_single(view_information,query_description, extra)
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\queries\big_roi.py", line 30, in handle_single
    return  possibilities[f](view_information,query_description, extra)
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\queries\big_roi.py", line 171, in case_one
    candidates = tiebreak_on_lca(definition_node,origin,find_all_nodes(definition_node, selector = selector))
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\library\traverse.py", line 31, in find_all_nodes
    return sorted([node  for node in reachable(root) if node_wanted(node) and hasattr(node,"first_token")],
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\library\traverse.py", line 31, in <listcomp>
    return sorted([node  for node in reachable(root) if node_wanted(node) and hasattr(node,"first_token")],
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\queries\big_roi.py", line 170, in <lambda>
    selector = lambda x:match_node(x,targets,exclusions) and generic_fix(x,build[1])
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\library\info.py", line 1187, in generic_fix
    fixer(root,atok)
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\library\info.py", line 1040, in fix_argument_list
    if already_fixed(root) or fix_definition(root.parent,atok):
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\library\info.py", line 1078, in fix_definition
    token = atok.find_token(token,tokenize.NAME,i.arg)
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\third_party\asttokens\asttokens.py", line 164, in find_token
    while not match_token(t, tok_type, tok_str) and not token.ISEOF(t.type):
  File "C:\Users\Admin\AppData\Roaming\Sublime Text 3\Packages\PythonVoiceCodingPlugin\third_party\asttokens\util.py", line 47, in match_token
    return token.type == tok_type and (tok_str is None or token.string == tok_str)
AttributeError: 'NoneType' object has no attribute 'type'