Recommend rust-analyzer for Cargo recipes and verify the extension appears
in the generated VS Code recommendations file.

AI-Generated: Uses GitHub Copilot
Signed-off-by: Enguerrand de Ribaucourt 
<[email protected]>
---
 meta/lib/oeqa/selftest/cases/devtool.py     | 14 ++++++++++++++
 scripts/lib/devtool/ide_plugins/ide_code.py |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/devtool.py 
b/meta/lib/oeqa/selftest/cases/devtool.py
index 265f2147a4..941f54e36b 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -4339,6 +4339,20 @@ class DevtoolIdeSdkGccTests(DevtoolIdeSdkTests):
         self._test_code_and_none_qemu(slirp=True)
 
 
+class DevtoolIdeSdkRustTests(DevtoolIdeSdkTests):
+
+    def test_code_cargo_rust_analyzer_recommendation(self):
+        recipe_name = "cargo-example"
+        self._check_workspace()
+        self._write_bb_config()
+        tempdir = self._devtool_ide_sdk_recipe(recipe_name, "Cargo.toml", None)
+        runCmd('devtool ide-sdk %s oe-selftest-image --ide=code' % recipe_name,
+               output_log=self._cmd_logger)
+
+        with open(os.path.join(tempdir, '.vscode', 'extensions.json')) as 
extensions_file:
+            extensions = json.load(extensions_file)
+        self.assertIn('rust-lang.rust-analyzer', extensions['recommendations'])
+
 class DevtoolIdeSdkKernelTests(DevtoolIdeSdkTests):
 
     @OETestTag("runqemu")
diff --git a/scripts/lib/devtool/ide_plugins/ide_code.py 
b/scripts/lib/devtool/ide_plugins/ide_code.py
index 081dc08657..cf7f81293c 100644
--- a/scripts/lib/devtool/ide_plugins/ide_code.py
+++ b/scripts/lib/devtool/ide_plugins/ide_code.py
@@ -303,6 +303,8 @@ class IdeVSCode(IdeBase):
 
     def vscode_extensions(self, modified_recipe):
         recommendations = []
+        if modified_recipe.build_tool is BuildTool.CARGO:
+            recommendations.append("rust-lang.rust-analyzer")
         # clangd (matched to the recipe's real cross compiler via
         # compile_commands.json) replaces cpptools as the IntelliSense provider
         # when selected via IDE_SDK_INTELLISENSE (defaults to clangd for the

-- 
2.53.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#248642): 
https://lists.openembedded.org/g/openembedded-core/message/248642
Mute This Topic: https://lists.openembedded.org/mt/121938785/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to