com.intellij.util.SmartList Java Examples

The following examples show how to use com.intellij.util.SmartList. 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: ExtractMethodPanel.java    From IntelliJDeodorant with MIT License 6 votes vote down vote up
/**
 * Collects statements that can be extracted into a separate method.
 */
public SmartList<PsiStatement> getStatementsToExtract(ASTSlice slice) {
    Set<PDGNode> nodes = slice.getSliceNodes();
    SmartList<PsiStatement> statementsToExtract = new SmartList<>();

    for (PDGNode pdgNode : nodes) {
        boolean isNotChild = true;
        for (PDGNode node : nodes) {
            if (isChild(node.getASTStatement(), pdgNode.getASTStatement())) {
                isNotChild = false;
            }
        }
        if (isNotChild) {
            statementsToExtract.add(pdgNode.getASTStatement());
        }
    }
    return statementsToExtract;
}
 
Example #2
Source File: CSharpCompositeResolveContext.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Nullable
@Override
public CSharpElementGroup<CSharpConversionMethodDeclaration> findConversionMethodGroup(@Nonnull CSharpCastType castType, boolean deep)
{
	List<CSharpElementGroup<CSharpConversionMethodDeclaration>> groups = new SmartList<CSharpElementGroup<CSharpConversionMethodDeclaration>>();
	for(CSharpResolveContext context : myContexts)
	{
		CSharpElementGroup<CSharpConversionMethodDeclaration> elementGroup = context.findConversionMethodGroup(castType, deep);
		if(elementGroup != null)
		{
			groups.add(elementGroup);
		}
	}
	return groups.isEmpty() ? null : new CSharpCompositeElementGroupImpl<CSharpConversionMethodDeclaration>(myProject, groups);
}
 
Example #3
Source File: CSharpCompositeResolveContext.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Nullable
@Override
public CSharpElementGroup<CSharpMethodDeclaration> findOperatorGroupByTokenType(@Nonnull IElementType type, boolean deep)
{
	List<CSharpElementGroup<CSharpMethodDeclaration>> groups = new SmartList<CSharpElementGroup<CSharpMethodDeclaration>>();
	for(CSharpResolveContext context : myContexts)
	{
		CSharpElementGroup<CSharpMethodDeclaration> elementGroup = context.findOperatorGroupByTokenType(type, deep);
		if(elementGroup != null)
		{
			groups.add(elementGroup);
		}
	}
	return groups.isEmpty() ? null : new CSharpCompositeElementGroupImpl<CSharpMethodDeclaration>(myProject, groups);
}
 
Example #4
Source File: StubTreeBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Order is deterministic. First element matches {@link FileViewProvider#getStubBindingRoot()}
 */
@Nonnull
public static List<Pair<IStubFileElementType, PsiFile>> getStubbedRoots(@Nonnull FileViewProvider viewProvider) {
  final List<Trinity<Language, IStubFileElementType, PsiFile>> roots = new SmartList<>();
  final PsiFile stubBindingRoot = viewProvider.getStubBindingRoot();
  for (Language language : viewProvider.getLanguages()) {
    final PsiFile file = viewProvider.getPsi(language);
    if (file instanceof PsiFileImpl) {
      final IElementType type = ((PsiFileImpl)file).getElementTypeForStubBuilder();
      if (type != null) {
        roots.add(Trinity.create(language, (IStubFileElementType)type, file));
      }
    }
  }

  ContainerUtil.sort(roots, (o1, o2) -> {
    if (o1.third == stubBindingRoot) return o2.third == stubBindingRoot ? 0 : -1;
    else if (o2.third == stubBindingRoot) return 1;
    else return StringUtil.compare(o1.first.getID(), o2.first.getID(), false);
  });

  return ContainerUtil.map(roots, trinity -> Pair.create(trinity.second, trinity.third));
}
 
Example #5
Source File: CSharpCompositeResolveContext.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Nullable
@Override
public CSharpElementGroup<CSharpConstructorDeclaration> constructorGroup()
{
	List<CSharpElementGroup<CSharpConstructorDeclaration>> groups = new SmartList<CSharpElementGroup<CSharpConstructorDeclaration>>();
	for(CSharpResolveContext context : myContexts)
	{
		CSharpElementGroup<CSharpConstructorDeclaration> elementGroup = context.constructorGroup();
		if(elementGroup != null)
		{
			groups.add(elementGroup);
		}
	}
	return groups.isEmpty() ? null : new CSharpCompositeElementGroupImpl<CSharpConstructorDeclaration>(myProject, groups);
}
 
Example #6
Source File: CSharpCompositeResolveContext.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Nullable
@Override
public CSharpElementGroup<CSharpIndexMethodDeclaration> indexMethodGroup(boolean deep)
{
	List<CSharpElementGroup<CSharpIndexMethodDeclaration>> groups = new SmartList<CSharpElementGroup<CSharpIndexMethodDeclaration>>();
	for(CSharpResolveContext context : myContexts)
	{
		CSharpElementGroup<CSharpIndexMethodDeclaration> elementGroup = context.indexMethodGroup(deep);
		if(elementGroup != null)
		{
			groups.add(elementGroup);
		}
	}
	return groups.isEmpty() ? null : new CSharpCompositeElementGroupImpl<CSharpIndexMethodDeclaration>(myProject, groups);
}
 
Example #7
Source File: StaticPathReferenceProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
public PathReference getPathReference(@Nonnull final String path, @Nonnull final PsiElement element) {
  final List<PsiReference> list = new SmartList<PsiReference>();
  createReferences(element, list, true);
  if (list.isEmpty()) return null;

  final PsiElement target = list.get(list.size() - 1).resolve();
  if (target == null) return null;

  return new PathReference(path, PathReference.ResolveFunction.NULL_RESOLVE_FUNCTION) {
    @Override
    public PsiElement resolve() {
      return target;
    }
  };

}
 
Example #8
Source File: LossyEncodingInspection.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
public ProblemDescriptor[] checkFile(@Nonnull PsiFile file, @Nonnull InspectionManager manager, boolean isOnTheFly) {
  if (InjectedLanguageManager.getInstance(file.getProject()).isInjectedFragment(file)) return null;
  if (!file.isPhysical()) return null;
  FileViewProvider viewProvider = file.getViewProvider();
  if (viewProvider.getBaseLanguage() != file.getLanguage()) return null;
  VirtualFile virtualFile = file.getVirtualFile();
  if (virtualFile == null) return null;
  if (!virtualFile.isInLocalFileSystem()) return null;
  CharSequence text = viewProvider.getContents();
  Charset charset = LoadTextUtil.extractCharsetFromFileContent(file.getProject(), virtualFile, text);

  // no sense in checking transparently decoded file: all characters there are already safely encoded
  if (charset instanceof Native2AsciiCharset) return null;

  List<ProblemDescriptor> descriptors = new SmartList<ProblemDescriptor>();
  boolean ok = checkFileLoadedInWrongEncoding(file, manager, isOnTheFly, virtualFile, charset, descriptors);
  if (ok) {
    checkIfCharactersWillBeLostAfterSave(file, manager, isOnTheFly, text, charset, descriptors);
  }

  return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
}
 
Example #9
Source File: PathMappingValidator.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static String validatePathMappings(@Nonnull Project project, @Nonnull RemoteSdkAdditionalData data) {
  boolean found = false;
  final List<String> locations = new SmartList<>();
  for (PathMappingProvider mappingProvider : PathMappingProvider.getSuitableMappingProviders(data)) {
    found = found || !mappingProvider.getPathMappingSettings(project, data).isEmpty();
    locations.add(mappingProvider.getProviderPresentableName(data));
  }

  if (!found) {
    final StringBuilder builder = new StringBuilder();
    builder.append("No path mappings were found.");
    if (!locations.isEmpty()) {
      builder.append(" Please, configure them at ").append(StringUtil.join(locations, " or "));
    }
    return builder.toString();
  }
  return null;
}
 
Example #10
Source File: CSharpBaseResolveContext.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nullable
private static CSharpElementGroup<CSharpMethodDeclaration> filterElementGroupToExtensionGroup(CSharpElementGroup<PsiElement> elementGroup)
{
	final List<CSharpMethodDeclaration> extensions = new SmartList<>();
	elementGroup.process(element ->
	{
		if(element instanceof CSharpMethodDeclaration && ((CSharpMethodDeclaration) element).isExtension())
		{
			extensions.add((CSharpMethodDeclaration) element);
		}
		return true;
	});
	if(extensions.isEmpty())
	{
		return null;
	}
	return new CSharpElementGroupImpl<>(elementGroup.getProject(), elementGroup.getKey(), extensions);
}
 
Example #11
Source File: RunManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public final void setBeforeRunTasks(final RunConfiguration runConfiguration, @Nonnull List<BeforeRunTask> tasks, boolean addEnabledTemplateTasksIfAbsent) {
  List<BeforeRunTask> result = new SmartList<>(tasks);
  if (addEnabledTemplateTasksIfAbsent) {
    List<BeforeRunTask> templates = getTemplateBeforeRunTasks(runConfiguration);
    Set<Key<BeforeRunTask>> idsToSet = new THashSet<>();
    for (BeforeRunTask task : tasks) {
      idsToSet.add(task.getProviderId());
    }
    int i = 0;
    for (BeforeRunTask template : templates) {
      if (!idsToSet.contains(template.getProviderId())) {
        result.add(i, template);
        i++;
      }
    }
  }
  myConfigurationToBeforeTasksMap.put(runConfiguration, ContainerUtil.notNullize(result));
  fireBeforeRunTasksUpdated();
}
 
Example #12
Source File: StateStorageManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private Collection<VfsFileBasedStorage> getCachedFileStorages(@Nonnull Collection<String> fileSpecs) {
  if (fileSpecs.isEmpty()) {
    return Collections.emptyList();
  }

  List<VfsFileBasedStorage> result = null;
  for (String fileSpec : fileSpecs) {
    StateStorage storage = myStorages.get(fileSpec);
    if (storage instanceof VfsFileBasedStorage) {
      if (result == null) {
        result = new SmartList<>();
      }
      result.add((VfsFileBasedStorage)storage);
    }
  }
  return result == null ? Collections.<VfsFileBasedStorage>emptyList() : result;
}
 
Example #13
Source File: CSharpVisibilityUtil.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
@Nonnull
@RequiredReadAction
private static List<DotNetTypeDeclaration> collectAllTypes(@Nonnull PsiElement place)
{
	List<DotNetTypeDeclaration> typeDeclarations = new SmartList<>();
	if(place instanceof CSharpTypeDeclaration)
	{
		typeDeclarations.add((DotNetTypeDeclaration) place);
	}
	PsiElement type = place;
	while((type = PsiTreeUtil.getContextOfType(type, DotNetTypeDeclaration.class)) != null)
	{
		typeDeclarations.add((DotNetTypeDeclaration) type);
	}
	return typeDeclarations;
}
 
Example #14
Source File: LibraryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getInvalidRootUrls(@Nonnull OrderRootType type) {
  if (myDisposed) return Collections.emptyList();

  VirtualFilePointerContainer container = myRoots.get(type);
  final List<VirtualFilePointer> pointers = container == null ? Collections.emptyList() : container.getList();
  List<String> invalidPaths = null;
  for (VirtualFilePointer pointer : pointers) {
    if (!pointer.isValid()) {
      if (invalidPaths == null) {
        invalidPaths = new SmartList<>();
      }
      invalidPaths.add(pointer.getUrl());
    }
  }
  return ContainerUtil.notNullize(invalidPaths);
}
 
Example #15
Source File: PsiTreeUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static <T extends PsiElement> List<T> getStubChildrenOfTypeAsList(@Nullable PsiElement element, @Nonnull Class<T> aClass) {
  if (element == null) return Collections.emptyList();
  StubElement<?> stub = element instanceof StubBasedPsiElement ? ((StubBasedPsiElement)element).getStub() : null;
  if (stub == null) {
    return getChildrenOfTypeAsList(element, aClass);
  }

  List<T> result = new SmartList<>();
  for (StubElement childStub : stub.getChildrenStubs()) {
    PsiElement child = childStub.getPsi();
    if (aClass.isInstance(child)) {
      result.add(aClass.cast(child));
    }
  }
  return result;
}
 
Example #16
Source File: ArbitraryPlaceUrlReferenceProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected CachedValue<PsiReference[]> compute(final PsiElement element, Object p) {
  return CachedValuesManager.getManager(element.getProject()).createCachedValue(() -> {
    IssueNavigationConfiguration navigationConfiguration = IssueNavigationConfiguration.getInstance(element.getProject());
    if (navigationConfiguration == null) {
      return CachedValueProvider.Result.create(PsiReference.EMPTY_ARRAY, element);
    }

    List<PsiReference> refs = null;
    GlobalPathReferenceProvider provider = myReferenceProvider.get();
    CharSequence commentText = StringUtil.newBombedCharSequence(element.getText(), 500);
    for (IssueNavigationConfiguration.LinkMatch link : navigationConfiguration.findIssueLinks(commentText)) {
      if (refs == null) refs = new SmartList<>();
      if (provider == null) {
        provider = (GlobalPathReferenceProvider)PathReferenceManager.getInstance().getGlobalWebPathReferenceProvider();
        myReferenceProvider.lazySet(provider);
      }
      provider.createUrlReference(element, link.getTargetUrl(), link.getRange(), refs);
    }
    PsiReference[] references = refs != null ? refs.toArray(new PsiReference[refs.size()]) : PsiReference.EMPTY_ARRAY;
    return new CachedValueProvider.Result<>(references, element, navigationConfiguration);
  }, false);
}
 
Example #17
Source File: PermanentLinearGraphImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<GraphEdge> getAdjacentEdges(int nodeIndex, @Nonnull EdgeFilter filter) {
  List<GraphEdge> result = new SmartList<>();

  boolean hasUpSimpleEdge = nodeIndex != 0 && mySimpleNodes.get(nodeIndex - 1);
  if (hasUpSimpleEdge && filter.upNormal) result.add(new GraphEdge(nodeIndex - 1, nodeIndex, null, USUAL));

  for (int i = myNodeToEdgeIndex.get(nodeIndex); i < myNodeToEdgeIndex.get(nodeIndex + 1); i++) {
    int adjacentNode = myLongEdges.get(i);

    if (adjacentNode < 0 && filter.special) {
      result.add(GraphEdge.createEdgeWithTargetId(nodeIndex, adjacentNode, GraphEdgeType.NOT_LOAD_COMMIT));
    }
    if (adjacentNode < 0) continue;

    if (nodeIndex > adjacentNode && filter.upNormal) result.add(new GraphEdge(adjacentNode, nodeIndex, null, USUAL));
    if (nodeIndex < adjacentNode && filter.downNormal) result.add(new GraphEdge(nodeIndex, adjacentNode, null, USUAL));
  }

  if (mySimpleNodes.get(nodeIndex) && filter.downNormal) result.add(new GraphEdge(nodeIndex, nodeIndex + 1, null, USUAL));

  return result;
}
 
Example #18
Source File: RunContentManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nonnull
public List<RunContentDescriptor> getAllDescriptors() {
  if (myToolwindowIdToContentManagerMap.isEmpty()) {
    return Collections.emptyList();
  }

  List<RunContentDescriptor> descriptors = new SmartList<>();
  for (String id : myToolwindowIdToContentManagerMap.keySet()) {
    for (Content content : myToolwindowIdToContentManagerMap.get(id).getContents()) {
      RunContentDescriptor descriptor = getRunContentDescriptorByContent(content);
      if (descriptor != null) {
        descriptors.add(descriptor);
      }
    }
  }
  return descriptors;
}
 
Example #19
Source File: InjectedLanguageManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nullable
public List<Pair<PsiElement, TextRange>> getInjectedPsiFiles(@Nonnull final PsiElement host) {
  if (!(host instanceof PsiLanguageInjectionHost) || !((PsiLanguageInjectionHost)host).isValidHost()) {
    return null;
  }
  final PsiElement inTree = InjectedLanguageUtil.loadTree(host, host.getContainingFile());
  final List<Pair<PsiElement, TextRange>> result = new SmartList<>();
  enumerate(inTree, (injectedPsi, places) -> {
    for (PsiLanguageInjectionHost.Shred place : places) {
      if (place.getHost() == inTree) {
        result.add(new Pair<>(injectedPsi, place.getRangeInsideHost()));
      }
    }
  });
  return result.isEmpty() ? null : result;
}
 
Example #20
Source File: LibraryPresentationManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getDescriptions(@Nonnull VirtualFile[] classRoots, final Set<LibraryKind> excludedKinds) {
  final SmartList<String> result = new SmartList<>();
  LibraryDetectionManager.getInstance().processProperties(Arrays.asList(classRoots), new LibraryDetectionManager.LibraryPropertiesProcessor() {
    @Override
    public <P extends LibraryProperties> boolean processProperties(@Nonnull LibraryKind kind, @Nonnull P properties) {
      if (!excludedKinds.contains(kind)) {
        final LibraryPresentationProvider<P> provider = getPresentationProvider(kind);
        if (provider != null) {
          ContainerUtil.addIfNotNull(result, provider.getDescription(properties));
        }
      }
      return true;
    }
  });
  return result;
}
 
Example #21
Source File: ExtensibleQueryFactory.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected ExtensibleQueryFactory(@NonNls final String epNamespace) {
  myPoint = new NotNullLazyValue<SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>>>() {
    @Override
    @Nonnull
    protected SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>> compute() {
      return new SimpleSmartExtensionPoint<QueryExecutor<Result, Parameters>>(new SmartList<QueryExecutor<Result, Parameters>>()){
        @Override
        @Nonnull
        protected ExtensionPoint<QueryExecutor<Result, Parameters>> getExtensionPoint() {
          String epName = ExtensibleQueryFactory.this.getClass().getName();
          int pos = epName.lastIndexOf('.');
          if (pos >= 0) {
            epName = epName.substring(pos+1);
          }
          epName = epNamespace + "." + StringUtil.decapitalize(epName);
          return Application.get().getExtensionPoint(ExtensionPointName.create(epName));
        }
      };
    }
  };
}
 
Example #22
Source File: SemServiceImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private List<SemElement> createSemElements(SemKey key, PsiElement psi) {
  List<SemElement> result = null;
  final Collection<NullableFunction<PsiElement, ? extends SemElement>> producers = myProducers.get(key);
  if (!producers.isEmpty()) {
    for (final NullableFunction<PsiElement, ? extends SemElement> producer : producers) {
      myCreatingSem.incrementAndGet();
      try {
        final SemElement element = producer.fun(psi);
        if (element != null) {
          if (result == null) result = new SmartList<>();
          result.add(element);
        }
      }
      finally {
        myCreatingSem.decrementAndGet();
      }
    }
  }
  return result == null ? Collections.emptyList() : Collections.unmodifiableList(result);
}
 
Example #23
Source File: RunManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Template configuration is not included
 */
@Override
@Nonnull
public List<RunConfiguration> getConfigurationsList(@Nonnull ConfigurationType type) {
  List<RunConfiguration> result = null;
  for (RunnerAndConfigurationSettings settings : getSortedConfigurations()) {
    RunConfiguration configuration = settings.getConfiguration();
    if (type.getId().equals(configuration.getType().getId())) {
      if (result == null) {
        result = new SmartList<>();
      }
      result.add(configuration);
    }
  }
  return ContainerUtil.notNullize(result);
}
 
Example #24
Source File: OrderEnumeratorBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public OrderEnumeratorBase(@Nullable Module module, @Nonnull Project project, @Nullable OrderRootsCache cache) {
  myCache = cache;
  List<OrderEnumerationHandler> customHandlers = null;
  for (OrderEnumerationHandler.Factory handlerFactory : OrderEnumerationHandler.EP_NAME.getExtensions()) {
    if (handlerFactory.isApplicable(project) && (module == null || handlerFactory.isApplicable(module))) {
      if (customHandlers == null) {
        customHandlers = new SmartList<>();
      }
      customHandlers.add(handlerFactory.createHandler(module));
    }
  }
  this.myCustomHandlers = customHandlers == null ? Collections.<OrderEnumerationHandler>emptyList() : customHandlers;
}
 
Example #25
Source File: RunManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Template configuration is not included
 */
@Override
@Nonnull
public List<RunnerAndConfigurationSettings> getConfigurationSettingsList(@Nonnull ConfigurationType type) {
  List<RunnerAndConfigurationSettings> result = new SmartList<>();
  for (RunnerAndConfigurationSettings configuration : getSortedConfigurations()) {
    ConfigurationType configurationType = configuration.getType();
    if (configurationType != null && type.getId().equals(configurationType.getId())) {
      result.add(configuration);
    }
  }
  return result;
}
 
Example #26
Source File: ChangeSet.java    From consulo with Apache License 2.0 5 votes vote down vote up
public List<String> getAffectedPaths() {
  return accessChanges(new Producer<List<String>>() {
    @Override
    public List<String> produce() {
      List<String> result = new SmartList<String>();
      for (Change each : myChanges) {
        if (each instanceof StructuralChange) {
          result.add(((StructuralChange)each).getPath());
        }
      }
      return result;
    }
  });
}
 
Example #27
Source File: CS1004.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Nonnull
@Override
public List<CompilerCheckBuilder> check(@Nonnull CSharpLanguageVersion languageVersion, @Nonnull CSharpHighlightContext highlightContext, @Nonnull DotNetModifierListOwner element)
{
	DotNetModifierList modifierList = element.getModifierList();
	if(modifierList == null)
	{
		return Collections.emptyList();
	}

	List<CompilerCheckBuilder> results = new SmartList<CompilerCheckBuilder>();
	for(CSharpModifier modifier : CSharpModifier.values())
	{
		List<PsiElement> modifierElements = modifierList.getModifierElements(modifier);
		if(modifierElements.size() <= 1)
		{
			continue;
		}

		for(PsiElement modifierElement : modifierElements)
		{
			results.add(newBuilder(modifierElement, modifier.getPresentableText()).addQuickFix(new RemoveModifierFix(modifier, element)));
		}
	}
	return results;
}
 
Example #28
Source File: ArtifactCompilerCompileItem.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ArtifactPackagingItemOutputState computeOutputState() {
  final SmartList<Pair<String, Long>> pairs = new SmartList<Pair<String, Long>>();
  for (DestinationInfo destination : myDestinations) {
    destination.update();
    final VirtualFile outputFile = destination.getOutputFile();
    long timestamp = outputFile != null ? outputFile.getTimeStamp() : -1;
    pairs.add(Pair.create(destination.getOutputPath(), timestamp));
  }
  return new ArtifactPackagingItemOutputState(pairs);
}
 
Example #29
Source File: CSharpParameterInfoHandler.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@RequiredReadAction
private static ItemToShow[] resolveToCallables(PsiElement element, CreateParameterInfoContext context)
{
	List<ItemToShow> list = new SmartList<>();
	if(element instanceof CSharpCallArgumentListOwner)
	{
		ResolveResult[] resolveResults = ((CSharpCallArgumentListOwner) element).multiResolve(true);

		for(ResolveResult resolveResult : resolveResults)
		{
			CSharpSimpleLikeMethod likeMethod = resolveSimpleMethod(resolveResult, element);
			if(likeMethod != null)
			{
				ItemToShow item = new ItemToShow(likeMethod, element);
				list.add(item);
				if(resolveResult.isValidResult() && context.getHighlightedElement() == null)
				{
					context.setHighlightedElement(item.valid());
				}
			}
		}
	}

	ContainerUtil.sort(list, (o1, o2) ->
	{
		if(o1.isValid())
		{
			return -1;
		}
		if(o2.isValid())
		{
			return 1;
		}
		return o1.myLikeMethod.getParameterInfos().length - o2.myLikeMethod.getParameterInfos().length;
	});
	return ContainerUtil.toArray(list, ItemToShow.ARRAY_FACTORY);
}
 
Example #30
Source File: ComparingClassifier.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Iterable<T> classify(@Nonnull final Iterable<T> source, @Nonnull final ProcessingContext context) {
  List<T> nulls = null;
  TreeMap<Comparable, List<T>> map = new TreeMap<Comparable, List<T>>();
  for (T t : source) {
    final Comparable weight = getWeight(t, context);
    if (weight == null) {
      if (nulls == null) nulls = new SmartList<T>();
      nulls.add(t);
    } else {
      List<T> list = map.get(weight);
      if (list == null) {
        map.put(weight, list = new SmartList<T>());
      }
      list.add(t);
    }
  }

  final List<List<T>> values = new ArrayList<List<T>>();
  values.addAll(myNegated ? map.descendingMap().values() : map.values());
  ContainerUtil.addIfNotNull(values, nulls);

  return new Iterable<T>() {
    @Override
    public Iterator<T> iterator() {
      return new FlatteningIterator<List<T>, T>(values.iterator()) {
        @Override
        protected Iterator<T> createValueIterator(List<T> group) {
          return myNext.classify(group, context).iterator();
        }
      };
    }
  };
}