com.intellij.util.containers.ArrayListSet Java Examples

The following examples show how to use com.intellij.util.containers.ArrayListSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DesktopEditorsSplitters.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: DesktopEditorsSplitters.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #3
Source File: PluginInstallUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Set<PluginDescriptor> getPluginsForInstall(List<PluginDescriptor> pluginsToInstall, List<PluginDescriptor> allPlugins) {
  final List<PluginId> pluginIds = new ArrayList<>();
  for (PluginDescriptor pluginNode : pluginsToInstall) {
    pluginIds.add(pluginNode.getPluginId());
  }

  final Set<PluginDescriptor> toInstallAll = new ArrayListSet<>();

  for (PluginDescriptor 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;
}
 
Example #4
Source File: TranslationStubIndexTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@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;
}
 
Example #5
Source File: PsiUpperSymbolReference.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
private Set<PsiQualifiedElement> resolveElementsFromPaths() {
    Project project = myElement.getProject();
    GlobalSearchScope scope = GlobalSearchScope.allScope(project);
    PsiFinder psiFinder = PsiFinder.getInstance(project);

    QNameFinder qnameFinder = m_types instanceof RmlTypes ? RmlQNameFinder.INSTANCE : OclQNameFinder.INSTANCE;
    Set<String> paths = qnameFinder.extractPotentialPaths(myElement);
    if (LOG.isTraceEnabled()) {
        LOG.trace(" -> Paths before resolution: " + Joiner.join(", ", paths));
    }

    Set<PsiQualifiedElement> resolvedElements = new ArrayListSet<>();
    for (String path : paths) {
        String qn = path + "." + m_referenceName;

        PsiQualifiedElement variant = psiFinder.findVariant(qn, scope);
        if (variant != null) {
            resolvedElements.add(variant);
        } else {
            // Trying to resolve variant from the name,
            // Variant might be locally open with module name only - and not including type name... qn can't be used
            Collection<PsiVariantDeclaration> variants = psiFinder.findVariantByName(path, m_referenceName, scope);
            if (!variants.isEmpty()) {
                resolvedElements.addAll(variants);
            } else {
                PsiQualifiedElement exception = psiFinder.findException(qn, both, scope);
                if (exception != null) {
                    resolvedElements.add(exception);
                } else {
                    // Don't resolve local module aliases to their real reference: this is needed for refactoring
                    Set<PsiModule> modulesFromQn = psiFinder.findModulesFromQn(qn, false, both, scope);
                    if (!modulesFromQn.isEmpty()) {
                        resolvedElements.addAll(modulesFromQn);
                    }
                }
            }
        }
    }

    PsiElement prevSibling = myElement.getPrevSibling();
    if (prevSibling == null || prevSibling.getNode().getElementType() != m_types.DOT) {
        Set<PsiModule> modulesReference = psiFinder.findModulesFromQn(m_referenceName, true, both, scope);
        if (modulesReference.isEmpty()) {
            if (LOG.isTraceEnabled()) {
                LOG.trace(" -> No module found for qn " + m_referenceName);
            }
        } else {
            resolvedElements.addAll(modulesReference);
        }
    }

    return resolvedElements;
}
 
Example #6
Source File: PropertyUtils.java    From data-mediator with Apache License 2.0 4 votes vote down vote up
static Set<PropertyDetector.PropInfo> getPropInfoWithSupers(UClass uClass){
    Set<PropertyDetector.PropInfo> mSet = new ArrayListSet<>();
    getPropInfoWithSupers(uClass.getPsi(), mSet);
    return mSet;
}
 
Example #7
Source File: PropertyUtils.java    From data-mediator with Apache License 2.0 4 votes vote down vote up
static Set<PropertyDetector.PropInfo> getPropInfoWithSupers(UClass uClass){
    Set<PropertyDetector.PropInfo> mSet = new ArrayListSet<>();
    getPropInfoWithSupers(uClass.getPsi(), mSet);
    return mSet;
}
 
Example #8
Source File: CSharpExtractMethodHandler.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@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;
}