Skip to content

Commit e11d5e9

Browse files
committed
Fix suggest algorithm bugs
1 parent 179a4db commit e11d5e9

File tree

3 files changed

+6
-49
lines changed

3 files changed

+6
-49
lines changed

swan_assist/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sourceCompatibility = 1.8
1010

1111
repositories {
1212
mavenCentral()
13+
mavenLocal()
1314
}
1415

1516
dependencies {

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/actions/suggest/SuggestAction.java

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,16 @@
1212
import com.intellij.openapi.actionSystem.AnActionEvent;
1313
import com.intellij.openapi.actionSystem.CommonDataKeys;
1414
import com.intellij.openapi.project.Project;
15-
import com.intellij.openapi.ui.DialogWrapper;
1615
import com.intellij.util.messages.MessageBus;
1716
import de.fraunhofer.iem.swan.assist.comm.SuggestNotifier;
1817
import de.fraunhofer.iem.swan.assist.data.JSONFileLoader;
19-
import de.fraunhofer.iem.swan.assist.ui.dialog.SwanLauncherDialog;
18+
import de.fraunhofer.iem.swan.assist.data.PropertiesManager;
2019
import de.fraunhofer.iem.swan.assist.util.Constants;
2120

22-
import java.io.File;
23-
import java.util.HashMap;
24-
2521
public class SuggestAction extends AnAction {
2622

2723
/**
2824
* Obtains suggested methods from SWAN and loads them in a dialog for user classification.
29-
*
3025
* @param e source event
3126
*/
3227
@Override
@@ -36,50 +31,17 @@ public void actionPerformed(AnActionEvent e) {
3631
MessageBus messageBus = project.getMessageBus();
3732

3833
//Set output directory for plugin, if not set
39-
if (!PropertiesComponent.getInstance(project).isValueSet(Constants.SWAN_OUTPUT_DIR)) {
40-
41-
setProjectPath(project);
42-
} else {
43-
File trainFile = new File(PropertiesComponent.getInstance(project).getValue(Constants.SWAN_OUTPUT_DIR));
44-
45-
if (!trainFile.exists())
46-
setProjectPath(project);
47-
}
34+
PropertiesManager.setProjectOutputPath(project);
4835

4936
SuggestThread suggestThread = new SuggestThread(project,
50-
"/Users/oshando/Projects/IdeaProjects/mois-evaluation/mois-rq3/resources/gxa-methods-r.json",
51-
"/Users/oshando/Projects/IdeaProjects/mois-evaluation/mois-executor/project-jars/gxa"
52-
);
37+
PropertiesComponent.getInstance(project).getValue(Constants.SWAN_CONFIG_FILE),
38+
PropertiesComponent.getInstance(project).getValue(Constants.SWAN_SOURCE_DIR));
5339
suggestThread.start();
5440

5541
SuggestNotifier suggestNotifier = messageBus.syncPublisher(SuggestNotifier.SUGGEST_METHOD_TOPIC);
5642
suggestNotifier.startSuggestMethod();
5743
}
5844

59-
private void setProjectPath(Project project) {
60-
61-
//Launch SWAN Properties Dialog
62-
SwanLauncherDialog dialog = new SwanLauncherDialog(project, true);
63-
dialog.show();
64-
65-
if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
66-
67-
HashMap<String, String> swanParameters = dialog.getParameters();
68-
69-
File outputFolder = new File(swanParameters.get(Constants.SWAN_OUTPUT_DIR));
70-
71-
if(!outputFolder.exists())
72-
outputFolder.mkdir();
73-
74-
PropertiesComponent.getInstance(project).setValue(Constants.SWAN_OUTPUT_DIR, swanParameters.get(Constants.SWAN_OUTPUT_DIR));
75-
76-
77-
78-
79-
System.out.println("Set project path: : "+ swanParameters.get(Constants.SWAN_OUTPUT_DIR));
80-
}
81-
}
82-
8345
/**
8446
* Controls whether the action is enabled or disabled
8547
*

swan_assist/src/main/java/de/fraunhofer/iem/swan/assist/actions/suggest/SuggestThread.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ public void run() {
7070
boolean methodPairFound = false;
7171

7272
//Get training methods
73-
Set<String> trainingMethods = new HashSet<>();
7473
TrainingFileManager trainingFileManager = new TrainingFileManager(project);
75-
trainingMethods = trainingFileManager.getTrainingMethods().keySet();
74+
Set<String> trainingMethods = new HashSet<>(trainingFileManager.getTrainingMethods().keySet());
7675
trainingMethods.addAll(MethodListTree.suggestedMethodsList);
7776

7877
while (!methodPairFound) {
@@ -81,20 +80,15 @@ public void run() {
8180

8281
if (methodPair != null) {
8382

84-
System.out.println("SUGMET: " + methodPair.getMethod1().getSignature(true) + " " + methodPair.getMethod2().getSignature(true));
85-
8683
if (trainingMethods.contains(methodPair.getMethod1().getSignature(true)) ||
8784
trainingMethods.contains(methodPair.getMethod2().getSignature(true))) {
88-
89-
System.out.println("skipping: " + methodPair.getMethod1().getSignature(true) + "\n" + methodPair.getMethod2().getSignature(true));
9085
continue;
9186
}
9287

9388
methodPair.getMethod1().setStatus(MethodWrapper.MethodStatus.SUGGESTED);
9489
suggestedMethods.add(methodPair.getMethod1());
9590
methodPair.getMethod2().setStatus(MethodWrapper.MethodStatus.SUGGESTED);
9691
suggestedMethods.add(methodPair.getMethod2());
97-
System.out.println("adding: ");
9892
methodPairFound = true;
9993
}
10094
}

0 commit comments

Comments
 (0)