idea: cleanup 'public', property access syntax
This commit is contained in:
@@ -27,8 +27,8 @@ import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import kotlin.test.fail
|
||||
|
||||
public object AstAccessControl {
|
||||
public val ALLOW_AST_ACCESS_DIRECTIVE: String = "ALLOW_AST_ACCESS"
|
||||
object AstAccessControl {
|
||||
val ALLOW_AST_ACCESS_DIRECTIVE: String = "ALLOW_AST_ACCESS"
|
||||
|
||||
// Please provide at least one test that fails ast switch check (shouldFail should be true for at least one test)
|
||||
// This kind of inconvenience is justified by the fact that the check can be invalidated by slight misconfiguration of the test
|
||||
@@ -56,7 +56,7 @@ public object AstAccessControl {
|
||||
val manager = (PsiManager.getInstance(project) as PsiManagerImpl)
|
||||
val filter = VirtualFileFilter {
|
||||
file ->
|
||||
if (file!!.getFileType() != KotlinFileType.INSTANCE || file in allowedFiles) {
|
||||
if (file!!.fileType != KotlinFileType.INSTANCE || file in allowedFiles) {
|
||||
false
|
||||
}
|
||||
else {
|
||||
|
||||
+7
-7
@@ -25,13 +25,13 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
|
||||
public object DirectiveBasedActionUtils {
|
||||
public fun checkForUnexpectedErrors(file: KtFile) {
|
||||
if (InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// DISABLE-ERRORS").isNotEmpty()) {
|
||||
object DirectiveBasedActionUtils {
|
||||
fun checkForUnexpectedErrors(file: KtFile) {
|
||||
if (InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// DISABLE-ERRORS").isNotEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
val expectedErrors = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ERROR:").sorted()
|
||||
val expectedErrors = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// ERROR:").sorted()
|
||||
|
||||
val actualErrors = file.analyzeFully().getDiagnostics()
|
||||
.filter { it.getSeverity() == Severity.ERROR }
|
||||
@@ -43,13 +43,13 @@ public object DirectiveBasedActionUtils {
|
||||
expectedErrors)
|
||||
}
|
||||
|
||||
public fun checkAvailableActionsAreExpected(file: PsiFile, availableActions: Collection<IntentionAction>) {
|
||||
val expectedActions = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ACTION:").sorted()
|
||||
fun checkAvailableActionsAreExpected(file: PsiFile, availableActions: Collection<IntentionAction>) {
|
||||
val expectedActions = InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.text, "// ACTION:").sorted()
|
||||
|
||||
UsefulTestCase.assertEmpty("Irrelevant actions should not be specified in ACTION directive for they are not checked anyway",
|
||||
expectedActions.filter { isIrrelevantAction(it) })
|
||||
|
||||
val actualActions = availableActions.map { it.getText() }.sorted()
|
||||
val actualActions = availableActions.map { it.text }.sorted()
|
||||
|
||||
UsefulTestCase.assertOrderedEquals("Some unexpected actions available at current position. Use // ACTION: directive",
|
||||
filterOutIrrelevantActions(actualActions),
|
||||
|
||||
+7
-7
@@ -40,20 +40,20 @@ import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
|
||||
public abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFixtureTestCase() {
|
||||
abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFixtureTestCase() {
|
||||
private var kotlinInternalModeOriginalValue = false
|
||||
|
||||
private val exceptions = ArrayList<Throwable>()
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
(StartupManager.getInstance(getProject()) as StartupManagerImpl).runPostStartupActivities()
|
||||
(StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities()
|
||||
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||
|
||||
kotlinInternalModeOriginalValue = KotlinInternalMode.enabled
|
||||
KotlinInternalMode.enabled = true
|
||||
|
||||
getProject().getComponent(EditorTracker::class.java)?.projectOpened()
|
||||
project.getComponent(EditorTracker::class.java)?.projectOpened()
|
||||
|
||||
invalidateLibraryCache(project)
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFi
|
||||
KotlinInternalMode.enabled = kotlinInternalModeOriginalValue
|
||||
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||
|
||||
unInvalidateBuiltinsAndStdLib(getProject()) {
|
||||
unInvalidateBuiltinsAndStdLib(project) {
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFi
|
||||
protected fun getProjectDescriptorFromFileDirective(): LightProjectDescriptor {
|
||||
if (!isAllFilesPresentInTest()) {
|
||||
try {
|
||||
val fileText = FileUtil.loadFile(File(getTestDataPath(), fileName()), true)
|
||||
val fileText = FileUtil.loadFile(File(testDataPath, fileName()), true)
|
||||
|
||||
val withLibraryDirective = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, "WITH_LIBRARY:")
|
||||
if (!withLibraryDirective.isEmpty()) {
|
||||
@@ -130,14 +130,14 @@ public abstract class KotlinLightCodeInsightFixtureTestCase : LightCodeInsightFi
|
||||
= getTestName(false) + ".kt"
|
||||
|
||||
protected fun performNotWriteEditorAction(actionId: String): Boolean {
|
||||
val dataContext = (myFixture.getEditor() as EditorEx).getDataContext()
|
||||
val dataContext = (myFixture.editor as EditorEx).dataContext
|
||||
|
||||
val managerEx = ActionManagerEx.getInstanceEx()
|
||||
val action = managerEx.getAction(actionId)
|
||||
val event = AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, Presentation(), managerEx, 0)
|
||||
|
||||
action.update(event)
|
||||
if (!event.getPresentation().isEnabled()) {
|
||||
if (!event.presentation.isEnabled) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -23,12 +23,12 @@ import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCa
|
||||
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
|
||||
public abstract class KotlinLightPlatformCodeInsightFixtureTestCase: LightPlatformCodeInsightFixtureTestCase() {
|
||||
abstract class KotlinLightPlatformCodeInsightFixtureTestCase: LightPlatformCodeInsightFixtureTestCase() {
|
||||
private var kotlinInternalModeOriginalValue: Boolean = false
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
(StartupManager.getInstance(getProject()) as StartupManagerImpl).runPostStartupActivities()
|
||||
(StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities()
|
||||
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||
invalidateLibraryCache(project)
|
||||
|
||||
@@ -40,7 +40,7 @@ public abstract class KotlinLightPlatformCodeInsightFixtureTestCase: LightPlatfo
|
||||
KotlinInternalMode.enabled = kotlinInternalModeOriginalValue
|
||||
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||
|
||||
unInvalidateBuiltinsAndStdLib(getProject()) {
|
||||
unInvalidateBuiltinsAndStdLib(project) {
|
||||
super.tearDown()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import com.intellij.refactoring.MultiFileTestCase
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
|
||||
public abstract class KotlinMultiFileTestCase : MultiFileTestCase() {
|
||||
abstract class KotlinMultiFileTestCase : MultiFileTestCase() {
|
||||
protected fun extractCaretOffset(doc: Document): Int {
|
||||
val offset = runWriteAction {
|
||||
val text = StringBuilder(doc.getText())
|
||||
|
||||
+2
-2
@@ -18,9 +18,9 @@ package org.jetbrains.kotlin.idea.test
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
|
||||
public open class KotlinStdJSProjectDescriptor : KotlinLightProjectDescriptor() {
|
||||
open class KotlinStdJSProjectDescriptor : KotlinLightProjectDescriptor() {
|
||||
companion object {
|
||||
public val instance: KotlinStdJSProjectDescriptor
|
||||
val instance: KotlinStdJSProjectDescriptor
|
||||
= Class.forName("org.jetbrains.kotlin.test.KotlinStdJSProjectDescriptorImpl").newInstance() as KotlinStdJSProjectDescriptor
|
||||
}
|
||||
}
|
||||
@@ -37,19 +37,19 @@ import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import java.util.*
|
||||
|
||||
public enum class ModuleKind {
|
||||
enum class ModuleKind {
|
||||
KOTLIN_JVM_WITH_STDLIB_SOURCES,
|
||||
KOTLIN_JAVASCRIPT
|
||||
}
|
||||
|
||||
public fun Module.configureAs(descriptor: KotlinLightProjectDescriptor) {
|
||||
fun Module.configureAs(descriptor: KotlinLightProjectDescriptor) {
|
||||
val module = this
|
||||
updateModel(module, object : Consumer<ModifiableRootModel> {
|
||||
override fun consume(model: ModifiableRootModel) {
|
||||
if (descriptor.getSdk() != null) {
|
||||
model.setSdk(descriptor.getSdk())
|
||||
if (descriptor.sdk != null) {
|
||||
model.sdk = descriptor.sdk
|
||||
}
|
||||
val entries = model.getContentEntries()
|
||||
val entries = model.contentEntries
|
||||
if (entries.isEmpty()) {
|
||||
descriptor.configureModule(module, model)
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public fun Module.configureAs(descriptor: KotlinLightProjectDescriptor) {
|
||||
})
|
||||
}
|
||||
|
||||
public fun Module.configureAs(kind: ModuleKind) {
|
||||
fun Module.configureAs(kind: ModuleKind) {
|
||||
when(kind) {
|
||||
ModuleKind.KOTLIN_JVM_WITH_STDLIB_SOURCES ->
|
||||
this.configureAs(ProjectDescriptorWithStdlibSources.INSTANCE)
|
||||
@@ -72,18 +72,18 @@ public fun Module.configureAs(kind: ModuleKind) {
|
||||
}
|
||||
}
|
||||
|
||||
public fun KtFile.dumpTextWithErrors(): String {
|
||||
fun KtFile.dumpTextWithErrors(): String {
|
||||
val diagnostics = analyzeFullyAndGetResult().bindingContext.getDiagnostics()
|
||||
val errors = diagnostics.filter { it.getSeverity() == Severity.ERROR }
|
||||
if (errors.isEmpty()) return getText()
|
||||
if (errors.isEmpty()) return text
|
||||
val header = errors.map { "// ERROR: " + DefaultErrorMessages.render(it).replace('\n', ' ') }.joinToString("\n", postfix = "\n")
|
||||
return header + getText()
|
||||
return header + text
|
||||
}
|
||||
|
||||
public fun closeAndDeleteProject(): Unit =
|
||||
fun closeAndDeleteProject(): Unit =
|
||||
ApplicationManager.getApplication().runWriteAction() { LightPlatformTestCase.closeAndDeleteProject() }
|
||||
|
||||
public fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: RunnableWithException) {
|
||||
fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: RunnableWithException) {
|
||||
val stdLibViewProviders = HashSet<KotlinDecompiledFileViewProvider>()
|
||||
val vFileToViewProviderMap = ((PsiManager.getInstance(project) as PsiManagerEx).fileManager as FileManagerImpl).vFileToViewProviderMap
|
||||
for ((file, viewProvider) in vFileToViewProviderMap) {
|
||||
@@ -97,7 +97,7 @@ public fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: RunnableWit
|
||||
// Base tearDown() invalidates builtins and std-lib files. Restore them with brute force.
|
||||
fun unInvalidateFile(file: PsiFileImpl) {
|
||||
val field = PsiFileImpl::class.java.getDeclaredField("myInvalidated")!!
|
||||
field.setAccessible(true)
|
||||
field.isAccessible = true
|
||||
field.set(file, false)
|
||||
}
|
||||
|
||||
@@ -109,10 +109,10 @@ public fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: RunnableWit
|
||||
|
||||
private val VirtualFile.isStdLibFile: Boolean get() = presentableUrl.contains("kotlin-runtime.jar")
|
||||
|
||||
public fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: () -> Unit) {
|
||||
fun unInvalidateBuiltinsAndStdLib(project: Project, runnable: () -> Unit) {
|
||||
unInvalidateBuiltinsAndStdLib(project, RunnableWithException { runnable() })
|
||||
}
|
||||
|
||||
public fun invalidateLibraryCache(project: Project) {
|
||||
fun invalidateLibraryCache(project: Project) {
|
||||
LibraryModificationTracker.getInstance(project).incModificationCount()
|
||||
}
|
||||
Reference in New Issue
Block a user