@@ -235,8 +235,8 @@ suite('Hover Definition', () => {
235235 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '30,4' , 'Start position is incorrect' ) ;
236236 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '30,11' , 'End position is incorrect' ) ;
237237 assert . equal ( def [ 0 ] . contents . length , 2 , 'Invalid content items' ) ;
238- assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'method1(self)' , 'function signature incorrect' ) ;
239- assert . equal ( def [ 0 ] . contents [ 1 ] , `${ EOL } This is method1` , 'Invalid conents' ) ;
238+ assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'def method1(self)' , 'function signature incorrect' ) ;
239+ assert . equal ( def [ 0 ] . contents [ 1 ] , `This is method1` , 'Invalid conents' ) ;
240240 } ) . then ( done , done ) ;
241241 } ) ;
242242
@@ -255,8 +255,8 @@ suite('Hover Definition', () => {
255255 assert . equal ( def . length , 1 , 'Definition lenght is incorrect' ) ;
256256 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '1,9' , 'Start position is incorrect' ) ;
257257 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '1,12' , 'End position is incorrect' ) ;
258- assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'fun()' , 'function signature incorrect' ) ;
259- assert . equal ( def [ 0 ] . contents [ 1 ] , `${ EOL } This is fun` , 'Invalid conents' ) ;
258+ assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'def fun()' , 'function signature incorrect' ) ;
259+ assert . equal ( def [ 0 ] . contents [ 1 ] , `This is fun` , 'Invalid conents' ) ;
260260 } ) . then ( done , done ) ;
261261 } ) ;
262262
@@ -275,8 +275,8 @@ suite('Hover Definition', () => {
275275 assert . equal ( def . length , 1 , 'Definition lenght is incorrect' ) ;
276276 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '25,4' , 'Start position is incorrect' ) ;
277277 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '25,7' , 'End position is incorrect' ) ;
278- assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'bar()' , 'function signature incorrect' ) ;
279- const documentation = `${ EOL } 说明 - keep this line, it works${ EOL } delete following line, it works${ EOL } 如果存在需要等待审批或正在执行的任务,将不刷新页面` ;
278+ assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'def bar()' , 'function signature incorrect' ) ;
279+ const documentation = `说明 - keep this line, it works${ EOL } delete following line, it works${ EOL } 如果存在需要等待审批或正在执行的任务,将不刷新页面` ;
280280 assert . equal ( def [ 0 ] . contents [ 1 ] , documentation , 'Invalid conents' ) ;
281281 } ) . then ( done , done ) ;
282282 } ) ;
@@ -296,8 +296,8 @@ suite('Hover Definition', () => {
296296 assert . equal ( def . length , 1 , 'Definition lenght is incorrect' ) ;
297297 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '1,5' , 'Start position is incorrect' ) ;
298298 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '1,16' , 'End position is incorrect' ) ;
299- assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'showMessage()' , 'Invalid content items' ) ;
300- const documentation = `${ EOL } Кюм ут жэмпэр пошжим льаборэж, коммюны янтэрэсщэт нам ед, декта игнота ныморэ жят эи. ${ EOL } Шэа декам экшырки эи, эи зыд эррэм докэндё, векж факэтэ пэрчыквюэрёж ку.` ;
299+ assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'def showMessage()' , 'Invalid content items' ) ;
300+ const documentation = `Кюм ут жэмпэр пошжим льаборэж, коммюны янтэрэсщэт нам ед, декта игнота ныморэ жят эи. ${ EOL } Шэа декам экшырки эи, эи зыд эррэм докэндё, векж факэтэ пэрчыквюэрёж ку.` ;
301301 assert . equal ( def [ 0 ] . contents [ 1 ] , documentation , 'Invalid conents' ) ;
302302 } ) . then ( done , done ) ;
303303 } ) ;
@@ -333,4 +333,88 @@ suite('Hover Definition', () => {
333333 assert . equal ( def . length , 0 , 'Definition lenght is incorrect' ) ;
334334 } ) . then ( done , done ) ;
335335 } ) ;
336+
337+ test ( 'Highlighting Class' , done => {
338+ let textEditor : vscode . TextEditor ;
339+ let textDocument : vscode . TextDocument ;
340+ return vscode . workspace . openTextDocument ( fileHover ) . then ( document => {
341+ textDocument = document ;
342+ return vscode . window . showTextDocument ( textDocument ) ;
343+ } ) . then ( editor => {
344+ assert ( vscode . window . activeTextEditor , 'No active editor' ) ;
345+ textEditor = editor ;
346+ const position = new vscode . Position ( 11 , 15 ) ;
347+ return vscode . commands . executeCommand ( 'vscode.executeHoverProvider' , textDocument . uri , position ) ;
348+ } ) . then ( ( def : [ { range : vscode . Range , contents : { language : string , value : string } [ ] } ] ) => {
349+ assert . equal ( def . length , 1 , 'Definition lenght is incorrect' ) ;
350+ assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '11,12' , 'Start position is incorrect' ) ;
351+ assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '11,18' , 'End position is incorrect' ) ;
352+ assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'class Random(self, x=None)' , 'Invalid content items' ) ;
353+ const documentation = `Random number generator base class used by bound module functions.${ EOL } ${ EOL } ` +
354+ `Used to instantiate instances of Random to get generators that don't${ EOL } ` +
355+ `share state.${ EOL } ${ EOL } ` +
356+ `Class Random can also be subclassed if you want to use a different basic${ EOL } ` +
357+ `generator of your own devising: in that case, override the following${ EOL } ` +
358+ `methods: random(), seed(), getstate(), and setstate().${ EOL } ` +
359+ `Optionally, implement a getrandbits() method so that randrange()${ EOL } ` +
360+ `can cover arbitrarily large ranges.`
361+
362+ assert . equal ( def [ 0 ] . contents [ 1 ] , documentation , 'Invalid conents' ) ;
363+ } ) . then ( done , done ) ;
364+ } ) ;
365+
366+ test ( 'Highlight Method' , done => {
367+ let textEditor : vscode . TextEditor ;
368+ let textDocument : vscode . TextDocument ;
369+ return vscode . workspace . openTextDocument ( fileHover ) . then ( document => {
370+ textDocument = document ;
371+ return vscode . window . showTextDocument ( textDocument ) ;
372+ } ) . then ( editor => {
373+ assert ( vscode . window . activeTextEditor , 'No active editor' ) ;
374+ textEditor = editor ;
375+ const position = new vscode . Position ( 12 , 10 ) ;
376+ return vscode . commands . executeCommand ( 'vscode.executeHoverProvider' , textDocument . uri , position ) ;
377+ } ) . then ( ( def : [ { range : vscode . Range , contents : { language : string , value : string } [ ] } ] ) => {
378+ assert . equal ( def . length , 1 , 'Definition lenght is incorrect' ) ;
379+ assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '12,5' , 'Start position is incorrect' ) ;
380+ assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '12,12' , 'End position is incorrect' ) ;
381+ assert . equal ( def [ 0 ] . contents [ 0 ] . value , 'def randint(self, a, b)' , 'Invalid content items' ) ;
382+ const documentation = `Return random integer in range [a, b], including both end points.${ EOL } ` ;
383+ assert . equal ( def [ 0 ] . contents [ 1 ] , documentation , 'Invalid conents' ) ;
384+ } ) . then ( done , done ) ;
385+ } ) ;
386+
387+ test ( 'Highlight Multiline Method Signature' , done => {
388+ let textEditor : vscode . TextEditor ;
389+ let textDocument : vscode . TextDocument ;
390+ return vscode . workspace . openTextDocument ( fileHover ) . then ( document => {
391+ textDocument = document ;
392+ return vscode . window . showTextDocument ( textDocument ) ;
393+ } ) . then ( editor => {
394+ assert ( vscode . window . activeTextEditor , 'No active editor' ) ;
395+ textEditor = editor ;
396+ const position = new vscode . Position ( 15 , 10 ) ;
397+ return vscode . commands . executeCommand ( 'vscode.executeHoverProvider' , textDocument . uri , position ) ;
398+ } ) . then ( ( def : [ { range : vscode . Range , contents : { language : string , value : string } [ ] } ] ) => {
399+ assert . equal ( def . length , 1 , 'Definition lenght is incorrect' ) ;
400+ assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '15,2' , 'Start position is incorrect' ) ;
401+ assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '15,10' , 'End position is incorrect' ) ;
402+ const signature = `def __init__(self, group=None, target=None, name=None,${ EOL } args=(), kwargs=None, verbose=None)` ;
403+ assert . equal ( def [ 0 ] . contents [ 0 ] . value , signature , 'Invalid content items' ) ;
404+ const documentation = `This constructor should always be called with keyword arguments. Arguments are:${ EOL } ${ EOL } ` +
405+ `*group* should be None; reserved for future extension when a ThreadGroup${ EOL } ` +
406+ `class is implemented.${ EOL } ${ EOL } ` +
407+ `*target* is the callable object to be invoked by the run()${ EOL } ` +
408+ `method. Defaults to None, meaning nothing is called.${ EOL } ${ EOL } ` +
409+ `*name* is the thread name. By default, a unique name is constructed of${ EOL } ` +
410+ `the form "Thread-N" where N is a small decimal number.${ EOL } ${ EOL } ` +
411+ `*args* is the argument tuple for the target invocation. Defaults to ().${ EOL } ${ EOL } ` +
412+ `*kwargs* is a dictionary of keyword arguments for the target${ EOL } ` +
413+ `invocation. Defaults to {}.${ EOL } ${ EOL } ` +
414+ `If a subclass overrides the constructor, it must make sure to invoke${ EOL } ` +
415+ `the base class constructor (Thread.__init__()) before doing anything${ EOL } ` +
416+ `else to the thread.` ;
417+ assert . equal ( def [ 0 ] . contents [ 1 ] , documentation , 'Invalid conents' ) ;
418+ } ) . then ( done , done ) ;
419+ } ) ;
336420} ) ;
0 commit comments