use of com.intellij.util.containers.HashSet in project android by JetBrains.
the class ResourceManager method getValueResourceNames.
@NotNull
public Collection<String> getValueResourceNames(@NotNull final ResourceType resourceType) {
final Set<String> result = new HashSet<String>();
final boolean attr = ResourceType.ATTR == resourceType;
for (ResourceEntry entry : getValueResourceEntries(resourceType)) {
final String name = entry.getName();
if (!attr || !name.startsWith("android:")) {
result.add(name);
}
}
return result;
}
use of com.intellij.util.containers.HashSet in project android by JetBrains.
the class AndroidFindStyleApplicationsProcessor method collectFilesToProcess.
public Collection<PsiFile> collectFilesToProcess() {
final Project project = myModule.getProject();
final List<VirtualFile> resDirs = new ArrayList<VirtualFile>();
if (mySearchOnlyInCurrentModule) {
collectResDir(myModule, myStyleNameAttrValue, myStyleName, resDirs);
} else {
for (Module m : getAllModulesToScan(myModule)) {
collectResDir(m, myStyleNameAttrValue, myStyleName, resDirs);
}
}
final List<VirtualFile> subdirs = AndroidResourceUtil.getResourceSubdirs(ResourceFolderType.LAYOUT, resDirs.toArray(new VirtualFile[resDirs.size()]));
List<VirtualFile> filesToProcess = new ArrayList<VirtualFile>();
for (VirtualFile subdir : subdirs) {
for (VirtualFile child : subdir.getChildren()) {
if (child.getFileType() == XmlFileType.INSTANCE && (myFileToScan == null || myFileToScan.equals(child))) {
filesToProcess.add(child);
}
}
}
if (filesToProcess.size() == 0) {
return Collections.emptyList();
}
final Set<PsiFile> psiFilesToProcess = new HashSet<PsiFile>();
for (VirtualFile file : filesToProcess) {
final PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
if (psiFile != null) {
psiFilesToProcess.add(psiFile);
}
}
final CacheManager cacheManager = CacheManager.SERVICE.getInstance(project);
final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(project);
for (Map.Entry<AndroidAttributeInfo, String> entry : myAttrMap.entrySet()) {
filterFilesToScan(cacheManager, entry.getKey().getName(), psiFilesToProcess, projectScope);
filterFilesToScan(cacheManager, entry.getValue(), psiFilesToProcess, projectScope);
}
return psiFilesToProcess;
}
use of com.intellij.util.containers.HashSet in project android by JetBrains.
the class AndroidInlineAllStyleUsagesProcessor method findUsages.
@NotNull
@Override
protected UsageInfo[] findUsages() {
final Set<UsageInfo> usages = new HashSet<UsageInfo>();
AndroidInlineUtil.addReferences(myStyleElement, usages);
for (PsiField field : AndroidResourceUtil.findResourceFieldsForValueResource(myStyleTag, false)) {
AndroidInlineUtil.addReferences(field, usages);
}
return usages.toArray(new UsageInfo[usages.size()]);
}
use of com.intellij.util.containers.HashSet in project android by JetBrains.
the class ResourceManager method findIdDeclarations.
// searches only declarations such as "@+id/..."
@NotNull
public List<XmlAttributeValue> findIdDeclarations(@NotNull final String id) {
if (!isResourcePublic(ResourceType.ID.getName(), id)) {
return Collections.emptyList();
}
final List<XmlAttributeValue> declarations = new ArrayList<XmlAttributeValue>();
final Collection<VirtualFile> files = FileBasedIndex.getInstance().getContainingFiles(AndroidIdIndex.INDEX_ID, "+" + id, GlobalSearchScope.allScope(myProject));
final Set<VirtualFile> fileSet = new HashSet<VirtualFile>(files);
final PsiManager psiManager = PsiManager.getInstance(myProject);
for (VirtualFile subdir : getResourceSubdirsToSearchIds()) {
for (VirtualFile file : subdir.getChildren()) {
if (fileSet.contains(file)) {
final PsiFile psiFile = psiManager.findFile(file);
if (psiFile instanceof XmlFile) {
psiFile.accept(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlAttributeValue(XmlAttributeValue attributeValue) {
if (AndroidResourceUtil.isIdDeclaration(attributeValue)) {
final String idInAttr = AndroidResourceUtil.getResourceNameByReferenceText(attributeValue.getValue());
if (id.equals(idInAttr)) {
declarations.add(attributeValue);
}
}
}
});
}
}
}
}
return declarations;
}
use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class GitRootConverter method convertRoots.
@NotNull
public List<VirtualFile> convertRoots(@NotNull List<VirtualFile> result) {
// TODO this should be faster, because it is called rather often. gitRootOrNull could be a bottle-neck.
ArrayList<VirtualFile> roots = new ArrayList<>();
HashSet<VirtualFile> listed = new HashSet<>();
for (VirtualFile f : result) {
VirtualFile r = GitUtil.gitRootOrNull(f);
if (r != null && listed.add(r)) {
roots.add(r);
}
}
return roots;
}
Aggregations