{"id":228790,"date":"2022-03-21T02:11:15","date_gmt":"2022-03-21T09:11:15","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/java\/?p=228790"},"modified":"2022-03-21T02:11:15","modified_gmt":"2022-03-21T09:11:15","slug":"java-on-visual-studio-code-update-march-2022","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/java\/java-on-visual-studio-code-update-march-2022\/","title":{"rendered":"Java on Visual Studio Code Update \u2013 March 2022"},"content":{"rendered":"<p>Hi everyone, welcome to the March update of Visual Studio Code Java. This time we are going to bring you some recent update regarding our code completion optimization, Maven improvements and pre-release version of our Java extensions. Let&#8217;s get right into it!<\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>More shortcuts to generate code snippets<\/strong><\/span><\/h2>\n<p>Because our language support for Java is provided via <a href=\"https:\/\/github.com\/eclipse\/eclipse.jdt.ls\">Eclipse \u2122 JDT Language Server, <\/a>the shortcuts to generate certain code snippets (such as <span style=\"font-family: 'courier new', courier, monospace;\">System.out.println<\/span>) are mostly based on Eclipse convention. For example, the shortcut for <span style=\"font-family: 'courier new', courier, monospace;\">System.out.println()<\/span> is <span style=\"font-family: 'courier new', courier, monospace;\">sysout<\/span>. However, we heard from a lot of users that they are used to shortcuts from other IDEs such as IntelliJ IDEA and would like to see shortcuts from these IDEs supported in Visual Studio Code as well. Therefore, we have added these shortcuts for common code snippets in our extensions. Here is a list of the shortcuts we support<\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 196px;\">\n<tbody>\n<tr style=\"height: 28px;\">\n<td style=\"width: 33.3333%; height: 28px;\">Code template<\/td>\n<td style=\"width: 33.3333%; height: 28px;\">Eclipse-style shortcuts<\/td>\n<td style=\"width: 33.3333%; height: 28px;\">IDEA-style shortcuts<\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">System.out.println()<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">sysout<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">sout<\/span><\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">System.err.println()<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">syserr<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">serr<\/span><\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">System.out.println() for current method signature<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">systrace<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">soutm<\/span><\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">public static void main(String[] args) {}<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">main<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">psvm \/ main<\/span><\/td>\n<\/tr>\n<tr style=\"height: 28px;\">\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">Iterator (for loop)<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">foreach<\/span><\/td>\n<td style=\"width: 33.3333%; height: 28px;\"><span style=\"font-family: 'courier new', courier, monospace;\">iter<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>A quick demo to showcase these new shortcuts<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/shortcuts.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-228800\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/shortcuts.gif\" alt=\"More shortcuts\" width=\"898\" height=\"446\" \/><\/a><\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>Code completion optimization for constructors (<span style=\"font-family: 'courier new', courier, monospace;\">new<\/span> keyword)<\/strong><\/span><\/h2>\n<p>Regarding the code completion, one of the top issues is that when writing a constructor in VS Code, developers expect that the suggestion should be directly related to the type that is defined (for example, <span style=\"font-family: 'courier new', courier, monospace;\">List&lt;String&gt; list = &#8230;<\/span>\u00a0 should prompt a List type auto-suggestion for &#8220;&#8230;&#8221; part), however, this is often not the case in the current implementation.<\/p>\n<p>During the last few iterations, we have investigated this issue and made changes to improve this experience. With these new improvements, the code completion will be more aware of the type that user is creating and suggests the most relevant type for the constructors. For example, a <span style=\"font-family: 'courier new', courier, monospace;\">List&lt;String&gt;<\/span> will result in a suggestion for new <span style=\"font-family: 'courier new', courier, monospace;\">ArrayList&lt;String&gt;<\/span>. Similarly, a <span style=\"font-family: 'courier new', courier, monospace;\">String[]<\/span> will result in a suggestion of an array type to complete the constructor. Here is a sneak peek for this improvement:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/newobject.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-228807\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/newobject.gif\" alt=\"Constructor Optimization\" width=\"1516\" height=\"964\" \/><\/a><\/p>\n<p>We are still making a few tweaks to the feature above and it will be available in the next few versions.<\/p>\n<p>Earlier this year, we released <a href=\"https:\/\/devblogs.microsoft.com\/java\/java-on-visual-studio-code-update-january-2022\/\">our roadmap for 2022<\/a> and better code completion experience is one of our major investments. We hope to continue improving this area so please let us know if you&#8217;d like to see any other enhancements regarding code completion quality and performance.<\/p>\n<h2><span style=\"font-size: 18pt;\"><strong>Maven improvements<\/strong><\/span><\/h2>\n<p>In addition to new features of code completion, we have also made a few improvements to our Maven extension.<\/p>\n<ul>\n<li><strong>Display a tooltip to show Maven POM file path\u00a0<\/strong><\/li>\n<\/ul>\n<p>Previously, when developers open several projects with the same name, it&#8217;s hard to distinguish which POM file the project belongs to. Also, it&#8217;s generally helpful to show the exact path of the POM file to give developers more information. Therefore, we added a minor improvement so that when developer hovers on the main node in the Maven extension view, a tooltip is shown to display the full Maven POM file path. Here is a screenshot of this improvement:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/mavenpom.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-228802\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/mavenpom.png\" alt=\"Maven POM file path\" width=\"522\" height=\"132\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/mavenpom.png 522w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/mavenpom-300x76.png 300w\" sizes=\"(max-width: 522px) 100vw, 522px\" \/><\/a><\/p>\n<ul>\n<li>Code completion in the POM version now correctly replaces the version<\/li>\n<\/ul>\n<p>When auto completing a Maven dependency version, previously our extension will add the the result to the existing text instead of replacing it, causing an issue in our user experience. We have fixed this issue in the recent version and now the autocompletion will correctly replace the version, and similar improvement also works for <span style=\"font-family: 'courier new', courier, monospace;\">artifactId<\/span> and <span style=\"font-family: 'courier new', courier, monospace;\">groupId<\/span>.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/completion.gif\"><img decoding=\"async\" class=\"alignnone size-full wp-image-228803\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/completion.gif\" alt=\"Maven completion\" width=\"894\" height=\"476\" \/><\/a><\/p>\n<h3><span style=\"font-size: 18pt;\"><strong>Pre-release version of extensions for Java<\/strong><\/span><\/h3>\n<p>Since <a href=\"https:\/\/code.visualstudio.com\/updates\/v1_63#_pre-release-extensions\">version 1.63<\/a>, Visual Studio Code has supported the pre-release version of extensions so developers can opt in to try out the latest cutting edge features and provide feedback. We are excited to announce that the pre-release channel has been enabled for <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-gradle\">Gradle for Java<\/a> and <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-maven\">Maven for Java<\/a> extension, and we will enable <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=vscjava.vscode-java-pack\">rest of the extensions in the extension pack<\/a> by the end of this month. For developers who always like to get the latest bits, feel free to install the pre-release version and leave us early feedback. For those who like to use a stable version, you can always choose to use the &#8220;release version&#8221; like before<\/p>\n<p>You can easily switch between pre-release and release versions by using the additional button next to the Install option in Visual Studio Code (shown in the pictures below)<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/prerelease.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-228794\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/prerelease.png\" alt=\"Pre release\" width=\"666\" height=\"204\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/prerelease.png 666w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/prerelease-300x92.png 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/release.png\"><img decoding=\"async\" class=\"alignnone wp-image-228795\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/release.png\" alt=\"Release\" width=\"668\" height=\"175\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/release.png 783w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/release-300x79.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2022\/03\/release-768x201.png 768w\" sizes=\"(max-width: 668px) 100vw, 668px\" \/><\/a><\/p>\n<h2><span style=\"font-size: 18pt;\"><strong><span class=\"x-hidden-focus\">Feedback and suggestions<\/span><\/strong><\/span><\/h2>\n<p>As always, your feedback and suggestions are very important to us and will help shape our product in future. There are several ways to give us feedback<\/p>\n<ul>\n<li>Leave your comment on this blog post<\/li>\n<li><a href=\"https:\/\/github.com\/microsoft\/vscode-java-pack\/issues\/new\/choose\" target=\"_blank\" rel=\"noopener\">Open an issue<\/a>\u00a0on our GitHub Issues page<\/li>\n<li>Send an email to: vscjfeedback@microsoft.com<\/li>\n<\/ul>\n<h2 id=\"try-it-out\" class=\"x-hidden-focus\"><span style=\"font-size: 18pt;\"><strong><span class=\"x-hidden-focus\">Resources<\/span><\/strong><\/span><\/h2>\n<p>Here is a list of links that are helpful to learn Java on Visual Studio Code.<\/p>\n<ul>\n<li class=\"x-hidden-focus\">Learn more about\u00a0<a class=\"x-hidden-focus\" href=\"https:\/\/code.visualstudio.com\/docs\/languages\/java\" target=\"_blank\" rel=\"noopener noreferrer\">Java on Visual Studio Code<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Hi everyone, welcome to the March update of Visual Studio Code Java. This time we are going to bring you some recent update regarding our code completion optimization, Maven improvements and pre-release version of our Java extensions. Let&#8217;s get right into it! More shortcuts to generate code snippets Because our language support for Java is [&hellip;]<\/p>\n","protected":false},"author":31999,"featured_media":228816,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[14,22,1,8,15],"tags":[],"class_list":["post-228790","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloud","category-desktop","category-java","category-open-source","category-vscode"],"acf":[],"blog_post_summary":"<p>Hi everyone, welcome to the March update of Visual Studio Code Java. This time we are going to bring you some recent update regarding our code completion optimization, Maven improvements and pre-release version of our Java extensions. Let&#8217;s get right into it! More shortcuts to generate code snippets Because our language support for Java is [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/228790","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/users\/31999"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/comments?post=228790"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/228790\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media\/228816"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media?parent=228790"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/categories?post=228790"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/tags?post=228790"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}