mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
update changed resources immediately inside IDEA process to speed up update on frame deactivation (IDEA-95060) [rev by Jeka]
This commit is contained in:
@@ -312,6 +312,18 @@ public class BuildManager implements ApplicationComponent{
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getFilesChangedSinceLastCompilation(Project project) {
|
||||
String projectPath = getProjectPath(project);
|
||||
synchronized (myProjectDataMap) {
|
||||
ProjectData data = myProjectDataMap.get(projectPath);
|
||||
if (data != null && !data.myNeedRescan) {
|
||||
return new ArrayList<String>(data.myChanged);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getProjectPath(final Project project) {
|
||||
final String url = project.getPresentableUrl();
|
||||
|
||||
@@ -322,11 +322,13 @@ public class ArtifactUtil {
|
||||
processPackagingElements(artifact, PackagingElementFactoryImpl.EXTRACTED_DIRECTORY_ELEMENT_TYPE, processor, context, processSubstitutions);
|
||||
}
|
||||
|
||||
public static Collection<Trinity<Artifact, PackagingElementPath, String>> findContainingArtifactsWithOutputPaths(@NotNull final VirtualFile file, @NotNull Project project) {
|
||||
public static Collection<Trinity<Artifact, PackagingElementPath, String>> findContainingArtifactsWithOutputPaths(@NotNull final VirtualFile file,
|
||||
@NotNull Project project,
|
||||
final Artifact[] artifacts) {
|
||||
final boolean isResourceFile = CompilerConfiguration.getInstance(project).isResourceFile(file);
|
||||
final List<Trinity<Artifact, PackagingElementPath, String>> artifacts = new ArrayList<Trinity<Artifact, PackagingElementPath, String>>();
|
||||
final List<Trinity<Artifact, PackagingElementPath, String>> result = new ArrayList<Trinity<Artifact, PackagingElementPath, String>>();
|
||||
final PackagingElementResolvingContext context = ArtifactManager.getInstance(project).getResolvingContext();
|
||||
for (final Artifact artifact : ArtifactManager.getInstance(project).getArtifacts()) {
|
||||
for (final Artifact artifact : artifacts) {
|
||||
processPackagingElements(artifact, null, new PackagingElementProcessor<PackagingElement<?>>() {
|
||||
@Override
|
||||
public boolean process(@NotNull PackagingElement<?> element, @NotNull PackagingElementPath path) {
|
||||
@@ -340,14 +342,14 @@ public class ArtifactUtil {
|
||||
else {
|
||||
relativePath = VfsUtilCore.getRelativePath(file, root, '/');
|
||||
}
|
||||
artifacts.add(Trinity.create(artifact, path, relativePath));
|
||||
result.add(Trinity.create(artifact, path, relativePath));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (isResourceFile && element instanceof ModuleOutputPackagingElement) {
|
||||
final String relativePath = getRelativePathInSources(file, (ModuleOutputPackagingElement)element, context);
|
||||
if (relativePath != null) {
|
||||
artifacts.add(Trinity.create(artifact, path, relativePath));
|
||||
result.add(Trinity.create(artifact, path, relativePath));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -355,7 +357,7 @@ public class ArtifactUtil {
|
||||
}
|
||||
}, context, true);
|
||||
}
|
||||
return artifacts;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+5
-33
@@ -3,21 +3,12 @@
|
||||
*/
|
||||
package com.intellij.packaging.impl.ui.actions;
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.compiler.CompilerManager;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
@@ -26,11 +17,11 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.artifacts.ArtifactManager;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactBySourceFileFinder;
|
||||
import com.intellij.util.text.SyncDateFormat;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -90,29 +81,10 @@ public class PackageFileAction extends AnAction {
|
||||
|
||||
FileDocumentManager.getInstance().saveAllDocuments();
|
||||
final List<VirtualFile> files = getFilesToPackage(event, project);
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Packaging Files") {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
for (final VirtualFile file : files) {
|
||||
indicator.checkCanceled();
|
||||
new ReadAction() {
|
||||
protected void run(final Result result) {
|
||||
try {
|
||||
PackageFileWorker.packageFile(file, project);
|
||||
}
|
||||
catch (IOException e) {
|
||||
Notifications.Bus.notify(
|
||||
new Notification("Package File", "Cannot package file", CompilerBundle.message("message.tect.package.file.io.error", e.toString()),
|
||||
NotificationType.ERROR));
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
setStatusText(project, files);
|
||||
}
|
||||
});
|
||||
Artifact[] allArtifacts = ArtifactManager.getInstance(project).getArtifacts();
|
||||
PackageFileWorker.startPackagingFiles(project, files, allArtifacts, new Runnable() {
|
||||
public void run() {
|
||||
setStatusText(project, files);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+40
-2
@@ -15,8 +15,18 @@
|
||||
*/
|
||||
package com.intellij.packaging.impl.ui.actions;
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ReadAction;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.deployment.DeploymentUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -54,9 +64,37 @@ public class PackageFileWorker {
|
||||
myRelativeOutputPath = relativeOutputPath;
|
||||
}
|
||||
|
||||
public static void packageFile(@NotNull VirtualFile file, @NotNull Project project) throws IOException {
|
||||
public static void startPackagingFiles(final Project project, final List<VirtualFile> files,
|
||||
final Artifact[] artifacts, final Runnable onFinished) {
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Packaging Files") {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
for (final VirtualFile file : files) {
|
||||
indicator.checkCanceled();
|
||||
new ReadAction() {
|
||||
protected void run(final Result result) {
|
||||
try {
|
||||
packageFile(file, project, artifacts);
|
||||
}
|
||||
catch (IOException e) {
|
||||
String message = CompilerBundle.message("message.tect.package.file.io.error", e.toString());
|
||||
Notifications.Bus.notify(new Notification("Package File", "Cannot package file", message, NotificationType.ERROR));
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
ApplicationManager.getApplication().invokeLater(onFinished);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void packageFile(@NotNull VirtualFile file, @NotNull Project project, final Artifact[] artifacts) throws IOException {
|
||||
LOG.debug("Start packaging file: " + file.getPath());
|
||||
final Collection<Trinity<Artifact, PackagingElementPath, String>> items = ArtifactUtil.findContainingArtifactsWithOutputPaths(file, project);
|
||||
final Collection<Trinity<Artifact, PackagingElementPath, String>> items = ArtifactUtil.findContainingArtifactsWithOutputPaths(file, project, artifacts);
|
||||
File ioFile = VfsUtil.virtualToIoFile(file);
|
||||
for (Trinity<Artifact, PackagingElementPath, String> item : items) {
|
||||
final Artifact artifact = item.getFirst();
|
||||
|
||||
Reference in New Issue
Block a user