Minor: refactoring
This commit is contained in:
committed by
Nikolay Krasko
parent
cf173d6963
commit
e2f1a5c092
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.renderer.render
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.CallResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
|
||||
@@ -97,7 +98,7 @@ class UsePropertyAccessSyntaxIntention : SelfTargetingOffsetIndependentIntention
|
||||
|
||||
val isSetUsage = callExpression.valueArguments.size == 1
|
||||
|
||||
if (isSetUsage && bindingContext[BindingContext.USED_AS_EXPRESSION, qualifiedExpression] == true) {
|
||||
if (isSetUsage && qualifiedExpression.isUsedAsExpression(bindingContext)) {
|
||||
// call to the setter used as expression can be converted in the only case when it's used as body expression for some declaration and its type is Unit
|
||||
val parent = qualifiedExpression.parent
|
||||
if (parent !is KtDeclarationWithBody || qualifiedExpression != parent.bodyExpression) return null
|
||||
|
||||
@@ -67,11 +67,11 @@ fun updateLibraries(
|
||||
project: Project,
|
||||
libraries: Collection<Library>) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
val kJvmConfigurator = getConfiguratorByName(KotlinJavaModuleConfigurator.NAME) as KotlinJavaModuleConfigurator?
|
||||
assert(kJvmConfigurator != null) { "Configurator with given name doesn't exists: " + KotlinJavaModuleConfigurator.NAME }
|
||||
val kJvmConfigurator = getConfiguratorByName(KotlinJavaModuleConfigurator.NAME) as KotlinJavaModuleConfigurator? ?:
|
||||
error("Configurator with given name doesn't exists: " + KotlinJavaModuleConfigurator.NAME)
|
||||
|
||||
val kJsConfigurator = getConfiguratorByName(KotlinJsModuleConfigurator.NAME) as KotlinJsModuleConfigurator?
|
||||
assert(kJsConfigurator != null) { "Configurator with given name doesn't exists: " + KotlinJsModuleConfigurator.NAME }
|
||||
val kJsConfigurator = getConfiguratorByName(KotlinJsModuleConfigurator.NAME) as KotlinJsModuleConfigurator? ?:
|
||||
error("Configurator with given name doesn't exists: " + KotlinJsModuleConfigurator.NAME)
|
||||
|
||||
for (library in libraries) {
|
||||
if (LibraryPresentationProviderUtil.isDetected(JavaRuntimePresentationProvider.getInstance(), library)) {
|
||||
@@ -79,7 +79,7 @@ fun updateLibraries(
|
||||
updateJar(project, JavaRuntimePresentationProvider.getReflectJar(library), LibraryJarDescriptor.REFLECT_JAR)
|
||||
updateJar(project, JavaRuntimePresentationProvider.getTestJar(library), LibraryJarDescriptor.TEST_JAR)
|
||||
|
||||
if (kJvmConfigurator!!.changeOldSourcesPathIfNeeded(project, library)) {
|
||||
if (kJvmConfigurator.changeOldSourcesPathIfNeeded(project, library)) {
|
||||
kJvmConfigurator.copySourcesToPathFromLibrary(project, library)
|
||||
}
|
||||
else {
|
||||
@@ -89,7 +89,7 @@ fun updateLibraries(
|
||||
else if (LibraryPresentationProviderUtil.isDetected(JSLibraryStdPresentationProvider.getInstance(), library)) {
|
||||
updateJar(project, JSLibraryStdPresentationProvider.getJsStdLibJar(library), LibraryJarDescriptor.JS_STDLIB_JAR)
|
||||
|
||||
if (kJsConfigurator!!.changeOldSourcesPathIfNeeded(project, library)) {
|
||||
if (kJsConfigurator.changeOldSourcesPathIfNeeded(project, library)) {
|
||||
kJsConfigurator.copySourcesToPathFromLibrary(project, library)
|
||||
}
|
||||
else {
|
||||
@@ -196,8 +196,8 @@ internal fun replaceFile(updatedFile: File, replacedJarFile: VirtualFile) {
|
||||
try {
|
||||
val replacedFile = getLocalFile(replacedJarFile)
|
||||
|
||||
val localPath = getLocalPath(replacedFile)
|
||||
assert(localPath != null) { "Should be called for replacing valid root file: " + replacedJarFile }
|
||||
val localPath = getLocalPath(replacedFile) ?:
|
||||
error("Should be called for replacing valid root file: $replacedJarFile")
|
||||
|
||||
val libraryJarPath = File(localPath)
|
||||
|
||||
@@ -229,13 +229,12 @@ private fun getLibraryRootsWithAbiIncompatibleVersion(
|
||||
val fileIndex = ProjectFileIndex.SERVICE.getInstance(module.project)
|
||||
|
||||
for (version in badVersions) {
|
||||
val indexedFiles = FileBasedIndex.getInstance().getContainingFiles(
|
||||
id, version, moduleWithAllDependentLibraries)
|
||||
|
||||
val indexedFiles = FileBasedIndex.getInstance().getContainingFiles(id, version, moduleWithAllDependentLibraries)
|
||||
for (indexedFile in indexedFiles) {
|
||||
val libraryRoot = fileIndex.getClassRootForFile(indexedFile)
|
||||
assert(libraryRoot != null) { "Only library roots were requested, " + "and only class files should be indexed with KotlinAbiVersionIndex key. " + "File: " + indexedFile.path }
|
||||
badRoots.add(getLocalFile(libraryRoot!!))
|
||||
val libraryRoot = fileIndex.getClassRootForFile(indexedFile) ?:
|
||||
error("Only library roots were requested, and only class files should be indexed with KotlinAbiVersionIndex key. " +
|
||||
"File: ${indexedFile.path}")
|
||||
badRoots.add(getLocalFile(libraryRoot))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user