Fix a number of compiler/IDE warnings in IDE and kapt modules

This commit is contained in:
Yan Zhulanow
2019-08-07 16:45:20 +09:00
parent 9fb622e148
commit f93549748a
22 changed files with 98 additions and 58 deletions
@@ -22,6 +22,7 @@ interface BuildSystemTypeDetector {
}
fun Module.getBuildSystemType(): BuildSystemType {
@Suppress("DEPRECATION")
for (extension in Extensions.getExtensions(BuildSystemTypeDetector.EP_NAME)) {
val result = extension.detectBuildSystemType(this)
if (result != null) {
@@ -31,15 +31,18 @@ abstract class AfterAnalysisHighlightingVisitor protected constructor(
holder: AnnotationHolder, protected var bindingContext: BindingContext
) : HighlightingVisitor(holder) {
protected fun attributeKeyForDeclarationFromExtensions(element: PsiElement, descriptor: DeclarationDescriptor) =
Extensions.getExtensions(HighlighterExtension.EP_NAME).firstNotNullResult { extension ->
protected fun attributeKeyForDeclarationFromExtensions(element: PsiElement, descriptor: DeclarationDescriptor): TextAttributesKey? {
@Suppress("DEPRECATION")
return Extensions.getExtensions(HighlighterExtension.EP_NAME).firstNotNullResult { extension ->
extension.highlightDeclaration(element, descriptor)
}
}
protected fun attributeKeyForCallFromExtensions(
expression: KtSimpleNameExpression,
resolvedCall: ResolvedCall<out CallableDescriptor>
): TextAttributesKey? {
@Suppress("DEPRECATION")
return Extensions.getExtensions(HighlighterExtension.EP_NAME).firstNotNullResult { extension ->
extension.highlightCall(expression, resolvedCall)
}
@@ -77,7 +77,10 @@ internal class FunctionsHighlightingVisitor(holder: AnnotationHolder, bindingCon
private fun highlightCall(callee: PsiElement, resolvedCall: ResolvedCall<out CallableDescriptor>) {
val calleeDescriptor = resolvedCall.resultingDescriptor
val key = Extensions.getExtensions(HighlighterExtension.EP_NAME).firstNotNullResult { extension ->
@Suppress("DEPRECATION")
val extensions = Extensions.getExtensions(HighlighterExtension.EP_NAME)
val key = extensions.firstNotNullResult { extension ->
extension.highlightCall(callee, resolvedCall)
} ?: when {
calleeDescriptor.fqNameOrNull() == KOTLIN_SUSPEND_BUILT_IN_FUNCTION_FQ_NAME -> KEYWORD
@@ -42,6 +42,7 @@ internal class PropertiesHighlightingVisitor(holder: AnnotationHolder, bindingCo
val resolvedCall = expression.getResolvedCall(bindingContext)
val attributesKey = resolvedCall?.let { call ->
@Suppress("DEPRECATION")
Extensions.getExtensions(HighlighterExtension.EP_NAME).firstNotNullResult { extension ->
extension.highlightCall(expression, call)
}
@@ -29,6 +29,7 @@ class QuickFixes {
private val actions: Multimap<DiagnosticFactory<*>, IntentionAction> = HashMultimap.create<DiagnosticFactory<*>, IntentionAction>()
init {
@Suppress("DEPRECATION")
Extensions.getExtensions(QuickFixContributor.EP_NAME).forEach { it.registerQuickFixes(this) }
}
@@ -75,7 +75,10 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
}
private fun PsiFile.isConfiguredByAnyGradleConfigurator(): Boolean {
return Extensions.getExtensions(KotlinProjectConfigurator.EP_NAME)
@Suppress("DEPRECATION")
val extensions = Extensions.getExtensions(KotlinProjectConfigurator.EP_NAME)
return extensions
.filterIsInstance<KotlinWithGradleConfigurator>()
.any { it.isFileConfigured(this) }
}
@@ -52,7 +52,10 @@ fun DataNode<*>.getResolvedVersionByModuleData(groupId: String, libraryIds: List
}
fun getDependencyModules(moduleData: DataNode<ModuleData>, gradleIdeaProject: IdeaProject): Collection<DataNode<ModuleData>> {
for (modelFacade in Extensions.getExtensions(KotlinGradleModelFacade.EP_NAME)) {
@Suppress("DEPRECATION")
val extensions = Extensions.getExtensions(KotlinGradleModelFacade.EP_NAME)
for (modelFacade in extensions) {
val dependencies = modelFacade.getDependencyModules(moduleData, gradleIdeaProject)
if (dependencies.isNotEmpty()) {
return dependencies
@@ -61,9 +64,10 @@ fun getDependencyModules(moduleData: DataNode<ModuleData>, gradleIdeaProject: Id
return emptyList()
}
// Removing the 'gradleIdeaProject' parameter, removing it breaks importer for some reason
fun findModulesByNames(
dependencyModuleNames: Set<String>,
gradleIdeaProject: IdeaProject,
@Suppress("UNUSED_PARAMETER") gradleIdeaProject: IdeaProject,
ideProject: DataNode<ProjectData>
): LinkedHashSet<DataNode<ModuleData>> {
val modules = ExternalSystemApiUtil.getChildren(ideProject, ProjectKeys.MODULE)
@@ -180,7 +180,10 @@ fun getConfiguratorByName(name: String): KotlinProjectConfigurator? {
return allConfigurators().firstOrNull { it.name == name }
}
fun allConfigurators() = Extensions.getExtensions(KotlinProjectConfigurator.EP_NAME)
fun allConfigurators(): Array<KotlinProjectConfigurator> {
@Suppress("DEPRECATION")
return Extensions.getExtensions(KotlinProjectConfigurator.EP_NAME)
}
fun getCanBeConfiguredModules(project: Project, configurator: KotlinProjectConfigurator): List<Module> {
return ModuleSourceRootMap(project).groupByBaseModules(project.allModules())
@@ -224,6 +227,7 @@ fun getConfigurationPossibilitiesForConfigureNotification(
runnableConfigurators.add(configurator)
}
ConfigureKotlinStatus.CONFIGURED -> moduleAlreadyConfigured = true
else -> {}
}
}
if (moduleCanBeConfigured && !moduleAlreadyConfigured && !SuppressNotificationState.isKotlinNotConfiguredSuppressed(
@@ -271,7 +275,7 @@ fun hasKotlinCommonRuntimeInScope(scope: GlobalSearchScope): Boolean {
class LibraryKindSearchScope(
val module: Module,
val baseScope: GlobalSearchScope,
baseScope: GlobalSearchScope,
val libraryKind: PersistentLibraryKind<*>
) : DelegatingGlobalSearchScope(baseScope) {
override fun contains(file: VirtualFile): Boolean {
@@ -28,7 +28,6 @@ import com.intellij.openapi.roots.OrderRootType
import com.intellij.openapi.roots.impl.libraries.LibraryEx
import com.intellij.openapi.roots.libraries.Library
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JvmCompilerArgumentsHolder
import org.jetbrains.kotlin.idea.facet.getOrCreateFacet
import org.jetbrains.kotlin.idea.facet.initializeIfNeeded
@@ -39,7 +38,6 @@ import org.jetbrains.kotlin.idea.util.projectStructure.allModules
import org.jetbrains.kotlin.idea.util.projectStructure.sdk
import org.jetbrains.kotlin.idea.util.projectStructure.version
import org.jetbrains.kotlin.idea.versions.LibraryJarDescriptor
import org.jetbrains.kotlin.platform.impl.JvmIdePlatformKind
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
@@ -73,11 +71,11 @@ open class KotlinJavaModuleConfigurator protected constructor() : KotlinWithLibr
override val targetPlatform: TargetPlatform
get() = JvmPlatforms.unspecifiedJvmPlatform
@Suppress("DEPRECATION_ERROR")
@Suppress("DEPRECATION_ERROR", "OverridingDeprecatedMember")
override fun getTargetPlatform() = JvmPlatforms.CompatJvmPlatform
override fun getLibraryJarDescriptors(sdk: Sdk?): List<LibraryJarDescriptor> {
var result = listOf(
val result = mutableListOf(
LibraryJarDescriptor.RUNTIME_JAR,
LibraryJarDescriptor.RUNTIME_SRC_JAR,
LibraryJarDescriptor.REFLECT_JAR,
@@ -142,7 +140,10 @@ open class KotlinJavaModuleConfigurator protected constructor() : KotlinWithLibr
const val NAME = "java"
val instance: KotlinJavaModuleConfigurator
get() = Extensions.findExtension(KotlinProjectConfigurator.EP_NAME, KotlinJavaModuleConfigurator::class.java)
get() {
@Suppress("DEPRECATION")
return Extensions.findExtension(KotlinProjectConfigurator.EP_NAME, KotlinJavaModuleConfigurator::class.java)
}
}
private fun hasBrokenJsRuntime(module: Module): Boolean {
@@ -50,6 +50,7 @@ class JSLibraryType : LibraryType<DummyLibraryProperties>(JSLibraryKind) {
override fun getIcon(properties: DummyLibraryProperties?) = KotlinIcons.JS
companion object {
@Suppress("DEPRECATION")
fun getInstance() = Extensions.findExtension(EP_NAME, JSLibraryType::class.java)
}
@@ -56,6 +56,8 @@ class KotlinTemplatesFactory : ProjectTemplatesFactory() {
)
)
)
@Suppress("DEPRECATION")
result.addAll(Extensions.getExtensions(EP_NAME).map { BuilderBasedTemplate(it) })
return result.toTypedArray()
}
@@ -190,7 +190,10 @@ internal fun findProblem(
internal fun getQualifiedNameFromProviders(element: PsiElement): String? {
DumbService.getInstance(element.project).isAlternativeResolveEnabled = true
try {
for (provider in Extensions.getExtensions(QualifiedNameProvider.EP_NAME)) {
@Suppress("DEPRECATION")
val extensions = Extensions.getExtensions(QualifiedNameProvider.EP_NAME)
for (provider in extensions) {
val result = provider.getQualifiedName(element)
if (result != null) return result
}
@@ -25,7 +25,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiReference
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.searches.ReferencesSearch
import com.intellij.xdebugger.impl.XDebugSessionImpl
import com.intellij.xdebugger.impl.XDebuggerManagerImpl
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.idea.debugger.DebuggerClassNameProvider.Companion.getRelevantElement
@@ -75,7 +75,7 @@ class InlineCallableUsagesSearcher(private val myDebugProcess: DebugProcess) {
}
if (!isSuccess) {
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(
XDebuggerManagerImpl.NOTIFICATION_GROUP.createNotification(
"Debugger can skip some executions of $declarationName because the computation of class names was interrupted",
MessageType.WARNING
).notify(myDebugProcess.project)
@@ -26,15 +26,12 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.psi.*;
import com.intellij.psi.search.GlobalSearchScope;
import kotlin.Unit;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.core.util.DescriptorMemberChooserObject;
import org.jetbrains.kotlin.idea.core.util.UiUtilsKt;
import org.jetbrains.kotlin.psi.KtProperty;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
public abstract class AddFieldBreakpointDialog extends DialogWrapper {
@@ -60,43 +57,41 @@ public abstract class AddFieldBreakpointDialog extends DialogWrapper {
}
);
myClassChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PsiClass currentClass = getSelectedClass();
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createAllProjectScopeChooser(
DebuggerBundle.message("add.field.breakpoint.dialog.classchooser.title"));
if (currentClass != null) {
PsiFile containingFile = currentClass.getContainingFile();
if (containingFile != null) {
PsiDirectory containingDirectory = containingFile.getContainingDirectory();
if (containingDirectory != null) {
chooser.selectDirectory(containingDirectory);
}
myClassChooser.addActionListener(e -> {
PsiClass currentClass = getSelectedClass();
TreeClassChooser chooser = TreeClassChooserFactory.getInstance(myProject).createAllProjectScopeChooser(
DebuggerBundle.message("add.field.breakpoint.dialog.classchooser.title"));
if (currentClass != null) {
PsiFile containingFile = currentClass.getContainingFile();
if (containingFile != null) {
PsiDirectory containingDirectory = containingFile.getContainingDirectory();
if (containingDirectory != null) {
chooser.selectDirectory(containingDirectory);
}
}
chooser.showDialog();
PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
myClassChooser.setText(selectedClass.getQualifiedName());
}
}
chooser.showDialog();
PsiClass selectedClass = chooser.getSelected();
if (selectedClass != null) {
myClassChooser.setText(selectedClass.getQualifiedName());
}
});
myFieldChooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(@NotNull ActionEvent e) {
PsiClass selectedClass = getSelectedClass();
DescriptorMemberChooserObject[] properties = FieldBreakpointDialogUtilKt.collectProperties(selectedClass);
MemberChooser<DescriptorMemberChooserObject> chooser = new MemberChooser<DescriptorMemberChooserObject>(properties, false, false, myProject);
chooser.setTitle(DebuggerBundle.message("add.field.breakpoint.dialog.field.chooser.title", properties.length));
chooser.setCopyJavadocVisible(false);
chooser.show();
List<DescriptorMemberChooserObject> selectedElements = chooser.getSelectedElements();
if (selectedElements != null && selectedElements.size() == 1) {
KtProperty field = (KtProperty) selectedElements.get(0).getElement();
myFieldChooser.setText(field.getName());
}
myFieldChooser.addActionListener(e -> {
PsiClass selectedClass = getSelectedClass();
if (selectedClass == null) {
return;
}
DescriptorMemberChooserObject[] properties = FieldBreakpointDialogUtilKt.collectProperties(selectedClass);
MemberChooser<DescriptorMemberChooserObject> chooser = new MemberChooser<>(properties, false, false, myProject);
chooser.setTitle(DebuggerBundle.message("add.field.breakpoint.dialog.field.chooser.title", properties.length));
chooser.setCopyJavadocVisible(false);
chooser.show();
List<DescriptorMemberChooserObject> selectedElements = chooser.getSelectedElements();
if (selectedElements != null && selectedElements.size() == 1) {
KtProperty field = (KtProperty) selectedElements.get(0).getElement();
myFieldChooser.setText(field.getName());
}
});
myFieldChooser.setEnabled(false);
@@ -111,7 +106,7 @@ public abstract class AddFieldBreakpointDialog extends DialogWrapper {
private PsiClass getSelectedClass() {
PsiManager psiManager = PsiManager.getInstance(myProject);
String classQName = myClassChooser.getText();
if (classQName == null || classQName.isEmpty()) {
if (classQName.isEmpty()) {
return null;
}
return JavaPsiFacade.getInstance(psiManager.getProject()).findClass(classQName, GlobalSearchScope.allScope(myProject));
@@ -179,6 +179,7 @@ public class DebuggerSteppingHelper {
}
}
}
//noinspection deprecation
for (DebuggerClassFilterProvider provider : Extensions.getExtensions(DebuggerClassFilterProvider.EP_NAME)) {
for (ClassFilter filter : provider.getFilters()) {
if (filter.isEnabled()) {
@@ -31,7 +31,11 @@ class KotlinRenameDispatcherHandler : RenameHandler {
companion object {
val EP_NAME = ExtensionPointName<RenameHandler>("org.jetbrains.kotlin.renameHandler")
private val handlers: Array<out RenameHandler> get() = Extensions.getExtensions(EP_NAME)
private val handlers: Array<out RenameHandler>
get() {
@Suppress("DEPRECATION")
return Extensions.getExtensions(EP_NAME)
}
}
internal fun getRenameHandler(dataContext: DataContext): RenameHandler? {
@@ -162,7 +162,9 @@ abstract class AbstractFindUsagesTest : KotlinLightCodeInsightFixtureTestCase()
return UsageType.COMMENT_USAGE
}
@Suppress("DEPRECATION")
val providers = Extensions.getExtensions(UsageTypeProvider.EP_NAME)
return providers
.mapNotNull {
it.getUsageType(element)
@@ -67,7 +67,9 @@ class InspectionDescriptionTest : LightPlatformTestCase() {
fun testExtensionPoints() {
val shortNames = THashMap<String, LocalInspectionEP>()
@Suppress("DEPRECATION")
val inspectionEPs = Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION)
val tools = inspectionEPs.size
val errors = StringBuilder()
for (ep in inspectionEPs) {
@@ -66,11 +66,17 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest
private fun enableInspectionTools(klass: Class<*>) {
val eps = ContainerUtil.newArrayList<InspectionEP>()
ContainerUtil.addAll(eps, *Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION))
ContainerUtil.addAll(eps, *Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION))
ContainerUtil.addAll<InspectionEP, LocalInspectionEP, List<InspectionEP>>(
eps,
*(@Suppress("DEPRECATION") Extensions.getExtensions(LocalInspectionEP.LOCAL_INSPECTION))
)
ContainerUtil.addAll<InspectionEP, InspectionEP, List<InspectionEP>>(
eps,
*(@Suppress("DEPRECATION") Extensions.getExtensions(InspectionEP.GLOBAL_INSPECTION))
)
val tool = eps.firstOrNull { it.implementationClass == klass.name }?.instantiateTool()
?: error("Could not find inspection tool for class: $klass")
?: error("Could not find inspection tool for class: $klass")
myFixture.enableInspections(tool)
}
@@ -47,7 +47,10 @@ abstract class AbstractInlineTest : KotlinLightCodeInsightFixtureTestCase() {
val afterFileExists = afterFile.exists()
val targetElement = TargetElementUtil.findTargetElement(myFixture.editor, ELEMENT_NAME_ACCEPTED or REFERENCED_ELEMENT_ACCEPTED)!!
@Suppress("DEPRECATION")
val handler = Extensions.getExtensions(InlineActionHandler.EP_NAME).firstOrNull { it.canInlineElement(targetElement) }
val expectedErrors = InTextDirectivesUtils.findLinesWithPrefixesRemoved(myFixture.file.text, "// ERROR: ")
if (handler != null) {
try {
@@ -416,10 +416,11 @@ fun runRenameProcessor(
val processor = createProcessor()
if (renameParamsObject["overloadRenamer.onlyPrimaryElement"]?.asBoolean ?: false) {
if (renameParamsObject["overloadRenamer.onlyPrimaryElement"]?.asBoolean == true) {
with(AutomaticOverloadsRenamer) { substitution.elementFilter = { false } }
}
if (processor is RenameProcessor) {
@Suppress("DEPRECATION")
Extensions.getExtensions(AutomaticRenamerFactory.EP_NAME).forEach { processor.addRenamerFactory(it) }
}
processor.run()
-1
View File
@@ -31,7 +31,6 @@ fun main(args: Array<String>) {
if (messageCollector.hasErrors()) {
exitProcess(ExitCode.COMPILATION_ERROR.code)
return
}
K2JVMCompiler.main(kaptTransformed.toTypedArray())