use of com.intellij.util.containers.hash.HashSet in project intellij-community by JetBrains.
the class SchemaDefinitionsSearch method gatherInheritors.
private Collection<SchemaTypeInfo> gatherInheritors(XmlTagImpl xml) {
XmlAttribute name = getNameAttr(xml);
if (name == null || StringUtil.isEmptyOrSpaces(name.getValue()))
return null;
String localName = name.getValue();
final boolean hasPrefix = localName.contains(":");
localName = hasPrefix ? localName.substring(localName.indexOf(':') + 1) : localName;
final String nsPrefix = hasPrefix ? name.getValue().substring(0, name.getValue().indexOf(':')) : null;
final XmlFile file = XmlUtil.getContainingFile(xml);
if (file == null)
return null;
final Project project = file.getProject();
if (project == null)
return null;
final Set<SchemaTypeInfo> result = new HashSet<>();
final ArrayDeque<SchemaTypeInfo> queue = new ArrayDeque<>();
String nsUri;
if (!hasPrefix) {
nsUri = getDefaultNs(file);
} else {
nsUri = XmlUtil.findNamespaceByPrefix(nsPrefix, file.getRootTag());
}
if (nsUri == null)
return null;
queue.add(new SchemaTypeInfo(localName, true, nsUri));
final BiFunction<String, String, List<Set<SchemaTypeInfo>>> worker = SchemaTypeInheritanceIndex.getWorker(project, file.getContainingFile().getVirtualFile());
while (!queue.isEmpty()) {
final SchemaTypeInfo info = queue.removeFirst();
final List<Set<SchemaTypeInfo>> childrenOfType = worker.apply(info.getNamespaceUri(), info.getTagName());
for (Set<SchemaTypeInfo> infos : childrenOfType) {
for (SchemaTypeInfo typeInfo : infos) {
if (typeInfo.isIsTypeName()) {
queue.add(typeInfo);
}
result.add(typeInfo);
}
}
}
return result;
}
use of com.intellij.util.containers.hash.HashSet in project intellij-plugins by JetBrains.
the class FlexCompositeSdkProjectViewStructureProvider method modify.
@NotNull
@Override
public Collection<AbstractTreeNode> modify(@NotNull final AbstractTreeNode parent, @NotNull final Collection<AbstractTreeNode> children, final ViewSettings settings) {
if (!(parent instanceof ExternalLibrariesNode)) {
return children;
}
Set<Sdk> processedSdks = new HashSet<>();
Collection<AbstractTreeNode> result = new ArrayList<>();
for (AbstractTreeNode child : children) {
Object value = child.getValue();
if (!(value instanceof NamedLibraryElement)) {
result.add(child);
continue;
}
NamedLibraryElement libraryElement = (NamedLibraryElement) value;
OrderEntry orderEntry = libraryElement.getOrderEntry();
if (!(orderEntry instanceof JdkOrderEntry)) {
result.add(child);
continue;
}
Sdk sdk = ((JdkOrderEntry) orderEntry).getJdk();
if (!(sdk instanceof FlexCompositeSdk)) {
result.add(child);
continue;
}
Sdk[] sdks = ((FlexCompositeSdk) sdk).getSdks();
for (Sdk individualSdk : sdks) {
if (processedSdks.add(individualSdk)) {
IndividualSdkOrderEntry entry = new IndividualSdkOrderEntry(individualSdk, orderEntry.getOwnerModule());
result.add(new NamedLibraryElementNode(parent.getProject(), new NamedLibraryElement(null, entry), ((ExternalLibrariesNode) parent).getSettings()));
}
}
}
return result;
}
Aggregations