Replace assert with lazy assert, times with repeat.

This commit is contained in:
Ilya Gorbunov
2015-10-01 20:13:34 +03:00
parent c1ba30b4bc
commit 3106458cc4
50 changed files with 79 additions and 87 deletions
@@ -93,7 +93,7 @@ public object JarUserDataManager {
private fun storeUserData(counter: JarBooleanPropertyCounter, localJarFile: VirtualFile,
hasFileWithProperty: Boolean?, timestamp: Long? = null) {
assert(localJarFile.isInLocalFileSystem)
assert((timestamp == null) == (hasFileWithProperty == null), "Using empty timestamp is only allowed for storing not counted value")
assert((timestamp == null) == (hasFileWithProperty == null)) { "Using empty timestamp is only allowed for storing not counted value" }
localJarFile.putUserData(counter.key,
PropertyData(hasFileWithProperty, timestamp ?: localJarFile.timeStamp))
@@ -53,7 +53,7 @@ public class IDELightClassGenerationSupport(private val project: Project) : Ligh
private val psiManager: PsiManager = PsiManager.getInstance(project)
override fun getContextForPackage(files: Collection<JetFile>): LightClassConstructionContext {
assert(!files.isEmpty(), "No files in package")
assert(!files.isEmpty()) { "No files in package" }
return getContextForFiles(files)
}
@@ -90,7 +90,7 @@ public class IDELightClassGenerationSupport(private val project: Project) : Ligh
}
override fun getContextForFacade(files: Collection<JetFile>): LightClassConstructionContext {
assert(!files.isEmpty(), "No files in facade")
assert(!files.isEmpty()) { "No files in facade" }
return getContextForFiles(files)
}
@@ -65,7 +65,7 @@ internal class ProjectResolutionFacade(
}, false)
fun getAnalysisResultsForElements(elements: Collection<JetElement>): AnalysisResult {
assert(elements.isNotEmpty(), "elements collection should not be empty")
assert(elements.isNotEmpty()) { "elements collection should not be empty" }
val slruCache = synchronized(analysisResults) {
analysisResults.getValue()!!
}
@@ -63,7 +63,7 @@ private fun Project.getOrCreateElementsToShorten(): MutableSet<ShorteningRequest
}
public fun JetElement.addToShorteningWaitSet(options: Options = Options.DEFAULT) {
assert (ApplicationManager.getApplication()!!.isWriteAccessAllowed(), "Write access needed")
assert(ApplicationManager.getApplication()!!.isWriteAccessAllowed()) { "Write access needed" }
val project = getProject()
val elementPointer = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(this)
project.getOrCreateElementsToShorten().add(ShorteningRequest(elementPointer, options))
@@ -132,8 +132,7 @@ private class ClassClsStubBuilder(
if (!isClass() || !classProto.hasPrimaryConstructor()) return
val primaryConstructorProto = classProto.getPrimaryConstructor()
assert(classProto.getPrimaryConstructor().hasData(),
"Primary constructor in class is always non-default, so data should not be empty")
assert(classProto.getPrimaryConstructor().hasData()) { "Primary constructor in class is always non-default, so data should not be empty" }
createCallableStub(classOrObjectStub, primaryConstructorProto.getData(), c, ProtoContainer(classProto, null, c.nameResolver))
}
@@ -91,7 +91,7 @@ public class KotlinSuppressIntentionAction(
private fun suppressAtExpression(caretBox: CaretBox<JetExpression>, id: String) {
val suppressAt = caretBox.expression
assert(suppressAt !is JetDeclaration, "Declarations should have been checked for above")
assert(suppressAt !is JetDeclaration) { "Declarations should have been checked for above" }
val parentheses = JetPsiPrecedences.getPrecedence(suppressAt) > JetPsiPrecedences.PRECEDENCE_OF_PREFIX_EXPRESSION
val placeholderText = "PLACEHOLDER_ID"
@@ -59,7 +59,7 @@ public class BuiltInsReferenceResolver(val project: Project, val startupManager:
}
private fun initialize() {
assert(moduleDescriptor == null, "Attempt to initialize twice")
assert(moduleDescriptor == null) { "Attempt to initialize twice" }
val jetBuiltInsFiles = getJetBuiltInsFiles()