11package com .antkorwin .betterstrings ;
22
3+
34import com .jupitertools .compiletest .CompileTest ;
45import org .intellij .lang .annotations .Language ;
56import org .junit .jupiter .api .Nested ;
@@ -259,4 +260,44 @@ void useEnumValue() {
259260 assertThat (result ).isEqualTo ("SECOND = 7" );
260261 }
261262 }
263+
264+ @ Nested
265+ class IgnoreInAnnotations {
266+
267+ @ Test
268+ void inAnnotationStringValue () {
269+ @ Language ("Java" ) String versionCode = "import java.lang.annotation.Retention;" +
270+ "import java.lang.annotation.RetentionPolicy;" +
271+ "import java.lang.annotation.Target;" +
272+ "import java.lang.annotation.ElementType;" +
273+ "\n " +
274+ "@Target({ ElementType.TYPE, ElementType.METHOD })\n " +
275+ "@Retention(RetentionPolicy.RUNTIME)" +
276+ "public @interface Version {" +
277+ " String value();" +
278+ "}" ;
279+
280+ @ Language ("Java" ) String classCode = "import java.lang.reflect.Method;" +
281+ "\n " +
282+ "public class Test { " +
283+ " @Version(\" ${1+2}\" ) " +
284+ " public String test() throws Exception { " +
285+ " Method name = this.getClass().getMethod(\" test\" ); " +
286+ " String value = name.getAnnotation(Version.class).value(); " +
287+ " return \" result = \" +value; " +
288+ " } " +
289+ "}" ;
290+
291+ Object result = new CompileTest ().classCode ("Test" , classCode )
292+ .classCode ("Version" , versionCode )
293+ .processor (new BetterStringsProcessor ())
294+ .compile ()
295+ .createClass ("Test" )
296+ .invoke ("test" );
297+
298+ assertThat (result ).isEqualTo ("result = ${1+2}" );
299+ }
300+ }
301+
302+
262303}
0 commit comments