Search in sources :

Example 1 with SmartList

use of com.intellij.util.SmartList in project scss-lint-plugin by idok.

the class FileUtils method findExeFilesInPath.

@NotNull
private static List<File> findExeFilesInPath(@Nullable String pathEnvVarValue, @NotNull String fileBaseName, boolean stopAfterFirstMatch, boolean logDetails) {
    if (logDetails) {
        LOG.info("Finding files in PATH (base name=" + fileBaseName + ", PATH=" + StringUtil.notNullize(pathEnvVarValue) + ").");
    }
    if (pathEnvVarValue == null) {
        return Collections.emptyList();
    }
    List<File> result = new SmartList<File>();
    List<String> paths = StringUtil.split(pathEnvVarValue, File.pathSeparator, true, true);
    for (String path : paths) {
        File dir = new File(path);
        if (logDetails) {
            File file = new File(dir, fileBaseName);
            LOG.info("path:" + path + ", path.isAbsolute:" + dir.isAbsolute() + ", path.isDirectory:" + dir.isDirectory() + ", file.isFile:" + file.isFile() + ", file.canExecute:" + file.canExecute());
        }
        if (dir.isAbsolute() && dir.isDirectory()) {
            File file = new File(dir, fileBaseName);
            if (file.isFile() && file.canExecute()) {
                result.add(file);
                if (stopAfterFirstMatch) {
                    return result;
                }
            }
        }
    }
    return result;
}
Also used : SmartList(com.intellij.util.SmartList) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) PsiFile(com.intellij.psi.PsiFile) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with SmartList

use of com.intellij.util.SmartList in project kotlin by JetBrains.

the class ResolvedCallImpl method setResultingSubstitutor.

@Override
public void setResultingSubstitutor(@NotNull TypeSubstitutor substitutor) {
    resultingDescriptor = (D) candidateDescriptor.substitute(substitutor);
    assert resultingDescriptor != null : candidateDescriptor;
    for (TypeParameterDescriptor typeParameter : candidateDescriptor.getTypeParameters()) {
        TypeProjection typeArgumentProjection = substitutor.getSubstitution().get(typeParameter.getDefaultType());
        if (typeArgumentProjection != null) {
            typeArguments.put(typeParameter, typeArgumentProjection.getType());
        }
    }
    if (candidateDescriptor.getValueParameters().isEmpty())
        return;
    List<ValueParameterDescriptor> substitutedParameters = resultingDescriptor.getValueParameters();
    Collection<Map.Entry<ValueParameterDescriptor, ResolvedValueArgument>> valueArgumentsBeforeSubstitution = new SmartList<Map.Entry<ValueParameterDescriptor, ResolvedValueArgument>>(valueArguments.entrySet());
    valueArguments.clear();
    for (Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> entry : valueArgumentsBeforeSubstitution) {
        ValueParameterDescriptor substitutedVersion = substitutedParameters.get(entry.getKey().getIndex());
        assert substitutedVersion != null : entry.getKey();
        valueArguments.put(substitutedVersion, entry.getValue());
    }
    Collection<Map.Entry<ValueArgument, ArgumentMatchImpl>> unsubstitutedArgumentMappings = new SmartList<Map.Entry<ValueArgument, ArgumentMatchImpl>>(argumentToParameterMap.entrySet());
    argumentToParameterMap.clear();
    for (Map.Entry<ValueArgument, ArgumentMatchImpl> entry : unsubstitutedArgumentMappings) {
        ArgumentMatchImpl argumentMatch = entry.getValue();
        ValueParameterDescriptor valueParameterDescriptor = argumentMatch.getValueParameter();
        ValueParameterDescriptor substitutedVersion = substitutedParameters.get(valueParameterDescriptor.getIndex());
        assert substitutedVersion != null : valueParameterDescriptor;
        argumentToParameterMap.put(entry.getKey(), argumentMatch.replaceValueParameter(substitutedVersion));
    }
}
Also used : TypeParameterDescriptor(org.jetbrains.kotlin.descriptors.TypeParameterDescriptor) TypeProjection(org.jetbrains.kotlin.types.TypeProjection) ValueArgument(org.jetbrains.kotlin.psi.ValueArgument) ValueParameterDescriptor(org.jetbrains.kotlin.descriptors.ValueParameterDescriptor) SmartList(com.intellij.util.SmartList)

Example 3 with SmartList

use of com.intellij.util.SmartList in project kotlin by JetBrains.

the class JavaElementFinder method findClasses.

@NotNull
@Override
public PsiClass[] findClasses(@NotNull String qualifiedNameString, @NotNull GlobalSearchScope scope) {
    if (!FqNamesUtilKt.isValidJavaFqName(qualifiedNameString)) {
        return PsiClass.EMPTY_ARRAY;
    }
    List<PsiClass> answer = new SmartList<PsiClass>();
    FqName qualifiedName = new FqName(qualifiedNameString);
    findClassesAndObjects(qualifiedName, scope, answer);
    answer.addAll(lightClassGenerationSupport.getFacadeClasses(qualifiedName, scope));
    answer.addAll(lightClassGenerationSupport.getMultifilePartClasses(qualifiedName, scope));
    return sortByClasspath(answer, scope).toArray(new PsiClass[answer.size()]);
}
Also used : FqName(org.jetbrains.kotlin.name.FqName) SmartList(com.intellij.util.SmartList) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with SmartList

use of com.intellij.util.SmartList in project kotlin by JetBrains.

the class JavaElementFinder method getClasses.

@NotNull
@Override
public PsiClass[] getClasses(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) {
    List<PsiClass> answer = new SmartList<PsiClass>();
    FqName packageFQN = new FqName(psiPackage.getQualifiedName());
    answer.addAll(lightClassGenerationSupport.getFacadeClassesInPackage(packageFQN, scope));
    Collection<KtClassOrObject> declarations = lightClassGenerationSupport.findClassOrObjectDeclarationsInPackage(packageFQN, scope);
    for (KtClassOrObject declaration : declarations) {
        PsiClass aClass = toLightClass(declaration);
        if (aClass != null) {
            answer.add(aClass);
        }
    }
    return sortByClasspath(answer, scope).toArray(new PsiClass[answer.size()]);
}
Also used : KtClassOrObject(org.jetbrains.kotlin.psi.KtClassOrObject) FqName(org.jetbrains.kotlin.name.FqName) SmartList(com.intellij.util.SmartList) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with SmartList

use of com.intellij.util.SmartList in project intellij-community by JetBrains.

the class MavenSmartCompletionContributor method getVariants.

@NotNull
private static Collection<?> getVariants(CompletionParameters parameters) {
    if (!MavenDomUtil.isMavenFile(parameters.getOriginalFile()))
        return Collections.emptyList();
    SmartList<?> result = new SmartList<>();
    for (PsiReference each : getReferences(parameters)) {
        if (each instanceof TagNameReference)
            continue;
        if (each instanceof GenericDomValueReference) {
            GenericDomValueReference reference = (GenericDomValueReference) each;
            Converter converter = reference.getConverter();
            if (converter instanceof MavenSmartConverter) {
                Collection variants = ((MavenSmartConverter) converter).getSmartVariants(reference.getConvertContext());
                if (converter instanceof ResolvingConverter) {
                    addVariants((ResolvingConverter) converter, variants, result);
                } else {
                    result.addAll(variants);
                }
            } else if (converter instanceof ResolvingConverter) {
                //noinspection unchecked
                ResolvingConverter resolvingConverter = (ResolvingConverter) converter;
                Collection variants = resolvingConverter.getVariants(reference.getConvertContext());
                addVariants(resolvingConverter, variants, result);
            }
        } else {
            //noinspection unchecked
            Collections.addAll((Collection) result, each.getVariants());
        }
    }
    return result;
}
Also used : ResolvingConverter(com.intellij.util.xml.ResolvingConverter) MavenSmartConverter(org.jetbrains.idea.maven.dom.converters.MavenSmartConverter) TagNameReference(com.intellij.psi.impl.source.xml.TagNameReference) GenericDomValueReference(com.intellij.util.xml.impl.GenericDomValueReference) PsiReference(com.intellij.psi.PsiReference) Converter(com.intellij.util.xml.Converter) MavenSmartConverter(org.jetbrains.idea.maven.dom.converters.MavenSmartConverter) ResolvingConverter(com.intellij.util.xml.ResolvingConverter) Collection(java.util.Collection) SmartList(com.intellij.util.SmartList) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

SmartList (com.intellij.util.SmartList)163 NotNull (org.jetbrains.annotations.NotNull)70 Nullable (org.jetbrains.annotations.Nullable)25 VirtualFile (com.intellij.openapi.vfs.VirtualFile)24 Module (com.intellij.openapi.module.Module)15 Project (com.intellij.openapi.project.Project)14 TextRange (com.intellij.openapi.util.TextRange)12 PsiElement (com.intellij.psi.PsiElement)12 List (java.util.List)12 Element (org.jdom.Element)12 File (java.io.File)11 THashSet (gnu.trove.THashSet)9 ContainerUtil (com.intellij.util.containers.ContainerUtil)8 ArrayList (java.util.ArrayList)8 Collection (java.util.Collection)8 Pair (com.intellij.openapi.util.Pair)7 PsiFile (com.intellij.psi.PsiFile)6 IOException (java.io.IOException)6 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)5 IElementType (com.intellij.psi.tree.IElementType)5