-
Notifications
You must be signed in to change notification settings - Fork 60
Add WSO2 integrator #901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WSO2 integrator #901
Changes from all commits
f546c76
c02ef8d
20b0106
771070c
d76490c
77864b7
6a71aaa
a1fc49e
2d3a9bf
4af1d2a
40a63a2
164ba05
dc1f1d9
f986372
146906f
aba040c
00b0793
b43e816
0f16660
189f45d
6280c5b
b55f298
2cf0ab8
195f1e9
43dcd6b
a239a01
c5876ec
f5da3b4
bc2a2cd
f11af15
eaa8145
c708556
55c0b9f
7d6d438
2edac1c
b9906c5
a5344c9
a9858b4
820bb6a
46c9bb7
e518b1e
98f4aab
0b79b6d
eac7056
df8b0db
a9393b7
6831a9a
44ebf1b
fec6f55
ff93bdf
c0aeeb5
31db42e
7a3e9f6
1066a3c
852c401
b18201c
c963d82
637c9f6
d4632a4
cd4e45d
ed39df1
807b1f8
b7dd186
2102269
80b7526
70dad0c
e13cf7c
d2dcfa4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,32 +20,35 @@ import { SHARED_COMMANDS, BI_COMMANDS, MACHINE_VIEW, NodePosition } from '@wso2/ | |||||||||||||||||||||||
| import { ProjectExplorerEntry, ProjectExplorerEntryProvider } from './project-explorer-provider'; | ||||||||||||||||||||||||
| import { ExtensionContext, TreeView, commands, window, workspace } from 'vscode'; | ||||||||||||||||||||||||
| import { extension } from '../biExtentionContext'; | ||||||||||||||||||||||||
| import { BI_PROJECT_EXPLORER_VIEW_ID, WI_PROJECT_EXPLORER_VIEW_ID, WI_PROJECT_EXPLORER_VIEW_REFRESH_COMMAND } from '../constants'; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| interface ExplorerActivationConfig { | ||||||||||||||||||||||||
| context: ExtensionContext; | ||||||||||||||||||||||||
| isBI: boolean; | ||||||||||||||||||||||||
| isBallerinaPackage?: boolean; | ||||||||||||||||||||||||
| isBallerinaWorkspace?: boolean; | ||||||||||||||||||||||||
| isEmptyWorkspace?: boolean; | ||||||||||||||||||||||||
| isInWI: boolean; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| export function activateProjectExplorer(config: ExplorerActivationConfig) { | ||||||||||||||||||||||||
| const { context, isBI, isBallerinaPackage, isBallerinaWorkspace, isEmptyWorkspace } = config; | ||||||||||||||||||||||||
| const { context, isBI, isBallerinaPackage, isBallerinaWorkspace, isEmptyWorkspace, isInWI } = config; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (extension.langClient && extension.biSupported) { | ||||||||||||||||||||||||
| setLoadingStatus(); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| const treeviewId = isInWI ? WI_PROJECT_EXPLORER_VIEW_ID : BI_PROJECT_EXPLORER_VIEW_ID; | ||||||||||||||||||||||||
| const projectExplorerDataProvider = new ProjectExplorerEntryProvider(); | ||||||||||||||||||||||||
| const projectTree = createProjectTree(projectExplorerDataProvider); | ||||||||||||||||||||||||
| const projectTree = createProjectTree(projectExplorerDataProvider, treeviewId); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| projectExplorerDataProvider.setTreeView(projectTree); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Always register core commands so they're available to the Ballerina extension | ||||||||||||||||||||||||
| registerCoreCommands(projectExplorerDataProvider); | ||||||||||||||||||||||||
| registerCoreCommands(projectExplorerDataProvider, isInWI); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (isBallerinaPackage || isBallerinaWorkspace) { | ||||||||||||||||||||||||
| registerBallerinaCommands(projectExplorerDataProvider, isBI, isBallerinaWorkspace, isEmptyWorkspace); | ||||||||||||||||||||||||
| registerBallerinaCommands(projectExplorerDataProvider, isBI, isInWI, isBallerinaWorkspace, isEmptyWorkspace); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| handleVisibilityChangeEvents( | ||||||||||||||||||||||||
|
|
@@ -62,11 +65,11 @@ function setLoadingStatus() { | |||||||||||||||||||||||
| commands.executeCommand('setContext', 'BI.status', 'loading'); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function createProjectTree(dataProvider: ProjectExplorerEntryProvider) { | ||||||||||||||||||||||||
| return window.createTreeView(BI_COMMANDS.PROJECT_EXPLORER, { treeDataProvider: dataProvider }); | ||||||||||||||||||||||||
| function createProjectTree(dataProvider: ProjectExplorerEntryProvider, treeviewId: string) { | ||||||||||||||||||||||||
| return window.createTreeView(treeviewId, { treeDataProvider: dataProvider }); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function registerCoreCommands(dataProvider: ProjectExplorerEntryProvider) { | ||||||||||||||||||||||||
| function registerCoreCommands(dataProvider: ProjectExplorerEntryProvider, isInWI: boolean) { | ||||||||||||||||||||||||
| // Register the notify command that's called by the Ballerina extension | ||||||||||||||||||||||||
| commands.registerCommand( | ||||||||||||||||||||||||
| BI_COMMANDS.NOTIFY_PROJECT_EXPLORER, | ||||||||||||||||||||||||
|
|
@@ -81,12 +84,13 @@ function registerCoreCommands(dataProvider: ProjectExplorerEntryProvider) { | |||||||||||||||||||||||
| ); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Register the refresh command | ||||||||||||||||||||||||
| commands.registerCommand(BI_COMMANDS.REFRESH_COMMAND, () => dataProvider.refresh()); | ||||||||||||||||||||||||
| commands.registerCommand(isInWI ? WI_PROJECT_EXPLORER_VIEW_REFRESH_COMMAND : BI_COMMANDS.REFRESH_COMMAND, () => dataProvider.refresh()); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function registerBallerinaCommands( | ||||||||||||||||||||||||
| dataProvider: ProjectExplorerEntryProvider, | ||||||||||||||||||||||||
| isBI: boolean, | ||||||||||||||||||||||||
| isInWI: boolean, | ||||||||||||||||||||||||
| isBallerinaWorkspace?: boolean, | ||||||||||||||||||||||||
| isEmptyWorkspace?: boolean | ||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||
|
|
@@ -99,7 +103,7 @@ function registerBallerinaCommands( | |||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| if (isBI) { | ||||||||||||||||||||||||
| registerBICommands(); | ||||||||||||||||||||||||
| registerBICommands(isInWI); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -153,8 +157,9 @@ function handleNonBallerinaVisibility() { | |||||||||||||||||||||||
| commands.executeCommand(SHARED_COMMANDS.OPEN_BI_WELCOME); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| function registerBICommands() { | ||||||||||||||||||||||||
| commands.executeCommand(BI_COMMANDS.FOCUS_PROJECT_EXPLORER); | ||||||||||||||||||||||||
| function registerBICommands(isInWI) { | ||||||||||||||||||||||||
| const treeViewId = isInWI ? WI_PROJECT_EXPLORER_VIEW_ID : BI_PROJECT_EXPLORER_VIEW_ID; | ||||||||||||||||||||||||
| commands.executeCommand(`${treeViewId}.focus`); | ||||||||||||||||||||||||
| commands.executeCommand(SHARED_COMMANDS.SHOW_VISUALIZER); | ||||||||||||||||||||||||
| commands.executeCommand('setContext', 'BI.project', true); | ||||||||||||||||||||||||
|
Comment on lines
+160
to
164
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Add missing type annotation for The parameter lacks a TypeScript type annotation, which is inconsistent with the rest of the file and may reduce type safety. -function registerBICommands(isInWI) {
+function registerBICommands(isInWI: boolean) {
const treeViewId = isInWI ? WI_PROJECT_EXPLORER_VIEW_ID : BI_PROJECT_EXPLORER_VIEW_ID;
commands.executeCommand(`${treeViewId}.focus`);
commands.executeCommand(SHARED_COMMANDS.SHOW_VISUALIZER);
commands.executeCommand('setContext', 'BI.project', true);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -324,14 +324,14 @@ const handlerFunction = handlerSourceFile.addFunction({ | |||||
| }] | ||||||
| }); | ||||||
| handleImportStatment(handlerSourceFile, 'vscode-messenger', 'Messenger'); | ||||||
|
|
||||||
| // Add statements to the function | ||||||
| const managerObject = `const rpcManger = new ${managerClassName}();` | ||||||
| handlerFunction.addStatements(managerObject); | ||||||
| typeMethods.forEach(value => { | ||||||
| handleMessengerTypes(handlerFunction, value, handlerSourceFile); | ||||||
| }) | ||||||
|
|
||||||
| console.log(`Adding handler function: ${headerComment}...`); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix incorrect variable in log message. The log message uses Apply this diff to fix the log message: -console.log(`Adding handler function: ${headerComment}...`);
+console.log(`Adding handler function: ${handlerName}...`);The 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| handleImportStatment(handlerSourceFile, './rpc-manager', managerClassName); | ||||||
|
|
||||||
| // Format imports into new lines | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| const { spawnSync } = require('child_process'); | ||
|
|
||
| const isPreRelease = process.env.isPreRelease === 'true'; | ||
| const args = ['vsce', 'package', '--no-dependencies']; | ||
|
|
||
| if (isPreRelease) { | ||
| args.push('--pre-release'); | ||
| } | ||
|
|
||
| console.log(`Packaging VSIX with args: ${args.join(' ')}`); | ||
|
|
||
| const result = spawnSync('npx', args, { stdio: 'inherit' }); | ||
|
|
||
| if (result.error) { | ||
| console.error(`Failed to spawn vsce: ${result.error.message}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| if (result.status === null) { | ||
| console.error('vsce process was terminated by a signal'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| process.exit(result.status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify context variables
isBIProjectandisBallerinaProjectare properly registered and maintained.The visibility gating for testing view commands relies on context variables
isBIProjectandisBallerinaProject. These must be:Run the following script to locate and verify context variable management in the extension source:
Also applies to: 813-813
🏁 Script executed:
Length of output: 2522
I'll search for more context around these context variable setups to verify they're properly coordinated and maintained during workspace changes.
🏁 Script executed:
Length of output: 4664
🏁 Script executed:
Length of output: 3603
🏁 Script executed:
Length of output: 2071
🏁 Script executed:
Length of output: 14194
Verify and fix asymmetric context variable management for
isBallerinaProject.The context variables
isBIProjectandisBallerinaProjectare registered and maintained during extension lifecycle, but there's a critical asymmetry:isBIProjectis properly managed viasetBIContext(isBI)inworkspaces/ballerina/ballerina-extension/src/stateMachine.ts:1051, allowing it to reset tofalsewhen a workspace is not a BI project.isBallerinaProjectis set totrueinworkspaces/ballerina/ballerina-extension/src/core/extension.ts:2497viasetCurrentProject(), but is never reset tofalse.This one-way toggle breaks the visibility gating logic. Conditions like
"isBIProject || isBallerinaProject"will remaintrueeven after switching to a non-Ballerina workspace, defeating the PR's objective to properly hide/show items based on project type.Required: Add a corresponding mechanism to reset
isBallerinaProjecttofalsewhen the workspace is not a Ballerina project, mirroring the pattern used forisBIProject.🤖 Prompt for AI Agents