How do I inspect my code with exceptions based on file pattern

已回答

Hi,

I want to inspect my code using some patterns, but that GUI "custom scope" is not intuitve at all, I don't understand if it's a regex or what it is.

So what should I put in the "Exclude patter" field to exclude tests and maybe examples. I want to exclude all files that contain the substring "test" and maybe substring "example". But I really want to exclude "test" substring.

Thanks

0

Hi Taw,

Creating a custom scope is the way to go. For more information on how to do it, see the following help pages:

In your case, the pattern will be:

!file:*test*&&!file:*Test*

0

Thanks a lot @..., now I have learn another synthax language to use JetBrains tools? :))))

I am glad that you give me an example to copy paste.:)

 

So I shouldn't press the Exclude button, because it's not needed, isn't it?

0

No problem Taw Moto

So I shouldn't press the Exclude button, because it's not needed, isn't it?

Pressing Include/Exclude buttons allows you to append the corresponding syntax to the pattern string per each item selected in the tree preview.

See example below. I selected the test_java.iml file, pressed Exclude, and a chunk of syntax was added to the pattern string automatically:

0

Oh, I see now, but this `Exclude` button only excludes one file, it does not excludes a pattern, so I still to add the pattern you mentioned.

Thanks a lot @... (btw, beautiful name, I never heard it before), you really helped me, the tutorial is awful:

https://www.jetbrains.com/help/idea/scope-language-syntax-reference.html

I also gave a feedback there that it's not helpful at all, only one example for the "exclude"?

  • file:*.js||file:*.coffee- include all JavaScript and CoffeeScript files. -> so it's an OR (||) operator but in fact means AND (&&). Wow...

0

Btw, do you know by any chance if this pattern is saved if I update my IntelliJ product? Or if I export the settings and import them into a clean IntelliJ product? thanks

0

Happy to help Taw Moto. Thanks for the compliment.

it does not excludes a pattern, so I still to add the pattern you mentioned

Yes, correct.

so it's an OR (||) operator but in fact means AND (&&)

The logical OR operator returns true if one or more operands is true.

I agree though, the tutorial probably needs some revamping. Leaving feedback was the right move.

do you know by any chance if this pattern is saved if I update my IntelliJ product? Or if I export the settings and import them into a clean IntelliJ product?

Custom scope settings are stored in the .idea configuration directory inside each project in the form of a <component> record in the workspace.xml file:

<component name="NamedScopeManager">
<scope name="test" pattern="!file:*test*&amp;&amp;!file:*Test*" />
</component>

Custom scopes are not part of the 'Export Settings' feature, but project configuration stays intact when you update the IDE, so the pattern will be saved.

0

请先登录再写评论。