@@ -602,7 +602,6 @@ def _cell_document__definition(self, cellDocument=None, position=None, **_kwargs
602
602
if notebookDocument is None :
603
603
raise ValueError ("Invalid notebook document" )
604
604
605
- random_uri = str (uuid .uuid4 ())
606
605
# cell_list helps us map the diagnostics back to the correct cell later.
607
606
cell_list : List [Dict [str , Any ]] = []
608
607
@@ -632,21 +631,8 @@ def _cell_document__definition(self, cellDocument=None, position=None, **_kwargs
632
631
633
632
offset += num_lines
634
633
635
- # TODO: make a workspace temp document context manager that yields the random uri and cleans up afterwards
636
- workspace .put_document (random_uri , total_source )
637
- log .info (f'Making new document { random_uri } ' )
638
- try :
634
+ with workspace .temp_document (total_source ) as random_uri :
639
635
definitions = self .definitions (random_uri , position )
640
- log .info (f'Got definitions: { definitions } ' )
641
-
642
- # {
643
- # 'uri': uris.uri_with(document.uri, path=str(d.module_path)),
644
- # 'range': {
645
- # 'start': {'line': d.line - 1, 'character': d.column},
646
- # 'end': {'line': d.line - 1, 'character': d.column + len(d.name)},
647
- # }
648
- # }
649
- print (definitions )
650
636
for definition in definitions :
651
637
# TODO: a better test for if a definition is the random_uri
652
638
if random_uri in definition ['uri' ]:
@@ -659,8 +645,6 @@ def _cell_document__definition(self, cellDocument=None, position=None, **_kwargs
659
645
definition ['range' ]['start' ]['line' ] -= cell ['line_start' ]
660
646
definition ['range' ]['end' ]['line' ] -= cell ['line_start' ]
661
647
return definitions
662
- finally :
663
- workspace .rm_document (random_uri )
664
648
665
649
def m_text_document__definition (self , textDocument = None , position = None , ** _kwargs ):
666
650
# textDocument here is just a dict with a uri
0 commit comments