[KAPT] Fix formatting
This commit is contained in:
committed by
teamcity
parent
8b960de76a
commit
af8caae387
+10
-7
@@ -40,12 +40,12 @@ open class PartialAnalysisHandlerExtension : AnalysisHandlerExtension {
|
||||
get() = false
|
||||
|
||||
override fun doAnalysis(
|
||||
project: Project,
|
||||
module: ModuleDescriptor,
|
||||
projectContext: ProjectContext,
|
||||
files: Collection<KtFile>,
|
||||
bindingTrace: BindingTrace,
|
||||
componentProvider: ComponentProvider
|
||||
project: Project,
|
||||
module: ModuleDescriptor,
|
||||
projectContext: ProjectContext,
|
||||
files: Collection<KtFile>,
|
||||
bindingTrace: BindingTrace,
|
||||
componentProvider: ComponentProvider
|
||||
): AnalysisResult? {
|
||||
if (!analyzePartially) {
|
||||
return null
|
||||
@@ -57,7 +57,8 @@ open class PartialAnalysisHandlerExtension : AnalysisHandlerExtension {
|
||||
val topDownAnalyzer = componentProvider.get<LazyTopDownAnalyzer>()
|
||||
|
||||
val topDownAnalysisContext = TopDownAnalysisContext(
|
||||
TopDownAnalysisMode.TopLevelDeclarations, DataFlowInfo.EMPTY, declarationScopeProvider)
|
||||
TopDownAnalysisMode.TopLevelDeclarations, DataFlowInfo.EMPTY, declarationScopeProvider
|
||||
)
|
||||
|
||||
for (file in files) {
|
||||
ForceResolveUtil.forceResolveAllContents(resolveSession.getFileAnnotations(file))
|
||||
@@ -81,6 +82,7 @@ open class PartialAnalysisHandlerExtension : AnalysisHandlerExtension {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
is PropertyDescriptor -> {
|
||||
if (declaration is KtProperty) {
|
||||
/* TODO Now we analyse body with anonymous object initializers. Check if we can't avoid it
|
||||
@@ -88,6 +90,7 @@ open class PartialAnalysisHandlerExtension : AnalysisHandlerExtension {
|
||||
bodyResolver.resolveProperty(topDownAnalysisContext, declaration, descriptor)
|
||||
}
|
||||
}
|
||||
|
||||
is FunctionDescriptor -> {
|
||||
if (declaration is KtPrimaryConstructor && (analyzeDefaultParameterValues || descriptor.isAnnotationConstructor())) {
|
||||
val containingScope = descriptor.containingScope
|
||||
|
||||
@@ -115,7 +115,8 @@ class ClasspathBasedKapt3Extension(
|
||||
val zipFileIndexCacheClass = Class.forName("com.sun.tools.javac.file.ZipFileIndexCache")
|
||||
val zipFileIndexCacheInstance = zipFileIndexCacheClass.getMethod("getSharedInstance").invoke(null)
|
||||
zipFileIndexCacheClass.getMethod("clearCache").invoke(zipFileIndexCacheInstance)
|
||||
} catch (e: Throwable) {}
|
||||
} catch (e: Throwable) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,7 +317,8 @@ abstract class AbstractKapt3Extension(
|
||||
val className = (stub.defs.first { it is JCTree.JCClassDecl } as JCTree.JCClassDecl).simpleName.toString()
|
||||
|
||||
val packageName = stub.getPackageNameJava9Aware()?.toString() ?: ""
|
||||
val packageDir = if (packageName.isEmpty()) options.stubsOutputDir else File(options.stubsOutputDir, packageName.replace('.', '/'))
|
||||
val packageDir =
|
||||
if (packageName.isEmpty()) options.stubsOutputDir else File(options.stubsOutputDir, packageName.replace('.', '/'))
|
||||
packageDir.mkdirs()
|
||||
|
||||
val sourceFile = File(packageDir, "$className.java")
|
||||
|
||||
+19
-1
@@ -678,6 +678,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
if (className.isEmpty()) throw IllegalStateException("Invalid package facade class name: ${clazz.name}")
|
||||
className
|
||||
}
|
||||
|
||||
else -> if (isDefaultImpls) "DefaultImpls" else descriptor.name.asString()
|
||||
}
|
||||
}
|
||||
@@ -846,6 +847,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
annotationNode.values = values
|
||||
return annotationNode
|
||||
}
|
||||
|
||||
is ArrayValue -> {
|
||||
val children = value.value
|
||||
val result = ArrayList<Any?>(children.size)
|
||||
@@ -858,6 +860,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
is BooleanValue -> value.value
|
||||
is DoubleValue -> value.value
|
||||
is EnumValue -> {
|
||||
@@ -865,6 +868,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
val enumType = AsmUtil.asmTypeByClassId(classId)
|
||||
return arrayOf(enumType.descriptor, name.asString())
|
||||
}
|
||||
|
||||
is FloatValue -> value.value
|
||||
is StringValue -> value.value
|
||||
is NullValue -> null
|
||||
@@ -1276,6 +1280,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
val receiver = tryParseTypeExpression(expression.receiverExpression) ?: return null
|
||||
return treeMaker.Select(receiver, treeMaker.name(selector.getReferencedName()))
|
||||
}
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -1296,6 +1301,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
else
|
||||
null
|
||||
}
|
||||
|
||||
is KtCollectionLiteralExpression -> singleArg.getInnerExpressions()
|
||||
is KtDotQualifiedExpression -> listOf(singleArg)
|
||||
null -> args
|
||||
@@ -1372,13 +1378,19 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
is Float ->
|
||||
when {
|
||||
value.isFinite() -> treeMaker.Literal(value)
|
||||
else -> treeMaker.Binary(Tag.DIV, treeMaker.Literal(specialFpValueNumerator(value.toDouble()).toFloat()), treeMaker.Literal(0.0F))
|
||||
else -> treeMaker.Binary(
|
||||
Tag.DIV,
|
||||
treeMaker.Literal(specialFpValueNumerator(value.toDouble()).toFloat()),
|
||||
treeMaker.Literal(0.0F)
|
||||
)
|
||||
}
|
||||
|
||||
is Double ->
|
||||
when {
|
||||
value.isFinite() -> treeMaker.Literal(value)
|
||||
else -> treeMaker.Binary(Tag.DIV, treeMaker.Literal(specialFpValueNumerator(value)), treeMaker.Literal(0.0))
|
||||
}
|
||||
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
@@ -1410,11 +1422,13 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
// But enums can't extend other enums, so this should be enough.
|
||||
desc is EnumValue && desc.enumEntryName.asString() == valueName
|
||||
}
|
||||
|
||||
is List<*> -> {
|
||||
desc is ArrayValue
|
||||
&& asm.size == desc.value.size
|
||||
&& asm.zip(desc.value).all { (eAsm, eDesc) -> checkIfAnnotationValueMatches(eAsm, eDesc) }
|
||||
}
|
||||
|
||||
is Type -> desc is KClassValue && typeMapper.mapType(desc.getArgumentType(kaptContext.generationState.module)) == asm
|
||||
is AnnotationNode -> {
|
||||
val annotationDescriptor = (desc as? AnnotationValue)?.value ?: return false
|
||||
@@ -1429,6 +1443,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
@@ -1459,12 +1474,14 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
|
||||
treeMaker.Select(treeMaker.Type(enumType), treeMaker.name(valueName))
|
||||
}
|
||||
|
||||
is List<*> -> treeMaker.NewArray(null, JavacList.nil(), mapJList(value, ::convertDeeper))
|
||||
|
||||
is Type -> {
|
||||
checkIfValidTypeName(containingClass, value)
|
||||
treeMaker.Select(treeMaker.Type(value), treeMaker.name("class"))
|
||||
}
|
||||
|
||||
is AnnotationNode -> convertAnnotation(containingClass, value, packageFqName = null, filtered = false)!!
|
||||
else -> throw IllegalArgumentException("Illegal literal expression value: $value (${value::class.java.canonicalName})")
|
||||
}
|
||||
@@ -1504,6 +1521,7 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
if (replaced != it) replaced else null
|
||||
}?.let(::convertKotlinType) ?: fieldType
|
||||
}
|
||||
|
||||
else -> fieldType
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -99,11 +99,13 @@ class ErrorTypeCorrector(
|
||||
val actualType = typeAlias?.getTypeReference() ?: return convert(target.expandedType)
|
||||
return convert(actualType, typeAlias.getSubstitutions(type))
|
||||
}
|
||||
|
||||
is ClassConstructorDescriptor -> {
|
||||
val asmType = KaptTypeMapper.mapType(target.constructedClass.defaultType, TypeMappingMode.GENERIC_ARGUMENT)
|
||||
|
||||
baseExpression = converter.treeMaker.Type(asmType)
|
||||
}
|
||||
|
||||
is ClassDescriptor -> {
|
||||
// We only get here if some type were an error type. In other words, 'type' is either an error type or its argument,
|
||||
// so it's impossible it to be unboxed primitive.
|
||||
@@ -111,6 +113,7 @@ class ErrorTypeCorrector(
|
||||
|
||||
baseExpression = converter.treeMaker.Type(asmType)
|
||||
}
|
||||
|
||||
else -> {
|
||||
val referencedName = type.referencedName ?: return defaultType
|
||||
val qualifier = type.qualifier
|
||||
@@ -130,6 +133,7 @@ class ErrorTypeCorrector(
|
||||
if (qualifierType === defaultType) return defaultType // Do not allow to use 'defaultType' as a qualifier
|
||||
treeMaker.Select(qualifierType, treeMaker.name(referencedName))
|
||||
}
|
||||
|
||||
else -> treeMaker.SimpleName(referencedName)
|
||||
}
|
||||
}
|
||||
@@ -186,8 +190,10 @@ class ErrorTypeCorrector(
|
||||
projectionKind === KtProjectionKind.STAR -> treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.UNBOUND), null)
|
||||
projectionKind === KtProjectionKind.IN || variance === Variance.IN_VARIANCE ->
|
||||
treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.SUPER), argumentExpression)
|
||||
|
||||
projectionKind === KtProjectionKind.OUT || variance === Variance.OUT_VARIANCE ->
|
||||
treeMaker.Wildcard(treeMaker.TypeBoundKind(BoundKind.EXTENDS), argumentExpression)
|
||||
|
||||
else -> argumentExpression // invariant
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -215,6 +215,7 @@ class SignatureParser(private val treeMaker: KaptTreeMaker) {
|
||||
|
||||
expression
|
||||
}
|
||||
|
||||
TypeVariable -> treeMaker.SimpleName(node.name!!)
|
||||
ArrayType -> treeMaker.TypeArray(parseType(node.children.single()))
|
||||
PrimitiveType -> {
|
||||
@@ -232,6 +233,7 @@ class SignatureParser(private val treeMaker: KaptTreeMaker) {
|
||||
}
|
||||
treeMaker.TypeIdent(typeTag)
|
||||
}
|
||||
|
||||
else -> error("Unsupported type: $node")
|
||||
}
|
||||
}
|
||||
@@ -417,4 +419,4 @@ private class SignatureParserVisitor : SignatureVisitor(Opcodes.API_VERSION) {
|
||||
}
|
||||
stack.pop()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class MessageCollectorBackedKaptLogger(
|
||||
messageCollector.report(INFO, PREFIX + message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun warn(message: String) {
|
||||
messageCollector.report(WARNING, PREFIX + message)
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ fun replaceAnonymousTypeWithSuperType(type: KotlinType): KotlinType {
|
||||
type.builtIns.anyType
|
||||
}
|
||||
}
|
||||
|
||||
else -> type
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user