Repository: palantir/python-language-server

Issue:
Implement continuous integration with CircleCi

Comments:

Patch:
diff --git a/circle.yml b/circle.yml
new file mode 100644
index 0000000..d66bb32
--- /dev/null
+++ b/circle.yml
@@ -0,0 +1,3 @@
+machine:
+  post:
+    - pyenv global 2.7.11 3.6.0
diff --git a/pyls/providers/code_lens.py b/pyls/providers/code_lens.py
deleted file mode 100644
index 3e97e68..0000000
--- a/pyls/providers/code_lens.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2017 Palantir Technologies, Inc.
-import logging
-from .base import JediProvider
-
-log = logging.getLogger(__name__)
-
-
-class JediReferencesProvider(JediProvider):
-    """ Returns the references to whatever is under the cursor, if it's known """
-
-    def run(self, doc_uri, position, exclude_declaration=False):
-        usages = self.jedi_script(doc_uri, position).usages()
-
-        if exclude_declaration:
-            # Filter out if the usage is the actual declaration of the thing
-            usages = [d for d in usages if not d.is_definition()]
-
-        return [{
-            'uri': self.workspace.get_uri_like(doc_uri, d.module_path),
-            'range': {
-                'start': {'line': d.line - 1, 'character': d.column},
-                'end': {'line': d.line - 1, 'character': d.column + len(d.name)}
-            }
-        } for d in usages]
diff --git a/pyls/providers/completion.py b/pyls/providers/completion.py
index e432808..584fd6a 100644
--- a/pyls/providers/completion.py
+++ b/pyls/providers/completion.py
@@ -28,13 +28,11 @@ def sort_text(definition):
     """ Ensure builtins appear at the bottom.
     Description is of format <type>: <module>.<item>
     """
-    mod = definition.description.split(":", 1)[1].strip()
-
     if definition.in_builtin_module():
         # It's a builtin, put it last
         return 'z' + definition.name
 
-    if '.' in mod and mod.rsplit(".", 1)[1].startswith("_"):
+    if definition.name.startswith("_"):
         # It's a 'hidden' func, put it next last
         return 'y' + definition.name
 
diff --git a/pyls/providers/hover.py b/pyls/providers/hover.py
index dc28016..74b7afa 100644
--- a/pyls/providers/hover.py
+++ b/pyls/providers/hover.py
@@ -9,16 +9,16 @@ class JediDocStringHoverProvider(JediProvider):
     """ Displays the docstring of whatever is under the cursor, if it's known """
 
     def run(self, doc_uri, position):
-        completions = self.jedi_script(doc_uri, position).completions()
+        definitions = self.jedi_script(doc_uri, position).goto_definitions()
         document = self.workspace.get_document(doc_uri)
         word = document.word_at_position(position)
 
         # Find an exact match for a completion
-        completions = [c for c in completions if c.name == word]
+        definitions = [d for d in definitions if d.name == word]
 
-        if len(completions) == 0:
+        if len(definitions) == 0:
             # :(
             return {'contents': ''}
 
         # Maybe the docstring could be huuuuuuuuuuge...
-        return {'contents': completions[0].docstring() or ""}
+        return {'contents': definitions[0].docstring() or ""}


Test patch:
diff --git a/test/providers/test_hover.py b/test/providers/test_hover.py
index 107bd31..596e014 100644
--- a/test/providers/test_hover.py
+++ b/test/providers/test_hover.py
@@ -2,17 +2,17 @@
 from pyls.providers.hover import JediDocStringHoverProvider
 
 DOC_URI = __file__
-DOC = """import sys
+DOC = """
 
 def main():
-    print sys.stdin.read()
-    raise Exception()
+    \"\"\"hello world\"\"\"
+    pass
 """
 
 
 def test_hover(workspace):
-    # Over 'Exception' in raise Exception()
-    hov_position = {'line': 4, 'character': 17}
+    # Over 'main' in def main():
+    hov_position = {'line': 2, 'character': 6}
     # Over the blank second line
     no_hov_position = {'line': 1, 'character': 0}
 
@@ -20,7 +20,7 @@ def test_hover(workspace):
     provider = JediDocStringHoverProvider(workspace)
 
     assert {
-        'contents': 'Common base class for all non-exit exceptions.'
+        'contents': 'main()\n\nhello world'
     } == provider.run(DOC_URI, hov_position)
 
     assert {'contents': ''} == provider.run(DOC_URI, no_hov_position)