{"id":947,"date":"2024-01-25T21:19:56","date_gmt":"2024-01-25T21:19:56","guid":{"rendered":"https:\/\/www.evan.org\/ghg\/?p=947"},"modified":"2024-01-25T21:53:54","modified_gmt":"2024-01-25T21:53:54","slug":"intellij-search-with-file-mask","status":"publish","type":"post","link":"https:\/\/www.evan.org\/ghg\/java\/intellij-search-with-file-mask\/","title":{"rendered":"IntelliJ Search with File Mask"},"content":{"rendered":"\n<p>You know how you can go to the edit menu in IntelliJ, pick &#8220;Find&#8221;, and then pick &#8220;Find in Files&#8221;? That opens a dialog box. And in the upper right, you can pick a <strong>File Mask<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"689\" height=\"326\" src=\"https:\/\/www.evan.org\/ghg\/wp-content\/themes\/maktub\/assets\/images\/transparent.gif\" data-lazy=\"true\" data-src=\"https:\/\/www.evan.org\/ghg\/wp-content\/uploads\/2024\/01\/FileMask.png\" alt=\"Where the File Mask is located\" class=\"wp-image-945\" data-srcset=\"https:\/\/www.evan.org\/ghg\/wp-content\/uploads\/2024\/01\/FileMask.png 689w, https:\/\/www.evan.org\/ghg\/wp-content\/uploads\/2024\/01\/FileMask-300x142.png 300w\" data-sizes=\"(max-width: 689px) 100vw, 689px\" \/><figcaption class=\"wp-element-caption\">File Mask location<\/figcaption><\/figure>\n\n\n\n<p>Hopefully you&#8217;ve tried that out! And hopefully you&#8217;ve realized it can take wildcards as well, so:<\/p>\n\n\n\n<p><code>pom.xml<\/code> to search only Maven poms<br><code>*.java<\/code> to search all java files<\/p>\n\n\n\n<p>But what if you want to search your code for something but don&#8217;t care about the unit test and integration test classes? Tough! You get hits from everything, and you&#8217;ll just have to visually search through it all. So that made me dig some more trying to see what else I could do. And it turns out that the File Mask supports a &#8220;not&#8221; operator!<\/p>\n\n\n\n<p><code>!*Test.java<\/code> will search everything but files that end in Test.java &#8211; so everything but unit tests.<\/p>\n\n\n\n<p>AND you can combine terms with commas! And that gives us enough pieces to make searching across files much more useful. <\/p>\n\n\n\n<p>To complete the example above, this will search just java code files while excluding all unit and integration test files:<br><code>.java,!Test.java,!*IT.java<\/code><br><br>This made my day, because I am a huge nerd and love finding out stuff like this.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>IntelliJ can search cross multiple files &#8211; and you can get all FANCY telling it which files!<\/p>\n","protected":false},"author":1,"featured_media":953,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[28,20],"tags":[29],"_links":{"self":[{"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/posts\/947"}],"collection":[{"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/comments?post=947"}],"version-history":[{"count":2,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/posts\/947\/revisions"}],"predecessor-version":[{"id":949,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/posts\/947\/revisions\/949"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/media\/953"}],"wp:attachment":[{"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/media?parent=947"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/categories?post=947"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.evan.org\/ghg\/wp-json\/wp\/v2\/tags?post=947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}