Cleanup: fix some compiler warnings (mostly deprecations, javaClass)
This commit is contained in:
@@ -34,14 +34,14 @@ fun OutputFileCollection.writeAll(outputDir: File, report: (file: OutputFile, so
|
||||
}
|
||||
}
|
||||
|
||||
private val REPORT_NOTHING = { file: OutputFile, sources: List<File>, output: File -> }
|
||||
private val REPORT_NOTHING: (OutputFile, List<File>, File) -> Unit = { _, _, _ -> }
|
||||
|
||||
fun OutputFileCollection.writeAllTo(outputDir: File) {
|
||||
writeAll(outputDir, REPORT_NOTHING)
|
||||
}
|
||||
|
||||
fun OutputFileCollection.writeAll(outputDir: File, messageCollector: MessageCollector) {
|
||||
writeAll(outputDir) { file, sources, output ->
|
||||
writeAll(outputDir) { _, sources, output ->
|
||||
messageCollector.report(CompilerMessageSeverity.OUTPUT, OutputMessageUtil.formatOutputMessage(sources, output), CompilerMessageLocation.NO_LOCATION)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ object PluginCliParser {
|
||||
?.map { File(it).toURI().toURL() }
|
||||
?.toTypedArray()
|
||||
?: arrayOf<URL>(),
|
||||
javaClass.classLoader
|
||||
this::class.java.classLoader
|
||||
)
|
||||
|
||||
val componentRegistrars = ServiceLoader.load(ComponentRegistrar::class.java, classLoader).toMutableList()
|
||||
|
||||
+1
-2
@@ -44,7 +44,6 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice
|
||||
import org.jetbrains.kotlin.utils.emptyOrSingletonList
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
@@ -147,7 +146,7 @@ class CliLightClassGenerationSupport(project: Project) : LightClassGenerationSup
|
||||
val filesForFacade = findFilesForFacade(facadeFqName, scope)
|
||||
if (filesForFacade.isEmpty()) return emptyList()
|
||||
|
||||
return emptyOrSingletonList<PsiClass>(
|
||||
return listOfNotNull<PsiClass>(
|
||||
KtLightClassForFacade.createForFacade(psiManager, facadeFqName, scope, filesForFacade))
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.MetadataPackageFragment
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import java.io.InputStream
|
||||
|
||||
class CliVirtualFileFinder(
|
||||
@@ -61,6 +60,6 @@ class CliVirtualFileFinder(
|
||||
|
||||
private fun findBinaryClass(classId: ClassId, fileName: String): VirtualFile? =
|
||||
index.findClass(classId, acceptedRootTypes = JavaRoot.OnlyBinary) { dir, _ ->
|
||||
dir.findChild(fileName)?.check(VirtualFile::isValid)
|
||||
}?.check { it in scope }
|
||||
dir.findChild(fileName)?.takeIf(VirtualFile::isValid)
|
||||
}?.takeIf { it in scope }
|
||||
}
|
||||
|
||||
+3
-7
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.jvm.KotlinCliJavaFileManager
|
||||
import org.jetbrains.kotlin.util.PerformanceCounter
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
import java.util.*
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
@@ -50,7 +49,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
|
||||
val classNameWithInnerClasses = classId.relativeClassName.asString()
|
||||
index.findClass(classId) { dir, type ->
|
||||
findClassGivenPackage(allScope, dir, classNameWithInnerClasses, type)
|
||||
}?.check { it.containingFile.virtualFile in searchScope }
|
||||
}?.takeIf { it.containingFile.virtualFile in searchScope }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +87,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
|
||||
override fun findPackage(packageName: String): PsiPackage? {
|
||||
var found = false
|
||||
val packageFqName = packageName.toSafeFqName() ?: return null
|
||||
index.traverseDirectoriesInPackage(packageFqName) { dir, rootType ->
|
||||
index.traverseDirectoriesInPackage(packageFqName) { _, _ ->
|
||||
found = true
|
||||
//abort on first found
|
||||
false
|
||||
@@ -149,10 +148,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
|
||||
var curClass = topLevelClass
|
||||
while (segments.hasNext()) {
|
||||
val innerClassName = segments.next()
|
||||
val innerClass = curClass.findInnerClassByName(innerClassName, false)
|
||||
if (innerClass == null) {
|
||||
return null
|
||||
}
|
||||
val innerClass = curClass.findInnerClassByName(innerClassName, false) ?: return null
|
||||
curClass = innerClass
|
||||
}
|
||||
return curClass
|
||||
|
||||
@@ -93,7 +93,7 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>): JvmDependenciesIndex {
|
||||
): Set<String> {
|
||||
val result = hashSetOf<String>()
|
||||
traverseDirectoriesInPackage(packageFqName, continueSearch = {
|
||||
dir, rootType ->
|
||||
dir, _ ->
|
||||
|
||||
for (child in dir.children) {
|
||||
if (child.extension != "class" && child.extension != "java") continue
|
||||
|
||||
@@ -73,7 +73,7 @@ open class GenericReplCompiler(disposable: Disposable,
|
||||
val scriptDescriptor = when (analysisResult) {
|
||||
is ReplCodeAnalyzer.ReplLineAnalysisResult.WithErrors -> return ReplCompileResult.Error(errorHolder.renderedDiagnostics)
|
||||
is ReplCodeAnalyzer.ReplLineAnalysisResult.Successful -> analysisResult.scriptDescriptor
|
||||
else -> error("Unexpected result ${analysisResult.javaClass}")
|
||||
else -> error("Unexpected result ${analysisResult::class.java}")
|
||||
}
|
||||
|
||||
val generationState = GenerationState(
|
||||
|
||||
@@ -103,7 +103,7 @@ class ReplInterpreter(
|
||||
val scriptDescriptor = when (analysisResult) {
|
||||
is ReplCodeAnalyzer.ReplLineAnalysisResult.WithErrors -> return LineResult.Error.CompileTime(errorHolder.renderedDiagnostics)
|
||||
is ReplCodeAnalyzer.ReplLineAnalysisResult.Successful -> analysisResult.scriptDescriptor
|
||||
else -> error("Unexpected result ${analysisResult.javaClass}")
|
||||
else -> error("Unexpected result ${analysisResult::class.java}")
|
||||
}
|
||||
|
||||
val state = GenerationState(
|
||||
@@ -185,7 +185,7 @@ class ReplInterpreter(
|
||||
private fun renderStackTrace(cause: Throwable, startFromMethodName: String): String {
|
||||
val newTrace = arrayListOf<StackTraceElement>()
|
||||
var skip = true
|
||||
for ((_, element) in cause.stackTrace.withIndex().reversed()) {
|
||||
for (element in cause.stackTrace.reversed()) {
|
||||
if ("${element.className}.${element.methodName}" == startFromMethodName) {
|
||||
skip = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user