Skip to content

Commit

Permalink
Turn code_object_oriented_accessor into list
Browse files Browse the repository at this point in the history
  • Loading branch information
auscompgeek committed Sep 3, 2023
1 parent d7237b5 commit 9197aa6
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 25 deletions.
3 changes: 0 additions & 3 deletions lang/csharp/csharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ def code_block():
actions.insert("{}")
actions.key("left enter enter up tab")

def code_operator_object_accessor():
actions.auto_insert(".")

def code_insert_null():
actions.auto_insert("null")

Expand Down
3 changes: 0 additions & 3 deletions lang/java/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ def code_operator_bitwise_right_shift():
def code_operator_bitwise_right_shift_assignment():
actions.insert(" >>= ")

def code_operator_object_accessor():
actions.insert(".")

def code_insert_null():
actions.insert("null")

Expand Down
3 changes: 0 additions & 3 deletions lang/javascript/javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ def code_block():
actions.user.insert_between("{", "}")
actions.key("enter")

def code_operator_object_accessor():
actions.auto_insert(".")

def code_state_while():
actions.user.insert_between("while (", ")")

Expand Down
8 changes: 5 additions & 3 deletions lang/php/php.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
}

ctx.lists["user.code_self"] = {"this": "$this"}
ctx.lists["user.code_operator_object_accessor"] = {
"arrow": "->",
# backwards compatibility
"dot": "->",
}


@ctx.action_class("user")
class UserActions:
def code_operator_object_accessor():
actions.auto_insert("->")

def code_define_class():
actions.auto_insert("class ")

Expand Down
3 changes: 0 additions & 3 deletions lang/python/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ def code_operator_bitwise_right_shift():
def code_operator_bitwise_right_shift_assignment():
actions.auto_insert(" >>= ")

def code_operator_object_accessor():
actions.auto_insert(".")

def code_insert_null():
actions.auto_insert("None")

Expand Down
3 changes: 0 additions & 3 deletions lang/ruby/ruby.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ def code_operator_bitwise_right_shift():
def code_operator_bitwise_right_shift_assignment():
actions.auto_insert(" >>= ")

def code_operator_object_accessor():
actions.auto_insert(".")

def code_insert_null():
actions.auto_insert("nil")

Expand Down
3 changes: 0 additions & 3 deletions lang/rust/rust.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ def code_next():

# tag: object_oriented

def code_operator_object_accessor():
actions.auto_insert(".")

def code_define_class():
actions.auto_insert("struct ")

Expand Down
3 changes: 0 additions & 3 deletions lang/scala/scala.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,6 @@ def code_insert_type_annotation(type: str):
def code_insert_return_type(type: str):
actions.insert(f": {type}")

def code_operator_object_accessor():
actions.insert(".")

def code_default_function(text: str):
"""Inserts function declaration"""
actions.user.code_public_function(text)
Expand Down
12 changes: 11 additions & 1 deletion lang/tags/object_oriented.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from talon import Module
from talon import Context, Module

ctx = Context()
mod = Module()

mod.tag(
Expand All @@ -12,6 +13,15 @@
desc="Reference to the current object (e.g. C++ `this` or Python `self`)",
)

mod.list(
"code_operator_object_accessor",
desc="An object accessor operator (e.g. Java `.` or PHP `->`)",
)

ctx.lists["self.code_operator_object_accessor"] = {
"dot": ".",
}


@mod.action_class
class Actions:
Expand Down
3 changes: 3 additions & 0 deletions lang/tags/object_oriented.talon
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ tag: user.code_object_oriented
state {user.code_self}: insert(code_self)

state class: user.code_define_class()

{user.code_self} {user.code_operator_object_accessor}:
insert("{code_self}{code_operator_object_accessor}")

0 comments on commit 9197aa6

Please sign in to comment.