Skip to content

chore: general plugin cleanups#1

Merged
Lauri "datafox" Heino (melodicore) merged 1 commit into
mainfrom
chore/cleanups
Jun 7, 2025
Merged

chore: general plugin cleanups#1
Lauri "datafox" Heino (melodicore) merged 1 commit into
mainfrom
chore/cleanups

Conversation

@sgammon
Copy link
Copy Markdown
Member

Summary

Small cleanups, sample project, READMEs.

Changelog

chore: clean up plugin code a bit
chore: add sample project for testing
chore: add README for outer and sample projects

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 thread sample/pom.xml
Comment on lines +7 to +8
<properties>
<maven.compiler.executable>/home/sam/bin/elide</maven.compiler.executable>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(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>()
Copy link
Copy Markdown
Member Author

@sgammon Sam Gammon (sgammon) Jun 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullable == true instead of nullable ?: false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good, thanks for the insights

@melodicore Lauri "datafox" Heino (melodicore) merged commit 1005bc0 into main Jun 7, 2025
1 check passed
@github-project-automation github-project-automation Bot moved this to Done in Elide Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants