-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: Add intelliJ plugin #33
Conversation
998843b
to
0df6c91
Compare
0df6c91
to
ca3a0cf
Compare
Will add a config for this in a follow-up PR. |
@@ -19,6 +19,14 @@ jobs: | |||
os: [ ubuntu-latest ] | |||
runs-on: ${{ matrix.os }} | |||
steps: | |||
# Free disk space to avoid running into "No space left on device" errors | |||
# when downloading multiple versions of IntelliJ for plugin verification | |||
- name: Maximize Build Space |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, the GH workflow fails with a disk space error. This just removes a whole bunch of packages which are not needed for our repository's CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might need this for publish step too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did it c6d4934
./gradlew idea-plugin:patchPluginXml | ||
./gradlew idea-plugin:publishPlugin | ||
env: | ||
JETBRAINS_TOKEN: ${{ secrets.JETBRAINS_PLUGIN_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this secret, but need to test the publishing when this is merged.
/** Returns formatted content or null if the file is already formatted. */ | ||
private fun formatFile(file: PsiFile): String? { | ||
var formattedContent = "" | ||
val config = FormattingConfigs.forStdStreams(file.virtualFile.inputStream) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced the bin/kotlin-format
call with using the kotlin-format lib here, but will bring back the former behind some form of configuration in a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case, we can call Ktfmt().format(request.documentText)
directly which speed up everything (because we no longer need to open the file).
@@ -46,14 +56,18 @@ internal class TriggerFormatter(private val formatter: Formatter) { | |||
} | |||
|
|||
companion object { | |||
sealed class FormattingResult(private val compareOrder: Int, val fileName: String) : Comparable<FormattingResult> { | |||
data class FormattingResults(val results: SortedSet<FormattingResult>, val charsProcessed: Long) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
charsProcessed
was being extracted from the formatter
instance and that meant the formatter needed to be returned from the formatForConfig
method. I created this results class instead to hold all we need to return.
data class FormattingResults(val results: SortedSet<FormattingResult>, val charsProcessed: Long) | ||
|
||
sealed class FormattingResult(private val compareOrder: Int, val fileName: String) : | ||
Comparable<FormattingResult> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting.
This reverts commit 1aa1179.
to avoid reading the file which improve performace
📝 Description
Implement an IntelliJ plugin as a lightweight wrapper around the existing ktfmt call, ensuring it uses the same configuration as the CLI for consistency across tools.
⬇️ In Scope
🔜 Follow-up PRs