diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt index 5ecd551b672..8cf6ff5887a 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment.kt @@ -18,6 +18,8 @@ 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.InferredAnnotationsManager import com.intellij.codeInsight.runner.JavaMainMethodProvider import com.intellij.core.CoreApplicationEnvironment import com.intellij.core.CoreJavaFileManager @@ -457,6 +459,9 @@ class KotlinCoreEnvironment private constructor( registerService(CliLightClassGenerationSupport::class.java, cliLightClassGenerationSupport) registerService(CodeAnalyzerInitializer::class.java, cliLightClassGenerationSupport) + registerService(ExternalAnnotationsManager::class.java, MockExternalAnnotationsManager()) + registerService(InferredAnnotationsManager::class.java, MockInferredAnnotationsManager()) + val area = Extensions.getArea(this) area.getExtensionPoint(PsiElementFinder.EP_NAME).registerExtension(JavaElementFinder(this, cliLightClassGenerationSupport)) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/MockExternalAnnotationsManager.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/MockExternalAnnotationsManager.kt new file mode 100644 index 00000000000..767d1fb1f4b --- /dev/null +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/MockExternalAnnotationsManager.kt @@ -0,0 +1,43 @@ +/* + * Copyright 2010-2016 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.ExternalAnnotationsManager +import com.intellij.psi.* + +class MockExternalAnnotationsManager : ExternalAnnotationsManager() { + override fun chooseAnnotationsPlace(element: PsiElement): AnnotationPlace? = null + + override fun isExternalAnnotationWritable(listOwner: PsiModifierListOwner, annotationFQN: String): Boolean = false + override fun isExternalAnnotation(annotation: PsiAnnotation): Boolean = false + + override fun findExternalAnnotationsFiles(listOwner: PsiModifierListOwner): List? = null + override fun findExternalAnnotation(listOwner: PsiModifierListOwner, annotationFQN: String): PsiAnnotation? = null + override fun findExternalAnnotations(listOwner: PsiModifierListOwner): Array? = null + + override fun annotateExternally(listOwner: PsiModifierListOwner, annotationFQName: String, fromFile: PsiFile, value: Array?) { + throw UnsupportedOperationException("not implemented") + } + + override fun deannotate(listOwner: PsiModifierListOwner, annotationFQN: String): Boolean { + throw UnsupportedOperationException("not implemented") + } + + override fun editExternalAnnotation(listOwner: PsiModifierListOwner, annotationFQN: String, value: Array?): Boolean { + throw UnsupportedOperationException("not implemented") + } +} \ No newline at end of file diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/MockInferredAnnotationsManager.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/MockInferredAnnotationsManager.kt new file mode 100644 index 00000000000..68734b8745d --- /dev/null +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/MockInferredAnnotationsManager.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2016 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.InferredAnnotationsManager +import com.intellij.psi.PsiAnnotation +import com.intellij.psi.PsiModifierListOwner + +class MockInferredAnnotationsManager : InferredAnnotationsManager() { + override fun findInferredAnnotation(listOwner: PsiModifierListOwner, annotationFQN: String): PsiAnnotation? = null + override fun ignoreInference(owner: PsiModifierListOwner, annotationFQN: String?): Boolean = true + override fun findInferredAnnotations(listOwner: PsiModifierListOwner): Array = EMPTY_PSI_ANNOTATION_ARRAY + override fun isInferredAnnotation(annotation: PsiAnnotation): Boolean = false + + companion object { + val EMPTY_PSI_ANNOTATION_ARRAY = arrayOf() + } +} \ No newline at end of file