2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @author: Eugene Zhuravlev
22 package com
.intellij
.compiler
.impl
.javaCompiler
;
24 import com
.intellij
.compiler
.CompilerConfiguration
;
25 import com
.intellij
.compiler
.CompilerConfigurationImpl
;
26 import com
.intellij
.compiler
.CompilerException
;
27 import com
.intellij
.compiler
.make
.CacheCorruptedException
;
28 import com
.intellij
.openapi
.compiler
.*;
29 import com
.intellij
.openapi
.compiler
.ex
.CompileContextEx
;
30 import com
.intellij
.openapi
.diagnostic
.Logger
;
31 import com
.intellij
.openapi
.fileTypes
.FileTypeManager
;
32 import com
.intellij
.openapi
.fileTypes
.StdFileTypes
;
33 import com
.intellij
.openapi
.module
.Module
;
34 import com
.intellij
.openapi
.project
.Project
;
35 import com
.intellij
.openapi
.vfs
.VirtualFile
;
36 import com
.intellij
.util
.Chunk
;
37 import org
.jetbrains
.annotations
.NotNull
;
39 import java
.util
.Arrays
;
41 public class JavaCompiler
implements TranslatingCompiler
{
42 private static final Logger LOG
= Logger
.getInstance("#com.intellij.compiler.impl.javaCompiler.JavaCompiler");
43 private final Project myProject
;
44 private static final FileTypeManager FILE_TYPE_MANAGER
= FileTypeManager
.getInstance();
46 public JavaCompiler(Project project
) {
51 public String
getDescription() {
52 return CompilerBundle
.message("java.compiler.description");
55 public boolean isCompilableFile(VirtualFile file
, CompileContext context
) {
56 return FILE_TYPE_MANAGER
.getFileTypeByFile(file
).equals(StdFileTypes
.JAVA
);
59 public void compile(CompileContext context
, Chunk
<Module
> moduleChunk
, VirtualFile
[] files
, OutputSink sink
) {
60 final BackendCompiler backEndCompiler
= getBackEndCompiler();
61 final BackendCompilerWrapper wrapper
= new BackendCompilerWrapper(moduleChunk
, myProject
, Arrays
.asList(files
), (CompileContextEx
)context
, backEndCompiler
, sink
);
65 catch (CompilerException e
) {
66 context
.addMessage(CompilerMessageCategory
.ERROR
, e
.getMessage(), null, -1, -1);
69 catch (CacheCorruptedException e
) {
71 context
.requestRebuildNextTime(e
.getMessage());
75 public boolean validateConfiguration(CompileScope scope
) {
76 return getBackEndCompiler().checkCompiler(scope
);
79 private BackendCompiler
getBackEndCompiler() {
80 CompilerConfigurationImpl configuration
= (CompilerConfigurationImpl
)CompilerConfiguration
.getInstance(myProject
);
81 return configuration
.getDefaultCompiler();