-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling proper code generation for comments (Comment with Line/Block…
… Comment) (#3582) * feat: enabling proper code generation for comments (toggleable, Comment with Line/Block Comment) * Add the correct ERL and elixir arguments for starting IEx depending on the version of elixir sdk * Bundle latest OtpErlang.jar from JInterface v1.14 for OTP v26 * Infer OTP_RELEASE & ERLANG_SDK_HOME if no environment variable is set (#3600) * Add compatibility for 2024.1 IDEs (#3569) * Update gradlewrapper to v7.6.4 ./gradlew wrapper --gradle-version=7.6.4 To fix gradle issue: gradle/gradle#27156 * Remove use of `FileUtil.FILE_HASHING_STRATEGY` from Intellij FileUtil, it was removed in 2024.1. (Note, this is only used in the jps-build test suite). This also removes references to Trove THashSet, and no longer stores File directly in sets or collections. See JetBrains/intellij-community@560e8fc * Add support for 2024.1 IDEs (and runs tests correctly against 2024.1) * Update usages group wording for 2024.1 * Fix more sdk configuration commits in application RW thread, fixes compatibility with IDEs v2024.1 * Fix whitespace in tests due to 2024.1 change I believe 2024.1 changed how the Usages work. In 2023.x: ```kotlin val usages = myFixture.testFindUsagesUsingAction("module_attribute_usage.ex", "kernel.ex") .map { it as UsageInfo2UsageAdapter } ``` In the debugger shows: ``` 0 = {ReadWriteAccessUsageInfo2UsageAdapter@19239} "4|def usage, |do|: |@|module_attribute" 1 = {ReadWriteAccessUsageInfo2UsageAdapter@19240} "2|@|module_attribute| |1" ``` For 2024.1, this shows: ``` 0 = {ReadWriteAccessUsageInfo2UsageAdapter@19421} "2| |@module_attribute| 1" 1 = {ReadWriteAccessUsageInfo2UsageAdapter@19422} "4| def usage, do: |@module_attribute" ``` I believe it not shows the whitespace for the file, where previously it didn't. * pin versions * use BasePlatformTestCase to stop warning * add do block match test * set 241.0 as the version, to fix certain intellij warnings * fix key * revert tests * use thread --------- Co-authored-by: Josh Taylor <[email protected]> * Add 18.0.0 changelog, fix version (#3602) * support only the newest version. * remove tests for now, kind of pointless --------- Co-authored-by: Ashley Sommer <[email protected]> Co-authored-by: Josh Taylor <[email protected]>
- Loading branch information
1 parent
029b5d0
commit 4822fa5
Showing
4 changed files
with
116 additions
and
16 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
src/org/elixir_lang/formatter/settings/CodeGenerationPanel.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,91 @@ | ||
package org.elixir_lang.formatter.settings | ||
|
||
import com.intellij.application.options.CodeStyleAbstractPanel | ||
import com.intellij.application.options.codeStyle.CommenterForm | ||
import com.intellij.lang.Language | ||
import com.intellij.openapi.editor.colors.EditorColorsScheme | ||
import com.intellij.openapi.editor.highlighter.EditorHighlighter | ||
import com.intellij.openapi.fileTypes.FileType | ||
import com.intellij.openapi.fileTypes.FileTypeEditorHighlighterProviders | ||
import com.intellij.openapi.util.NlsContexts.TabTitle | ||
import com.intellij.psi.codeStyle.CodeStyleSettings | ||
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable.CommenterOption | ||
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider | ||
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider.SettingsType | ||
import com.intellij.ui.IdeBorderFactory | ||
import com.intellij.ui.components.JBScrollPane | ||
import com.intellij.util.ui.JBInsets | ||
import org.elixir_lang.ElixirFileType | ||
import org.elixir_lang.ElixirLanguage | ||
import javax.swing.BoxLayout | ||
import javax.swing.JComponent | ||
import javax.swing.JPanel | ||
|
||
class CodeGenerationPanel(settings: CodeStyleSettings) : CodeStyleAbstractPanel(settings) { | ||
|
||
private val panel: JPanel | ||
private val myCommenterForm: CommenterForm = CommenterForm(ElixirLanguage) | ||
private var myPanel: JComponent? = null | ||
|
||
init { | ||
panel = JPanel().apply { | ||
layout = BoxLayout(this, BoxLayout.Y_AXIS) | ||
border = IdeBorderFactory.createEmptyBorder(JBInsets(0, 10, 10, 10)) | ||
add(myCommenterForm.commenterPanel) | ||
} | ||
} | ||
|
||
override fun getFileType(): FileType = ElixirFileType.INSTANCE | ||
|
||
override fun getTabTitle(): @TabTitle String = "Code Generation" | ||
|
||
override fun getDefaultLanguage(): Language = ElixirLanguage | ||
|
||
override fun getRightMargin(): Int = 47 | ||
|
||
override fun getPreviewText(): String = LanguageCodeStyleSettingsProvider.forLanguage(ElixirLanguage)!! | ||
.getCodeSample(SettingsType.LANGUAGE_SPECIFIC)!! | ||
|
||
override fun apply(settings: CodeStyleSettings) { | ||
if (isModified(settings)) myCommenterForm.apply(settings) | ||
} | ||
|
||
override fun isModified(settings: CodeStyleSettings): Boolean { | ||
return myCommenterForm.isModified(settings) | ||
} | ||
|
||
fun getPanelInner(): JComponent { | ||
return panel | ||
} | ||
|
||
override fun resetImpl(settings: CodeStyleSettings) { | ||
myCommenterForm.reset(settings) | ||
} | ||
|
||
override fun getPanel(): JComponent? { | ||
if (myPanel == null) { | ||
val contentPanel = getPanelInner() | ||
myPanel = JBScrollPane(contentPanel) | ||
} | ||
return myPanel!! | ||
} | ||
|
||
override fun createHighlighter(colors: EditorColorsScheme): EditorHighlighter { | ||
val fileType: FileType = getFileType() | ||
return FileTypeEditorHighlighterProviders.INSTANCE.forFileType(fileType) | ||
.getEditorHighlighter(null, fileType, null, colors) | ||
} | ||
|
||
companion object { | ||
fun getSupportedCommenterStandardOptionNames(): MutableList<String> { | ||
val supportedCommenterStandardOptionNames = mutableListOf<String>().apply { | ||
add(CommenterOption.LINE_COMMENT_AT_FIRST_COLUMN.name) | ||
add(CommenterOption.LINE_COMMENT_ADD_SPACE.name) | ||
add(CommenterOption.LINE_COMMENT_ADD_SPACE_ON_REFORMAT.name) | ||
add(CommenterOption.BLOCK_COMMENT_AT_FIRST_COLUMN.name) | ||
add(CommenterOption.BLOCK_COMMENT_ADD_SPACE.name) | ||
} | ||
return supportedCommenterStandardOptionNames | ||
} | ||
} | ||
} |
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
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