mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
save using store.save to avoid global flag manipulation
cleanup (overrides)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,6 +47,9 @@ import org.junit.Assert;
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -183,10 +186,10 @@ public class CompilerTester {
|
||||
PlatformTestUtil.saveProject(getProject());
|
||||
CompilerTestUtil.saveApplicationSettings();
|
||||
for (Module module : myModules) {
|
||||
File ioFile = new File(module.getModuleFilePath());
|
||||
if (!ioFile.exists()) {
|
||||
Path ioFile = Paths.get(module.getModuleFilePath());
|
||||
if (!Files.exists(ioFile)) {
|
||||
getProject().save();
|
||||
assert ioFile.exists() : "File does not exist: " + ioFile.getPath();
|
||||
assert Files.exists(ioFile) : "File does not exist: " + ioFile.toString();
|
||||
}
|
||||
}
|
||||
runnable.consume(callback);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface ProjectEx extends Project {
|
||||
interface ProjectSaved {
|
||||
Topic<ProjectSaved> TOPIC = Topic.create("SaveProjectTopic", ProjectSaved.class, Topic.BroadcastDirection.NONE);
|
||||
|
||||
void saved(@NotNull final Project project);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,9 +31,9 @@ import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.application.impl.LaterInvocator;
|
||||
import com.intellij.openapi.components.ServiceKt;
|
||||
import com.intellij.openapi.components.impl.stores.StoreUtil;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
@@ -71,7 +71,10 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
@@ -532,16 +535,8 @@ public class PlatformTestUtil {
|
||||
return SystemInfo.isAppleJvm ? FileUtil.toCanonicalPath(home + "/../Classes/classes.jar") : home + "/lib/rt.jar";
|
||||
}
|
||||
|
||||
public static void saveProject(Project project) {
|
||||
ApplicationEx application = ApplicationManagerEx.getApplicationEx();
|
||||
boolean oldValue = application.isDoNotSave();
|
||||
try {
|
||||
application.doNotSave(false);
|
||||
project.save();
|
||||
}
|
||||
finally {
|
||||
application.doNotSave(oldValue);
|
||||
}
|
||||
public static void saveProject(@NotNull Project project) {
|
||||
StoreUtil.save(ServiceKt.getStateStore(project), project);
|
||||
}
|
||||
|
||||
public static class TestInfo {
|
||||
|
||||
+6
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -115,14 +116,11 @@ public abstract class ModuleFixtureBuilderImpl<T extends ModuleFixture> implemen
|
||||
protected abstract T instantiateFixture();
|
||||
|
||||
Module buildModule() {
|
||||
final Module[] module = {null};
|
||||
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
module[0] = createModule();
|
||||
initModule(module[0]);
|
||||
return ApplicationManager.getApplication().runWriteAction((Computable<Module>)() -> {
|
||||
Module module = createModule();
|
||||
initModule(module);
|
||||
return module;
|
||||
});
|
||||
|
||||
return module[0];
|
||||
}
|
||||
|
||||
protected void initModule(Module module) {
|
||||
|
||||
Reference in New Issue
Block a user