@Override protected void run(CompilationContext info, RuleContext context, List<Hint> result) { ELParserResult elResult = (ELParserResult) context.parserResult; for (ELElement each : elResult.getElements()) { if (!each.isValid()) { // broken AST, skip (perhaps could try just plain string search) continue; } for (Pair<AstIdentifier, AstString> pair : resourceBundles.collectKeys(each.getNode(), info.context())) { if (!resourceBundles.isValidKey(pair.first.getImage(), pair.second.getString())) { Hint hint = new Hint( this, NbBundle.getMessage( ResourceBundleKeys.class, "ResourceBundleKeys_Unknown", pair.second.getString()), elResult.getFileObject(), each.getOriginalOffset(pair.second), Collections.<HintFix>emptyList(), 200); result.add(hint); } } } }
@Override public boolean appliesTo(RuleContext context) { FileObject fo = context.parserResult.getSnapshot().getSource().getFileObject(); if (fo == null) { return false; } this.resourceBundles = ResourceBundles.get(fo); return resourceBundles.canHaveBundles(); }