Keep order of parsed annotations
This commit is contained in:
+5
-6
@@ -19,15 +19,14 @@ package org.jetbrains.kotlin.annotation
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.Reader
|
import java.io.Reader
|
||||||
import java.io.StringReader
|
import java.io.StringReader
|
||||||
import java.util.*
|
|
||||||
import org.jetbrains.kotlin.annotation.CompactNotationType as Notation
|
import org.jetbrains.kotlin.annotation.CompactNotationType as Notation
|
||||||
|
|
||||||
open class KotlinAnnotationProvider(annotationsReader: Reader) {
|
open class KotlinAnnotationProvider(annotationsReader: Reader) {
|
||||||
constructor(annotationsFile: File) : this(annotationsFile.reader().buffered())
|
constructor(annotationsFile: File) : this(annotationsFile.reader().buffered())
|
||||||
constructor() : this(StringReader(""))
|
constructor() : this(StringReader(""))
|
||||||
|
|
||||||
protected val kotlinClassesInternal = hashSetOf<String>()
|
protected val kotlinClassesInternal = linkedSetOf<String>()
|
||||||
protected val annotatedKotlinElementsInternal = hashMapOf<String, MutableSet<AnnotatedElement>>()
|
protected val annotatedKotlinElementsInternal = linkedMapOf<String, MutableSet<AnnotatedElement>>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
readAnnotations(annotationsReader)
|
readAnnotations(annotationsReader)
|
||||||
@@ -49,8 +48,8 @@ open class KotlinAnnotationProvider(annotationsReader: Reader) {
|
|||||||
cache.put(id, name)
|
cache.put(id, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
val shortenedAnnotationCache = hashMapOf<String, String>()
|
val shortenedAnnotationCache = linkedMapOf<String, String>()
|
||||||
val shortenedPackageNameCache = hashMapOf<String, String>()
|
val shortenedPackageNameCache = linkedMapOf<String, String>()
|
||||||
|
|
||||||
fun expandAnnotation(s: String) = shortenedAnnotationCache.getOrElse(s) { s }
|
fun expandAnnotation(s: String) = shortenedAnnotationCache.getOrElse(s) { s }
|
||||||
|
|
||||||
@@ -82,7 +81,7 @@ open class KotlinAnnotationProvider(annotationsReader: Reader) {
|
|||||||
val classFqName = expandClassName(lineParts[2]).replace('$', '.')
|
val classFqName = expandClassName(lineParts[2]).replace('$', '.')
|
||||||
val elementName = if (lineParts.size == 4) lineParts[3] else null
|
val elementName = if (lineParts.size == 4) lineParts[3] else null
|
||||||
|
|
||||||
val set = annotatedKotlinElementsInternal.getOrPut(annotationName) { HashSet() }
|
val set = annotatedKotlinElementsInternal.getOrPut(annotationName) { linkedSetOf() }
|
||||||
set.add(when (type) {
|
set.add(when (type) {
|
||||||
Notation.ANNOTATED_CLASS -> AnnotatedElement.Class(classFqName)
|
Notation.ANNOTATED_CLASS -> AnnotatedElement.Class(classFqName)
|
||||||
Notation.ANNOTATED_FIELD -> {
|
Notation.ANNOTATED_FIELD -> {
|
||||||
|
|||||||
+5
-5
@@ -1,15 +1,15 @@
|
|||||||
a annotations.Ann 0
|
a annotations.Ann 0
|
||||||
p foo 0
|
p foo 0
|
||||||
|
c 0 0/A
|
||||||
|
m 0 0/A valA$annotations
|
||||||
m 0 0/A funA
|
m 0 0/A funA
|
||||||
p bar 1
|
p bar 1
|
||||||
c 0 1/B
|
c 0 1/B
|
||||||
c 0 0/A
|
|
||||||
m 0 1/B funB
|
|
||||||
m 0 0/A valA$annotations
|
|
||||||
m 0 1/B valB$annotations
|
m 0 1/B valB$annotations
|
||||||
|
m 0 1/B funB
|
||||||
a java.lang.annotation.Retention 1
|
a java.lang.annotation.Retention 1
|
||||||
p annotations 2
|
p annotations 2
|
||||||
c 1 2/Ann
|
c 1 2/Ann
|
||||||
d 0/A
|
d 0/A
|
||||||
d 1/B
|
d 2/Ann
|
||||||
d 2/Ann
|
d 1/B
|
||||||
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
a annotations.Ann 0
|
a annotations.Ann 0
|
||||||
p bar 0
|
p bar 0
|
||||||
c 0 0/B
|
c 0 0/B
|
||||||
m 0 0/B funB
|
|
||||||
m 0 0/B valB$annotations
|
m 0 0/B valB$annotations
|
||||||
|
m 0 0/B funB
|
||||||
a java.lang.annotation.Retention 1
|
a java.lang.annotation.Retention 1
|
||||||
p annotations 1
|
p annotations 1
|
||||||
c 1 1/Ann
|
c 1 1/Ann
|
||||||
|
|||||||
Reference in New Issue
Block a user