@@ -112,8 +112,8 @@ def _create_document(self, doc_uri, source=None, version=None):
112112
113113class Document (object ):
114114
115- def __init__ (self , uri , source = None , version = None , local = True , extra_sys_path = None , rope_project_builder = None ,
116- config = None , workspace = None ):
115+ def __init__ (self , uri , workspace , source = None , version = None , local = True , extra_sys_path = None ,
116+ rope_project_builder = None , config = None ):
117117 self .uri = uri
118118 self .version = version
119119 self .path = uris .to_fs_path (uri )
@@ -213,16 +213,9 @@ def word_at_position(self, position):
213213 return m_start [0 ] + m_end [- 1 ]
214214
215215 def jedi_names (self , all_scopes = False , definitions = True , references = False ):
216- environment_path = None
217- if self ._config :
218- jedi_settings = self ._config .plugin_settings ('jedi' , document_path = self .path )
219- environment_path = jedi_settings .get ('environment' )
220- environment = self .get_enviroment (environment_path ) if environment_path else None
221-
222- return jedi .api .names (
223- source = self .source , path = self .path , all_scopes = all_scopes ,
224- definitions = definitions , references = references , environment = environment ,
225- )
216+ script = self .jedi_script ()
217+ return script .get_names (all_scopes = all_scopes , definitions = definitions ,
218+ references = references )
226219
227220 def jedi_script (self , position = None ):
228221 extra_paths = []
@@ -233,19 +226,20 @@ def jedi_script(self, position=None):
233226 environment_path = jedi_settings .get ('environment' )
234227 extra_paths = jedi_settings .get ('extra_paths' ) or []
235228
236- sys_path = self .sys_path (environment_path ) + extra_paths
237229 environment = self .get_enviroment (environment_path ) if environment_path else None
230+ sys_path = self .sys_path (environment_path ) + extra_paths
231+ project_path = self ._workspace .root_path
238232
239233 kwargs = {
240- 'source ' : self .source ,
234+ 'code ' : self .source ,
241235 'path' : self .path ,
242- 'sys_path' : sys_path ,
243236 'environment' : environment ,
237+ 'project' : jedi .Project (path = project_path , sys_path = sys_path ),
244238 }
245239
246240 if position :
247- kwargs [ 'line' ] = position [ 'line' ] + 1
248- kwargs [ 'column' ] = _utils .clip_column ( position [ 'character' ], self . lines , position [ 'line' ] )
241+ # Deprecated by Jedi to use in Script() constructor
242+ kwargs + = _utils .position_to_jedi_linecolumn ( self , position )
249243
250244 return jedi .Script (** kwargs )
251245
0 commit comments