introduce ExternalCompiler.isCompilableFile() method

This commit is contained in:
Eugene Zhuravlev
2011-02-07 17:28:01 +01:00
parent 84c5492172
commit 0a56290931
2 changed files with 18 additions and 1 deletions
@@ -19,6 +19,7 @@ import com.intellij.openapi.compiler.CompileContext;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.EnvironmentUtil;
import com.intellij.util.StringBuilderSpinAllocator;
import org.jetbrains.annotations.NonNls;
@@ -41,6 +42,18 @@ public abstract class ExternalCompiler implements BackendCompiler {
return COMPILABLE_TYPES;
}
/**
* Checks if the compiler can compile the specified file.
*
* @param file the file to check.
* @param context the context for the current compile operation.
* @return true if can compile the file, false otherwise. If the method returns false, <code>file</code>
* will not be included in the list of files passed to {@link #compile(CompileContext, com.intellij.util.Chunk < com.intellij.openapi.module.Module >,com.intellij.openapi.vfs.VirtualFile[], com.intellij.openapi.compiler.TranslatingCompiler.OutputSink)}.
*/
public boolean isCompilableFile(VirtualFile file, CompileContext context) {
return getCompilableFileTypes().contains(file.getFileType());
}
@NotNull
public Process launchProcess(@NotNull final ModuleChunk chunk, @NotNull final String outputDir, @NotNull final CompileContext compileContext) throws IOException {
final String[] commands = createStartupCommand(chunk, compileContext, outputDir);
@@ -50,7 +50,11 @@ public class JavaCompiler implements TranslatingCompiler {
}
public boolean isCompilableFile(VirtualFile file, CompileContext context) {
return getBackEndCompiler().getCompilableFileTypes().contains(file.getFileType());
final BackendCompiler backEndCompiler = getBackEndCompiler();
if (backEndCompiler instanceof ExternalCompiler) {
return ((ExternalCompiler)backEndCompiler).isCompilableFile(file, context);
}
return backEndCompiler.getCompilableFileTypes().contains(file.getFileType());
}
public void compile(CompileContext context, Chunk<Module> moduleChunk, VirtualFile[] files, OutputSink sink) {