mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
if resource patterns list changes, rescan sources and mark for compilation newly found resources
This commit is contained in:
+71
-66
@@ -932,6 +932,76 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public void scanSourcesForCompilableFiles(final Project project) {
|
||||
final int projectId = getProjectId(project);
|
||||
synchronized (myInitializationLock) {
|
||||
myInitInProgress.add(projectId);
|
||||
myInitializationLock.notifyAll();
|
||||
}
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
|
||||
public void run() {
|
||||
new Task.Backgroundable(project, CompilerBundle.message("compiler.initial.scanning.progress.text"), false) {
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
try {
|
||||
final IntermediateOutputCompiler[] compilers =
|
||||
CompilerManager.getInstance(project).getCompilers(IntermediateOutputCompiler.class);
|
||||
|
||||
final Set<VirtualFile> intermediateRoots = new HashSet<VirtualFile>();
|
||||
if (compilers.length > 0) {
|
||||
final Module[] modules = ModuleManager.getInstance(project).getModules();
|
||||
for (IntermediateOutputCompiler compiler : compilers) {
|
||||
for (Module module : modules) {
|
||||
final VirtualFile outputRoot = LocalFileSystem.getInstance().refreshAndFindFileByPath(CompilerPaths.getGenerationOutputPath(compiler, module, false));
|
||||
if (outputRoot != null) {
|
||||
intermediateRoots.add(outputRoot);
|
||||
}
|
||||
final VirtualFile testsOutputRoot = LocalFileSystem.getInstance().refreshAndFindFileByPath(CompilerPaths.getGenerationOutputPath(compiler, module, true));
|
||||
if (testsOutputRoot != null) {
|
||||
intermediateRoots.add(testsOutputRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<VirtualFile> projectRoots = Arrays.asList(ProjectRootManager.getInstance(project).getContentSourceRoots());
|
||||
final int totalRootsCount = projectRoots.size() + intermediateRoots.size();
|
||||
scanSourceContent(project, projectRoots, totalRootsCount, true);
|
||||
|
||||
if (!intermediateRoots.isEmpty()) {
|
||||
final FileProcessor processor = new FileProcessor() {
|
||||
public void execute(final VirtualFile file) {
|
||||
if (!isMarkedForRecompilation(projectId, getFileId(file))) {
|
||||
final SourceFileInfo srcInfo = loadSourceInfo(file);
|
||||
if (srcInfo == null || srcInfo.getTimestamp(projectId) != file.getTimeStamp()) {
|
||||
addSourceForRecompilation(projectId, file, srcInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
int processed = projectRoots.size();
|
||||
for (VirtualFile root : intermediateRoots) {
|
||||
indicator.setText2(root.getPresentableUrl());
|
||||
indicator.setFraction(++processed / (double)totalRootsCount);
|
||||
processRecursively(root, false, processor);
|
||||
}
|
||||
}
|
||||
|
||||
markOldOutputRoots(project, buildOutputRootsLayout(project));
|
||||
}
|
||||
finally {
|
||||
synchronized (myInitializationLock) {
|
||||
if (myInitInProgress.remove(projectId)) {
|
||||
myInitializationLock.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private class MyProjectManagerListener extends ProjectManagerAdapter {
|
||||
|
||||
final Map<Project, MessageBusConnection> myConnections = new HashMap<Project, MessageBusConnection>();
|
||||
@@ -975,72 +1045,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
});
|
||||
|
||||
final int projectId = getProjectId(project);
|
||||
synchronized (myInitializationLock) {
|
||||
myInitInProgress.add(projectId);
|
||||
myInitializationLock.notifyAll();
|
||||
}
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
|
||||
public void run() {
|
||||
new Task.Backgroundable(project, CompilerBundle.message("compiler.initial.scanning.progress.text"), false) {
|
||||
public void run(@NotNull final ProgressIndicator indicator) {
|
||||
try {
|
||||
final IntermediateOutputCompiler[] compilers =
|
||||
CompilerManager.getInstance(project).getCompilers(IntermediateOutputCompiler.class);
|
||||
|
||||
final Set<VirtualFile> intermediateRoots = new HashSet<VirtualFile>();
|
||||
if (compilers.length > 0) {
|
||||
final Module[] modules = ModuleManager.getInstance(project).getModules();
|
||||
for (IntermediateOutputCompiler compiler : compilers) {
|
||||
for (Module module : modules) {
|
||||
final VirtualFile outputRoot = LocalFileSystem.getInstance().refreshAndFindFileByPath(CompilerPaths.getGenerationOutputPath(compiler, module, false));
|
||||
if (outputRoot != null) {
|
||||
intermediateRoots.add(outputRoot);
|
||||
}
|
||||
final VirtualFile testsOutputRoot = LocalFileSystem.getInstance().refreshAndFindFileByPath(CompilerPaths.getGenerationOutputPath(compiler, module, true));
|
||||
if (testsOutputRoot != null) {
|
||||
intermediateRoots.add(testsOutputRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final List<VirtualFile> projectRoots = Arrays.asList(ProjectRootManager.getInstance(project).getContentSourceRoots());
|
||||
final int totalRootsCount = projectRoots.size() + intermediateRoots.size();
|
||||
scanSourceContent(project, projectRoots, totalRootsCount, true);
|
||||
|
||||
if (!intermediateRoots.isEmpty()) {
|
||||
final FileProcessor processor = new FileProcessor() {
|
||||
public void execute(final VirtualFile file) {
|
||||
if (!isMarkedForRecompilation(projectId, getFileId(file))) {
|
||||
final SourceFileInfo srcInfo = loadSourceInfo(file);
|
||||
if (srcInfo == null || srcInfo.getTimestamp(projectId) != file.getTimeStamp()) {
|
||||
addSourceForRecompilation(projectId, file, srcInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
int processed = projectRoots.size();
|
||||
for (VirtualFile root : intermediateRoots) {
|
||||
indicator.setText2(root.getPresentableUrl());
|
||||
indicator.setFraction(++processed / (double)totalRootsCount);
|
||||
processRecursively(root, false, processor);
|
||||
}
|
||||
}
|
||||
|
||||
markOldOutputRoots(project, buildOutputRootsLayout(project));
|
||||
}
|
||||
finally {
|
||||
synchronized (myInitializationLock) {
|
||||
if (myInitInProgress.remove(projectId)) {
|
||||
myInitializationLock.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
});
|
||||
scanSourcesForCompilableFiles(project);
|
||||
}
|
||||
|
||||
public void projectClosed(final Project project) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerConfigurationImpl;
|
||||
import com.intellij.compiler.CompilerWorkspaceConfiguration;
|
||||
import com.intellij.compiler.MalformedPatternException;
|
||||
import com.intellij.compiler.impl.TranslatingCompilerFilesMonitor;
|
||||
import com.intellij.openapi.compiler.CompilerBundle;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
@@ -87,6 +88,9 @@ public class CompilerUIConfigurable implements Configurable {
|
||||
applyResourcePatterns(extensionString, (CompilerConfigurationImpl)CompilerConfiguration.getInstance(myProject));
|
||||
|
||||
configuration.DEPLOY_AFTER_MAKE = getSelectedDeploymentOption();
|
||||
|
||||
// this will schedule for compilation all files that might become compilable after resource patterns' changing
|
||||
TranslatingCompilerFilesMonitor.getInstance().scanSourcesForCompilableFiles(myProject);
|
||||
}
|
||||
|
||||
private static void applyResourcePatterns(String extensionString, final CompilerConfigurationImpl configuration)
|
||||
|
||||
Reference in New Issue
Block a user