use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class JavaTestFinder method collectTests.
private boolean collectTests(PsiClass klass, Processor<Pair<? extends PsiNamedElement, Integer>> processor) {
GlobalSearchScope scope = getSearchScope(klass, false);
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(klass.getProject());
String klassName = klass.getName();
Pattern pattern = Pattern.compile(".*" + StringUtil.escapeToRegexp(klassName) + ".*", Pattern.CASE_INSENSITIVE);
HashSet<String> names = new HashSet<>();
cache.getAllClassNames(names);
for (String eachName : names) {
if (pattern.matcher(eachName).matches()) {
for (PsiClass eachClass : cache.getClassesByName(eachName, scope)) {
if (isTestClass(eachClass, klass)) {
if (!processor.process(Pair.create(eachClass, TestFinderHelper.calcTestNameProximity(klassName, eachName)))) {
return true;
}
}
}
}
}
return false;
}
use of com.intellij.util.containers.HashSet in project intellij-community by JetBrains.
the class JspContextManager method getRootContextFile.
@NotNull
public BaseJspFile getRootContextFile(@NotNull BaseJspFile file) {
BaseJspFile rootContext = file;
HashSet<BaseJspFile> recursionPreventer = new HashSet<>();
do {
recursionPreventer.add(rootContext);
BaseJspFile context = getContextFile(rootContext);
if (context == null || recursionPreventer.contains(context))
break;
rootContext = context;
} while (true);
return rootContext;
}
use of com.intellij.util.containers.HashSet in project intellij-plugins by JetBrains.
the class Struts2TilesModelProvider method computeModels.
@NotNull
public Collection<TilesModel> computeModels(@NotNull final Module module) {
final Project project = module.getProject();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
final GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, false);
// struts2-tiles plugin must be available
final PsiClass strutsTilesListenerClass = facade.findClass(STRUTS_TILES_LISTENER_CLASS, moduleScope);
if (strutsTilesListenerClass == null) {
return Collections.emptyList();
}
final PsiClass tilesListenerClass = facade.findClass(TilesConstants.TILES_LISTENER, moduleScope);
final StrutsPluginDomFactory<TilesDefinitions, TilesModel> factory = StrutsProjectComponent.getInstance(project).getTilesFactory();
final Set<TilesModel> struts2TilesModels = new HashSet<>();
final Consumer<Set<XmlFile>> consumer = definitions -> {
final DomFileElement<TilesDefinitions> domFileElement = factory.createMergedModelRoot(definitions);
if (domFileElement != null) {
struts2TilesModels.add(new TilesModelImpl(definitions, domFileElement, STRUTS2_TILES_MODEL));
}
};
final WebDirectoryUtil webDirectoryUtil = WebDirectoryUtil.getWebDirectoryUtil(project);
final Collection<WebFacet> webFacets = WebFacet.getInstances(module);
for (final WebFacet webFacet : webFacets) {
final WebApp webApp = webFacet.getRoot();
if (webApp == null) {
continue;
}
// determine configured tiles config files
@NonNls final Set<String> tilesConfigNames = findConfiguredTilesPaths(webApp);
// no configured paths? use default
if (tilesConfigNames.isEmpty()) {
tilesConfigNames.add(DEFAULT_TILES_XML);
}
// resolve to XmlFile
final Set<XmlFile> tilesFileSet = new HashSet<>();
for (final String tilesPath : tilesConfigNames) {
final PsiElement tilesXmlFile = webDirectoryUtil.findFileByPath(tilesPath, webFacet);
if (tilesXmlFile instanceof XmlFile) {
tilesFileSet.add((XmlFile) tilesXmlFile);
}
}
final List<Listener> listenerList = webApp.getListeners();
for (final Listener listener : listenerList) {
final PsiClass listenerClass = listener.getListenerClass().getValue();
if (strutsTilesListenerClass.equals(listenerClass) || Comparing.equal(tilesListenerClass, listenerClass)) {
consumer.consume(tilesFileSet);
}
}
}
return struts2TilesModels;
}
use of com.intellij.util.containers.HashSet in project intellij-plugins by JetBrains.
the class DartVmServiceDebugProcess method getUrisForFile.
@NotNull
public Collection<String> getUrisForFile(@NotNull final VirtualFile file) {
final Set<String> result = new HashSet<>();
String uriByIde = myDartUrlResolver.getDartUrlForFile(file);
// If dart:, short circuit the results.
if (uriByIde.startsWith(DartUrlResolver.DART_PREFIX)) {
result.add(uriByIde);
return result;
}
// file:
if (uriByIde.startsWith(DartUrlResolver.FILE_PREFIX)) {
result.add(threeSlashize(uriByIde));
} else {
result.add(uriByIde);
result.add(threeSlashize(new File(file.getPath()).toURI().toString()));
}
// straight path - used by some VM embedders
result.add(file.getPath());
// package: (if applicable)
if (myDASExecutionContextId != null) {
final String uriByServer = DartAnalysisServerService.getInstance(getSession().getProject()).execution_mapUri(myDASExecutionContextId, file.getPath(), null);
if (uriByServer != null) {
result.add(uriByServer);
}
}
// remote prefix (if applicable)
if (myRemoteProjectRootUri != null) {
final VirtualFile pubspec = myDartUrlResolver.getPubspecYamlFile();
if (pubspec != null) {
final String projectPath = pubspec.getParent().getPath();
final String filePath = file.getPath();
if (filePath.startsWith(projectPath)) {
result.add(myRemoteProjectRootUri + filePath.substring(projectPath.length()));
}
} else if (myCurrentWorkingDirectory != null) {
// Handle projects with no pubspecs.
final String projectPath = myCurrentWorkingDirectory.getPath();
final String filePath = file.getPath();
if (filePath.startsWith(projectPath)) {
result.add(myRemoteProjectRootUri + filePath.substring(projectPath.length()));
}
}
}
return result;
}
use of com.intellij.util.containers.HashSet in project android by JetBrains.
the class DeviceArtDescriptor method getDescriptorFiles.
private static List<File> getDescriptorFiles(@Nullable File[] additionalRoots) {
Set<File> roots = new HashSet<File>();
File base = getBundledDescriptorsFolder();
if (base != null) {
roots.add(base);
}
if (additionalRoots != null) {
Collections.addAll(roots, additionalRoots);
}
List<File> files = new ArrayList<File>(roots.size());
for (File root : roots) {
File file = getDescriptorFile(root);
if (file != null) {
files.add(file);
}
}
return files;
}
Aggregations