DescriptorSerializer: add skip argument to packageProto method
This commit is contained in:
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.serialization;
|
package org.jetbrains.kotlin.serialization;
|
||||||
|
|
||||||
|
import kotlin.Function1;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotated;
|
||||||
@@ -379,6 +381,11 @@ public class DescriptorSerializer {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ProtoBuf.Package.Builder packageProto(@NotNull Collection<PackageFragmentDescriptor> fragments) {
|
public ProtoBuf.Package.Builder packageProto(@NotNull Collection<PackageFragmentDescriptor> fragments) {
|
||||||
|
return packageProto(fragments, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public ProtoBuf.Package.Builder packageProto(@NotNull Collection<PackageFragmentDescriptor> fragments, @Nullable Function1<DeclarationDescriptor, Boolean> skip) {
|
||||||
ProtoBuf.Package.Builder builder = ProtoBuf.Package.newBuilder();
|
ProtoBuf.Package.Builder builder = ProtoBuf.Package.newBuilder();
|
||||||
|
|
||||||
Collection<DeclarationDescriptor> members = new ArrayList<DeclarationDescriptor>();
|
Collection<DeclarationDescriptor> members = new ArrayList<DeclarationDescriptor>();
|
||||||
@@ -387,6 +394,8 @@ public class DescriptorSerializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (DeclarationDescriptor declaration : sort(members)) {
|
for (DeclarationDescriptor declaration : sort(members)) {
|
||||||
|
if (skip != null && skip.invoke(declaration)) continue;
|
||||||
|
|
||||||
if (declaration instanceof PropertyDescriptor || declaration instanceof FunctionDescriptor) {
|
if (declaration instanceof PropertyDescriptor || declaration instanceof FunctionDescriptor) {
|
||||||
builder.addMember(callableProto((CallableMemberDescriptor) declaration));
|
builder.addMember(callableProto((CallableMemberDescriptor) declaration));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user