Skip to content

Commit c6478fa

Browse files
author
John Towers
committed
Merge branch 'release/0.0.5'
2 parents ebbaa94 + 166fc79 commit c6478fa

File tree

5 files changed

+52
-9
lines changed

5 files changed

+52
-9
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ Supports most useful CLI commands including:
1313
* Push\Pull source
1414
* Create Apex classes
1515
* Run tests for an org or specific class
16-
16+
* Code completion
17+
* Diagnostics
1718
Uses syntax highlighting from MavensMate
1819

19-
Supports code completion with the [Apex Language Server](https://developer.salesforce.com/docs/atlas.en-us.sfdx_ide2.meta/sfdx_ide2/sfdx_ide2_build_app_apex_language_server_protocol.htm)
20+
Language services (e.g., code completion and diagnostics) are provided by the [Apex Language Server](https://developer.salesforce.com/docs/atlas.en-us.sfdx_ide2.meta/sfdx_ide2/sfdx_ide2_build_app_apex_language_server_protocol.htm)
2021

2122
## Settings
2223

apex-jorje-lsp.jar

11.2 KB
Binary file not shown.

dxmate.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .lib.languageServer import *
1515
from .lib.event_hub import EventHub
1616
from .lib.util import *
17+
from .lib.diagnostic import *
1718
import ntpath
1819

1920

@@ -148,7 +149,7 @@ def __init__(self):
148149
self.refreshing = False
149150

150151
def on_pre_close(self, view):
151-
EventHub.publish('on_pre_close')
152+
EventHub.publish('on_pre_close', view)
152153

153154

154155
def on_close(self, view):
@@ -161,6 +162,22 @@ def on_post_save_async(self, view):
161162
EventHub.publish('on_post_save_async', view)
162163
def on_close(self, view):
163164
EventHub.publish('on_close', view)
165+
def on_hover(self, view, point, hover_zone):
166+
EventHub.publish('on_hover', view, point, hover_zone)
167+
def on_window_command(self, window, command_name, *args):
168+
if command_name == 'exit':
169+
EventHub.publish('exit', window, *args)
170+
elif command_name == 'close_window':
171+
EventHub.publish('close_window', window, *args)
172+
else:
173+
EventHub.publish('on_window_command', window, command_name, *args)
174+
def on_text_command(self, window, command_name, *args):
175+
if command_name == 'exit':
176+
EventHub.publish('exit', window, *args)
177+
elif command_name == 'close_window':
178+
EventHub.publish('close_window', window, *args)
179+
else:
180+
EventHub.publish('on_window_command', window, command_name, *args)
164181
def on_modified_async(self, view):
165182
active_file_extension = file_extension(view)
166183
if active_file_extension != '.cls' and active_file_extension != '.trigger':
@@ -252,6 +269,8 @@ def is_enabled(self):
252269
self.active_file = active_file()
253270
if not self.active_file.endswith('.cls'):
254271
return False
272+
if not file_is_test(self.window.active_view()):
273+
return False
255274
return True
256275

257276
def run_command(self):

lib/languageServer.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
from urllib.request import url2pathname
3737
from .request import Request
3838
from .notification import Notification
39-
4039
client = None
4140

4241

@@ -161,6 +160,7 @@ def initialize_document_sync(text_document_sync_kind):
161160
def handle_initialize_result(result, client, window, config):
162161
global didopen_after_initialize
163162
capabilities = result.get("capabilities")
163+
debug(capabilities)
164164
client.set_capabilities(capabilities)
165165

166166
# TODO: These handlers is already filtered by syntax but does not need to
@@ -170,8 +170,7 @@ def handle_initialize_result(result, client, window, config):
170170
if document_sync:
171171
initialize_document_sync(document_sync)
172172

173-
EventHub.subscribe('document.diagnostics', handle_diagnostics)
174-
EventHub.subscribe('on_close', remove_diagnostics)
173+
175174
for view in didopen_after_initialize:
176175
notify_did_open(view)
177176
if show_status_messages:
@@ -234,6 +233,9 @@ def start_server():
234233
except Exception as err:
235234
debug(err)
236235

236+
def get_client():
237+
global client
238+
return client
237239

238240
def start_client():
239241
global client
@@ -250,6 +252,9 @@ def start_client():
250252
"completionItem": {
251253
"snippetSupport": True
252254
}
255+
},
256+
"hover":{
257+
"dynamicRegistration": True
253258
}
254259
}
255260
}

lib/util.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from .languageServer import *
1010
from .event_hub import EventHub
1111
import json
12-
12+
import re
1313
settings = None
1414

1515
def load_settings():
@@ -37,6 +37,10 @@ def dxProjectFolder():
3737
return folder
3838
return ''
3939

40+
def file_is_test(view):
41+
contents = view.substr(sublime.Region(0, view.size()))
42+
debug(contents)
43+
return '@istest' in contents.lower() or 'testmethod' in contents.lower()
4044

4145
def run_events():
4246
if dxProjectFolder() != '':
@@ -59,6 +63,13 @@ def file_extension(view):
5963
return file_extension
6064

6165

66+
def is_apex_file(view):
67+
ext = file_extension(view)
68+
if ext and (ext == '.cls' or ext == '.trigger'):
69+
return True
70+
return False
71+
72+
6273
def get_plugin_folder():
6374
packages_path = os.path.join(sublime.packages_path(), plugin_name())
6475
debug(packages_path)
@@ -99,10 +110,17 @@ def debug(*args):
99110
print(plugin_name(), ': ', *args)
100111

101112

102-
def handle_close():
103-
if dxProjectFolder() == '':
113+
114+
def handle_close(window, *args):
115+
if dxProjectFolder() == '' and client:
116+
client.kill()
117+
118+
def handle_exit(window, *args):
119+
if client:
104120
client.kill()
105121

122+
EventHub.subscribe('exit', handle_exit)
123+
EventHub.subscribe('close_window', handle_close)
106124

107125
def format_request(payload: 'Dict[str, Any]'):
108126
"""Converts the request into json and adds the Content-Length header"""

0 commit comments

Comments
 (0)