chore: general plugin cleanups#1
Merged
Merged
Conversation
chore: clean up plugin code a bit chore: add sample project for testing chore: add README for outer and sample projects Signed-off-by: Sam Gammon <sam@elide.dev>
Comment on lines
+7
to
+8
| <properties> | ||
| <maven.compiler.executable>/home/sam/bin/elide</maven.compiler.executable> |
Member
Author
There was a problem hiding this comment.
note to self: fix with resolution
Comment on lines
-32
to
+51
| val args = buildElideArgs(config, sources) | ||
| val args = buildList<String> { | ||
| addAll(buildElideArgs(config, sources)) | ||
| config.maxmem?.ifEmpty { null }?.let { add("-J-Xmx$this") } | ||
| config.meminitial?.ifEmpty { null }?.let { add("-J-Xms$this") } | ||
|
|
||
| config.customCompilerArgumentsAsMap.entries | ||
| .filter { it.value != null && it.key.startsWith("-J") } | ||
| .ifEmpty { null } | ||
| ?.forEach { add("${it.key}=${it.value}") } | ||
| } | ||
|
|
||
| val cli = Commandline() | ||
| cli.setWorkingDirectory(config.workingDirectory.absolutePath) | ||
| cli.executable = executable | ||
| cli.addArguments(args) | ||
| config.maxmem?.apply { if(isNotEmpty()) "-J-Xmx$this" } | ||
| config.meminitial?.apply { if(isNotEmpty()) "-J-Xms$this" } | ||
| config.getCustomCompilerArgumentsAsMap().keys | ||
| config.customCompilerArgumentsAsMap.keys | ||
| .filter { it != null && it.startsWith("-J") } | ||
| .apply { if(isNotEmpty()) cli.addArguments(toTypedArray()) } | ||
|
|
||
| cli.addArguments(args.toTypedArray()) |
Member
Author
There was a problem hiding this comment.
(1) cleaner assembly of these args with buildList
(2) return lists, actualize to arrays only when args are finalized
(3) use x?.ifEmpty { null }?.let { ... } instead of x?.apply { if (isNotEmpty()) ... }
Comment on lines
+75
to
+76
| private fun buildElideArgs(config: CompilerConfiguration, sources: Array<String>): MutableList<String> { | ||
| val args: MutableList<String> = LinkedList<String>() |
Member
Author
There was a problem hiding this comment.
LinkedList is more efficient for assembly of arrays from mutable lists
Comment on lines
-112
to
+124
| if(config.isVerbose) args.add("-verbose") | ||
| if(config.isParameters) args.add("-parameters") | ||
| if(config.isEnablePreview) args.add("--enable-preview") | ||
| if (config.isVerbose) args.add("-verbose") | ||
| if (config.isParameters) args.add("-parameters") | ||
| if (config.isEnablePreview) args.add("--enable-preview") |
Member
Author
There was a problem hiding this comment.
nit: please add space after if (configuring local formatting will fix this)
Comment on lines
-137
to
+147
| if(config.targetVersion?.isEmpty() ?: true) { | ||
| if (config.targetVersion?.isEmpty() == true) { |
Member
Author
There was a problem hiding this comment.
nullable == true instead of nullable ?: false
Lauri "datafox" Heino (melodicore)
approved these changes
Jun 7, 2025
Member
Lauri "datafox" Heino (melodicore)
left a comment
There was a problem hiding this comment.
Everything looks good, thanks for the insights
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Small cleanups, sample project, READMEs.
Changelog