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;
}
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));
}
}
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()]);
}
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()]);
}
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;
}
Aggregations