Merge remote-tracking branch 'origin/master'

This commit is contained in:
Pavel V. Talanov
2012-08-16 13:21:49 +04:00
148 changed files with 2992 additions and 3016 deletions
@@ -0,0 +1,73 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.cli.jvm.compiler;
import com.intellij.codeInsight.BaseExternalAnnotationsManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* @author Evgeny Gerashchenko
* @since 14 August 2012
*/
public class CoreExternalAnnotationsManager extends BaseExternalAnnotationsManager {
static {
// This is an ugly workaround for JDOM 1.1 used from application started from Ant 1.8 without forking
System.setProperty("javax.xml.parsers.SAXParserFactory", "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
}
private final List<VirtualFile> externalAnnotationsRoots = new ArrayList<VirtualFile>();
public CoreExternalAnnotationsManager(@NotNull PsiManager psiManager) {
super(psiManager);
}
public void addExternalAnnotationsRoot(VirtualFile externalAnnotationsRoot) {
externalAnnotationsRoots.add(externalAnnotationsRoot);
}
@Override
protected boolean hasAnyAnnotationsRoots() {
return true;
}
@NotNull
@Override
protected List<VirtualFile> getExternalAnnotationsRoots(@NotNull VirtualFile libraryFile) {
return externalAnnotationsRoots;
}
@Override
public void annotateExternally(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQName, @NotNull PsiFile fromFile,
PsiNameValuePair[] value) {
throw new UnsupportedOperationException();
}
@Override
public boolean deannotate(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN) {
throw new UnsupportedOperationException();
}
@Override
public AnnotationPlace chooseAnnotationsPlace(@NotNull PsiElement element) {
throw new UnsupportedOperationException();
}
}
@@ -16,6 +16,7 @@
package org.jetbrains.jet.cli.jvm.compiler;
import com.intellij.codeInsight.ExternalAnnotationsManager;
import com.intellij.core.CoreJavaFileManager;
import com.intellij.core.JavaCoreApplicationEnvironment;
import com.intellij.core.JavaCoreProjectEnvironment;
@@ -36,13 +37,10 @@ import org.jetbrains.jet.asJava.JavaElementFinder;
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
import org.jetbrains.jet.config.CommonConfigurationKeys;
import org.jetbrains.jet.config.CompilerConfiguration;
import org.jetbrains.jet.lang.parsing.JetParser;
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
import org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.java.JetFilesProvider;
import org.jetbrains.jet.lang.resolve.java.extAnnotations.CoreAnnotationsProvider;
import org.jetbrains.jet.lang.resolve.java.extAnnotations.ExternalAnnotationsProvider;
import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
import org.jetbrains.jet.plugin.JetFileType;
import org.jetbrains.jet.utils.PathUtil;
@@ -60,7 +58,7 @@ public class JetCoreEnvironment {
private final JavaCoreProjectEnvironment projectEnvironment;
private final List<JetFile> sourceFiles = new ArrayList<JetFile>();
private final CoreAnnotationsProvider annotationsProvider;
private final CoreExternalAnnotationsManager annotationsManager;
private final CompilerConfiguration configuration;
@@ -89,8 +87,8 @@ public class JetCoreEnvironment {
.getExtensionPoint(PsiElementFinder.EP_NAME)
.registerExtension(new JavaElementFinder(project));
annotationsProvider = new CoreAnnotationsProvider();
project.registerService(ExternalAnnotationsProvider.class, annotationsProvider);
annotationsManager = new CoreExternalAnnotationsManager(project.getComponent(PsiManager.class));
project.registerService(ExternalAnnotationsManager.class, annotationsManager);
for (File path : configuration.getList(JVMConfigurationKeys.CLASSPATH_KEY)) {
addToClasspath(path);
@@ -123,7 +121,7 @@ public class JetCoreEnvironment {
}
private void addExternalAnnotationsRoot(VirtualFile root) {
annotationsProvider.addExternalAnnotationsRoot(root);
annotationsManager.addExternalAnnotationsRoot(root);
}
private void addSources(File file) {