Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1d907c4
Fixing problems with sub indexing strings volume 2, fixing typo and h…
mpourmpoulis Apr 17, 2020
0007784
Make fix_argument and fix_argument_list not call fix_definition on La…
mpourmpoulis Apr 17, 2020
fe466db
Small ROI support for identity,identity left, identity right
mpourmpoulis Apr 18, 2020
c38e245
Bug fix: repairing rejected valid lambda definitions If they started …
mpourmpoulis Apr 19, 2020
b767fec
Add supportFor repairing lambda Which is followed by comma
mpourmpoulis Apr 22, 2020
fef04cd
Repair Change in after_star, remove special cases like surrounded by …
mpourmpoulis Apr 23, 2020
7dc83f9
Fix exceptions raised from trying to obtain the node from cursor , W…
mpourmpoulis Apr 23, 2020
af0b66b
nearest_note_from_offset rewrite In order to utilize the safer next_t…
mpourmpoulis Apr 23, 2020
c0d79ed
Reuse note_from_range inside nearest_node_from_offset
mpourmpoulis Apr 24, 2020
79e11a8
Update 0.1.2.txt
mpourmpoulis Apr 24, 2020
e161840
Include ast.ExceptHandler in the big statements
mpourmpoulis Apr 24, 2020
dc86edc
Add missing parent and parent field attributes in create fake in fixe…
mpourmpoulis Apr 24, 2020
099e87f
Remove some debugging stuff
mpourmpoulis Apr 24, 2020
abf0805
Fix a bug that rejected keywords following a : inside a single-line c…
mpourmpoulis Apr 25, 2020
41dedf9
Bug fix, odd quote = False so as to avoid escaping quotes
mpourmpoulis Apr 26, 2020
090043c
stuff For pylint and travis
mpourmpoulis May 4, 2020
417185a
Update .travis.yml
mpourmpoulis May 4, 2020
67f0647
Decorate handle_single,handle_multiple with @abc.abstractmethod to pr…
mpourmpoulis May 4, 2020
00bdf01
Fixed missing self In modification handler
mpourmpoulis May 4, 2020
f8a842a
Fix various small mistakes
mpourmpoulis May 4, 2020
d9cd502
Fix error in calling line_partial and support for Single-point select…
mpourmpoulis May 4, 2020
4e66b2d
Small cleanup
mpourmpoulis May 4, 2020
f662883
Temporary
mpourmpoulis May 6, 2020
64109fc
Neighbor should be none instead of end of file token And additional c…
mpourmpoulis May 7, 2020
8666dbc
Bug fix. add check To prevent off by one errorsThese are the boundari…
mpourmpoulis May 8, 2020
bc3c542
Restructure priority reestablishing and allow for an object of strate…
mpourmpoulis May 9, 2020
4cea129
Add check So that selection With an offset of 0 Does not result in a …
mpourmpoulis May 10, 2020
bd74210
Remove pop-up error message for installation of 0.1.2
mpourmpoulis May 10, 2020
1973b44
Remove accidental comma
mpourmpoulis May 10, 2020
d576bd4
Revert "Remove accidental comma"
mpourmpoulis May 10, 2020
c565682
Revert "Revert "Remove accidental comma""
mpourmpoulis May 10, 2020
0cf7518
Bug fix: make node_from_range Correctly yielded decorator when the cu…
mpourmpoulis May 10, 2020
f337a3d
Make LCA tie-breaking Aware of keyvalue pairs
mpourmpoulis May 11, 2020
38a0560
Minor cleanup selection_node
mpourmpoulis Jul 20, 2020
39d63e3
Update Main.sublime-menu to point To the new readthedocs documentation
mpourmpoulis Jul 20, 2020
acbf56e
Prompt the user for the quick installation utility right after install!
mpourmpoulis Jul 20, 2020
bebe6f1
Version bump
mpourmpoulis Jul 20, 2020
cb0fb87
application: add staticmethod decorator
mpourmpoulis Jul 20, 2020
2861fc7
Fix problem with not checking None values in a nearest_node_from_offset
mpourmpoulis Jul 21, 2020
b43492a
minor cleanup
mpourmpoulis Jul 21, 2020
e4a6b57
Modify tiebreak_on_lca to accept an optional pre-build LCA
mpourmpoulis Jul 21, 2020
2b01299
add invert_then_tiebreak argument to process_line Argument Queries
mpourmpoulis Jul 21, 2020
278985b
Remove print() causing crashes in correspond_to_index_in_call
mpourmpoulis Jul 21, 2020
d578450
Inside nth argument: replace query_description with deepcopy that is …
mpourmpoulis Jul 21, 2020
76e49b0
Bump version messages
mpourmpoulis Jul 21, 2020
8389c8b
Merge branch 'master' into develop-0.1.0
mpourmpoulis Jul 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.app

[MESSAGES CONTROL]
disable=all



enable=E

16 changes: 8 additions & 8 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -35,49 +35,49 @@
"caption": "Argument Queries",
"command": "open_url",
"args":{
"url": "http://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/SelectArgument.md"
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/SelectArgument/"
}
},
{
"caption": "Big Roi Queries",
"command": "open_url",
"args":{
"url":"https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/SelectBigROI.md"
"url":"https://pythonvoicecodingplugin.readthedocs.io/en/latest/SelectBigROI/"
}
},
{
"caption": "General Documentation",
"command": "open_url",
"args":{
"url":"https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/README.md"
"url":"https://pythonvoicecodingplugin.readthedocs.io/en/latest/"
}
},
{
"caption": "Operations",
"command": "open_url",
"args":{
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/Operations.md"
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/Operations/"
}
},
{
"caption": "Sub Indexing",
"command": "open_url",
"args":{
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/SubIndexing.md"
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/SubIndexing/"
}
},
{
"caption": "CollectionQueries",
"command": "open_url",
"args":{
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/CollectionQueries.md"
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/CollectionQueries/"
}
},
{
"caption": "Unofficial",
"command": "open_url",
"args":{
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/doc/README.md#experiment-or-unofficial-and-so-on-features-you-need-to-enable-manually"
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/#experiment-or-unofficial-and-so-on-features-you-need-to-enable-manually"
}
}

Expand Down Expand Up @@ -125,7 +125,7 @@
"caption": "Grammar Installation Doc",
"command": "open_url",
"args":{
"url": "https://github.com/mpourmpoulis/PythonVoiceCodingPlugin/blob/master/bundles/README.md"
"url": "https://pythonvoicecodingplugin.readthedocs.io/en/latest/Installation/"
}
},
{
Expand Down
3 changes: 3 additions & 0 deletions application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ def __init__(self,vid):
self.ui_controller = None
self.vid = vid

@staticmethod
def create_application_for_view(vid):
if vid not in Application.active_applications:
Application.active_applications[vid] = Application(vid)

@staticmethod
def get_application(vid):
Application.create_application_for_view(vid)
return Application.active_applications[vid]
Expand Down Expand Up @@ -77,6 +79,7 @@ def respond_to_query(self,interface,query_description,secondary=False):
except Exception as e:
# check if there are exceptions with parsing
if s.exceptions_raised:
# traceback.print_tb(s.exceptions_raised)
interface.clear_actions()
interface.push_action(PopUpErrorAction(str(s.exceptions_raised)))
return False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#########################################################################################

GRAMMAR_VERSION = (0,1,2)
GRAMMAR_VERSION = (0,1,3)

#########################################################################################

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#########################################################################################

GRAMMAR_VERSION = (0,1,2)
GRAMMAR_VERSION = (0,1,3)

#########################################################################################

Expand Down
2 changes: 1 addition & 1 deletion bundles/Caster/python_voice_coding_plugin_caster_v1-0-0.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#########################################################################################

GRAMMAR_VERSION = (0,1,2)
GRAMMAR_VERSION = (0,1,3)

#########################################################################################

Expand Down
3 changes: 2 additions & 1 deletion interface/common/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,11 @@ class PopUpErrorAction(InterfaceAction):
"""docstring for DisplayErrorAction"""
def __init__(self, text):
self.text = text

def execute(self,view,settings, sublime,**kwargs):
if not settings.get("show_error",False):
return
final_text = "<p></p><h>Something is off!</h>" + "<p>" + html.escape(self.text) + "</p>"
final_text = "<p></p><h>Something is off!</h>" + "<p>" + html.escape(self.text,quote = False) + "</p>"
def on_hide():
view.show_popup(final_text,max_width=1024, max_height=10000, flags= sublime.HIDE_ON_MOUSE_MOVE_AWAY)
view.show_popup(final_text,max_width=1024, max_height=10000,
Expand Down
9 changes: 6 additions & 3 deletions library/LCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def visit(self, node):
def get_depth(self, node):
return self.sequence[self.visits[node][0]][0]

def __call__(self,first_node,second_node,include_depth = False):
def __call__(self,first_node,second_node,only_depth = False,node_and_depth = True):
try :
x,y = self.visits[first_node]
w,v = self.visits[second_node]
Expand All @@ -52,9 +52,12 @@ def __call__(self,first_node,second_node,include_depth = False):
r = max(y,v)

ancestor = self.tree.query(l,r,"min")
if include_depth:
if node_and_depth:
return ancestor
elif only_depth:
return ancestor[0]
return ancestor[1]
else:
return ancestor[1]

def get_field_with_respect_to(self,node,parent_node):
index = bisect.bisect_left(self.field_history[parent_node],(self.visits[node][0],))
Expand Down
45 changes: 29 additions & 16 deletions library/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ def fake_attribute_from_tokens(root,tokens,**kwargs):

def is_store(root):
return match_node(root,ast.Store) or (match_node(root,ast.Name) and match_node(root.ctx,ast.Store))

def single(root):
return match_parent(node,(),ast.Attribute)
return match_parent(root,(),ast.Attribute)

def name(root):
return match_node(root,ast.Name)
Expand Down Expand Up @@ -207,8 +208,6 @@ def get_weak_header(root,atok):
root.items if match_node(root,(ast.With)) else
root.type if match_node(root,(ast.ExceptHandler)) else None
)
def get_body(root):
return root.body if match_node(root,(ast.IfExp, ast.If ,ast.For,ast.While, ast.Try)) else None



Expand Down Expand Up @@ -255,12 +254,12 @@ def get_return_value(root):
# need to revisit
def get_elements(root):
return (
root.elts if hasattr(root,elts) else None
root.elts if hasattr(root,"elts") else None
)

def get_context(root):
return (
root.ctx if hasattr(root,ctx) else None
root.ctx if hasattr(root,"ctx") else None
)

def get_key_value(root):
Expand Down Expand Up @@ -321,6 +320,17 @@ def get_container_check(root):
def get_membership(root):
return root if match_node(root,ast.Compare) and all([match_node(x,(ast.In,ast.NotIn)) for x in root.ops]) else None


# Extracting Identity Left And Right
def get_identity_check_left(root):
return root.left if match_node(root,ast.Compare) and all([match_node(x,(ast.Is,ast.IsNot)) for x in root.ops]) else None

def get_identity_check_right(root):
return root.comparators[-1] if match_node(root,ast.Compare) and all([match_node(x,(ast.Is,ast.IsNot)) for x in root.ops]) else None

def get_identity_check(root):
return root if match_node(root,ast.Compare) and all([match_node(x,(ast.Is,ast.IsNot)) for x in root.ops]) else None

# Extract Left Middle And Right from numerical comparisons
def get_comparison_left_side(root):
return root.left if match_node(root,ast.Compare) else None
Expand Down Expand Up @@ -667,28 +677,29 @@ def get_subparts_of_string(root,name_mode = False):
start_position = 1
if not check_fake(root):
x = root.first_token.string
# print("String:\n",x)
y1 = x.find("'")
y2 = x.find("\"")
if y1>=0 and y2>=0:
z = mean(y1,y2)
z = min(y1,y2)
elif y1>=0:
z = y1
elif y2>=0:
z = y2
else:
raise Exception("problem with splitting a string , there is no beginning!")
try :
if x[z]==x[z+1]==x[z+2]:
z = z + 2
except :
pass
start_position += z
start_position += root.first_token.startpos
# print("Start Position:\n",start_position)
# start_position = root.first_token.startpos + ( 1+(len(root.first_token.string) if root.first_token.type==tokenize.NAME else 0) if not name_mode else 0)
original = root.s if not name_mode else root.id
try :
splitted = split_string(root.s if not name_mode else root.id,even_letters = False if name_mode else True)
except :
print(" exceptions were thrown")
index = 0
print("splitted ",splitted)
for s in splitted:
if not s:
continue
Expand Down Expand Up @@ -881,12 +892,11 @@ def get_raw(root):

def correspond_to_index_in_call(root, index,field,field_index):
x = get_argument_from_call(root,index)
print("entering index taking \n",ast.dump(x))
if not x:
return False
if x.parent_field=="value":
x = x.parent
print("inside checking for index ",(x.parent_field,x.parent_field_index),(field,field_index))
# print("inside checking for index ",(x.parent_field,x.parent_field_index),(field,field_index))
return (field, field_index)==(x.parent_field,x.parent_field_index) if x else False


Expand Down Expand Up @@ -1016,6 +1026,9 @@ def fix_alias(root,atok):
def fix_argument(root,atok,token = None):
if already_fixed(root):
return token
# the following check was introduced to work around issue #17
if not match_node(root.parent.parent,ast.FunctionDef):
return None
if token is None:
fix_definition(root.parent.parent,atok)
if not already_fixed(root):
Expand All @@ -1037,15 +1050,14 @@ def fix_argument(root,atok,token = None):
def fix_argument_list(root,atok):
if not match_node(root,ast.arguments):
return False
if already_fixed(root) or fix_definition(root.parent,atok):
if already_fixed(root) or match_node(root.parent,(ast.FunctionDef)) and fix_definition(root.parent,atok):
return True
return False


def fix_definition(root,atok):
if already_fixed(root):
return True

# there is a discrepancy between the 3.3 and 3.4 versions of the abstract syntax tree
# in 3.3 the variable arguments and the variable keyboard arguments are stored in a little bit differently
x = root.args
Expand Down Expand Up @@ -1116,12 +1128,13 @@ def fix_exception_handler(root,atok):
if not root.type or not root.name:
mark_fixed(root)
return True
print("Exception Handler:\n",[root.first_token,root.last_token])

token = root.type.last_token
token = atok.find_token(next_token(atok,token),tokenize.NAME, root.name)
f = root.type.first_token
f = atok.find_token(previous_token(atok,f),tokenize.NAME, "except",reverse = True)
fake_name_node = create_fake(root,ast.Name,real_tokens = token,id = token.string,ctx = ast.Load())
fake_name_node = create_fake(root,ast.Name,real_tokens = token,id = token.string,ctx = ast.Load(),
parent = root,parent_field = "name")
set_fake(root,"name",fake_name_node)
# root.first_token=root.type.first_token
# root.last_token = token
Expand Down
2 changes: 1 addition & 1 deletion library/modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def add_modification_from(self,timestamp, origin, destination,original_code =
return self.add_modification(origin, destination, original_code, destination_code,comment)

def add_modification_updated(self, origin, destination,original_code = None,destination_code = "", comment= None):
return add_modification_from(self.current_time, origin, destination,original_code ,destination_code , comment)
return self.add_modification_from(self.current_time, origin, destination,original_code ,destination_code , comment)



Expand Down
18 changes: 13 additions & 5 deletions library/repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def get_dummy(atok):

def neighbors(atok,t):
x = next_token(atok,t)
x = x if x and x.type != 0 else None
y = next_token(atok,x) if x else None
z = previous_token(atok,t)
w = previous_token(atok,z) if z else None
Expand Down Expand Up @@ -92,15 +93,15 @@ def finish_atom(t):
def before_star(t):
# of these does not check all cases
return t[-1] is None or not (
finish_atom(t[-1]) or t[-1].string in ["(","[","{",",","import","for"] or t[-1].type in [token.INDENT]
finish_atom(t[-1]) or t[-1].string in ["(","[","{",",","import","for","lambda"] or t[-1].type in [token.INDENT]
)


def after_star(t):
# of these does not check all cases
return t[1] is None or not (
start_atom(t[1]) or t[-1] is not None and (
(t[-1].string,t[1].string) in [('(',','),(',',","),(",",")")] or
# (t[-1].string,t[1].string) in [('(',','),(',',","),(",",")")] or
t[-1].string in ["import"]

)
Expand All @@ -123,7 +124,7 @@ def after_both_sides(t):
return t[1] is None or not(
start_atom(t[1]) or
t[1].string in STARTING_UNARY or
(t[1].string,t[2].string) in STARTING_UNARY
(t[2] is not None and (t[1].string,t[2].string) in STARTING_UNARY)
)

def before_both_sides(t):
Expand Down Expand Up @@ -151,7 +152,7 @@ def after_unary(t):
def after_comma(t):
return t[1] is None or t[1].string ==","
def before_comma(t):
return t[ -1] is None or t[-1].string in ["(","[","{"]
return t[ -1] is None or t[-1].string in ["(","[","{","lambda"]

def after_bracket(t):
return t[1] is None or t[1].string in ["for","if","while","with"] or (
Expand All @@ -168,7 +169,13 @@ def after_double_dot(t):
return t[1] is None or not(
start_atom(t[1]) or
t[1].string.isspace() or
t[1].string=="]"
t[1].string in [
"]","assert","raise"
"break","continue","pass",
"return","yield","await","del",
"global","nonlocal",
"import","from"
]
)

def before_double_dot(t):
Expand Down Expand Up @@ -208,6 +215,7 @@ def after_else(t):
start_atom(t[1]) or t[1].string in [":"]
)
'''

def handle_empty_compound(atok ,t,l,b,dummy):
n = neighbors(atok, t)
left,right = expand_to_line_or_statement(atok,t, l, b)
Expand Down
Loading