简体   繁体   English

从Android Studio lint拼写检查器中排除文件

[英]Exclude files from Android Studio lint spell checker

The Android Studio lint spell checker flags hex codes that look to it like words in certain files that would be better off unchecked, such as values/colors.xml and build/intermediates/dex-cache/cache.xml . Android Studio lint拼写检查程序会标记十六进制代码,这些代码看起来像某些文件中的单词,这些单词最好不要选中,例如values/colors.xmlbuild/intermediates/dex-cache/cache.xml

How do I tell lint to not spell check certain folders or files? 如何告诉lint不拼写检查某些文件夹或文件?

This can be done by using IDE scopes. 这可以通过使用IDE范围来完成。 In Android Studio (at least 3.4) you can configure each inspection per scope. 在Android Studio(至少3.4)中,您可以为每个范围配置每个检查。 The idea is that you create a scope that contains all files you don't want to be spellchecked, and then switch Spelling inspection off for this scope, but keep it on for everything else. 我们的想法是,您创建一个包含您不希望拼写检查的所有文件的范围,然后关闭此范围的拼写检查,但保留其他所有内容。

  1. Add a new scope in Settings / Appearance & Behavior / Scopes that contains all files which you want to exclude from spell checking. Settings / Appearance & Behavior / Scopes添加新范围,其中包含要从拼写检查中排除的所有文件。 For example, this pattern covers all svg files: file:*.svg . 例如,此模式涵盖所有svg文件: file:*.svg In your case it could be like file:*/colors.xml||file:*/cache.xml . 在你的情况下,它可能像file:*/colors.xml||file:*/cache.xml IDE will highlight all affected files by green, so you can check if you entered correct pattern. IDE将以绿色突出显示所有受影响的文件,因此您可以检查是否输入了正确的模式。

  2. Then set up Spelling inspection, so that it is OFF for your new scope and ON everywhere else. 然后设置拼写检查,以便新范围为OFF,其他地方为ON。 拼字

Had the same problem with colors.xml colors.xml有同样的问题

I couldn't find a way to disable the check for a certain file, but I could get rid of the spellcheck on the hex codes. 我找不到禁用某个文件检查的方法,但我可以摆脱十六进制代码的拼写检查。

Click Analyze->Inspect Code . 单击Analyze->Inspect Code Choose Whole Project and click OK. 选择Whole Project ,然后单击确定。

The inspection tool window will open with the results. 检查工具窗口将打开并显示结果。

You should be able to see the problematic hex codes under Spelling->typo . 您应该能够在Spelling->typo下看到有问题的十六进制代码。 Right click any one of them and choose Exclude . 右键单击其中任何一个,然后选择“ Exclude

Did the trick for me. 对我有把戏。 HTH HTH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM