Skip to content

Commit 5b8a9b2

Browse files
author
John Towers
committed
Merge branch 'hotfix/fix-dependencies'
2 parents c6478fa + 8826c03 commit 5b8a9b2

File tree

7 files changed

+444
-6
lines changed

7 files changed

+444
-6
lines changed

dependencies.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"*": {
2+
"*": [
3+
"mdpopups"
4+
]
5+
}

dxmate.py

+63-1
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,70 @@ def run_command(self):
563563
printer.write('\n' + str(err, 'utf-8'))
564564

565565

566-
class DxmateCreateApexClassCommand(sublime_plugin.WindowCommand):
566+
class DxmateRunSoqlCommand(sublime_plugin.WindowCommand):
567+
568+
def run(self):
569+
sublime.active_window().show_input_panel(
570+
'Query', '', self.run_query, None, None)
571+
572+
def is_enabled(self, paths=[]):
573+
dx_folder = dxProjectFolder()
574+
if(dx_folder == ''):
575+
return False
576+
return True
567577

578+
def run_query(self, input):
579+
self.query = input
580+
printer.show()
581+
t = threading.Thread(target=self.run_command)
582+
t.start()
583+
t.printer = printer
584+
t.process_id = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
585+
ThreadProgress(t, 'Running query', 'Query run')
586+
printer.write('\nRunning query')
587+
printer.write('\nResult: ')
588+
PanelThreadProgress(t, 'Query run')
589+
590+
def run_command(self):
591+
dx_folder = dxProjectFolder()
592+
args = ['sfdx', 'force:data:soql:query',
593+
'-q', self.query]
594+
startupinfo = None
595+
if os.name == 'nt':
596+
startupinfo = subprocess.STARTUPINFO()
597+
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
598+
p = subprocess.Popen(args, stdout=subprocess.PIPE,
599+
stderr=subprocess.PIPE, startupinfo=startupinfo, cwd=dx_folder)
600+
601+
p.wait()
602+
603+
out, err = p.communicate()
604+
r = p.returncode
605+
if p.returncode == 0:
606+
printer.write('\nOpening results file')
607+
content = str(out,'UTF-8')
608+
#try:
609+
# parsed = json.loads(content)
610+
# content = json.dumps(parsed, sort_keys=True,indent=1, separators=(',', ':'))
611+
# debug(content)
612+
#except Exception as e:
613+
# debug('could not format query results\n', e)
614+
file = sublime.active_window().new_file()
615+
file.set_scratch(True)
616+
file.set_name('SOQL')
617+
syntax_path = None
618+
if "linux" in sys.platform or "darwin" in sys.platform:
619+
syntax_path = os.path.join("Packages",plugin_name(),"sublime","lang","JSON.tmLanguage")
620+
else:
621+
syntax_path = os.path.join("Packages/"+plugin_name()+"/sublime/lang/JSON.tmLanguage")
622+
#file.set_syntax_file(syntax_path)
623+
file.run_command("insert", {"characters":content})
624+
else:
625+
printer.write('\nError running query:')
626+
printer.write('\n' + str(err, 'utf-8'))
627+
628+
629+
class DxmateCreateApexClassCommand(sublime_plugin.WindowCommand):
568630
def run(self, paths=[]):
569631
if len(paths) != 1 or (len(paths) > 0 and os.path.isfile(paths[0])):
570632
printer.show()

lib/languageServer.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def get_document_state(path: str) -> DocumentState:
6060
return document_states[path]
6161

6262
def notify_did_open(view: sublime.View):
63-
if client and view and view.file_name():
63+
if client and view and view.file_name() and is_apex_file(view):
6464
view.settings().set("show_definitions", False)
6565
if view.file_name() not in document_states:
6666
get_document_state(view.file_name())
@@ -75,15 +75,15 @@ def notify_did_open(view: sublime.View):
7575

7676

7777
def notify_did_close(view: sublime.View):
78-
if view.file_name() in document_states:
78+
if is_apex_file(view) and view.file_name() in document_states:
7979
del document_states[view.file_name()]
8080
if client:
8181
params = {"textDocument": {"uri": filename_to_uri(view.file_name())}}
8282
client.send_notification(Notification.didClose(params))
8383

8484

8585
def notify_did_save(view: sublime.View):
86-
if view.file_name() in document_states:
86+
if is_apex_file(view) and view.file_name() in document_states:
8787
if client:
8888
params = {"textDocument": {"uri": filename_to_uri(view.file_name())}}
8989
client.send_notification(Notification.didSave(params))
@@ -122,7 +122,7 @@ def queue_did_change(view: sublime.View):
122122

123123

124124
def notify_did_change(view: sublime.View):
125-
if view.buffer_id() in pending_buffer_changes:
125+
if is_apex_file(view) and view.buffer_id() in pending_buffer_changes:
126126
del pending_buffer_changes[view.buffer_id()]
127127
if client:
128128
document_state = get_document_state(view.file_name())

lib/util.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def get_plugin_folder():
7979
def get_syntax_folder():
8080
plugin_folder = get_plugin_folder()
8181
syntax_folder = os.path.join(plugin_folder, "sublime", "lang")
82-
debug(syntax_folder)
8382
return syntax_folder
8483

8584

@@ -112,10 +111,12 @@ def debug(*args):
112111

113112

114113
def handle_close(window, *args):
114+
client = get_client()
115115
if dxProjectFolder() == '' and client:
116116
client.kill()
117117

118118
def handle_exit(window, *args):
119+
client = get_client()
119120
if client:
120121
client.kill()
121122

sublime/Default.sublime-commands

+4
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@
3030
{
3131
"caption" : "dxmate: Run Tests for This Class",
3232
"command": "dxmate_run_file_tests"
33+
},
34+
{
35+
"caption" : "dxmate: Run SOQL Query",
36+
"command": "dxmate_run_soql"
3337
}
3438
]

sublime/Main.sublime-menu

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
"caption" : "DXMate",
55
"children":
66
[
7+
{
8+
"caption": "Data",
9+
"children" :
10+
[
11+
{
12+
"caption": "SOQL Query",
13+
"command" : "dxmate_run_soql"
14+
}
15+
]
16+
},
717
{
818
"caption": "Project",
919
"children" :

0 commit comments

Comments
 (0)