forked from palantir/python-language-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_highlight.py
More file actions
56 lines (46 loc) · 1.46 KB
/
Copy pathtest_highlight.py
File metadata and controls
56 lines (46 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright 2017 Palantir Technologies, Inc.
from pyls import lsp, uris
from pyls.workspace import Document
from pyls.plugins.highlight import pyls_document_highlight
DOC_URI = uris.from_fs_path(__file__)
DOC = """a = "hello"
a.startswith("b")
"""
def test_highlight(workspace):
# Over 'a' in a.startswith
cursor_pos = {'line': 1, 'character': 0}
doc = Document(DOC_URI, workspace, DOC)
assert pyls_document_highlight(doc, cursor_pos) == [{
'range': {
'start': {'line': 0, 'character': 0},
'end': {'line': 0, 'character': 1},
},
# The first usage is Write
'kind': lsp.DocumentHighlightKind.Write
}, {
'range': {
'start': {'line': 1, 'character': 0},
'end': {'line': 1, 'character': 1},
},
# The second usage is Read
'kind': lsp.DocumentHighlightKind.Read
}]
SYS_DOC = '''import sys
print sys.path
'''
def test_sys_highlight(workspace):
cursor_pos = {'line': 0, 'character': 8}
doc = Document(DOC_URI, workspace, SYS_DOC)
assert pyls_document_highlight(doc, cursor_pos) == [{
'range': {
'start': {'line': 0, 'character': 7},
'end': {'line': 0, 'character': 10}
},
'kind': lsp.DocumentHighlightKind.Write
}, {
'range': {
'start': {'line': 1, 'character': 6},
'end': {'line': 1, 'character': 9}
},
'kind': lsp.DocumentHighlightKind.Read
}]