Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to check if a KSFunctionDeclaration is a constructor #113

Closed
IVIanuu opened this issue Oct 6, 2020 · 2 comments
Closed

Add a way to check if a KSFunctionDeclaration is a constructor #113

IVIanuu opened this issue Oct 6, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request P3 desirable
Milestone

Comments

@IVIanuu
Copy link

IVIanuu commented Oct 6, 2020

The only way i found was to check if the simpleName == <init>
There's already a FunctionKind enum which could include CONSTRUCTOR

@ting-yuan
Copy link
Collaborator

Elements in FunctionKind are disjoint. CONSTRUCTOR would overlap with MEMBER. Does an extension like KSFunctionDeclaration.isConstructor in utils make sense?

@IVIanuu
Copy link
Author

IVIanuu commented Oct 13, 2020

Yes i think the extension is a good idea.

@ting-yuan ting-yuan added enhancement New feature or request P3 desirable labels Dec 9, 2020
@ting-yuan ting-yuan added this to the 2021Q1 milestone Dec 31, 2020
yigit added a commit to yigit/ksp that referenced this issue Jan 28, 2021
This PR fixes a bunch of issues / inconsistencies in constuctor
delcarations.

* changed KSFunctionDeclarationImpl and KSFunctionDeclarationJavaImpl
to return <init> from name if it is constructor for consistency
* added KSFunctionDeclaration.isConstructor extension function for
convenience
* changed getConstructors to simply use
declaredFunctions.filter { it.kind == CONSTURCTOR } for consistency
* updated KSClassDeclarationDescriptorImpl.kt declarations to include
* added synthetic constructors for non-interface classes that do not
have a constructor (including java annotations which do get a
constructor when they are in .class files)
* fixed KSConstructorSyntheticImpl to implement returnType

Fixes: google#273
Fixes: google#114
Fixes: google#113
Test: constructorDeclarations.kt
ting-yuan pushed a commit to ting-yuan/ksp that referenced this issue Feb 18, 2022
This PR adds caching for host classpath to avoid calling ClassGraph for
every compilation. In my local tests, it saves between 50 to 80ms per
compilation on my laptop, which is not necessarily much but adds up when
you run hundreds of them.

I've also cached common jars we find from there. It does not necessarily
help with performance but rather as a cleanup to keep all of them in 1
place.

Test: existing tests
Issue: google#113
ting-yuan pushed a commit to ting-yuan/ksp that referenced this issue Feb 18, 2022
…eveloper

This PR updates KCT to use in process compilation unless the developer
explicitly provides a jdkHome that does not match the java home of the
current process.

In most cases, it won't be provided and because we have a default,
current implementation makes KCT spin off another process to compile java
sources, causing a significant compilation time penalty.
tschuchortdev/kotlin-compile-testing#113 (comment)

With this change, KCT won't create another process unless jdkHome is
set to a value that does not match the jdk home inherited from the
current process.

Issue: google#113
Test: As this is a bit difficult to test, I've added test that will
check the logs ¯\_(ツ)_/¯
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P3 desirable
Projects
None yet
Development

No branches or pull requests

3 participants