use of com.intellij.util.Function in project intellij-community by JetBrains.
the class PySkeletonRefresher method calculateExtraSysPath.
private static String calculateExtraSysPath(@NotNull final Sdk sdk, @Nullable final String skeletonsPath) {
final File skeletons = skeletonsPath != null ? new File(skeletonsPath) : null;
final VirtualFile userSkeletonsDir = PyUserSkeletonsUtil.getUserSkeletonsDirectory();
final File userSkeletons = userSkeletonsDir != null ? new File(userSkeletonsDir.getPath()) : null;
final VirtualFile remoteSourcesDir = PySdkUtil.findAnyRemoteLibrary(sdk);
final File remoteSources = remoteSourcesDir != null ? new File(remoteSourcesDir.getPath()) : null;
final List<VirtualFile> paths = new ArrayList<>();
paths.addAll(Arrays.asList(sdk.getRootProvider().getFiles(OrderRootType.CLASSES)));
paths.addAll(BuildoutFacet.getExtraPathForAllOpenModules());
return Joiner.on(File.pathSeparator).join(ContainerUtil.mapNotNull(paths, (Function<VirtualFile, Object>) file -> {
if (file.isInLocalFileSystem()) {
final File canonicalFile = new File(file.getPath());
if (canonicalFile.exists() && !FileUtil.filesEqual(canonicalFile, skeletons) && !FileUtil.filesEqual(canonicalFile, userSkeletons) && !FileUtil.filesEqual(canonicalFile, remoteSources)) {
return file.getPath();
}
}
return null;
}));
}
use of com.intellij.util.Function in project intellij-elixir by KronicDeth.
the class Import method onlyCallDefinitionClauseCallFilter.
@NotNull
private static Function<Call, Boolean> onlyCallDefinitionClauseCallFilter(PsiElement element) {
final Map<String, List<Integer>> aritiesByName = aritiesByNameFromNameByArityKeywordList(element);
return new Function<Call, Boolean>() {
@Override
public Boolean fun(Call call) {
Pair<String, IntRange> callNameArityRange = nameArityRange(call);
boolean include = false;
if (callNameArityRange != null) {
String callName = callNameArityRange.first;
if (callName != null) {
List<Integer> arities = aritiesByName.get(callName);
if (arities != null) {
IntRange callArityRange = callNameArityRange.second;
for (int arity : arities) {
if (callArityRange.containsInteger(arity)) {
include = true;
break;
}
}
}
}
}
return include;
}
};
}
use of com.intellij.util.Function in project intellij-elixir by KronicDeth.
the class CallDefinitionClause method implicitImports.
private boolean implicitImports(@NotNull PsiElement element, @NotNull ResolveState state) {
Project project = element.getProject();
boolean keepProcessing = org.elixir_lang.reference.Module.forEachNavigationElement(project, KERNEL, new Function<PsiElement, Boolean>() {
@Override
public Boolean fun(PsiElement navigationElement) {
boolean keepProcessingNavigationElements = true;
if (navigationElement instanceof Call) {
Call modular = (Call) navigationElement;
keepProcessingNavigationElements = Modular.callDefinitionClauseCallWhile(modular, new Function<Call, Boolean>() {
@Override
public Boolean fun(Call callDefinitionClause) {
return executeOnCallDefinitionClause(callDefinitionClause, state);
}
});
}
return keepProcessingNavigationElements;
}
});
// the implicit `import Kernel.SpecialForms`
if (keepProcessing) {
ResolveState modularCanonicalNameState = state.put(MODULAR_CANONICAL_NAME, KERNEL_SPECIAL_FORMS);
keepProcessing = org.elixir_lang.reference.Module.forEachNavigationElement(project, KERNEL_SPECIAL_FORMS, new Function<PsiElement, Boolean>() {
@Override
public Boolean fun(PsiElement navigationElement) {
boolean keepProcessingNavigationElements = true;
if (navigationElement instanceof Call) {
Call modular = (Call) navigationElement;
keepProcessingNavigationElements = Modular.callDefinitionClauseCallWhile(modular, new Function<Call, Boolean>() {
@Override
public Boolean fun(Call callDefinitionClause) {
return executeOnCallDefinitionClause(callDefinitionClause, modularCanonicalNameState);
}
});
}
return keepProcessingNavigationElements;
}
});
}
return keepProcessing;
}
Aggregations