void () { configureByText(JavaFileType.INSTANCE, """ class A { String cons; void foo() { String local = null; <selection>cons</selection>.substring(1); } public static void main(String[] args) { new A().foo(); }}"""); enableInspectionTool(new UnusedDeclarationInspection(true)); List<HighlightInfo> infos = doHighlighting(HighlightSeverity.WARNING); assertSize(1, infos); assertEquals("Variable 'local' is never used", infos.get(0).getDescription()); type("local"); infos = doHighlighting(HighlightSeverity.WARNING); assertSize(1, infos); assertEquals("Field 'cons' is never used", infos.get(0).getDescription()); }