@NotNull public VirtualFile[] getSelectedFiles() { final Set<VirtualFile> files = new ArrayListSet<VirtualFile>(); for (final EditorWindow window : myWindows) { final VirtualFile file = window.getSelectedFile(); if (file != null) { files.add(file); } } final VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files); final VirtualFile currentFile = getCurrentFile(); if (currentFile != null) { for (int i = 0; i != virtualFiles.length; ++i) { if (Comparing.equal(virtualFiles[i], currentFile)) { virtualFiles[i] = virtualFiles[0]; virtualFiles[0] = currentFile; break; } } } return virtualFiles; }
private Set<String> getExistingNames() { final AntDomElement hostingElement = getHostingAntDomElement(); if (hostingElement == null) { return Collections.emptySet(); } final AntDomTarget contextTarget = hostingElement.getParentOfType(AntDomTarget.class, false); if (contextTarget == null) { return Collections.emptySet(); } final Set<String> existing = new ArrayListSet<String>(); final String selfName = contextTarget.getName().getStringValue(); if (selfName != null) { existing.add(selfName); } final String dependsString = contextTarget.getDependsList().getRawText(); if (dependsString != null) { final StringTokenizer tokenizer = new StringTokenizer(dependsString, ",", false); while (tokenizer.hasMoreTokens()) { existing.add(tokenizer.nextToken().trim()); } } return existing; }
@NotNull public VirtualFile[] getSelectedFiles() { final ArrayListSet<VirtualFile> files = new ArrayListSet<VirtualFile>(); for (final EditorWindow window : myWindows) { final VirtualFile file = window.getSelectedFile(); if (file != null) { files.add(file); } } final VirtualFile[] virtualFiles = VfsUtil.toVirtualFileArray(files); final VirtualFile currentFile = getCurrentFile(); if (currentFile != null) { for (int i = 0; i != virtualFiles.length; ++i) { if (Comparing.equal(virtualFiles[i], currentFile)) { virtualFiles[i] = virtualFiles[0]; virtualFiles[0] = currentFile; break; } } } return virtualFiles; }
@Override @Nonnull public VirtualFile[] getOpenFiles() { final Set<VirtualFile> files = new ArrayListSet<>(); for (final DesktopEditorWindow myWindow : myWindows) { final EditorWithProviderComposite[] editors = myWindow.getEditors(); for (final EditorWithProviderComposite editor : editors) { VirtualFile file = editor.getFile(); // background thread may call this method when invalid file is being removed // do not return it here as it will quietly drop out soon if (file.isValid()) { files.add(file); } } } return VfsUtilCore.toVirtualFileArray(files); }
@Override @Nonnull public VirtualFile[] getSelectedFiles() { final Set<VirtualFile> files = new ArrayListSet<>(); for (final DesktopEditorWindow window : myWindows) { final VirtualFile file = window.getSelectedFile(); if (file != null) { files.add(file); } } final VirtualFile[] virtualFiles = VfsUtilCore.toVirtualFileArray(files); final VirtualFile currentFile = getCurrentFile(); if (currentFile != null) { for (int i = 0; i != virtualFiles.length; ++i) { if (Comparing.equal(virtualFiles[i], currentFile)) { virtualFiles[i] = virtualFiles[0]; virtualFiles[0] = currentFile; break; } } } return virtualFiles; }
@Nonnull public static Set<IdeaPluginDescriptor> getPluginsForInstall(List<IdeaPluginDescriptor> pluginsToInstall, List<IdeaPluginDescriptor> allPlugins) { final List<PluginId> pluginIds = new ArrayList<>(); for (IdeaPluginDescriptor pluginNode : pluginsToInstall) { pluginIds.add(pluginNode.getPluginId()); } final Set<IdeaPluginDescriptor> toInstallAll = new ArrayListSet<>(); for (IdeaPluginDescriptor toInstall : pluginsToInstall) { Set<PluginNode> depends = new ArrayListSet<>(); collectDepends(toInstall, pluginIds, depends, allPlugins); toInstallAll.addAll(depends); toInstallAll.add(toInstall); } if(toInstallAll.isEmpty()) { throw new IllegalArgumentException("No plugins for install"); } return toInstallAll; }
@Override public void projectOpened() { work = new ArrayListSet<InferenceCapable>(); inferenceQueueProcessor = new QueueProcessor<InferenceCapable>(new InferenceQueue(myProject), myProject.getDisposed(), false); StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new Runnable() { @Override public void run() { DumbService.getInstance(myProject).runWhenSmart(new InitRunnable()); } }); }
@NotNull public VirtualFile[] getOpenFiles() { final Set<VirtualFile> files = new ArrayListSet<VirtualFile>(); for (final EditorWindow myWindow : myWindows) { final EditorWithProviderComposite[] editors = myWindow.getEditors(); for (final EditorWithProviderComposite editor : editors) { VirtualFile file = editor.getFile(); // background thread may call this method when invalid file is being removed // do not return it here as it will quietly drop out soon if (file.isValid()) { files.add(file); } } } return VfsUtilCore.toVirtualFileArray(files); }
@NotNull public VirtualFile[] getOpenFiles() { final ArrayListSet<VirtualFile> files = new ArrayListSet<VirtualFile>(); for (final EditorWindow myWindow : myWindows) { final EditorWithProviderComposite[] editors = myWindow.getEditors(); for (final EditorWithProviderComposite editor : editors) { VirtualFile file = editor.getFile(); // background thread may call this method when invalid file is being removed // do not return it here as it will quietly drop out soon if (file.isValid()) { files.add(file); } } } return VfsUtil.toVirtualFileArray(files); }
@NotNull private Set<String> getDomainKeys(@NotNull String domain) { Set<String> uniqueKeySet = new ArrayListSet<String>(); for(Set<String> splits: FileBasedIndex.getInstance().getValues(TranslationStubIndex.KEY, domain, GlobalSearchScope.allScope(getProject()))) { ContainerUtil.addAll(uniqueKeySet, splits); } return uniqueKeySet; }
public VariableAssignedVisitor(@NotNull JSVariable variable, @NotNull JSElement context, @NotNull Set<JSVariable> notUpdatedSymbols) { this.variable = variable; this.context = context; this.notUpdatedSymbols = notUpdatedSymbols; this.candidateSymbols = new ArrayListSet<JSVariable>(); this.candidateSymbols.add(variable); }
@NotNull @Override public DataType getDataType() { Set<DataType.Feature> features = new ArrayListSet<>(); return new DataType("type", "type", 1,1, LengthUnit.BYTE, true, "a", "a", false, null, features, 0); }
static Set<PropertyDetector.PropInfo> getPropInfoWithSupers(UClass uClass){ Set<PropertyDetector.PropInfo> mSet = new ArrayListSet<>(); getPropInfoWithSupers(uClass.getPsi(), mSet); return mSet; }
PackageIndex(Project project) { this.project = project; // build toQualified by traversing directories //final GlobalSearchScope scope = new ProjectAndLibrariesScope(project); final ProjectRootManager prm = ProjectRootManager.getInstance(project); final ProjectFileIndexImpl idx = (ProjectFileIndexImpl)prm.getFileIndex(); ContentIterator iter = new ContentIterator() { @Override public boolean processFile(VirtualFile fileOrDir) { if (fileOrDir.isDirectory()) { if (idx.isIgnored(fileOrDir)) return true; // ignore resource files (some resource directories are just sitting in regular packages. Not // much we can do. Those will just never have classes in them. if (idx.isUnderSourceRootOfType(fileOrDir, JavaModuleSourceRootTypes.RESOURCES)) return true; // source file VirtualFile root = idx.getSourceRootForFile(fileOrDir); // class file if (root == null) root = idx.getClassRootForFile(fileOrDir); // if not source, not class, or root, ignore if (root == null || root.getUrl().equals(fileOrDir.getUrl())) return true; String qpkg = fileOrDir.getPath().substring(root.getPath().length()).replace('/','.'); // hacky, but we know no better way if (qpkg.isEmpty() || qpkg.equals(".") || qpkg.startsWith("META-INF")) return true; // non-jar classes end up with a '.' in front if (qpkg.charAt(0) == '.') qpkg = qpkg.substring(1); String pkg = qpkg.substring(qpkg.lastIndexOf('.')+1); Set<String> quals = toQualified.get(pkg); if (quals == null) { quals = new ArrayListSet<String>(); toQualified.put(pkg,quals); } quals.add(qpkg); } return true; } }; FileBasedIndex.getInstance().iterateIndexableFiles(iter, project, null); }
@RequiredReadAction private DotNetStatement[] getStatements(PsiFile file, int startOffset, int endOffset) { Set<DotNetStatement> set = new ArrayListSet<DotNetStatement>(); PsiElement element1 = file.findElementAt(startOffset); PsiElement element2 = file.findElementAt(endOffset - 1); if(element1 instanceof PsiWhiteSpace) { startOffset = element1.getTextRange().getEndOffset(); element1 = file.findElementAt(startOffset); } if(element2 instanceof PsiWhiteSpace) { endOffset = element2.getTextRange().getStartOffset(); element2 = file.findElementAt(endOffset - 1); } PsiElement statement1 = getTopmostParentOfType(element1, DotNetStatement.class); if(statement1 == null) { return EMPTY_ARRAY; } PsiElement statement2 = getTopmostParentOfType(element2, DotNetStatement.class); if(statement2 == null) { return EMPTY_ARRAY; } PsiElement temp = statement1; while(temp != null) { if(temp instanceof DotNetStatement) { set.add((DotNetStatement) temp); } if(temp == statement2) { return ContainerUtil.toArray(set, EMPTY_ARRAY); } temp = temp.getNextSibling(); } return EMPTY_ARRAY; }
@NotNull @RequiredReadAction public static NewArtifactConfiguration doCreateArtifactTemplate(Module module, PackagingElementResolvingContext packagingElementResolvingContext) { ModulesProvider modulesProvider = packagingElementResolvingContext.getModulesProvider(); Project project = module.getProject(); CompositePackagingElement<?> root = ExplodedWarArtifactType.getInstance().createRootElement(module.getName()); DirectoryPackagingElement webInfDir = DirectoryElementType.getInstance().createEmpty(project); webInfDir.setDirectoryName(JavaWebConstants.WEB_INF); root.addFirstChild(webInfDir); DirectoryPackagingElement libDir = DirectoryElementType.getInstance().createEmpty(project); libDir.setDirectoryName("lib"); webInfDir.addFirstChild(libDir); Set<Library> libraries = new ArrayListSet<>(); Set<Module> modules = new ArrayListSet<>(); collectInfo(modules, libraries, modulesProvider, module); for(Module toAddModule : modules) { NamedPointer<Module> pointer = ModuleUtilCore.createPointer(toAddModule); ModuleRootModel rootModel = modulesProvider.getRootModel(toAddModule); ZipArchivePackagingElement zipArchivePackagingElement = ZipArchiveElementType.getInstance().createEmpty(project); zipArchivePackagingElement.setArchiveFileName(toAddModule.getName() + ".jar"); if(rootModel.getContentFolders(ContentFolderScopes.of(ProductionContentFolderTypeProvider.getInstance())).length > 0) { zipArchivePackagingElement.addFirstChild(ProductionModuleOutputElementType.getInstance().createElement(project, pointer)); } if(rootModel.getContentFolders(ContentFolderScopes.of(ProductionResourceContentFolderTypeProvider.getInstance())).length > 0) { zipArchivePackagingElement.addFirstChild(ProductionResourceModuleOutputElementType.getInstance().createElement(project, pointer)); } libDir.addFirstChild(zipArchivePackagingElement); if(rootModel.getContentFolders(ContentFolderScopes.of(WebResourcesFolderTypeProvider.getInstance())).length > 0) { root.addFirstChild(WebResourceModuleOutputElementType.getInstance().createElement(project, pointer)); } } for(Library library : libraries) { LibraryPackagingElement libraryPackagingElement = LibraryElementType.getInstance().createEmpty(project); libraryPackagingElement.setLibraryName(library.getName()); LibraryTable table = library.getTable(); String tableLevel = table == null ? null : table.getTableLevel(); libraryPackagingElement.setLevel(tableLevel); if(LibraryTableImplUtil.MODULE_LEVEL.equals(tableLevel)) { libraryPackagingElement.setModuleName(((ModuleLibraryTable) table).getModule().getName()); } libDir.addFirstChild(libraryPackagingElement); } return new NewArtifactConfiguration(root, ExplodedWarArtifactType.getInstance().getPresentableName() + ": " + module.getName(), ExplodedWarArtifactType.getInstance()); }