1
1
import * as net from "net" ;
2
2
import * as path from "path" ;
3
+ import * as fs from "fs" ;
3
4
import * as vscode from "vscode" ;
4
5
import { LanguageClient , LanguageClientOptions , ServerOptions } from "vscode-languageclient/node" ;
5
6
import { sleep } from "./utils" ;
@@ -27,8 +28,8 @@ function getPythonCommand(folder: vscode.WorkspaceFolder | undefined): string |
27
28
if ( configPython !== undefined && configPython != "" ) {
28
29
result = configPython ;
29
30
} else {
30
- const extension = vscode . extensions . getExtension ( "ms-python.python" ) ! ;
31
- let pythonExtensionPythonPath : string [ ] | undefined = extension . exports . settings . getExecutionDetails (
31
+ const pythonExtension = vscode . extensions . getExtension ( "ms-python.python" ) ! ;
32
+ let pythonExtensionPythonPath : string [ ] | undefined = pythonExtension . exports . settings . getExecutionDetails (
32
33
folder ?. uri
33
34
) ?. execCommand ;
34
35
@@ -439,62 +440,6 @@ async function attachPython(session: vscode.DebugSession, event: string, options
439
440
}
440
441
}
441
442
442
- async function openReportInternal ( reportFile : string ) {
443
- let panel = vscode . window . createWebviewPanel ( "robotcode.report" , "Robot Report" , vscode . ViewColumn . Active , {
444
- enableScripts : true ,
445
- enableFindWidget : true ,
446
- enableCommandUris : true ,
447
- retainContextWhenHidden : true ,
448
- localResourceRoots : [ vscode . Uri . file ( path . dirname ( reportFile ) ) ] ,
449
- } ) ;
450
-
451
- let uri = vscode . Uri . file ( reportFile ) ;
452
-
453
- panel . webview . html = `<!DOCTYPE html>
454
- <html>
455
-
456
- <head>
457
- <meta http-equiv="Content-Security-Policy" content="
458
- default-src none 'unsafe-inline';
459
- frame-src ${ panel . webview . cspSource } 'unsafe-inline';
460
- style-src ${ panel . webview . cspSource } 'unsafe-inline';
461
- img-src ${ panel . webview . cspSource } ;
462
- script-src ${ panel . webview . cspSource } 'unsafe-inline';">
463
-
464
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
465
- <title>Robot Report</title>
466
- </head>
467
-
468
- <body>
469
- <script>
470
- function frame_loaded() {
471
- function WhichLinkWasClicked(evt) {
472
- alert(evt.target);
473
- //evt.preventDefault();
474
- }
475
-
476
- var links = myFrame.document.querySelectorAll('a');
477
- for (var link of links) {
478
- console.log("blah link");
479
- link.addEventListener('click', WhichLinkWasClicked);
480
- }
481
- }
482
- </script>
483
-
484
- <iframe style="position: absolute; height: 100%; width: 100%; border: none" src="${ panel . webview
485
- . asWebviewUri ( uri )
486
- . toString ( ) } " name="myFrame"
487
- onload="frame_loaded()" sandbox="allow-scripts allow-same-origin" referrerpolicy="origin" >
488
- </iframe>
489
- </body>
490
-
491
- </html>` ;
492
- //panel.webview.html = fs.readFileSync(event.body?.reportFile).toString();
493
- // panel.webview.onDidReceiveMessage(async (event) => {
494
- // console.log(`hello ${JSON.stringify(event)}`);
495
- // });
496
- }
497
-
498
443
async function onRobotExited ( session : vscode . DebugSession , outputFile ?: string , logFile ?: string , reportFile ?: string ) {
499
444
if ( reportFile ) {
500
445
let config = vscode . workspace . getConfiguration ( CONFIG_SECTION , session . workspaceFolder ) ;
@@ -503,12 +448,7 @@ async function onRobotExited(session: vscode.DebugSession, outputFile?: string,
503
448
case "disabled" :
504
449
return ;
505
450
case "external" :
506
- vscode . env . openExternal ( vscode . Uri . file ( reportFile ) ) ;
507
- break ;
508
-
509
- case "internal" :
510
- openReportInternal ( reportFile ) ;
511
- break ;
451
+ vscode . env . openExternal ( vscode . Uri . file ( reportFile ) ) ;
512
452
}
513
453
}
514
454
}
@@ -533,17 +473,13 @@ export async function activateAsync(context: vscode.ExtensionContext) {
533
473
pythonDebugAdapterMain = context . asAbsolutePath ( path . join ( "robotcode" , "debug_adapter" , "__main__.py" ) ) ;
534
474
535
475
OUTPUT_CHANNEL . appendLine ( "Try to activate Python extension." ) ;
536
- const extension = vscode . extensions . getExtension ( "ms-python.python" ) ! ;
476
+ const pythonExtension = vscode . extensions . getExtension ( "ms-python.python" ) ! ;
537
477
538
- await extension . activate ( ) . then ( function ( ) {
539
- OUTPUT_CHANNEL . appendLine ( "Python Extension is active" ) ;
540
- } ) ;
478
+ await pythonExtension . activate ( ) ;
541
479
542
- context . subscriptions . push (
543
- extension . exports . settings . onDidChangeExecutionDetails ( ( uri : vscode . Uri ) => {
544
- OUTPUT_CHANNEL . appendLine ( uri . toString ( ) ) ;
545
- } ) ,
480
+ OUTPUT_CHANNEL . appendLine ( "Python Extension is active" ) ;
546
481
482
+ context . subscriptions . push (
547
483
vscode . commands . registerCommand ( "robotcode.runSuite" , async ( resource ) => {
548
484
return await debugSuiteOrTestcase ( resource ?? vscode . window . activeTextEditor ?. document . uri , undefined , {
549
485
noDebug : true ,
@@ -630,7 +566,6 @@ export async function activateAsync(context: vscode.ExtensionContext) {
630
566
} ) ,
631
567
vscode . window . registerTerminalLinkProvider ( {
632
568
provideTerminalLinks ( context : vscode . TerminalLinkContext , token : vscode . CancellationToken ) {
633
- console . log ( "ho" ) ;
634
569
if (
635
570
( context . line . startsWith ( "Log:" ) || context . line . startsWith ( "Report:" ) ) &&
636
571
context . line . endsWith ( "html" )
@@ -658,9 +593,6 @@ export async function activateAsync(context: vscode.ExtensionContext) {
658
593
) ;
659
594
660
595
switch ( config . get < string > ( "run.openReportAfterRun" ) ) {
661
- case "internal" :
662
- openReportInternal ( link . path ) ;
663
- break ;
664
596
default :
665
597
vscode . env . openExternal ( vscode . Uri . file ( link . path ) ) ;
666
598
break ;
@@ -706,7 +638,35 @@ export async function activateAsync(context: vscode.ExtensionContext) {
706
638
vscode . window . onDidChangeTextEditorSelection ( async ( event ) => {
707
639
await updateEditorContext ( event . textEditor ) ;
708
640
} ) ,
709
- vscode . workspace . onDidOpenTextDocument ( getLanguageClientForDocument )
641
+ vscode . workspace . onDidOpenTextDocument ( getLanguageClientForDocument ) ,
642
+
643
+ vscode . languages . registerInlineValuesProvider ( "robotframework" , {
644
+ provideInlineValues (
645
+ document : vscode . TextDocument ,
646
+ viewPort : vscode . Range ,
647
+ context : vscode . InlineValueContext ,
648
+ token : vscode . CancellationToken
649
+ ) : vscode . ProviderResult < vscode . InlineValue [ ] > {
650
+ const allValues : vscode . InlineValue [ ] = [ ] ;
651
+
652
+ for ( let l = 0 ; l <= context . stoppedLocation . end . line ; l ++ ) {
653
+ const line = document . lineAt ( l ) ;
654
+ let text = line . text . split ( "#" ) [ 0 ] ;
655
+
656
+ const variableMatches =
657
+ / ( [ $ @ & % ] \{ ) (?: ( (?: \d + \. ? \d * ) | (?: 0 x [ \/ d a - f ] + ) | (?: 0 o [ 0 - 7 ] + ) | (?: 0 b [ 0 1 ] + ) ) | ( t r u e | f a l s e | n o n e | n u l l | e m p t y | s p a c e | \/ | : | \\ n ) | ( ( .+ ?} * ) ) ) ( \} ) (?: ( \[ ) (?: ( \d + ) | ( .* ?) ) ? ( \] ) ) ? / gi;
658
+
659
+ let match ;
660
+ while ( ( match = variableMatches . exec ( text ) ) ) {
661
+ let varName = match [ 0 ] ;
662
+
663
+ const rng = new vscode . Range ( l , match . index , l , match . index + varName . length ) ;
664
+ allValues . push ( new vscode . InlineValueVariableLookup ( rng , varName , false ) ) ;
665
+ }
666
+ }
667
+ return allValues ;
668
+ } ,
669
+ } )
710
670
) ;
711
671
712
672
for ( let document of vscode . workspace . textDocuments ) {
0 commit comments