Search in sources :

Example 6 with Function1

use of kotlin.jvm.functions.Function1 in project kotlin by JetBrains.

the class KotlinBuiltIns method createPackage.

@NotNull
private PackageFragmentDescriptor createPackage(@NotNull PackageFragmentProvider fragmentProvider, @Nullable Map<FqName, PackageFragmentDescriptor> packageNameToPackageFragment, @NotNull final FqName packageFqName) {
    final List<PackageFragmentDescriptor> packageFragments = fragmentProvider.getPackageFragments(packageFqName);
    PackageFragmentDescriptor result = packageFragments.isEmpty() ? new EmptyPackageFragmentDescriptor(builtInsModule, packageFqName) : packageFragments.size() == 1 ? packageFragments.iterator().next() : new PackageFragmentDescriptorImpl(builtInsModule, packageFqName) {

        @NotNull
        @Override
        public MemberScope getMemberScope() {
            return new ChainedMemberScope("built-in package " + packageFqName, CollectionsKt.map(packageFragments, new Function1<PackageFragmentDescriptor, MemberScope>() {

                @Override
                public MemberScope invoke(PackageFragmentDescriptor descriptor) {
                    return descriptor.getMemberScope();
                }
            }));
        }
    };
    if (packageNameToPackageFragment != null)
        packageNameToPackageFragment.put(packageFqName, result);
    return result;
}
Also used : ChainedMemberScope(org.jetbrains.kotlin.resolve.scopes.ChainedMemberScope) Function1(kotlin.jvm.functions.Function1) EmptyPackageFragmentDescriptor(org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor) EmptyPackageFragmentDescriptor(org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor) PackageFragmentDescriptorImpl(org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl) MemoizedFunctionToNotNull(org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with Function1

use of kotlin.jvm.functions.Function1 in project kotlin by JetBrains.

the class MavenPluginLogMessageCollector method throwKotlinCompilerException.

public void throwKotlinCompilerException() throws KotlinCompilationFailureException {
    throw new KotlinCompilationFailureException(CollectionsKt.map(getCollectedErrors(), new Function1<Pair<CompilerMessageLocation, String>, CompilerMessage>() {

        @Override
        public CompilerMessage invoke(Pair<CompilerMessageLocation, String> pair) {
            CompilerMessageLocation location = pair.getFirst();
            String message = pair.getSecond();
            String lineContent = location.getLineContent();
            int lineContentLength = lineContent == null ? 0 : lineContent.length();
            return new CompilerMessage(location.getPath(), CompilerMessage.Kind.ERROR, fixLocation(location.getLine()), fixLocation(location.getColumn()), fixLocation(location.getLine()), Math.min(fixLocation(location.getColumn()), lineContentLength), message);
        }
    }));
}
Also used : CompilerMessage(org.codehaus.plexus.compiler.CompilerMessage) Function1(kotlin.jvm.functions.Function1) CompilerMessageLocation(org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation) Pair(com.intellij.openapi.util.Pair)

Aggregations

Function1 (kotlin.jvm.functions.Function1)7 NotNull (org.jetbrains.annotations.NotNull)4 File (java.io.File)2 FqName (org.jetbrains.kotlin.name.FqName)2 KtFile (org.jetbrains.kotlin.psi.KtFile)2 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1 Pair (com.intellij.openapi.util.Pair)1 IOException (java.io.IOException)1 LinkedHashSet (java.util.LinkedHashSet)1 CompilerMessage (org.codehaus.plexus.compiler.CompilerMessage)1 BuiltInsPackageFragmentProviderKt.createBuiltInPackageFragmentProvider (org.jetbrains.kotlin.builtins.BuiltInsPackageFragmentProviderKt.createBuiltInPackageFragmentProvider)1 CompilerMessageLocation (org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation)1 ModuleDescriptor (org.jetbrains.kotlin.descriptors.ModuleDescriptor)1 PackageFragmentDescriptor (org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor)1 PackageFragmentProvider (org.jetbrains.kotlin.descriptors.PackageFragmentProvider)1 EmptyPackageFragmentDescriptor (org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor)1 PackageFragmentDescriptorImpl (org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl)1 SyntheticFieldDescriptor (org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor)1 KotlinRefactoringSettings (org.jetbrains.kotlin.idea.refactoring.KotlinRefactoringSettings)1