-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Resolver.asMemberOf for Properties and Functions (#110)
* Initial implementation and test setup for AsMemberOf This is just a copy of the implementation in Room. Still need more tests, support for other declarations and possible optimizations * use compiler utils for substitution * AsMemberOf for function, initial setup * Use new type substitutor Old type substitutor seems to have problems with * projection where as new one seems to work (failing test case: receiveArgs method). I've replaced the code to use the new substitutor (even with fields) and also implemented a fallback implementation for KSFunctionType that derives from a KSFunctionDeclaration. * add more documentation and support for java * code cleanup pre-review * update java to ksp reference docs * Throw errors for illegal arguments, rename KSFunctionType to KSFunction * remove unused imports from as member of test * cache as member of calls * implement equals in KSFunction
- Loading branch information
Showing
10 changed files
with
735 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
api/src/main/kotlin/com/google/devtools/ksp/symbol/KSFunction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.devtools.ksp.symbol | ||
import com.google.devtools.ksp.processing.Resolver | ||
/** | ||
* Holds the information for a [KSFunctionDeclaration] where type arguments are resolved as member | ||
* of a specific [KSType]. | ||
* | ||
* @see Resolver.asMemberOf | ||
*/ | ||
interface KSFunction { | ||
/** | ||
* The return type of the function. Note that this might be `null` if an error happened when | ||
* the type is resolved. | ||
* | ||
* @see KSFunctionDeclaration.returnType | ||
*/ | ||
val returnType: KSType? | ||
|
||
/** | ||
* The types of the value parameters of the function. Note that this list might have `null` | ||
* values in it if the type of a parameter could not be resolved. | ||
* | ||
* @see KSFunctionDeclaration.parameters | ||
*/ | ||
val parameterTypes: List<KSType?> | ||
|
||
/** | ||
* The type parameters of the function. | ||
* | ||
* @see KSFunctionDeclaration.typeParameters | ||
*/ | ||
val typeParameters: List<KSTypeParameter> | ||
|
||
/** | ||
* The receiver type of the function. | ||
* | ||
* @see KSFunctionDeclaration.extensionReceiver | ||
*/ | ||
val extensionReceiverType: KSType? | ||
|
||
/** | ||
* True if the compiler couldn't resolve the function. | ||
*/ | ||
val isError: Boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.