mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
IJPL-339 support duplicated package annotations in ApiCheckTest
GitOrigin-RevId: 020a88e1b5568b1be10dd2738c6a56dde229868d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
43c77df49f
commit
fc5ef6c5b5
@@ -53,10 +53,13 @@ class ApiIndex private constructor(
|
||||
return classes[className]
|
||||
}
|
||||
|
||||
internal fun discoverPackages(packages: Map<String, ApiAnnotations>): ApiIndex {
|
||||
internal fun discoverPackages(packages: Map<String, ApiAnnotations>, root: Path): ApiIndex {
|
||||
val builder = this.packages.builder()
|
||||
for ((packageName, packageAnnotations) in packages) {
|
||||
check(this.packages[packageName] == null)
|
||||
val existingAnnotations = this.packages[packageName]
|
||||
if (existingAnnotations != null && existingAnnotations != packageAnnotations) {
|
||||
error("$packageName has different annotations in different modules. The current root = $root")
|
||||
}
|
||||
builder[packageName] = packageAnnotations
|
||||
}
|
||||
return ApiIndex(
|
||||
@@ -65,11 +68,17 @@ class ApiIndex private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
internal fun discoverClass(signature: ClassBinarySignature): ApiIndex {
|
||||
internal fun discoverClass(signature: ClassBinarySignature, root: Path): ApiIndex {
|
||||
val className = signature.name
|
||||
check(classes[className] == null) {
|
||||
"Class already discovered $className"
|
||||
if (className.endsWith("/package-info")) {
|
||||
// ignore package-info.java
|
||||
return this
|
||||
}
|
||||
|
||||
check(classes[className] == null) {
|
||||
"$className already declared. The current root = $root"
|
||||
}
|
||||
|
||||
return ApiIndex(
|
||||
packages,
|
||||
classes = classes.put(className, signature),
|
||||
@@ -104,7 +113,7 @@ fun api(index: ApiIndex, root: Path): API {
|
||||
val classFilePaths: Sequence<Path> = classFilePaths(root)
|
||||
|
||||
val packages: Map<String, ApiAnnotations> = classFilePaths.packages()
|
||||
index = index.discoverPackages(packages)
|
||||
index = index.discoverPackages(packages, root)
|
||||
|
||||
val signatures: List<ClassBinarySignature> = classFilePaths
|
||||
.map { it.inputStream() }
|
||||
@@ -118,7 +127,7 @@ fun api(index: ApiIndex, root: Path): API {
|
||||
* because the next [handleAnnotationsAndVisibility] call relies on it
|
||||
* to resolve the outer class name.
|
||||
*/
|
||||
index = index.discoverClass(it)
|
||||
index = index.discoverClass(it, root)
|
||||
}
|
||||
}
|
||||
return API(index, signatures)
|
||||
|
||||
Reference in New Issue
Block a user