Minor: remove some redundant not null assertions from Kotlin code
This commit is contained in:
+2
-2
@@ -31,7 +31,7 @@ import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
|||||||
import org.jetbrains.jet.lang.psi.JetUserType
|
import org.jetbrains.jet.lang.psi.JetUserType
|
||||||
|
|
||||||
public class KotlinShortenReferencesRefactoringHelper: RefactoringHelper<Any> {
|
public class KotlinShortenReferencesRefactoringHelper: RefactoringHelper<Any> {
|
||||||
private val LOG = Logger.getInstance(javaClass<KotlinShortenReferencesRefactoringHelper>().getCanonicalName())!!
|
private val LOG = Logger.getInstance(javaClass<KotlinShortenReferencesRefactoringHelper>().getCanonicalName())
|
||||||
|
|
||||||
override fun prepareOperation(usages: Array<out UsageInfo>?): Any? {
|
override fun prepareOperation(usages: Array<out UsageInfo>?): Any? {
|
||||||
if (usages != null && usages.isNotEmpty()) {
|
if (usages != null && usages.isNotEmpty()) {
|
||||||
@@ -74,5 +74,5 @@ private fun Project.clearElementsToShorten() {
|
|||||||
public fun JetElement.addToShorteningWaitSet() {
|
public fun JetElement.addToShorteningWaitSet() {
|
||||||
assert (ApplicationManager.getApplication()!!.isWriteAccessAllowed(), "Write access needed")
|
assert (ApplicationManager.getApplication()!!.isWriteAccessAllowed(), "Write access needed")
|
||||||
val project = getProject()
|
val project = getProject()
|
||||||
project.getElementsToShorten(true)!!.add(SmartPointerManager.getInstance(project)!!.createSmartPsiElementPointer(this))
|
project.getElementsToShorten(true)!!.add(SmartPointerManager.getInstance(project).createSmartPsiElementPointer(this))
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -51,7 +51,7 @@ public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBl
|
|||||||
public override fun collectTransferableData(file: PsiFile, editor: Editor, startOffsets: IntArray, endOffsets: IntArray): List<TextBlockTransferableData> {
|
public override fun collectTransferableData(file: PsiFile, editor: Editor, startOffsets: IntArray, endOffsets: IntArray): List<TextBlockTransferableData> {
|
||||||
if (file !is PsiJavaFile) return listOf()
|
if (file !is PsiJavaFile) return listOf()
|
||||||
|
|
||||||
val lightFile = PsiFileFactory.getInstance(file.getProject())!!.createFileFromText(file.getText()!!, file)
|
val lightFile = PsiFileFactory.getInstance(file.getProject()).createFileFromText(file.getText()!!, file)
|
||||||
return listOf(CopiedCode(lightFile as? PsiJavaFile, startOffsets, endOffsets))
|
return listOf(CopiedCode(lightFile as? PsiJavaFile, startOffsets, endOffsets))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,6 +172,6 @@ public class ConvertJavaCopyPastePostProcessor() : CopyPastePostProcessor<TextBl
|
|||||||
}
|
}
|
||||||
|
|
||||||
class object {
|
class object {
|
||||||
private val LOG = Logger.getInstance("#org.jetbrains.jet.plugin.conversion.copy.ConvertJavaCopyPastePostProcessor")!!
|
private val LOG = Logger.getInstance("#org.jetbrains.jet.plugin.conversion.copy.ConvertJavaCopyPastePostProcessor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,14 +110,14 @@ fun createKotlinFile(fileName: String, targetDir: PsiDirectory): JetFile {
|
|||||||
val packageName = targetDir.getPackage()?.getQualifiedName()
|
val packageName = targetDir.getPackage()?.getQualifiedName()
|
||||||
|
|
||||||
targetDir.checkCreateFile(fileName)
|
targetDir.checkCreateFile(fileName)
|
||||||
val file = PsiFileFactory.getInstance(targetDir.getProject())!!.createFileFromText(
|
val file = PsiFileFactory.getInstance(targetDir.getProject()).createFileFromText(
|
||||||
fileName, JetFileType.INSTANCE, if (packageName != null) "package $packageName \n\n" else ""
|
fileName, JetFileType.INSTANCE, if (packageName != null) "package $packageName \n\n" else ""
|
||||||
)
|
)
|
||||||
|
|
||||||
return targetDir.add(file) as JetFile
|
return targetDir.add(file) as JetFile
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun File.toVirtualFile(): VirtualFile? = LocalFileSystem.getInstance()!!.findFileByIoFile(this)
|
public fun File.toVirtualFile(): VirtualFile? = LocalFileSystem.getInstance().findFileByIoFile(this)
|
||||||
|
|
||||||
public fun File.toPsiFile(project: Project): PsiFile? {
|
public fun File.toPsiFile(project: Project): PsiFile? {
|
||||||
return toVirtualFile()?.let { vfile -> PsiManager.getInstance(project).findFile(vfile) }
|
return toVirtualFile()?.let { vfile -> PsiManager.getInstance(project).findFile(vfile) }
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class KotlinUpdatePluginComponent : ApplicationComponent {
|
|||||||
requestFullJarUpdate(ideaPluginPaths.getAndroidSdkAnnotationsPath())
|
requestFullJarUpdate(ideaPluginPaths.getAndroidSdkAnnotationsPath())
|
||||||
|
|
||||||
// Force update indices for files under config directory
|
// Force update indices for files under config directory
|
||||||
val fileBasedIndex = FileBasedIndex.getInstance()!!
|
val fileBasedIndex = FileBasedIndex.getInstance()
|
||||||
fileBasedIndex.requestRebuild(KotlinAbiVersionIndex.INSTANCE.getName())
|
fileBasedIndex.requestRebuild(KotlinAbiVersionIndex.INSTANCE.getName())
|
||||||
fileBasedIndex.requestRebuild(KotlinClassFileIndex.KEY)
|
fileBasedIndex.requestRebuild(KotlinClassFileIndex.KEY)
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ class KotlinUpdatePluginComponent : ApplicationComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun requestFullJarUpdate(jarFilePath: File) {
|
private fun requestFullJarUpdate(jarFilePath: File) {
|
||||||
val localVirtualFile = LocalFileSystem.getInstance()!!.refreshAndFindFileByIoFile(jarFilePath)
|
val localVirtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jarFilePath)
|
||||||
|
|
||||||
// Build and update JarHandler
|
// Build and update JarHandler
|
||||||
val jarFile = JarFileSystem.getInstance()!!.getJarRootForLocalFile(localVirtualFile!!)
|
val jarFile = JarFileSystem.getInstance()!!.getJarRootForLocalFile(localVirtualFile!!)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public object JavaToKotlinTranslator {
|
|||||||
|
|
||||||
private fun createFile(text: String): PsiFile? {
|
private fun createFile(text: String): PsiFile? {
|
||||||
val javaCoreEnvironment: JavaCoreProjectEnvironment? = setUpJavaCoreEnvironment()
|
val javaCoreEnvironment: JavaCoreProjectEnvironment? = setUpJavaCoreEnvironment()
|
||||||
return PsiFileFactory.getInstance(javaCoreEnvironment?.getProject()!!)?.createFileFromText("test.java", JavaLanguage.INSTANCE, text)
|
return PsiFileFactory.getInstance(javaCoreEnvironment?.getProject()!!).createFileFromText("test.java", JavaLanguage.INSTANCE, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUpJavaCoreEnvironment(): JavaCoreProjectEnvironment {
|
fun setUpJavaCoreEnvironment(): JavaCoreProjectEnvironment {
|
||||||
|
|||||||
Reference in New Issue
Block a user