How to use NoNls

I have seen the announced feature of using the annotation NoNls to supress hard coded string warnings for special methods, parameters and fields. But I'm lost how to use it, I have tried several things, but the editor never accepts it. My build: #3562

Sample:

@SuppressWarnings({"DuplicateStringLiteralInspection"})
public static Icon getIconImage(String url) {...}

Callers of this method should be able to specify the url as hard coded string.

Thanks
Thomas

2 comments

Hello Thomas,

TH> I have seen the announced feature of using the annotation NoNls to
TH> supress hard coded string warnings for special methods, parameters
TH> and fields. But I'm lost how to use it, I have tried several things,
TH> but the editor never accepts it. My build: #3562
TH>
TH> Sample:
TH>
TH> @SuppressWarnings({"DuplicateStringLiteralInspection"}) public
TH> static Icon getIconImage(String url) {...}
TH>
TH> Callers of this method should be able to specify the url as hard
TH> coded string.

What do you mean by "editor does not accept it"? You need to add redist\annotations.jar
as a library to your project in order for the annotation to be understood.

Then simply annotate the parameter:
@NonNls String url

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

Hello Dmitry,

it worked as you described, thank you very much.

Thomas

0

Please sign in to leave a comment.