Skip to content

Commit

Permalink
feat: support the Pact 5 language server (#75)
Browse files Browse the repository at this point in the history
* refactor(settings): rename `pactPath` and `pactLanguageServerPath`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(settings): create `PactSettingsUtils`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(settings): update `AppSettingsComponent`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* docs(readme): update settings label

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* refactor(settings): rename `AppSettingsComponent`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* refactor(settings): rename `AppSettingsConfigurable`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* refactor(settings): rename `AppSettingsState`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(settings): update `PactSettingsEditor`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(lsp): update `PactLspServerDescriptor`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(settings): update `PactSettingsUtils`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(settings): update `PactSettingsUtils`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(settings): update `PactSettingsUtils`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(settings): update `PactSettingsEditor`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(settings): update `PactSettingsEditor`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* wip(settings): update `PactRunConfigurationOptions`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* build: update minor version to `0.5.0`

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

* docs(changelog): add entry

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>

---------

Signed-off-by: Luke Gareth Ribchester <luke@luke.gr>
  • Loading branch information
lukeribchester authored May 31, 2024
1 parent 572797d commit d012875
Show file tree
Hide file tree
Showing 15 changed files with 286 additions and 248 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

## [Unreleased]

### Added

- Support for the [Pact 5 Language Server (LSP)](https://github.com/kadena-io/pact-5)

## [0.4.0] - 2024-05-13

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Configuration is required to enable functionality from the Pact Language Server:

1. Navigate to <kbd>Settings/Preferences</kbd>
2. Select <kbd>Languages & Frameworks</kbd> > <kbd>Pact</kbd>
3. Specify your <kbd>Pact</kbd> and <kbd>Pact Language Server</kbd> paths
3. Specify your <kbd>Pact Compiler</kbd> and <kbd>Pact Language Server</kbd> paths

#### Homebrew

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = io.kadena.pact
pluginName = Pact
pluginRepositoryUrl = https://github.com/lukeribchester/pact-intellij
# SemVer format -> https://semver.org
pluginVersion = 0.4.0
pluginVersion = 0.5.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 232
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ package io.kadena.pact.ide.runner

import com.intellij.execution.configurations.RunConfigurationOptions
import com.intellij.openapi.components.StoredProperty
import io.kadena.pact.ide.settings.AppSettingsState
import io.kadena.pact.ide.settings.PactSettingsState


class PactRunConfigurationOptions : RunConfigurationOptions() {
private val settings: AppSettingsState = AppSettingsState.instance
private val settings: PactSettingsState = PactSettingsState.instance

private val _compilerPath: StoredProperty<String?> =
string(settings.pactPath.takeIf { it.isNotBlank() } ?: "")
string(settings.compilerPath.takeIf { it.isNotBlank() } ?: "")
.provideDelegate(this, "compilerPath")

private val _modulePath: StoredProperty<String?> =
string("")
.provideDelegate(this, "modulePath")

var compilerPath: String
get() = _compilerPath.getValue(this).toString()
get() = _compilerPath.getValue(this).takeIf { !it.equals(null) } ?: ""
set(newCompilerPath) {
_compilerPath.setValue(this, newCompilerPath)
}

var modulePath: String
get() = _modulePath.getValue(this).toString()
get() = _modulePath.getValue(this).takeIf { !it.equals(null) } ?: ""
set(newModulePath) {
_modulePath.setValue(this, newModulePath)
}
Expand Down
58 changes: 40 additions & 18 deletions src/main/kotlin/io/kadena/pact/ide/runner/PactSettingsEditor.kt
Original file line number Diff line number Diff line change
@@ -1,44 +1,66 @@
package io.kadena.pact.ide.runner

import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.fileChooser.FileChooserDescriptor
import com.intellij.openapi.options.SettingsEditor
import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.ui.TextFieldWithBrowseButton
import com.intellij.util.ui.FormBuilder
import com.intellij.ui.dsl.builder.Align
import com.intellij.ui.dsl.builder.RowLayout
import io.kadena.pact.ide.settings.createComboBox
import org.jetbrains.annotations.NotNull
import javax.swing.JComponent
import javax.swing.JPanel
import com.intellij.ui.dsl.builder.panel as dslPanel


class PactSettingsEditor : SettingsEditor<PactRunConfiguration>() {
private val panel: JPanel

private val compilerPathField = TextFieldWithBrowseButton()
private val modulePathField = TextFieldWithBrowseButton()
private val compilerPathField: ComboBox<String> = createComboBox(
"Select a Pact Compiler", "Choose an executable file"
)

init {
compilerPathField.addBrowseFolderListener(
"Select a Pact Compiler", null, null,
FileChooserDescriptorFactory.createSingleFileDescriptor()
private val modulePathField = TextFieldWithBrowseButton().apply {
addBrowseFolderListener(
"Select a Pact Module",
"Choose a Pact file",
null,
FileChooserDescriptor(
true,
false,
false,
false,
false,
false
)
)
}

modulePathField.addBrowseFolderListener(
"Select a Pact Module", null, null,
FileChooserDescriptorFactory.createSingleFileDescriptor()
)
init {
panel = dslPanel {
// Compiler path
row("Pact compiler:") {
cell(compilerPathField)
.align(Align.FILL)
.resizableColumn()
}.layout(RowLayout.LABEL_ALIGNED)

panel = FormBuilder.createFormBuilder()
.addLabeledComponent("Pact compiler:", compilerPathField)
.addLabeledComponent("Pact module:", modulePathField)
.panel
// Module path
row("Pact module:") {
cell(modulePathField)
.align(Align.FILL)
.resizableColumn()
}.layout(RowLayout.LABEL_ALIGNED)
}
}

override fun resetEditorFrom(pactRunConfiguration: PactRunConfiguration) {
compilerPathField.text = pactRunConfiguration.compilerPath
compilerPathField.selectedItem = pactRunConfiguration.compilerPath
modulePathField.text = pactRunConfiguration.modulePath
}

override fun applyEditorTo(@NotNull pactRunConfiguration: PactRunConfiguration) {
pactRunConfiguration.compilerPath = compilerPathField.text
pactRunConfiguration.compilerPath = compilerPathField.selectedItem?.toString() ?: ""
pactRunConfiguration.modulePath = modulePathField.text
}

Expand Down
148 changes: 0 additions & 148 deletions src/main/kotlin/io/kadena/pact/ide/settings/AppSettingsComponent.kt

This file was deleted.

This file was deleted.

Loading

0 comments on commit d012875

Please sign in to comment.