Skip to content
This repository was archived by the owner on Dec 20, 2022. It is now read-only.

Commit 36be0c6

Browse files
authored
Merge pull request #1 from feilfeilundfeil/master
Fix some problems
2 parents b732322 + 48378ad commit 36be0c6

File tree

4 files changed

+41
-26
lines changed

4 files changed

+41
-26
lines changed

mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/common/ClassParser.kt

+17-12
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,31 @@ class ClassParser() {
3939
}
4040

4141
private fun parseClassConstructor(descriptor: ClassDescriptor, processor: AbstractProcessor, round: RoundEnvironment, annotation: String) {
42-
descriptor.constructors.forEach {
43-
if (checkit(it, annotation)) {
44-
val annotatedConstructors = descriptor.constructors.filter { constructor -> constructor.hasAnnotation(annotation) }
42+
try {
43+
descriptor.constructors.forEach {
44+
if (checkit(it, annotation)) {
45+
val annotatedConstructors =
46+
descriptor.constructors.filter { constructor -> constructor.hasAnnotation(annotation) }
4547

46-
annotatedConstructors.forEach { annotatedConstructor ->
48+
annotatedConstructors.forEach { annotatedConstructor ->
4749

48-
val annotationDesc = annotatedConstructor.annotations.findAnnotation(annotation)
50+
val annotationDesc = annotatedConstructor.annotations.findAnnotation(annotation)
4951

50-
round.module = descriptor.module
51-
round.elements.add(
52+
round.module = descriptor.module
53+
round.elements.add(
5254
Element.ClassConstructorElement(
53-
classConstructorDescriptor = annotatedConstructor,
54-
annotation = annotationDesc
55+
classConstructorDescriptor = annotatedConstructor,
56+
annotation = annotationDesc
5557

5658
)
57-
)
58-
processor.process(round)
59-
}
59+
)
60+
processor.process(round)
61+
}
6062

63+
}
6164
}
65+
} catch (e: Exception) {
66+
println(e)
6267
}
6368

6469
}

mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/common/FunctionDescriptorExt.kt

+18-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
66
import org.jetbrains.kotlin.descriptors.SourceElement
77
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
88
import org.jetbrains.kotlin.resolve.source.getPsi
9+
import de.jensklingenberg.mpapt.model.Package
910

1011

1112
/**
@@ -15,15 +16,23 @@ fun FunctionDescriptor.getFunctionParameters(): List<FunctionParameter> {
1516
//@de.ktorfit.POST public abstract suspend fun postPictures(helloWorld: sample.model.HelloWorld): kotlin.Unit defined in sample.data.Api[SimpleFunctionDescriptorImpl@470930f5]
1617

1718
return if (valueParameters.isNotEmpty()) {
18-
val list = this.toString().replace(" ", "").substringAfter("(").substringBefore(")").split(",")
19-
.map {
20-
val split = it.split(":")
21-
FunctionParameter(
22-
split.first(),
23-
de.jensklingenberg.mpapt.model.Package(split[1].substringAfterLast("."), split[1].substringBeforeLast("."))
24-
)
25-
}
26-
list
19+
this.valueParameters.map { parameter ->
20+
// normal:
21+
//value-parameter id: kotlin.Int defined in de.jensklingenberg.mpapt.CommonAnnotated.firstFunction2[ValueParameterDescriptorImpl@725a91a6]
22+
// Typedefs:
23+
//value-parameter id: de.jensklingenberg.mpapt.Datum /* = kotlin.ranges.CharProgression */ defined in de.jensklingenberg.mpapt.CommonAnnotated.firstFunction2[ValueParameterDescriptorImpl@692444bb]
24+
val fullPackage = parameter.toString().substringAfter(": ")
25+
.substringBefore(" defined")
26+
.substringBefore(" /* =")
27+
FunctionParameter(
28+
parameter.name.asString(),
29+
parameter.type.toString().endsWith("?"),
30+
Package(
31+
fullPackage.split(".").last().replace("?", ""),
32+
fullPackage.split(".").dropLast(1).joinToString(".")
33+
)
34+
)
35+
}.toList()
2736
} else {
2837
emptyList()
2938
}

mpapt-runtime/src/main/java/de/jensklingenberg/mpapt/extension/SyntheticResolveExtensionImpl.kt

-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ internal class SyntheticResolveExtensionImpl(val abstractProcessor: AbstractProc
5656
}
5757

5858
override fun generateSyntheticProperties(thisDescriptor: ClassDescriptor, name: Name, bindingContext: BindingContext, fromSupertypes: ArrayList<PropertyDescriptor>, result: MutableSet<PropertyDescriptor>) {
59-
val isLastClass = abstractProcessor.configuration.kotlinSourceRoots.last().path == (thisDescriptor.source as KotlinSourceElement).psi.containingKtFile.virtualFilePath
60-
val isLastProperty = ((thisDescriptor.source as KotlinSourceElement).psi as KtClass).getProperties().last().equals(name)
61-
6259

6360
result.forEach {
6461
ClassParser.parseProperty(it, abstractProcessor, RoundEnvironment())
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package de.jensklingenberg.mpapt.model
22

3-
data class FunctionParameter(val parameterName: String, val packagee: Package)
3+
data class FunctionParameter(
4+
val parameterName: String,
5+
val nullable: Boolean,
6+
val packagee: Package
7+
)
48

5-
data class Package(val classname: String, val packagename: String)
9+
data class Package(val classname: String, val packagename: String)

0 commit comments

Comments
 (0)