Skip to content

Commit

Permalink
#1835 Extracted java-dependent code to a separate module with optiona…
Browse files Browse the repository at this point in the history
…l java dependency
  • Loading branch information
hurricup committed Nov 9, 2024
1 parent b646223 commit 811375a
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 30 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ intellijPlatform {
dependencies {
listOf(
":core",
":java",
).forEach {
compileOnly(project(it))
testCompileOnly(project(it))
Expand Down
38 changes: 10 additions & 28 deletions core/src/main/java/org/ice1000/julia/lang/module/julia-modules.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,24 @@

package org.ice1000.julia.lang.module

import com.intellij.ide.util.projectWizard.*
import com.intellij.ide.util.projectWizard.ModuleBuilder
import com.intellij.ide.util.projectWizard.ModuleBuilderListener
import com.intellij.ide.util.projectWizard.ModuleWizardStep
import com.intellij.ide.util.projectWizard.WizardContext
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.module.*
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleType
import com.intellij.openapi.module.ModuleTypeManager
import com.intellij.openapi.project.guessProjectDir
import com.intellij.openapi.project.rootManager
import com.intellij.openapi.projectRoots.SdkTypeId
import com.intellij.openapi.roots.ModifiableModelsProvider
import com.intellij.openapi.roots.ModifiableRootModel
import com.intellij.openapi.roots.ui.configuration.*
import icons.JuliaIcons
import org.ice1000.julia.lang.*
import org.ice1000.julia.lang.JULIA_DEFAULT_MODULE_NAME
import org.ice1000.julia.lang.JULIA_MODULE_ID
import org.ice1000.julia.lang.JuliaBundle
import org.ice1000.julia.lang.action.errorNotification
import org.ice1000.julia.lang.module.ui.JuliaSetupSdkWizardStepImpl

Expand Down Expand Up @@ -90,27 +96,3 @@ class JuliaModuleType : ModuleType<JuliaModuleBuilder>(JULIA_MODULE_ID) {
}
}

/**
* Module Configure
* Inspired by Haskell plugin
* @author: zxj5470
* @date: 2018/1/29
*/
class JuliaModuleConfigEditor : ModuleConfigurationEditorProvider {
override fun createEditors(state: ModuleConfigurationState): Array<ModuleConfigurationEditor> {
val module = state.rootModel?.module ?: return emptyArray()
return arrayOf(ContentEntriesEditor(module.name, state),
JuliaCompileOutputEditor(state))
}
}

class JuliaCompileOutputEditor(state: ModuleConfigurationState) : ModuleElementsEditor(state) {
var editor: BuildElementsEditor = object : BuildElementsEditor(state) {
}

override fun createComponentImpl() = editor.createComponentImpl()
override fun saveData() = editor.saveData()
override fun getDisplayName() = "Paths"
override fun getHelpTopic() = editor.helpTopic
}

18 changes: 18 additions & 0 deletions java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
fun properties(key: String) = providers.gradleProperty(key)
fun environment(key: String) = providers.environmentVariable(key)

dependencies {
listOf(
":core",
).forEach {
compileOnly(project(it))
testCompileOnly(project(it))
runtimeOnly(project(it))
}
intellijPlatform {
val platformVersionProvider: Provider<String> by rootProject.extra
create("IC", platformVersionProvider.get(), useInstaller = properties("useInstaller").get().toBoolean())
bundledPlugins("com.intellij.java")
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Julia language support plugin for Intellij-based IDEs.
* Copyright (C) 2024 julia-intellij contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.ice1000.julia.java.ui.configuration

import com.intellij.openapi.roots.ui.configuration.BuildElementsEditor
import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState
import com.intellij.openapi.roots.ui.configuration.ModuleElementsEditor

class JuliaCompileOutputEditor(state: ModuleConfigurationState) : ModuleElementsEditor(state) {
var editor: BuildElementsEditor = object : BuildElementsEditor(state) {
}

override fun createComponentImpl() = editor.createComponentImpl()
override fun saveData() = editor.saveData()
override fun getDisplayName() = "Paths"
override fun getHelpTopic() = editor.helpTopic
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Julia language support plugin for Intellij-based IDEs.
* Copyright (C) 2024 julia-intellij contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package org.ice1000.julia.java.ui.configuration

import com.intellij.openapi.module.ModuleConfigurationEditor
import com.intellij.openapi.roots.ui.configuration.ContentEntriesEditor
import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationEditorProvider
import com.intellij.openapi.roots.ui.configuration.ModuleConfigurationState

class JuliaModuleConfigEditorProvider : ModuleConfigurationEditorProvider {
override fun createEditors(state: ModuleConfigurationState): Array<ModuleConfigurationEditor> {
val module = state.currentRootModel?.module ?: return emptyArray()
return arrayOf(
ContentEntriesEditor(module.name, state),
JuliaCompileOutputEditor(state)
)
}
}
9 changes: 9 additions & 0 deletions java/src/main/resources/org.ice1000.julia.java.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<idea-plugin package="org.ice1000.julia.java">
<dependencies>
<plugin id="com.intellij.modules.java"/>
</dependencies>
<extensions defaultExtensionNs="com.intellij">
<moduleConfigurationEditorProvider
implementation="org.ice1000.julia.java.ui.configuration.JuliaModuleConfigEditorProvider"/>
</extensions>
</idea-plugin>
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ pluginManagement {
rootProject.name = "julia-intellij"
include("core")
project(":core").projectDir = file("core")
include("java")
project(":java").projectDir = file("java")
8 changes: 6 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<idea-plugin>
<id>"org.ice1000.julia</id>
<idea-plugin url="https://github.com/JuliaEditorSupport/julia-intellij/">
<id>org.ice1000.julia</id>
<name>Julia</name>
<vendor email="[email protected]" url="https://github.com/hurricup">Alexandr Evstigneev</vendor>
<category>Custom Languages</category>
Expand All @@ -10,6 +10,10 @@
<depends optional="true" config-file="plugin-goland.xml">com.intellij.modules.go</depends>
<depends optional="true" config-file="plugin-idea.xml">com.intellij.modules.idea</depends>

<content>
<module name="org.ice1000.julia.java"/>
</content>

<extensions defaultExtensionNs="com.intellij">
<liveTemplateContext implementation="org.ice1000.julia.lang.editing.JuliaTemplateContextType$Base"/>
<liveTemplateContext implementation="org.ice1000.julia.lang.editing.JuliaTemplateContextType$Module"/>
Expand Down

0 comments on commit 811375a

Please sign in to comment.