private void processElements( Attribute attribute, CssElementType elementType, Map<String, Collection<FileObject>> elements2files) { CharSequence value = attribute.unquotedValue(); if (value == null) { return; } if (value.length() == 0) { return; // ignore empty value } // all files containing the id declaration Collection<FileObject> filesWithTheId = elements2files.get(value.toString()); // all referred files with the id declaration Collection<FileObject> referredFilesWithTheId = new LinkedList<FileObject>(); if (filesWithTheId != null) { referredFilesWithTheId.addAll(filesWithTheId); referredFilesWithTheId.retainAll(referredFiles); } if (referredFilesWithTheId.isEmpty()) { // unknown id hints.add( new MissingCssElement( rule, context, getAttributeValueOffsetRange(attribute, context), filesWithTheId)); } }
@Override public Collection<Attribute> attributes(AttributeFilter filter) { Collection<Attribute> filtered = new ArrayList<Attribute>(attributes().size() / 2); for (Attribute attr : attributes()) { if (filter.accepts(attr)) { filtered.add(attr); } } return filtered; }
private static Map<String, Collection<FileObject>> createReversedMap( Map<FileObject, Collection<String>> file2elements) { Map<String, Collection<FileObject>> map = new HashMap<String, Collection<FileObject>>(); for (FileObject file : file2elements.keySet()) { for (String element : file2elements.get(file)) { Collection<FileObject> files = map.get(element); if (files == null) { files = new HashSet<FileObject>(); } files.add(file); map.put(element, files); } } return map; }