-
Notifications
You must be signed in to change notification settings - Fork 73
Refactor toDataFrame implementation in compiler plugin #782
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,13 +91,14 @@ fun <T> KotlinTypeFacade.interpret( | |
val actualArgsMap = refinedArguments.associateBy { it.name.identifier }.toSortedMap() | ||
val conflictingKeys = additionalArguments.keys intersect actualArgsMap.keys | ||
if (conflictingKeys.isNotEmpty()) { | ||
error("Conflicting keys: $conflictingKeys") | ||
interpretationFrameworkError("Conflicting keys: $conflictingKeys") | ||
} | ||
val expectedArgsMap = processor.expectedArguments | ||
.filterNot { it.name.startsWith("typeArg") } | ||
.associateBy { it.name }.toSortedMap().minus(additionalArguments.keys) | ||
|
||
if (expectedArgsMap.keys - defaultArguments != actualArgsMap.keys - defaultArguments) { | ||
val unexpectedArguments = expectedArgsMap.keys - defaultArguments != actualArgsMap.keys - defaultArguments | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. very interesting algebra of arguments (great to explain somehow this kind of logic) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is needed to simplify debug if someone writes an interpreter for
actualArg = myArgument, expectedArg = myArg123123ument, myArgument1. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But i can't say that i like the idea of adding this as a comment though. It might not be obvious in PR and i'm ok with providing a better explanations here. But in IDEA, won't you agree that code is enough? |
||
if (unexpectedArguments) { | ||
val message = buildString { | ||
appendLine("ERROR: Different set of arguments") | ||
appendLine("Implementation class: $processor") | ||
|
@@ -107,8 +108,7 @@ fun <T> KotlinTypeFacade.interpret( | |
appendLine("add arguments to an interpeter:") | ||
appendLine(diff.map { actualArgsMap[it] }) | ||
} | ||
reporter.reportInterpretationError(functionCall, message) | ||
return null | ||
interpretationFrameworkError(message) | ||
} | ||
|
||
val arguments = mutableMapOf<String, Interpreter.Success<Any?>>() | ||
|
@@ -206,7 +206,8 @@ fun <T> KotlinTypeFacade.interpret( | |
} | ||
|
||
is Interpreter.Dsl -> { | ||
{ receiver: Any -> | ||
{ receiver: Any, dslArguments: Map<String, Interpreter.Success<Any?>> -> | ||
val map = mapOf("dsl" to Interpreter.Success(receiver)) + dslArguments | ||
(it.expression as FirAnonymousFunctionExpression) | ||
.anonymousFunction.body!! | ||
.statements.filterIsInstance<FirFunctionCall>() | ||
|
@@ -215,7 +216,7 @@ fun <T> KotlinTypeFacade.interpret( | |
interpret( | ||
call, | ||
schemaProcessor, | ||
mapOf("dsl" to Interpreter.Success(receiver)), | ||
map, | ||
reporter | ||
) | ||
} | ||
|
@@ -271,6 +272,10 @@ fun <T> KotlinTypeFacade.interpret( | |
} | ||
} | ||
|
||
fun interpretationFrameworkError(message: String): Nothing = throw InterpretationFrameworkError(message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the name looks like object name, not a function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't argue, but i was inspired by "error" function from standard library |
||
|
||
class InterpretationFrameworkError(message: String) : Error(message) | ||
|
||
interface InterpretationErrorReporter { | ||
val errorReported: Boolean | ||
fun reportInterpretationError(call: FirFunctionCall, message: String) | ||
|
Uh oh!
There was an error while loading. Please reload this page.