use of com.intellij.util.containers.SmartHashSet in project intellij-community by JetBrains.
the class DependencyResolvingBuilder method getRepositoryLibraries.
@NotNull
private static Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> getRepositoryLibraries(ModuleChunk chunk) {
final Collection<JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>>> result = new SmartHashSet<>();
for (JpsModule module : chunk.getModules()) {
for (JpsDependencyElement dep : module.getDependenciesList().getDependencies()) {
if (dep instanceof JpsLibraryDependency) {
final JpsLibrary _lib = ((JpsLibraryDependency) dep).getLibrary();
final JpsTypedLibrary<JpsSimpleElement<RepositoryLibraryDescriptor>> lib = _lib != null ? _lib.asTyped(JpsMavenRepositoryLibraryType.INSTANCE) : null;
if (lib != null) {
result.add(lib);
}
}
}
}
return result;
}
use of com.intellij.util.containers.SmartHashSet in project intellij-community by JetBrains.
the class LogFileOptions method getPaths.
@NotNull
public Set<String> getPaths() {
File logFile = new File(myPathPattern);
if (logFile.exists()) {
return Collections.singleton(myPathPattern);
}
int dirIndex = myPathPattern.lastIndexOf(File.separator);
if (dirIndex == -1) {
return Collections.emptySet();
}
List<File> files = new SmartList<>();
collectMatchedFiles(new File(myPathPattern.substring(0, dirIndex)), Pattern.compile(FileUtil.convertAntToRegexp(myPathPattern.substring(dirIndex + File.separator.length()))), files);
if (files.isEmpty()) {
return Collections.emptySet();
}
if (myShowAll) {
SmartHashSet<String> result = new SmartHashSet<>();
result.ensureCapacity(files.size());
for (File file : files) {
result.add(file.getPath());
}
return result;
} else {
File lastFile = null;
for (File file : files) {
if (lastFile != null) {
if (file.lastModified() > lastFile.lastModified()) {
lastFile = file;
}
} else {
lastFile = file;
}
}
assert lastFile != null;
return Collections.singleton(lastFile.getPath());
}
}
use of com.intellij.util.containers.SmartHashSet in project intellij-community by JetBrains.
the class InspectionEngine method getDialectIdsSpecifiedForTool.
@Nullable("null means not specified")
public static Set<String> getDialectIdsSpecifiedForTool(@NotNull LocalInspectionToolWrapper wrapper) {
String langId = wrapper.getLanguage();
if (langId == null) {
return null;
}
Language language = Language.findLanguageByID(langId);
Set<String> result;
if (language == null) {
// unknown language in plugin.xml, ignore
result = Collections.singleton(langId);
} else {
List<Language> dialects = language.getDialects();
boolean applyToDialects = wrapper.applyToDialects();
result = applyToDialects && !dialects.isEmpty() ? new THashSet<>(1 + dialects.size()) : new SmartHashSet<>();
result.add(langId);
if (applyToDialects) {
for (Language dialect : dialects) {
result.add(dialect.getID());
}
}
}
return result;
}
use of com.intellij.util.containers.SmartHashSet in project intellij-community by JetBrains.
the class LocalInspectionsPass method getElementsAndDialectsFrom.
private static void getElementsAndDialectsFrom(@NotNull PsiFile file, @NotNull List<PsiElement> outElements, @NotNull Set<String> outDialects) {
final FileViewProvider viewProvider = file.getViewProvider();
final Set<PsiElement> result = new LinkedHashSet<>();
Set<Language> processedLanguages = new SmartHashSet<>();
final PsiElementVisitor visitor = new PsiRecursiveElementVisitor() {
@Override
public void visitElement(PsiElement element) {
ProgressManager.checkCanceled();
PsiElement child = element.getFirstChild();
if (child == null) {
// leaf element
} else {
// composite element
while (child != null) {
child.accept(this);
result.add(child);
appendDialects(child, processedLanguages, outDialects);
child = child.getNextSibling();
}
}
}
};
for (Language language : viewProvider.getLanguages()) {
final PsiFile psiRoot = viewProvider.getPsi(language);
if (psiRoot == null || !HighlightingLevelManager.getInstance(file.getProject()).shouldInspect(psiRoot)) {
continue;
}
psiRoot.accept(visitor);
result.add(psiRoot);
appendDialects(psiRoot, processedLanguages, outDialects);
}
outElements.addAll(result);
}
use of com.intellij.util.containers.SmartHashSet in project oxy-template-support-plugin by mutant-industries.
the class ExtenderProvider method getExtenders.
@NotNull
public static Set<PsiClass> getExtenders(@NotNull PsiClass original) {
Set<PsiClass> result = new SmartHashSet<>();
PsiClass extender;
for (PsiClass psiClass : getExtenderProvidersFor(original)) {
if ((extender = getExtenderFromProvider(psiClass)) != null) {
result.add(extender);
}
}
return result;
}
Aggregations