Drop JVMConfigurationKeys.ANNOTATIONS_PATH_KEY and external annotations in CLI
CoreExternalAnnotationsManager is moved to the only usage left, which is in the test
This commit is contained in:
committed by
Dmitry Jemerov
parent
b0a4e812e5
commit
c41aefe2cb
-76
@@ -1,76 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 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.kotlin.cli.jvm.compiler;
|
||||
|
||||
import com.intellij.codeInsight.BaseExternalAnnotationsManager;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 boolean editExternalAnnotation(@NotNull PsiModifierListOwner listOwner, @NotNull String annotationFQN,
|
||||
@Nullable PsiNameValuePair[] value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnnotationPlace chooseAnnotationsPlace(@NotNull PsiElement element) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import com.google.common.collect.Sets
|
||||
import com.intellij.codeInsight.ContainerProvider
|
||||
import com.intellij.codeInsight.ExternalAnnotationsManager
|
||||
import com.intellij.codeInsight.runner.JavaMainMethodProvider
|
||||
import com.intellij.core.CoreApplicationEnvironment
|
||||
import com.intellij.core.CoreJavaFileManager
|
||||
@@ -39,7 +38,6 @@ import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.FileContextProvider
|
||||
import com.intellij.psi.PsiElementFinder
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.augment.PsiAugmentProvider
|
||||
import com.intellij.psi.compiled.ClassFileDecompilers
|
||||
import com.intellij.psi.impl.JavaClassSupersImpl
|
||||
@@ -102,8 +100,6 @@ public class KotlinCoreEnvironment private constructor(
|
||||
private val sourceFiles = ArrayList<JetFile>()
|
||||
private val javaRoots = ArrayList<JavaRoot>()
|
||||
|
||||
private val annotationsManager: CoreExternalAnnotationsManager
|
||||
|
||||
public val configuration: CompilerConfiguration = configuration.copy().let {
|
||||
it.setReadOnly(true)
|
||||
it
|
||||
@@ -111,8 +107,6 @@ public class KotlinCoreEnvironment private constructor(
|
||||
|
||||
init {
|
||||
val project = projectEnvironment.getProject()
|
||||
annotationsManager = CoreExternalAnnotationsManager(project.getComponent(javaClass<PsiManager>())!!)
|
||||
project.registerService(javaClass<ExternalAnnotationsManager>(), annotationsManager)
|
||||
project.registerService(javaClass<DeclarationProviderFactoryService>(), CliDeclarationProviderFactoryService(sourceFiles))
|
||||
project.registerService(ModuleVisibilityManager::class.java, CliModuleVisibilityManagerImpl())
|
||||
|
||||
@@ -124,9 +118,6 @@ public class KotlinCoreEnvironment private constructor(
|
||||
val index = JvmDependenciesIndex(javaRoots)
|
||||
(fileManager as KotlinCliJavaFileManagerImpl).initIndex(index)
|
||||
|
||||
for (path in configuration.getList(JVMConfigurationKeys.ANNOTATIONS_PATH_KEY)) {
|
||||
addExternalAnnotationsRoot(path)
|
||||
}
|
||||
sourceFiles.addAll(CompileEnvironmentUtil.getJetFiles(project, getSourceRootsCheckingForDuplicates(), {
|
||||
message ->
|
||||
report(ERROR, message)
|
||||
@@ -169,14 +160,6 @@ public class KotlinCoreEnvironment private constructor(
|
||||
StringUtil.getLineBreakCount(it.getText()) + (if (StringUtil.endsWithLineBreak(text)) 0 else 1)
|
||||
}
|
||||
|
||||
private fun addExternalAnnotationsRoot(path: File) {
|
||||
if (!path.exists()) {
|
||||
report(WARNING, "Annotations path entry points to a non-existent location: " + path)
|
||||
return
|
||||
}
|
||||
annotationsManager.addExternalAnnotationsRoot(PathUtil.jarFileOrDirectoryToVirtualFile(path))
|
||||
}
|
||||
|
||||
private fun fillClasspath(configuration: CompilerConfiguration) {
|
||||
for (root in configuration.getList(CommonConfigurationKeys.CONTENT_ROOTS)) {
|
||||
val javaRoot = root as? JvmContentRoot ?: continue
|
||||
|
||||
@@ -22,16 +22,12 @@ import org.jetbrains.kotlin.config.CompilerConfigurationKey;
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents;
|
||||
import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class JVMConfigurationKeys {
|
||||
private JVMConfigurationKeys() {
|
||||
}
|
||||
|
||||
public static final CompilerConfigurationKey<List<File>> ANNOTATIONS_PATH_KEY =
|
||||
CompilerConfigurationKey.create("external annotations path");
|
||||
|
||||
public static final CompilerConfigurationKey<List<AnalyzerScriptParameter>> SCRIPT_PARAMETERS =
|
||||
CompilerConfigurationKey.create("script");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user