Skip to content

Commit

Permalink
## [0.1.5]
Browse files Browse the repository at this point in the history
### Problems
- no javax.tools.ToolProvider.getSystemJavaCompiler in JRE
### Fixes
- java_home error from astor
### Added
- full arguments
  • Loading branch information
JakkuSakura committed Jul 28, 2021
1 parent 0730a19 commit 6106fde
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 29 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
# IntelliJ Idea Astor Plugin ChangeLog

## [Unreleased]
### Plans
Wrap `ASTOR` as a language server or hack JRE to achieve provide JDK. https://github.com/JetBrains/gradle-intellij-plugin/issues/755

## [0.1.5]
### Problems
- no javax.tools.ToolProvider.getSystemJavaCompiler in JRE
### Fixes
- java_home error from astor
### Added
- full arguments
## [0.1.4]
### Added
- Extract jreVersion
Expand Down
2 changes: 1 addition & 1 deletion astor
Submodule astor updated from cf2b22 to eb36ca
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repositories {
mavenLocal()
}
dependencies {
implementation("org.inria.sacha.automaticRepair:astor:1.1.0") {
implementation("org.inria.sacha.automaticRepair:astor:1.1.1") {
exclude("org.slf4j")
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

pluginGroup = org.bytecamp.program_repair.astor_plugin
pluginName = IntelliJ Idea Astor Plugin
pluginVersion = 0.1.4
pluginVersion = 0.1.5

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.bytecamp.program_repair.astor_plugin.actions

import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.components.service
import com.intellij.openapi.ui.Messages
import org.bytecamp.program_repair.astor_plugin.services.AstorProjectService

class AstorExecuteAstorAction: AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val service = e.project?.service<AstorProjectService>()!!
service.execute()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.bytecamp.program_repair.astor_plugin.listeners

import com.intellij.ide.plugins.DynamicPluginListener

Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package org.bytecamp.program_repair.astor_plugin.services

import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.module.ModuleManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.CompilerProjectExtension
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.ui.Messages
import com.intellij.openapi.vfs.VirtualFile
import fr.inria.main.evolution.AstorMain
import java.io.IOException
import kotlin.math.log
import java.io.File


object Keys {
Expand All @@ -31,7 +27,19 @@ class AstorConfig {
var srcTest: String = ""
var bin: String = ""
var binTest: String = ""
private var normaized = false
private fun normalize() {
if (!normaized) {
val location = File(this.location)
src = File(src).relativeTo(location).path
srcTest = File(srcTest).relativeTo(location).path
bin = File(bin).relativeTo(location).path
binTest = File(binTest).relativeTo(location).path
normaized = true
}
}
fun toArgs(): Array<String> {
normalize()
return arrayOf(
Keys.MODE,
mode,
Expand All @@ -55,7 +63,6 @@ class AstorConfig {
}
}

@Service
class AstorProjectService(val project: Project) {
val main: AstorMain = AstorMain()
val logger = com.intellij.openapi.diagnostic.Logger.getInstance("AstorProjectService")
Expand All @@ -71,8 +78,10 @@ class AstorProjectService(val project: Project) {
} else if (file.children.isEmpty()) {
prefix
} else {
if (file.children[0].name == "java") {
if (file.name == "java") {
getCommonPackage(file.children[0], prefix)
} else if (prefix.isEmpty()) {
getCommonPackage(file.children[0], file.name)
} else {
getCommonPackage(file.children[0], prefix + "." + file.name)
}
Expand Down Expand Up @@ -113,14 +122,16 @@ class AstorProjectService(val project: Project) {
}
}
}

val base = project.projectFile!!.parent!!.parent.path
when (getBuildSystem()) {
"gradle" -> {
config.bin = project.projectFile!!.parent.path + "build/classes/java/main"
config.binTest = project.projectFile!!.parent.path + "build/classes/java/test"
config.bin = "$base/build/classes/java/main"
config.binTest = "$base/build/classes/java/test"
}
"maven" -> {
config.bin = project.projectFile!!.parent.path + "target/classes"
config.binTest = project.projectFile!!.parent.path + "target/test-classes"
config.bin = "$base/target/classes"
config.binTest = "$base/target/test-classes"
}
else -> {
Messages.showErrorDialog(project, "Does not support build systems other than gradle or maven", "Astor")
Expand All @@ -131,6 +142,7 @@ class AstorProjectService(val project: Project) {

fun execute() {
val config = getConfig()
logger.info("Executing with config $config")
main.execute(config.toArgs())
}
}
11 changes: 9 additions & 2 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
<!-- https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
<depends>com.intellij.modules.platform</depends>


<extensions defaultExtensionNs="com.intellij">
<!-- <applicationService serviceImplementation="org.jetbrains.plugins.template.services.MyApplicationService"/>-->
<projectService serviceImplementation="org.bytecamp.program_repair.astor_plugin.services.AstorProjectService"/>
</extensions>

<projectListeners>
<listener class="org.bytecamp.program_repair.astor_plugin.listeners.MyProjectManagerListener"
topic="com.intellij.openapi.project.ProjectManagerListener"/>
<!-- <listener class="org.bytecamp.program_repair.astor_plugin.listeners.OnLoadUnloadListener"-->
<!-- topic="r com.intellij.ide.plugins.DynamicPluginListener"/>-->
</projectListeners>
<actions>
<group id="astor_plugin.AstorAction" text="Astor" description="Analyze with Astor">
<add-to-group group-id="MainMenu" anchor="last" />
<action class="org.bytecamp.program_repair.astor_plugin.actions.AstorPrintArgumentAction" id="astor_plugin.AstorPrintArgumentAction" text="Print Arguments"/>
<action class="org.bytecamp.program_repair.astor_plugin.actions.AstorExecuteAstorAction" id="astor_plugin.AstorExecuteAstorAction" text="Execute Astor"/>
</group>
</actions>
<depends>com.intellij.java</depends>
Expand Down

0 comments on commit 6106fde

Please sign in to comment.