Fix source compatibility with 183 platform

This commit is contained in:
Vyacheslav Gerasimov
2018-08-02 22:44:33 +03:00
parent 57963d2e03
commit c7a00971fe
11 changed files with 44 additions and 49 deletions
@@ -74,7 +74,7 @@ class ExtensionFunctionTypeValueCompletion(
}
}
override fun handleInsert(context: InsertionContext?) {
override fun handleInsert(context: InsertionContext) {
insertHandler.handleInsert(context, this)
}
}
@@ -16,7 +16,6 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.ScrollType
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.util.ProgressWindow
import com.intellij.openapi.progress.util.ProgressWindowWithNotification
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.TextRange
import org.jetbrains.kotlin.idea.KotlinBundle
@@ -176,7 +176,7 @@ class PomFile private constructor(private val xmlFile: XmlFile, val domModel: Ma
// rearrange
val referenceElement = referencePlugin.xmlElement!!
val newElement = referenceElement.parent.addAfter(plugin.xmlElement!!, referenceElement)
plugin.xmlTag.delete()
plugin.xmlTag?.delete()
return domModel.build.plugins.plugins.single { it.xmlElement == newElement }
}
@@ -203,7 +203,7 @@ class PomFile private constructor(private val xmlFile: XmlFile, val domModel: Ma
val existingGoals = execution.goals.goals.mapNotNull { it.rawText }
for (goal in goals.filter { it !in existingGoals }) {
val goalTag = execution.goals.ensureTagExists().createChildTag("goal", goal)
execution.goals.xmlTag.add(goalTag)
execution.goals.xmlTag?.add(goalTag)
}
return execution
@@ -301,20 +301,22 @@ class PomFile private constructor(private val xmlFile: XmlFile, val domModel: Ma
execution.configuration.xmlTag?.findSubTags("sourceDirs")?.forEach { it.deleteCascade() }
} else {
val sourceDirsTag = executionConfiguration(execution, "sourceDirs")
val newSourceDirsTag = execution.configuration.createChildTag("sourceDirs")
for (dir in sourceDirs) {
newSourceDirsTag.add(newSourceDirsTag.createChildTag("source", dir))
execution.configuration.createChildTag("sourceDirs")?.let { newSourceDirsTag ->
for (dir in sourceDirs) {
newSourceDirsTag.add(newSourceDirsTag.createChildTag("source", dir))
}
sourceDirsTag.replace(newSourceDirsTag)
}
sourceDirsTag.replace(newSourceDirsTag)
}
}
fun executionSourceDirs(execution: MavenDomPluginExecution): List<String> {
return execution.configuration.xmlTag
.getChildrenOfType<XmlTag>().firstOrNull { it.localName == "sourceDirs" }
?.getChildrenOfType<XmlTag>()
?.firstOrNull { it.localName == "sourceDirs" }
?.getChildrenOfType<XmlTag>()
?.map { it.getChildrenOfType<XmlText>().joinToString("") { it.text } }
?: emptyList()
?: emptyList()
}
private fun executionConfiguration(execution: MavenDomPluginExecution, name: String): XmlTag {
@@ -439,7 +441,7 @@ class PomFile private constructor(private val xmlFile: XmlFile, val domModel: Ma
null
)
private fun MavenDomElement.createChildTag(name: String, value: String? = null) = xmlTag.createChildTag(name, value)
private fun MavenDomElement.createChildTag(name: String, value: String? = null) = xmlTag?.createChildTag(name, value)
private fun XmlTag.createChildTag(name: String, value: String? = null) = createChildTag(name, namespace, value, false)!!
private tailrec fun XmlTag.deleteCascade() {
@@ -667,7 +669,7 @@ private fun PomFile.changeConfigurationOrProperty(
): XmlTag? {
val configuration = kotlinPlugin.configuration
if (configuration.exists()) {
val subTag = configuration.xmlTag.findFirstSubTag(configurationTagName)
val subTag = configuration.xmlTag?.findFirstSubTag(configurationTagName)
if (subTag != null) {
subTag.value.text = value
return subTag
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
class SearchNotPropertyCandidatesAction : AnAction() {
override fun actionPerformed(e: AnActionEvent?) {
override fun actionPerformed(e: AnActionEvent) {
val project = e?.project!!
val psiFile = e.getData(CommonDataKeys.PSI_FILE) as? KtFile ?: return
@@ -55,8 +55,8 @@ import javax.swing.JFileChooser
import javax.swing.JPanel
abstract class AbstractCompletionBenchmarkAction : AnAction() {
override fun actionPerformed(e: AnActionEvent?) {
val project = e?.project ?: return
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val benchmarkSink = CompletionBenchmarkSink.enableAndGet()
val scenario = createBenchmarkScenario(project, benchmarkSink) ?: return
@@ -46,8 +46,8 @@ import javax.swing.JFileChooser
import kotlin.properties.Delegates
class HighlightingBenchmarkAction : AnAction() {
override fun actionPerformed(e: AnActionEvent?) {
val project = e?.project ?: return
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return
val settings = showSettingsDialog() ?: return
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.idea.actions.internal.benchmark
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.DialogBuilder
import com.intellij.psi.PsiWhiteSpace
@@ -66,7 +67,6 @@ class TopLevelCompletionBenchmarkAction : AbstractCompletionBenchmarkAction() {
return TopLevelCompletionBenchmarkScenario(ktFiles, settings, project, benchmarkSink, random)
}
data class Settings(val seed: Long, val lines: Int, val files: Int)
private fun showSettingsDialog(): Settings? {
@@ -8,10 +8,10 @@ package org.jetbrains.kotlin.idea.migration
import com.intellij.openapi.actionSystem.AnActionEvent
class CodeMigrationAction : CodeInspectionAction("Code Migration", "Code migration") {
override fun update(e: AnActionEvent?) {
override fun update(e: AnActionEvent) {
super.update(e)
val project = e?.project
val project = e.project
if (project != null) {
e.presentation.isEnabledAndVisible = CodeMigrationToggleAction.isEnabled(project)
}
@@ -196,34 +196,28 @@ class InplaceRenameTest : LightPlatformCodeInsightTestCase() {
assertTrue(handler.isRenaming(dataContext), "In-place rename not allowed for " + element)
val project = editor.project!!
val templateManager = TemplateManager.getInstance(project) as TemplateManagerImpl
try {
templateManager.setTemplateTesting(true)
object : WriteCommandAction.Simple<Any>(project) {
override fun run() {
handler.invoke(project, editor, file, dataContext)
}
}.execute()
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
var state = TemplateManagerImpl.getTemplateState(editor)
assert(state != null)
val range = state!!.currentVariableRange
assert(range != null)
object : WriteCommandAction.Simple<Any>(project) {
override fun run() {
editor.document.replaceString(range!!.startOffset, range.endOffset, newName)
}
}.execute().throwException()
object : WriteCommandAction.Simple<Any>(project) {
override fun run() {
handler.invoke(project, editor, file, dataContext)
}
}.execute()
state = TemplateManagerImpl.getTemplateState(editor)
assert(state != null)
state!!.gotoEnd(false)
}
finally {
templateManager.setTemplateTesting(false)
}
var state = TemplateManagerImpl.getTemplateState(editor)
assert(state != null)
val range = state!!.currentVariableRange
assert(range != null)
object : WriteCommandAction.Simple<Any>(project) {
override fun run() {
editor.document.replaceString(range!!.startOffset, range.endOffset, newName)
}
}.execute().throwException()
state = TemplateManagerImpl.getTemplateState(editor)
assert(state != null)
state!!.gotoEnd(false)
checkResultByFile(getTestName(false) + ".kt.after")
}
@@ -235,8 +229,8 @@ class InplaceRenameTest : LightPlatformCodeInsightTestCase() {
private fun doTestInplaceRename(newName: String?, handler: VariableInplaceRenameHandler = KotlinVariableInplaceRenameHandler()) {
configureByFile(getTestName(false) + ".kt")
val element = TargetElementUtil.findTargetElement(
LightPlatformCodeInsightTestCase.myEditor,
TargetElementUtil.ELEMENT_NAME_ACCEPTED or TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED
LightPlatformCodeInsightTestCase.myEditor,
TargetElementUtil.ELEMENT_NAME_ACCEPTED or TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED
)
assertNotNull(element)
@@ -140,7 +140,7 @@ class KotlinChangeSignatureTest : KotlinLightCodeInsightFixtureTestCase() {
else -> throw e
}
val conflictsFile = File(testDataPath + getTestName(false) + "Messages.txt")
UsefulTestCase.assertSameLinesWithFile(conflictsFile.absolutePath, message)
UsefulTestCase.assertSameLinesWithFile(conflictsFile.absolutePath, message!!)
}
}
@@ -161,7 +161,7 @@ class KotlinChangeSignatureTest : KotlinLightCodeInsightFixtureTestCase() {
else -> throw e
}
val conflictsFile = File(testDataPath + getTestName(false) + "Messages.txt")
UsefulTestCase.assertSameLinesWithFile(conflictsFile.absolutePath, message)
UsefulTestCase.assertSameLinesWithFile(conflictsFile.absolutePath, message!!)
}
}
@@ -56,7 +56,7 @@ class AndroidGotoDeclarationHandler : GotoDeclarationHandler {
return ModuleServiceManager.getService(moduleInfo.module, AndroidLayoutXmlFileManager::class.java)
}
override fun getActionText(context: DataContext?): String? {
override fun getActionText(context: DataContext): String? {
return null
}
}