|
10 | 10 | import com.intellij.execution.configurations.RunConfigurationBase;
|
11 | 11 | import com.intellij.execution.configurations.coverage.CoverageEnabledConfiguration;
|
12 | 12 | import com.intellij.openapi.application.ModalityState;
|
| 13 | +import com.intellij.openapi.diagnostic.Logger; |
| 14 | +import com.intellij.openapi.vfs.VirtualFile; |
13 | 15 | import com.intellij.ui.GuiUtils;
|
14 | 16 | import io.flutter.FlutterBundle;
|
15 | 17 | import io.flutter.pub.PubRoot;
|
|
20 | 22 | import java.util.List;
|
21 | 23 |
|
22 | 24 | public class FlutterCoverageEnabledConfiguration extends CoverageEnabledConfiguration {
|
| 25 | + private static final Logger LOG = Logger.getInstance(FlutterCoverageEnabledConfiguration.class.getName()); |
23 | 26 |
|
24 | 27 | public FlutterCoverageEnabledConfiguration(@NotNull RunConfigurationBase<?> configuration) {
|
25 | 28 | super(configuration);
|
26 | 29 | super.setCoverageRunner(CoverageRunner.getInstance(FlutterCoverageRunner.class));
|
27 |
| - final List<PubRoot> roots = PubRoots.forProject(configuration.getProject()); |
28 |
| - if (roots.isEmpty()) { |
29 |
| - throw new RuntimeException(FlutterBundle.message("project.root.not.found")); |
30 |
| - } |
31 |
| - myCoverageFilePath = roots.get(0).getRoot().getCanonicalPath() + "/coverage/lcov.info"; |
| 30 | + createCoverageFile(); |
32 | 31 | GuiUtils.invokeLaterIfNeeded(
|
33 | 32 | () -> setCurrentCoverageSuite(CoverageDataManager.getInstance(configuration.getProject()).addCoverageSuite(this)),
|
34 | 33 | ModalityState.any());
|
35 | 34 | }
|
36 | 35 |
|
| 36 | + @Override |
| 37 | + protected String createCoverageFile() { |
| 38 | + if (myCoverageFilePath == null) { |
| 39 | + final List<PubRoot> roots = PubRoots.forProject(getConfiguration().getProject()); |
| 40 | + if (roots.isEmpty()) { |
| 41 | + throw new RuntimeException(FlutterBundle.message("project.root.not.found")); |
| 42 | + } |
| 43 | + final VirtualFile root = roots.get(0).getRoot(); |
| 44 | + myCoverageFilePath = root.getPath() + "/coverage/lcov.info"; |
| 45 | + } |
| 46 | + return myCoverageFilePath; |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
37 | 50 | public void setCoverageRunner(@Nullable final CoverageRunner coverageRunner) {
|
38 | 51 | // Save and restore myCoverageFilePath because the super method clears it.
|
39 | 52 | final String path = myCoverageFilePath;
|
40 | 53 | super.setCoverageRunner(coverageRunner);
|
41 | 54 | myCoverageFilePath = path;
|
42 | 55 | }
|
43 | 56 |
|
| 57 | + @Override |
44 | 58 | public void coverageRunnerExtensionRemoved(@NotNull CoverageRunner runner) {
|
45 | 59 | final String path = myCoverageFilePath;
|
46 | 60 | super.coverageRunnerExtensionRemoved(runner);
|
|
0 commit comments