@Test public void get_method() { ImmutableList<MethodSymbolData> methods = ImmutableList.of( method("methodA"), method("methodB") ); ClassSymbolIndex symbols = createSymbols( data("a", methods), data("b") ); ClassSymbol a = symbols.get(fqn("a")); assertThat(a.declaredMethods()).hasSize(2); assertThat(a.getDeclaredMethod("methodA").isUnknownSymbol()).isFalse(); assertThat(a.getDeclaredMethod("random").isUnknownSymbol()).isTrue(); assertThat(a.is(ClassSymbol.Kind.NORMAL)).isTrue(); ClassSymbol b = symbols.get(fqn("b")); assertThat(b.declaredMethods()).isEmpty(); assertThat(b.getDeclaredMethod("methodA")).isInstanceOf(UnknownMethodSymbol.class); assertThat(a.is(ClassSymbol.Kind.INTERFACE)).isFalse(); ClassSymbol unknown = symbols.get(fqn("unknown")); assertThat(unknown.declaredMethods()).isEmpty(); assertThat(unknown.getDeclaredMethod("foo")).isInstanceOf(UnknownMethodSymbol.class); }
public ClassSymbol get(QualifiedName qualifiedName) { return symbolsByQualifiedName.computeIfAbsent(qualifiedName, qn -> projectSymbolData.classSymbolData(qn) .<ClassSymbol>map(ClassSymbolImpl::new) .orElse(new UnknownClassSymbol(qualifiedName))); }
ClassSymbolIndex { public ClassSymbol get(QualifiedName qualifiedName) { return symbolsByQualifiedName.computeIfAbsent(qualifiedName, qn -> projectSymbolData.classSymbolData(qn) .<ClassSymbol>map(ClassSymbolImpl::new) .orElse(new UnknownClassSymbol(qualifiedName))); } }
ClassSymbolIndex { public ClassSymbol get(QualifiedName qualifiedName) { return symbolsByQualifiedName.computeIfAbsent(qualifiedName, qn -> projectSymbolData.classSymbolData(qn) .<ClassSymbol>map(ClassSymbolImpl::new) .orElse(new UnknownClassSymbol(qualifiedName))); } private  ClassSymbolIndex(ProjectSymbolData projectSymbolData); }
ClassSymbolIndex { public ClassSymbol get(QualifiedName qualifiedName) { return symbolsByQualifiedName.computeIfAbsent(qualifiedName, qn -> projectSymbolData.classSymbolData(qn) .<ClassSymbol>map(ClassSymbolImpl::new) .orElse(new UnknownClassSymbol(qualifiedName))); } private  ClassSymbolIndex(ProjectSymbolData projectSymbolData); static ClassSymbolIndex create(Set<ClassSymbolData> fileDeclarations, ProjectSymbolData projectSymbolData); ClassSymbol get(QualifiedName qualifiedName); ClassSymbol get(ClassSymbolData classSymbolData); }
ClassSymbolIndex { public ClassSymbol get(QualifiedName qualifiedName) { return symbolsByQualifiedName.computeIfAbsent(qualifiedName, qn -> projectSymbolData.classSymbolData(qn) .<ClassSymbol>map(ClassSymbolImpl::new) .orElse(new UnknownClassSymbol(qualifiedName))); } private  ClassSymbolIndex(ProjectSymbolData projectSymbolData); static ClassSymbolIndex create(Set<ClassSymbolData> fileDeclarations, ProjectSymbolData projectSymbolData); ClassSymbol get(QualifiedName qualifiedName); ClassSymbol get(ClassSymbolData classSymbolData);  }