mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
compiler configuration: distinguish compilable resources (IDEA-124599)
This commit is contained in:
@@ -53,6 +53,8 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactBySourceFileFinder;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import org.apache.oro.text.regex.*;
|
||||
@@ -978,7 +980,15 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
}
|
||||
return extensionsString.toString();
|
||||
}
|
||||
|
||||
|
||||
public boolean isCompilableResourceFile(final Project project, final VirtualFile file) {
|
||||
if (!isResourceFile(file)) {
|
||||
return false;
|
||||
}
|
||||
final Collection<? extends Artifact> artifacts = ArtifactBySourceFileFinder.getInstance(project).findArtifacts(file);
|
||||
return artifacts.isEmpty();
|
||||
}
|
||||
|
||||
private static class CompiledPattern {
|
||||
@NotNull final Pattern fileName;
|
||||
@Nullable final Pattern dir;
|
||||
|
||||
@@ -26,14 +26,11 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactBySourceFileFinder;
|
||||
import com.intellij.psi.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class CompileAction extends CompileActionBase {
|
||||
@@ -108,7 +105,8 @@ public class CompileAction extends CompileActionBase {
|
||||
else if (files.length == 1) {
|
||||
final VirtualFile file = files[0];
|
||||
FileType fileType = file.getFileType();
|
||||
if (CompilerManager.getInstance(project).isCompilableFileType(fileType) || isCompilableResourceFile(project, compilerConfiguration, file)) {
|
||||
if (CompilerManager.getInstance(project).isCompilableFileType(fileType) || compilerConfiguration
|
||||
.isCompilableResourceFile(project, file)) {
|
||||
elementDescription = "'" + file.getName() + "'";
|
||||
}
|
||||
else {
|
||||
@@ -135,7 +133,7 @@ public class CompileAction extends CompileActionBase {
|
||||
}
|
||||
|
||||
private static String createPresentationText(String elementDescription) {
|
||||
StringBuffer buffer = new StringBuffer(40);
|
||||
StringBuilder buffer = new StringBuilder(40);
|
||||
buffer.append(ActionsBundle.actionText(IdeActions.ACTION_COMPILE)).append(" ");
|
||||
int length = elementDescription.length();
|
||||
if (length > 23) {
|
||||
@@ -175,20 +173,12 @@ public class CompileAction extends CompileActionBase {
|
||||
}
|
||||
else {
|
||||
FileType fileType = file.getFileType();
|
||||
if (!(compilerManager.isCompilableFileType(fileType) || isCompilableResourceFile(project, compilerConfiguration, file))) {
|
||||
if (!(compilerManager.isCompilableFileType(fileType) || compilerConfiguration.isCompilableResourceFile(project, file))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
filesToCompile.add(file);
|
||||
}
|
||||
return VfsUtil.toVirtualFileArray(filesToCompile);
|
||||
}
|
||||
|
||||
private static boolean isCompilableResourceFile(final Project project, final CompilerConfiguration compilerConfiguration, final VirtualFile file) {
|
||||
if (!compilerConfiguration.isResourceFile(file)) {
|
||||
return false;
|
||||
}
|
||||
final Collection<? extends Artifact> artifacts = ArtifactBySourceFileFinder.getInstance(project).findArtifacts(file);
|
||||
return artifacts.isEmpty();
|
||||
return VfsUtilCore.toVirtualFileArray(filesToCompile);
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,8 @@ public abstract class CompilerConfiguration {
|
||||
|
||||
public abstract boolean isResourceFile(String path);
|
||||
|
||||
public abstract boolean isCompilableResourceFile(Project project, VirtualFile file);
|
||||
|
||||
public abstract void addResourceFilePattern(String namePattern) throws MalformedPatternException;
|
||||
|
||||
public abstract boolean isAddNotNullAssertions();
|
||||
|
||||
@@ -59,7 +59,8 @@ public class TestClassFilter implements ClassFilter.ClassFilterWithScope {
|
||||
(aClass.isInheritor(myBase, true) || JUnitUtil.isTestClass(aClass))) {
|
||||
final CompilerConfiguration compilerConfiguration = CompilerConfiguration.getInstance(getProject());
|
||||
final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(aClass);
|
||||
return !compilerConfiguration.isExcludedFromCompilation(virtualFile) && !compilerConfiguration.isResourceFile(virtualFile);
|
||||
return !compilerConfiguration.isExcludedFromCompilation(virtualFile) &&
|
||||
(!compilerConfiguration.isResourceFile(virtualFile) || compilerConfiguration.isCompilableResourceFile(myProject, virtualFile));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user