Add .internal modules to IDEInfo.deps of top-level java_sdk_library

libraries and apps can depend on the top-level java_sdk_library like
such
```
java_library {
  name: "mylib",
  libs: ["somesdklib"],
}
```
and soong will automatically resolve mylib's classpath to either the
stub or impl library based on the api container these libraries are in.

Since the top-level java_sdk_library has no compilation actions, code
completion of `mylib` is not feasible today via
`module_bp_java_deps.json`. This CL adds support for this code
completion by registering the .impl (or public stubs) as a transtive
dependency of `mylib`.

The implication of this change is that implementation symbols of the sdk
library will be surfaced during code-completion of mylib, even when
mylib is in a different container. Long term, this should go away when
all the library dependencies are made explicit in Android.bp files.

Test: go build ./java
Test: verified that symbols of android.car.builtin (a java_sdk_library)
can be resolved with the repro instructions in b/356572093#comment5

Bug: 356572093
Bug: 358613520
Change-Id: Ia3887bae34bbd25b8c6346f43602835da32af84a
diff --git a/java/sdk_library.go b/java/sdk_library.go
index a8cc1b8..4f95a99 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -3602,3 +3602,19 @@
 		propertySet.AddProperty("doctag_files", dests)
 	}
 }
+
+// TODO(b/358613520): This can be removed when modules are no longer allowed to depend on the top-level library.
+func (s *SdkLibrary) IDEInfo(dpInfo *android.IdeInfo) {
+	s.Library.IDEInfo(dpInfo)
+	if s.implLibraryModule != nil {
+		dpInfo.Deps = append(dpInfo.Deps, s.implLibraryModule.Name())
+	} else {
+		// This java_sdk_library does not have an implementation (it sets `api_only` to true).
+		// Examples of this are `art.module.intra.core.api` (IntraCore api surface).
+		// Return the "public" stubs for these.
+		stubPaths := s.findClosestScopePath(apiScopePublic)
+		if len(stubPaths.stubsHeaderPath) > 0 {
+			dpInfo.Jars = append(dpInfo.Jars, stubPaths.stubsHeaderPath[0].String())
+		}
+	}
+}