1
1
import * as vscode from "vscode" ;
2
2
import { KonveyorGUIWebviewViewProvider } from "./KonveyorGUIWebviewViewProvider" ;
3
3
import { setupWebviewMessageListener } from "./webviewMessageHandler" ;
4
+ import { ExtensionState } from "./extensionState" ;
5
+ import { getWebviewContent } from "./webviewContent" ;
4
6
5
7
let fullScreenPanel : vscode . WebviewPanel | undefined ;
6
8
@@ -13,12 +15,39 @@ function getFullScreenTab() {
13
15
14
16
const commandsMap : (
15
17
extensionContext : vscode . ExtensionContext ,
16
- sidebar : KonveyorGUIWebviewViewProvider ,
17
- ) => { [ command : string ] : ( ...args : any ) => any } = (
18
- extensionContext ,
19
- sidebar ,
18
+ state : ExtensionState
20
19
) => {
20
+ [ command : string ] : ( ...args : any ) => any ;
21
+ } = ( extensionContext , state ) => {
22
+ const { sidebarProvider } = state ;
21
23
return {
24
+ "konveyor.startAnalysis" : async ( resource : vscode . Uri ) => {
25
+ if ( ! resource ) {
26
+ vscode . window . showErrorMessage ( "No file selected for analysis." ) ;
27
+ return ;
28
+ }
29
+
30
+ // Get the file path
31
+ const filePath = resource . fsPath ;
32
+
33
+ // Perform your analysis logic here
34
+ try {
35
+ // For example, read the file content
36
+ const fileContent = await vscode . workspace . fs . readFile ( resource ) ;
37
+ const contentString = Buffer . from ( fileContent ) . toString ( "utf8" ) ;
38
+
39
+ console . log ( contentString , fileContent ) ;
40
+
41
+ // TODO: Analyze the file content
42
+ vscode . window . showInformationMessage ( `Analyzing file: ${ filePath } ` ) ;
43
+
44
+ // Call your analysis function/module
45
+ // analyzeFileContent(contentString);
46
+ } catch ( error ) {
47
+ vscode . window . showErrorMessage ( `Failed to analyze file: ${ error } ` ) ;
48
+ }
49
+ } ,
50
+
22
51
"konveyor.focusKonveyorInput" : async ( ) => {
23
52
const fullScreenTab = getFullScreenTab ( ) ;
24
53
if ( ! fullScreenTab ) {
@@ -28,14 +57,14 @@ const commandsMap: (
28
57
// focus fullscreen
29
58
fullScreenPanel ?. reveal ( ) ;
30
59
}
31
- // sidebar.webviewProtocol?.request("focusContinueInput ", undefined);
60
+ // sidebar.webviewProtocol?.request("focusInput ", undefined);
32
61
// await addHighlightedCodeToContext(sidebar.webviewProtocol);
33
62
} ,
34
63
"konveyor.toggleFullScreen" : ( ) => {
35
64
// Check if full screen is already open by checking open tabs
36
65
const fullScreenTab = getFullScreenTab ( ) ;
37
66
38
- // Check if the active editor is the Continue GUI View
67
+ // Check if the active editor is the GUI View
39
68
if ( fullScreenTab && fullScreenTab . isActive ) {
40
69
//Full screen open and focused - close it
41
70
vscode . commands . executeCommand ( "workbench.action.closeActiveEditor" ) ; //this will trigger the onDidDispose listener below
@@ -61,10 +90,10 @@ const commandsMap: (
61
90
fullScreenPanel = panel ;
62
91
63
92
//Add content to the panel
64
- panel . webview . html = sidebar . getSidebarContent (
93
+ panel . webview . html = getWebviewContent (
65
94
extensionContext ,
66
- panel ,
67
- true ,
95
+ sidebarProvider ?. webview || panel . webview ,
96
+ true
68
97
) ;
69
98
70
99
setupWebviewMessageListener ( panel . webview ) ;
@@ -83,10 +112,10 @@ const commandsMap: (
83
112
84
113
export function registerAllCommands (
85
114
context : vscode . ExtensionContext ,
86
- sidebar : KonveyorGUIWebviewViewProvider
115
+ state : ExtensionState
87
116
) {
88
117
for ( const [ command , callback ] of Object . entries (
89
- commandsMap ( context , sidebar )
118
+ commandsMap ( context , state )
90
119
) ) {
91
120
context . subscriptions . push (
92
121
vscode . commands . registerCommand ( command , callback ) ,
0 commit comments