Configuring and using the Visual Studio Code Extension for MTA
Using the migration toolkit for applications extension for Visual Studio Code to identify and resolve migration issues
Abstract
- 1. Introduction to the MTA extension for Microsoft Visual Code
- 2. Installing the MTA extension for Visual Studio Code
- 3. Configuring and using the MTA analyzer RPC binary in your system
- 4. Configuring the IDE settings
- 5. Configuring the MTA profile settings
- 6. Running an application analysis
- 7. Reviewing and resolving migration issues
Chapter 1. Introduction to the MTA extension for Microsoft Visual Code
You can migrate and modernize applications by using the migration toolkit for applications (MTA) extension for Microsoft Visual Studio Code.
The MTA extension can perform the following actions:
- Analyze your projects with customizable rulesets.
- Mark issues in the source code.
- Provide guidance to fix the issues.
- Perform automatic code replacement, if possible.
The MTA extension is also compatible with Visual Studio Codespaces, the Microsoft cloud-hosted development environment.
Chapter 2. Installing the MTA extension for Visual Studio Code
You can use the migration toolkit for applications (MTA) Visual Studio Code plugin to perform a standard application analysis.
You can download the MTA plugin version 8.1.0 as an extension pack that bundles the Core extension along with all the supported language-specific extensions. You can use this extension even when you want to analyze a project in a specific programming language.
Alternatively, you can also download the MTA Core extension and one language-specific extension to analyze a project coded in the programming language supported by the extension.
You can also enable Red Hat Developer Lightspeed for the migration toolkit for applications to use Generative AI (GenAI) capabilities to fix code issues before migrating to target technologies. Note that Developer Lightspeed for MTA is enabled by default. For more information, see Configuring and using Developer Lightspeed for MTA.
Prerequisites
You installed the Java Development Kit (JDK). MTA supports the following JDKs:
- Oracle JDK 17 or later
- Eclipse Temurin™ JDK 17 or later
- OpenJDK 17 or later
- You have 8 GB of RAM available.
-
For macOS installation, you have the value of
maxprocset to2048or greater.
Procedure
- Install the MTA 8.1.0 Visual Studio (VS) Code plugin extension pack from the VS Code marketplace.
- Alternatively, install the MTA 8.1.0 Core plugin along with the MTA extension for a supported language from the VS Code marketplace
Chapter 3. Configuring and using the MTA analyzer RPC binary in your system
The migration toolkit for applications (MTA) Visual Studio Code extension consists of an analyzer RPC binary that runs an analysis for Java, Go, Python, Node.js and C# or .NET applications.
When you install the MTA Visual Studio Code extension, the extension downloads the analyzer RPC binary of the latest version from the Red Hat Developer portal.
In a restricted network environment where the MTA extension cannot access the link to download the analyzer RPC binary, you can download the binary in your system and configure its path in the Visual Studio Code extension.
Prerequisites
You installed the Java Development Kit (JDK). MTA supports the following JDKs:
- Oracle JDK 17 or later
- Eclipse Temurin™ JDK 17 or later
- OpenJDK 17 or later
- You have 8 GB of RAM available.
-
For macOS installation, you have the value of
maxprocset to2048or greater.
Procedure
- Download the MTA 8.1.0 analyzer RPC from Red Hat Developer portal to your system.
Access the MTA extension settings in either of the following ways:
-
Click
Extensions > MTA Extension for VSCode > Settings. -
Type
Preferences: Open User Settings (JSON)in the Command Palette to open thesettings.jsonfile.
-
Click
Configure the analyzer RPC binary path for the extension in one of the following ways:
-
Enter the analyzer RPC binary path in the
Analyzer Pathfield in the MTA extension settings. -
Configure the path to the local analyzer RPC binary in the
mta-vscode-extension.analyzerPathfield in thesettings.jsonfile. -
Type
MTA: Override Analyzer Binaryin the Command Palette to select the analyzer binary in your system.
-
Enter the analyzer RPC binary path in the
-
Reload the Visual Studio Code window by typing
Developer: Reload Windowin the Command Palette. -
Open the extension analysis view by typing
MTA: Open Analysis Viewin the Command Palette. - Click Start to use the analyzer RPC binary to perform an analysis.
Chapter 4. Configuring the IDE settings
MTA settings apply to every analysis that you perform by using the Visual Studio (VS) Code extension. The extension settings have the following categories:
- Analysis-related settings
- Debugging and logging settings
- Solution server settings
- Generative AI settings
Procedure
Open the MTA settings by clicking
Extensions>MTA Extension for VSCode>Settings.Alternatively, open the setting by performing the following steps:
-
Type
Ctrl + Shift + PorCmd + Shift + Pon the search bar to open the Command Palette. -
Enter
Preferences: Open Settings (UI). -
Open the settings page by clicing
Extensions>MTA.
-
Type
Configure the following settings:
-
Log level: Set the log level for the MTA binary. The default log level is
debug. The log level increases or decreases the verbosity of logs. - Analyzer path: Specify an MTA custom binary path. If you do not provide a path, Red Hat Developer Lightspeed for MTA uses the default path to the binary.
- Debug:Webview: Enable debug level logging for Webview message handling in VS Code.
-
Log level: Set the log level for the MTA binary. The default log level is
Next steps
Additional resources
Chapter 5. Configuring the MTA profile settings
You can use the Visual Studio (VS) Code plugin to run an analysis to discover issues in the code.
To generate code changes by using the MTA extension, you must configure a profile that contains all the necessary configurations, such as rules and source and target technologies.
Prerequisites
- You configured the VS Code IDE settings. For more information, see Configuring the Red Hat Developer Lightspeed for MTA IDE settings.
- You opened a Java project in your VS Code workspace.
Procedure
Open the
MTA View Analysispage by clicking the book icon on theMTA: Issuespane of the MTA extension.Alternatively, type
Ctrl + Shift + PorCmd + Shift + Pin the search bar to open the Command Palette and enterMTA:Open Analysis View.Click the settings button on the
MTA View Analysispage to configure a profile for your project. TheGet Ready to Analyzepane has the following basic configurations required for an application analysis:- Select profile: Create a profile that you can reuse for one or more analyses.
Configure label selector: A label selector filters rules for analysis based on the source or target technology.
Specify one or more target or source technologies. Red Hat Developer Lightspeed for MTA uses this configuration to determine the rules to apply to a project during the analysis. If you mentioned a new target or a source technology in your custom rule, you can type that name to create and add the new item to the list.
ImportantYou must configure target or source technologies before running an analysis.
- Set rules: Enable default rules and select your custom rule that you want MTA to use for the analysis. You can use the custom rules in addition to the default rules.
Verification
-
After you completed the profile configuration, close the
Get Ready to Analyzepane and run an application analysis.
Next steps
Additional resources
Chapter 6. Running an application analysis
You can run a static code analysis of an application with or without enabling the Generative AI (GenAI) features. The RPC (Remote Procedure Call) server runs the analysis to detect all issues in the code for one or more target technologies which you want to migrate the application to.
Prerequisites
- You opened a Java project in your VS Code workspace.
- You configured an analysis profile on the MTA Analysis View page. For more information, see Configuring the MTA profile settings.
Procedure
- Click the Red Hat Developer Lightspeed for MTA extension and click Open MTA Analysis View.
- Select a profile for the analysis.
- Click Start to start the MTA RPC server.
- Click Run Analysis on the MTA Analysis View page.
Additional resources
Chapter 7. Reviewing and resolving migration issues
You can use the MTA extension icons to prioritize issues based on their severity.
Procedure
- Select a run configuration directory on the left pane.
- Expand its folders to view the Hints generated for each application file.
- Select a hint to view the source code.
- Right-click a hint and select View Details to view the Rule ID and other information.
Prioritize issues based on the following icons, which are displayed next to each hint:
-
: You must fix the issue for a successful migration.
-
: You might need to address the issue during the migration.
-
Resolve issues by editing the code of a file with a hint:
- In the left pane, right-click an issue and select Open Code.
- Make any changes needed to the code and save the file.
- Optional: Right-click the issue and select Mark as Complete or Delete.