{"id":227421,"date":"2020-04-30T09:06:58","date_gmt":"2020-04-30T16:06:58","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/java\/?p=227421"},"modified":"2020-06-08T22:37:06","modified_gmt":"2020-06-09T05:37:06","slug":"java-on-visual-studio-code-update-april-2020","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/java\/java-on-visual-studio-code-update-april-2020\/","title":{"rendered":"Java on Visual Studio Code Update \u2013 April 2020"},"content":{"rendered":"<p>Welcome back to the April update of Java on Visual Studio Code.<\/p>\n<p>In this update, we will show you the effect of our latest performance improvements. You can also see new Java 14 support and semantic highlighting. We&#8217;d also like to show you how to easily create new Java class, perform rename refactoring from file explorer and preview the proposed changes before committing. <span style=\"font-size: 1rem;\">On to the update.<\/span><\/p>\n<h3>Performance improvement<\/h3>\n<p>If you&#8217;ve followed our update last month, we&#8217;ve enabled parallel dependency download to improve project loading performance as well as syntax mode. In this release, we&#8217;ve enabled syntax server for all project. You will be able to see the big difference on how fast you can do code navigation after opening a new project below.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227424\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/syntax-server-startup.gif\" alt=\"Image syntax server startup\" width=\"1280\" height=\"720\" \/><\/p>\n<p>The idea is since building and indexing the project takes a long time, it&#8217;s annoying for our developers to wait. With the help of syntax server, instead of waiting for all the dependencies to be downloaded, you can use the features listed below right away:<\/p>\n<ul>\n<li>Syntax Highlighting &amp; Syntax Errors<\/li>\n<li>Code Navigation (Go to Definition, etc.)<\/li>\n<li>Documentation (Hover to See Javadoc)<\/li>\n<li>Code Structures (Outline, Folding Range, etc.)<\/li>\n<\/ul>\n<p>Once the full language server is ready, the syntax server would be turned off automatically.<\/p>\n<h3>Java 14 Support<\/h3>\n<p>Java 14 is out and is supported by the language server now. To use the preview features, you may need to modify your project settings.<\/p>\n<p>Maven &#8211; modify\u00a0<code>pom.xml<\/code>:<\/p>\n<div class=\"highlight highlight-text-xml\">\n<pre><code>  &lt;<span class=\"pl-ent\">build<\/span>&gt;\r\n    &lt;<span class=\"pl-ent\">pluginManagement<\/span>&gt;\r\n      &lt;<span class=\"pl-ent\">plugins<\/span>&gt;\r\n        &lt;<span class=\"pl-ent\">plugin<\/span>&gt;\r\n          &lt;<span class=\"pl-ent\">artifactId<\/span>&gt;maven-compiler-plugin&lt;\/<span class=\"pl-ent\">artifactId<\/span>&gt;\r\n          &lt;<span class=\"pl-ent\">configuration<\/span>&gt;\r\n            &lt;<span class=\"pl-ent\">release<\/span>&gt;14&lt;\/<span class=\"pl-ent\">release<\/span>&gt;\r\n            &lt;<span class=\"pl-ent\">compilerArgs<\/span>&gt;--enable-preview&lt;\/<span class=\"pl-ent\">compilerArgs<\/span>&gt;\r\n          &lt;\/<span class=\"pl-ent\">configuration<\/span>&gt;\r\n        &lt;\/<span class=\"pl-ent\">plugin<\/span>&gt;\r\n      &lt;\/<span class=\"pl-ent\">plugins<\/span>&gt;\r\n    &lt;\/<span class=\"pl-ent\">pluginManagement<\/span>&gt;\r\n  &lt;\/<span class=\"pl-ent\">build<\/span>&gt;<\/code><\/pre>\n<\/div>\n<p>Gradle:<\/p>\n<div class=\"highlight highlight-source-groovy\">\n<pre><code>sourceCompatibility <span class=\"pl-k\">=<\/span> <span class=\"pl-c1\">14<\/span>\r\n\r\ntasks<span class=\"pl-k\">.<\/span>withType(<span class=\"pl-k\">JavaCompile<\/span>) {\r\n    options<span class=\"pl-k\">.<\/span>compilerArgs <span class=\"pl-k\">+<\/span><span class=\"pl-k\">=<\/span> <span class=\"pl-s\"><span class=\"pl-pds\">'<\/span>--enable-preview<span class=\"pl-pds\">'<\/span><\/span>\r\n}\r\ntasks<span class=\"pl-k\">.<\/span>withType(<span class=\"pl-k\">Test<\/span>) {\r\n    jvmArgs <span class=\"pl-k\">+<\/span><span class=\"pl-k\">=<\/span> <span class=\"pl-s\"><span class=\"pl-pds\">\"<\/span>--enable-preview<span class=\"pl-pds\">\"<\/span><\/span>\r\n}<\/code><\/pre>\n<\/div>\n<blockquote><p>Note: if you are modifying a project that was already opened in VS Code before, you may need to force clean the workspace and reload. To do so, run command\u00a0<code>Java: Clean the Java language server workspace<\/code>.<\/p><\/blockquote>\n<h3>Semantic Highlighting<\/h3>\n<p>As you read and write code, syntax highlighting is a very important feature which allows you to read code more efficiently. However, since syntax highlighting colors the text based on lexical rules, it&#8217;s difficult to make it accurate for all scenarios. This month, VS Code Java brings semantic highlighting which enriches the syntax coloring based on symbol information from Java language service that has the full understanding of the project. Below is just one example, left is the behavior after enabling semantic highlighting and right is the one with only syntax highlighting.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227428\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting.png\" alt=\"Image semantic highlighting\" width=\"1910\" height=\"506\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting.png 1910w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting-300x79.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting-1024x271.png 1024w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting-768x203.png 768w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting-1536x407.png 1536w\" sizes=\"(max-width: 1910px) 100vw, 1910px\" \/><\/p>\n<div>\n<div>To enable semantic highlighting, you can toggle the the `java.semanticHighlighting.enabled` preference. You will also be prompted to enable or disable it on startup:<\/div>\n<\/div>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227429\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting-switch.png\" alt=\"Image semantic highlighting switch\" width=\"1094\" height=\"218\" srcset=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting-switch.png 1094w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting-switch-300x60.png 300w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting-switch-1024x204.png 1024w, https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/semantic-highlighting-switch-768x153.png 768w\" sizes=\"(max-width: 1094px) 100vw, 1094px\" \/><\/p>\n<p>You can also find more details of Java semantic highlighting <a href=\"https:\/\/github.com\/redhat-developer\/vscode-java\/wiki\/Semantic-Highlighting\">here<\/a>.<\/p>\n<h3>Create New Class from File Explorer<\/h3>\n<p>Here to mention a new way of creating a class. Now, when you create a\u00a0<code>.java<\/code>\u00a0file in the File Explorer, the language server will automatically generate the class body, and fill the package info for you:<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227432\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/create-class.gif\" alt=\"Image create class\" width=\"1280\" height=\"720\" \/><\/p>\n<p>You can also create\u00a0<code>interface<\/code>,\u00a0<code>enum<\/code>, and\u00a0<code>record<\/code>\u00a0in the same way.<\/p>\n<h3>Rename Refactoring and Preview<\/h3>\n<p>Now you can do rename refactoring from file explorer. And for each refactoring, you now have the option to preview the changes before committing it to your code base.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-227433\" src=\"https:\/\/devblogs.microsoft.com\/java\/wp-content\/uploads\/sites\/51\/2020\/04\/preview-rename-explorer.gif\" alt=\"Image preview rename explorer\" width=\"1752\" height=\"1318\" \/><\/p>\n<p>We&#8217;re also working on other refactoring, such as move from the file explorer, please stay tuned.<\/p>\n<h3>More improvements<\/h3>\n<p class=\"\">The latest updates also brings a lot of other enhancements for Java experience in Visual Studio Code.<\/p>\n<ol>\n<li>Improved support for Gradle projects<\/li>\n<li>Improved organize import to resolve static imports and asterisk (*) wildcard character.<\/li>\n<li>New extension from Red Hat, <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=redhat.vscode-community-server-connector\">Community Server Connectors<\/a> brings better support for Apache Felix, Karaf and Tomcat.<\/li>\n<li>Skipped tests can be toggled out in the test report<\/li>\n<li>New documents are added to our <a href=\"https:\/\/code.visualstudio.com\/docs\/java\">official site<\/a>.<\/li>\n<\/ol>\n<h3>Try it out<\/h3>\n<p>Please don\u2019t hesitate to give it a try! Your feedback and suggestions are very important to us and will help shape our product in future.<\/p>\n<ul>\n<li>Learn more about <a href=\"https:\/\/code.visualstudio.com\/docs\/languages\/java\" target=\"_blank\" rel=\"noopener noreferrer\">Java on Visual Studio Code<\/a>.<\/li>\n<li>Explore our step by step <a href=\"https:\/\/code.visualstudio.com\/docs\/java\/java-tutorial\" target=\"_blank\" rel=\"noopener noreferrer\">Java Tutorials on Visual Studio Code<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Java on VS Code April update will show you the effect of latest performance improvements, new Java 14 support and semantic highlighting. Also including how to easily create new Java class, perform rename refactoring from file explorer and preview the proposed changes.<\/p>\n","protected":false},"author":668,"featured_media":227446,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,8,15],"tags":[248,26,27,12],"class_list":["post-227421","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-open-source","category-vscode","tag-java","tag-performance","tag-refactoring","tag-visual-studio-code"],"acf":[],"blog_post_summary":"<p>Java on VS Code April update will show you the effect of latest performance improvements, new Java 14 support and semantic highlighting. Also including how to easily create new Java class, perform rename refactoring from file explorer and preview the proposed changes.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/227421","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\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/comments?post=227421"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/posts\/227421\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media\/227446"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/media?parent=227421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/categories?post=227421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/java\/wp-json\/wp\/v2\/tags?post=227421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}