use our groovy stub generator by default, give an UI option to switch to groovyc...
[fedora-idea.git] / plugins / groovy / src / org / jetbrains / plugins / groovy / compiler / GroovyCompilerLoader.java
blob5e90f1b291d125895e3194847d1f3b93a66d9bc0
1 /*
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.
16 package org.jetbrains.plugins.groovy.compiler;
18 import com.intellij.openapi.compiler.CompilerManager;
19 import com.intellij.openapi.components.AbstractProjectComponent;
20 import com.intellij.openapi.fileTypes.FileType;
21 import com.intellij.openapi.fileTypes.StdFileTypes;
22 import com.intellij.openapi.project.Project;
23 import org.jetbrains.annotations.NotNull;
24 import org.jetbrains.plugins.groovy.GroovyFileType;
25 import org.jetbrains.plugins.groovy.compiler.generator.GroovyToJavaGenerator;
26 import org.jetbrains.plugins.groovy.compiler.generator.GroovycStubGenerator;
28 import java.util.Arrays;
29 import java.util.HashSet;
31 /**
32 * @author ilyas
34 public class GroovyCompilerLoader extends AbstractProjectComponent {
36 public GroovyCompilerLoader(Project project) {
37 super(project);
40 public void projectOpened() {
41 CompilerManager compilerManager = CompilerManager.getInstance(myProject);
42 compilerManager.addCompilableFileType(GroovyFileType.GROOVY_FILE_TYPE);
44 compilerManager.addTranslatingCompiler(new GroovycStubGenerator(myProject),
45 new HashSet<FileType>(Arrays.asList(GroovyFileType.GROOVY_FILE_TYPE, StdFileTypes.JAVA)),
46 new HashSet<FileType>(Arrays.asList(StdFileTypes.JAVA)));
48 GroovyToJavaGenerator generator = new GroovyToJavaGenerator(myProject);
49 compilerManager.addCompiler(generator);
50 compilerManager.addCompilationStatusListener(generator);
52 compilerManager.addTranslatingCompiler(new GroovyCompiler(myProject),
53 new HashSet<FileType>(Arrays.asList(GroovyFileType.GROOVY_FILE_TYPE, StdFileTypes.CLASS)),
54 new HashSet<FileType>(Arrays.asList(StdFileTypes.CLASS)));
57 @NotNull
58 public String getComponentName() {
59 return "GroovyCompilerLoader";