Skip to content

Commit

Permalink
Merge pull request #1088 from Aalto-LeTech/fix-exceptions
Browse files Browse the repository at this point in the history
Fix miscellaneous bugs and incompatibilities
  • Loading branch information
Taikelenn authored Jan 12, 2024
2 parents c1504b1 + f9ea3ce commit 7192066
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/main/java/fi/aalto/cs/apluscourses/model/Course.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import fi.aalto.cs.apluscourses.utils.Callbacks;
import fi.aalto.cs.apluscourses.utils.CourseHiddenElements;
import fi.aalto.cs.apluscourses.utils.CoursesClient;
import fi.aalto.cs.apluscourses.utils.JsonUtil;
import fi.aalto.cs.apluscourses.utils.PluginDependency;
import fi.aalto.cs.apluscourses.utils.ResourceException;
import fi.aalto.cs.apluscourses.utils.Resources;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/fi/aalto/cs/apluscourses/model/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.OptionalLong;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.io.IOException;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Progress start(int maxValue, String label, boolean indeterminate) {
*/
public void stopAll() {
synchronized (lock) {
progresses.forEach(Progress::finish);
new ArrayDeque<>(progresses).forEach(Progress::finish);
}
this.updateValues();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ public ReplConfigurationFormModel(
public static List<String> getScalaModuleNames(@NotNull Module[] modules) {
return Arrays.stream(modules)
.filter(module -> {
// Scala modules are of a "JAVA_MODULE" type,
// so it the way to distinct them from SBT-built ones.
return ModuleType.get(module).getName().equals("JAVA_MODULE");
// Java and Scala modules used to be called "JAVA_MODULE".
// Then, it was changes to "Java Module". We will check for both.
String moduleName = ModuleType.get(module).getName();
return moduleName.equalsIgnoreCase("JAVA_MODULE") || moduleName.equalsIgnoreCase("Java Module");
})
.map(Module::getName)
.collect(Collectors.toList());
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
<actions>
<group id="fi.aalto.cs.apluscourses.intellij.actions.ActionGroups.MENU_ACTIONS"
text="A+"
description="Actions for A+ menu">
description="Actions for A+ menu"
popup="true">
<add-to-group group-id="MainMenu" anchor="last"/>
<action id="fi.aalto.cs.apluscourses.intellij.actions.CourseProjectAction"
class="fi.aalto.cs.apluscourses.intellij.actions.CourseProjectAction"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fi.aalto.cs.apluscourses.intellij.actions

import com.intellij.concurrency.ThreadContext
import com.intellij.execution.configurations._
import com.intellij.execution.filters.TextConsoleBuilderImpl
import com.intellij.execution.runners.ExecutionEnvironment
Expand All @@ -24,6 +25,7 @@ import org.jetbrains.plugins.scala.console.configuration.ScalaConsoleRunConfigur
import org.jetbrains.plugins.scala.project.ProjectExt

import scala.jdk.CollectionConverters.ListHasAsScala
import scala.util.Using

/**
* Custom class that adjusts Scala Plugin's own RunConsoleAction with A+ requirements.
Expand Down Expand Up @@ -197,9 +199,18 @@ class ReplAction extends RunConsoleAction {
@NotNull module: Module): ReplConfigurationFormModel = {
val configModel = new ReplConfigurationFormModel(project, ModuleUtils.getModuleDirectory(module), module.getName)
val configForm = new ReplConfigurationForm(configModel, project)
val configDialog = new ReplConfigurationDialog
configDialog.setReplConfigurationForm(configForm)
configDialog.setVisible(true)

// This will reset the current thread context. We need to do this because
// we have been invoked from an UI event processing loop, and we are about
// to spawn a dialog box with its own processing loop (which sets a thread context).
// This makes IntelliJ unhappy because a thread context can only be set once.
// Once the Using block exits (i.e. the dialog box closes), the original thread context is restored.
Using(ThreadContext.resetThreadContext()) { _ => {
val configDialog = new ReplConfigurationDialog
configDialog.setReplConfigurationForm(configForm)
configDialog.setVisible(true)
}}

configModel
}

Expand Down

0 comments on commit 7192066

Please sign in to comment.