private void markRoots(ProtoMember protoMember) { if (identifierSet.includes(protoMember)) { marks.root(protoMember); queue.add(protoMember); } }
/** Returns true if {@code type} is a root. */ public boolean includes(ProtoType type) { return includes(type.toString()); }
/** Returns true if {@code protoMember} is a root. */ public boolean includes(ProtoMember protoMember) { return includes(protoMember.toString()); }
private void markRoots(Service service) { ProtoType protoType = service.type(); if (identifierSet.includes(protoType)) { marks.root(protoType); queue.add(protoType); } else { for (Rpc rpc : service.rpcs()) { markRoots(ProtoMember.get(protoType, rpc.name())); } } }
private Policy policy(IdentifierSet set, String identifier) { if (identifier.contains("#")) { ProtoMember protoMember = ProtoMember.get(identifier); if (set.includes(protoMember)) return Policy.INCLUDED; if (set.excludes(protoMember)) return Policy.EXCLUDED; return Policy.UNSPECIFIED; } else { ProtoType protoType = ProtoType.get(identifier); if (set.includes(protoType)) return Policy.INCLUDED; if (set.excludes(protoType)) return Policy.EXCLUDED; return Policy.UNSPECIFIED; } }
private void markRoots(Type type) { ProtoType protoType = type.type(); if (identifierSet.includes(protoType)) { marks.root(protoType); queue.add(protoType); } else { if (type instanceof MessageType) { for (Field field : ((MessageType) type).fieldsAndOneOfFields()) { markRoots(ProtoMember.get(protoType, field.name())); } } else if (type instanceof EnumType) { for (EnumConstant enumConstant : ((EnumType) type).constants()) { markRoots(ProtoMember.get(protoType, enumConstant.name())); } } else { throw new AssertionError(); } } for (Type nested : type.nestedTypes()) { markRoots(nested); } }
@Test public void trackingUnusedIncludes() throws Exception { IdentifierSet set = new IdentifierSet.Builder() .include("a.*") .include("b.IncludedType") .include("c.IncludedMember#member") .build(); assertThat(set.unusedIncludes()).containsExactly( "a.*", "b.IncludedType", "c.IncludedMember#member"); set.includes(ProtoType.get("a.*")); assertThat(set.unusedIncludes()).containsExactly( "b.IncludedType", "c.IncludedMember#member"); set.includes(ProtoType.get("b.IncludedType")); assertThat(set.unusedIncludes()).containsExactly( "c.IncludedMember#member"); set.includes(ProtoMember.get("c.IncludedMember#member")); assertThat(set.unusedIncludes()).isEmpty(); }
@Test public void trackingUnusedExcludes() throws Exception { IdentifierSet set = new IdentifierSet.Builder() .exclude("a.*") .exclude("b.ExcludedType") .exclude("c.ExcludedMember#member") .build(); assertThat(set.unusedExcludes()).containsExactly( "a.*", "b.ExcludedType", "c.ExcludedMember#member"); set.includes(ProtoType.get("a.*")); assertThat(set.unusedExcludes()).containsExactly( "b.ExcludedType", "c.ExcludedMember#member"); set.includes(ProtoType.get("b.ExcludedType")); assertThat(set.unusedExcludes()).containsExactly( "c.ExcludedMember#member"); set.includes(ProtoMember.get("c.ExcludedMember#member")); assertThat(set.unusedExcludes()).isEmpty(); }
@Test public void trackingUnusedExcludesPrecedence() throws Exception { IdentifierSet set = new IdentifierSet.Builder() .exclude("a.*") .exclude("a.IncludedType") .build(); set.includes(ProtoMember.get("a.IncludedType#member")); assertThat(set.unusedExcludes()).containsExactly("a.IncludedType"); }
@Test public void trackingUnusedPrecedence() throws Exception { IdentifierSet set = new IdentifierSet.Builder() .include("a.*") .exclude("a.*") .build(); set.includes(ProtoType.get("a.Message")); assertThat(set.unusedExcludes()).isEmpty(); assertThat(set.unusedIncludes()).containsExactly("a.*"); }
@Test public void trackingUnusedIncludesPrecedence() throws Exception { IdentifierSet set = new IdentifierSet.Builder() .include("a.*") .include("a.IncludedType") .build(); set.includes(ProtoMember.get("a.IncludedType#member")); assertThat(set.unusedIncludes()).containsExactly("a.IncludedType"); }
private void markRoots(ProtoMember protoMember) { if (identifierSet.includes(protoMember)) { marks.root(protoMember); queue.add(protoMember); } }
private void markRoots(ProtoMember protoMember) { if (identifierSet.includes(protoMember)) { marks.root(protoMember); queue.add(protoMember); } }
/** Returns true if {@code protoMember} is a root. */ public boolean includes(ProtoMember protoMember) { return includes(protoMember.toString()); }
/** Returns true if {@code protoMember} is a root. */ public boolean includes(ProtoMember protoMember) { return includes(protoMember.toString()); }
/** Returns true if {@code type} is a root. */ public boolean includes(ProtoType type) { return includes(type.toString()); }
/** Returns true if {@code type} is a root. */ public boolean includes(ProtoType type) { return includes(type.toString()); }
private void markRoots(Service service) { ProtoType protoType = service.type(); if (identifierSet.includes(protoType)) { marks.root(protoType); queue.add(protoType); } else { for (Rpc rpc : service.rpcs()) { markRoots(ProtoMember.get(protoType, rpc.name())); } } }
private void markRoots(Service service) { ProtoType protoType = service.type(); if (identifierSet.includes(protoType)) { marks.root(protoType); queue.add(protoType); } else { for (Rpc rpc : service.rpcs()) { markRoots(ProtoMember.get(protoType, rpc.name())); } } }
private void markRoots(Type type) { ProtoType protoType = type.type(); if (identifierSet.includes(protoType)) { marks.root(protoType); queue.add(protoType); } else { if (type instanceof MessageType) { for (Field field : ((MessageType) type).fieldsAndOneOfFields()) { markRoots(ProtoMember.get(protoType, field.name())); } } else if (type instanceof EnumType) { for (EnumConstant enumConstant : ((EnumType) type).constants()) { markRoots(ProtoMember.get(protoType, enumConstant.name())); } } else { throw new AssertionError(); } } for (Type nested : type.nestedTypes()) { markRoots(nested); } }