SymbolImpl implements Symbol { public void removeUsages() { usages.clear(); childrenSymbolByName.values().forEach(symbol -> ((SymbolImpl) symbol).removeUsages()); } SymbolImpl(String name, @Nullable String fullyQualifiedName);  SymbolImpl(String name, @Nullable String fullyQualifiedName, @Nullable String annotatedTypeName); @Override String name(); @Override List<Usage> usages(); @CheckForNull @Override String fullyQualifiedName(); @Override boolean is(Kind... kinds); @Override Kind kind(); void setKind(Kind kind); InferredType inferredType(); void setInferredType(InferredType inferredType); @Override String annotatedTypeName(); void setAnnotatedTypeName(TypeAnnotation typeAnnotation); void removeUsages();  }
@Test public void removeUsages() { Symbol x = symbols("x = 42").get("x"); assertThat(x.usages()).isNotEmpty(); ((SymbolImpl) x).removeUsages(); assertThat(x.usages()).isEmpty(); FileInput fileInput = parse( "obj = {}", "obj.foo"); QualifiedExpression qualifiedExpr = PythonTestUtils.getLastDescendant(fileInput, tree -> tree.is(Tree.Kind.QUALIFIED_EXPR)); assertThat(qualifiedExpr.symbol().usages()).isNotEmpty(); Symbol obj = ((HasSymbol) qualifiedExpr.qualifier()).symbol(); ((SymbolImpl) obj).removeUsages(); assertThat(qualifiedExpr.symbol().usages()).isEmpty(); }