Make 'sure' an inline function with a lazy parameter
Also replace some other non-lazy stdlib function usages with the new lazy 'sure'
This commit is contained in:
+1
-1
@@ -32,7 +32,7 @@ public abstract class VirtualFileKotlinClassFinder : VirtualFileFinder {
|
||||
if (javaClass.getOuterClass() != null) {
|
||||
// For nested classes we get a file of the containing class, to get the actual class file for A.B.C,
|
||||
// we take the file for A, take its parent directory, then in this directory we look for A$B$C.class
|
||||
file = file.getParent()!!.findChild(classFileName(javaClass) + ".class").sure("Virtual file not found for $javaClass")
|
||||
file = file.getParent()!!.findChild(classFileName(javaClass) + ".class").sure { "Virtual file not found for $javaClass" }
|
||||
}
|
||||
|
||||
return KotlinBinaryClassCache.getKotlinBinaryClass(file)
|
||||
|
||||
@@ -21,12 +21,12 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiNameIdentifierOwner
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
import org.jetbrains.kotlin.JetNodeTypes
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.lexer.JetKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.JetTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import kotlin.platform.platformStatic
|
||||
import org.jetbrains.kotlin.psi.psiUtil.*
|
||||
|
||||
public object PositioningStrategies {
|
||||
private open class DeclarationHeader<T : JetDeclaration> : PositioningStrategy<T>() {
|
||||
@@ -234,7 +234,7 @@ public object PositioningStrategies {
|
||||
public fun modifierSetPosition(vararg tokens: JetKeywordToken): PositioningStrategy<JetModifierListOwner> {
|
||||
return object : PositioningStrategy<JetModifierListOwner>() {
|
||||
override fun mark(element: JetModifierListOwner): List<TextRange> {
|
||||
val modifierList = element.getModifierList().sure("No modifier list, but modifier has been found by the analyzer")
|
||||
val modifierList = element.getModifierList().sure { "No modifier list, but modifier has been found by the analyzer" }
|
||||
|
||||
for (token in tokens) {
|
||||
val node = modifierList.getModifierNode(token)
|
||||
|
||||
@@ -16,24 +16,23 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.callUtil
|
||||
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ArgumentUnmapped
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getTextWithLocation
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.CALL
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.RESOLVED_CALL
|
||||
import org.jetbrains.kotlin.resolve.InlineDescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatchStatus
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.CALL
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.RESOLVED_CALL
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ArgumentUnmapped
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getTextWithLocation
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.resolve.InlineDescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||
|
||||
// resolved call
|
||||
|
||||
@@ -161,15 +160,15 @@ public fun JetElement?.getParentResolvedCall(context: BindingContext, strict: Bo
|
||||
}
|
||||
|
||||
public fun JetElement.getCallWithAssert(context: BindingContext): Call {
|
||||
return getCall(context).sure("No call for ${this.getTextWithLocation()}")
|
||||
return getCall(context).sure { "No call for ${this.getTextWithLocation()}" }
|
||||
}
|
||||
|
||||
public fun JetElement.getResolvedCallWithAssert(context: BindingContext): ResolvedCall<out CallableDescriptor> {
|
||||
return getResolvedCall(context).sure("No resolved call for ${this.getTextWithLocation()}")
|
||||
return getResolvedCall(context).sure { "No resolved call for ${this.getTextWithLocation()}" }
|
||||
}
|
||||
|
||||
public fun Call.getResolvedCallWithAssert(context: BindingContext): ResolvedCall<out CallableDescriptor> {
|
||||
return getResolvedCall(context).sure("No resolved call for ${this.getCallElement().getTextWithLocation()}")
|
||||
return getResolvedCall(context).sure { "No resolved call for ${this.getCallElement().getTextWithLocation()}" }
|
||||
}
|
||||
|
||||
public fun JetExpression.getFunctionResolvedCallWithAssert(context: BindingContext): ResolvedCall<out FunctionDescriptor> {
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class CliDeclarationProviderFactoryService(private val sourceFiles: Colle
|
||||
): DeclarationProviderFactory {
|
||||
val allFiles = ArrayList<JetFile>()
|
||||
sourceFiles.filterTo(allFiles) {
|
||||
val vFile = it.getVirtualFile().sure("Source files should be physical files")
|
||||
val vFile = it.getVirtualFile().sure { "Source files should be physical files" }
|
||||
filesScope.contains(vFile)
|
||||
}
|
||||
allFiles addAll syntheticFiles
|
||||
|
||||
+20
-24
@@ -16,31 +16,27 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.kotlin.psi.JetScript
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyEntity
|
||||
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorNonRootImpl
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ScriptReceiver
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import org.jetbrains.kotlin.resolve.ScriptParameterResolver
|
||||
import org.jetbrains.kotlin.resolve.ScriptBodyResolver
|
||||
import org.jetbrains.kotlin.descriptors.impl.ScriptCodeDescriptor
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.WritableScopeImpl
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedScope
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor
|
||||
import org.jetbrains.kotlin.resolve.scopes.RedeclarationHandler
|
||||
import org.jetbrains.kotlin.resolve.scopes.WritableScope
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorNonRootImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ScriptCodeDescriptor
|
||||
import org.jetbrains.kotlin.psi.JetScript
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.ScriptBodyResolver
|
||||
import org.jetbrains.kotlin.resolve.ScriptParameterResolver
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
|
||||
import org.jetbrains.kotlin.resolve.lazy.LazyEntity
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ScriptReceiver
|
||||
import org.jetbrains.kotlin.resolve.source.toSourceElement
|
||||
import org.jetbrains.kotlin.types.DeferredType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
|
||||
public class LazyScriptDescriptor(
|
||||
private val resolveSession: ResolveSession,
|
||||
@@ -50,12 +46,12 @@ public class LazyScriptDescriptor(
|
||||
) : ScriptDescriptor, LazyEntity, DeclarationDescriptorNonRootImpl(
|
||||
jetScript.getContainingJetFile().getPackageFqName().let {
|
||||
fqName ->
|
||||
resolveSession.getPackageFragment(fqName).sure("Package not found $fqName")
|
||||
resolveSession.getPackageFragment(fqName).sure { "Package not found $fqName" }
|
||||
},
|
||||
Annotations.EMPTY,
|
||||
ScriptDescriptor.NAME,
|
||||
jetScript.toSourceElement()
|
||||
) {
|
||||
) {
|
||||
init {
|
||||
resolveSession.getTrace().record(BindingContext.SCRIPT, jetScript, this)
|
||||
}
|
||||
@@ -108,6 +104,6 @@ public class LazyScriptDescriptor(
|
||||
override fun substitute(substitutor: TypeSubstitutor) = this
|
||||
|
||||
override fun <R, D> accept(visitor: DeclarationDescriptorVisitor<R, D>, data: D): R {
|
||||
return visitor.visitScriptDescriptor(this, data) as R
|
||||
return visitor.visitScriptDescriptor(this, data)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -148,11 +148,11 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
|
||||
for (classFile in allClassFiles) {
|
||||
val className = tmpdir.relativePath(classFile).substringBeforeLast(".class").replace('/', '.').replace('\\', '.')
|
||||
|
||||
val klass = classLoader.loadClass(className).sure("Couldn't load class $className")
|
||||
val klass = classLoader.loadClass(className).sure { "Couldn't load class $className" }
|
||||
val header = ReflectKotlinClass.create(klass)?.getClassHeader()
|
||||
|
||||
if (header?.kind == KotlinClassHeader.Kind.PACKAGE_FACADE) {
|
||||
val packageView = module.getPackage(actual.getFqName()).sure("Couldn't resolve package ${actual.getFqName()}")
|
||||
val packageView = module.getPackage(actual.getFqName()).sure { "Couldn't resolve package ${actual.getFqName()}" }
|
||||
scope.importScope(packageView.getMemberScope())
|
||||
}
|
||||
else if (header == null ||
|
||||
@@ -160,7 +160,7 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
|
||||
// Either a normal Kotlin class or a Java class
|
||||
val classId = klass.classId
|
||||
if (!classId.isLocal()) {
|
||||
val classDescriptor = module.findClassAcrossModuleDependencies(classId).sure("Couldn't resolve class $className")
|
||||
val classDescriptor = module.findClassAcrossModuleDependencies(classId).sure { "Couldn't resolve class $className" }
|
||||
if (DescriptorUtils.isTopLevelDeclaration(classDescriptor)) {
|
||||
scope.addClassifierDescriptor(classDescriptor)
|
||||
}
|
||||
|
||||
+25
-21
@@ -16,29 +16,34 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.lazy.types
|
||||
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.components.TypeUsage.*
|
||||
import org.jetbrains.kotlin.load.java.components.*
|
||||
import org.jetbrains.kotlin.types.Variance.*
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.load.java.lazy.*
|
||||
import org.jetbrains.kotlin.storage.*
|
||||
import java.util.HashSet
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeFlexibility.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||
import org.jetbrains.kotlin.load.java.components.TypeUsage.*
|
||||
import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext
|
||||
import org.jetbrains.kotlin.load.java.lazy.TypeParameterResolver
|
||||
import org.jetbrains.kotlin.load.java.lazy.hasNotNullAnnotation
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeFlexibility.FLEXIBLE_UPPER_BOUND
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeFlexibility.INFLEXIBLE
|
||||
import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import kotlin.platform.platformStatic
|
||||
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.storage.get
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.Variance.INVARIANT
|
||||
import org.jetbrains.kotlin.types.Variance.IN_VARIANCE
|
||||
import org.jetbrains.kotlin.types.Variance.OUT_VARIANCE
|
||||
import org.jetbrains.kotlin.types.checker.JetTypeChecker
|
||||
import org.jetbrains.kotlin.types.typeUtil.replaceAnnotations
|
||||
import kotlin.properties.*
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import java.util.HashSet
|
||||
import kotlin.platform.platformStatic
|
||||
|
||||
private val JAVA_LANG_CLASS_FQ_NAME: FqName = FqName("java.lang.Class")
|
||||
|
||||
@@ -118,8 +123,7 @@ class LazyJavaTypeResolver(
|
||||
}
|
||||
return when (classifier) {
|
||||
is JavaClass -> {
|
||||
val fqName = classifier.getFqName()
|
||||
.sure("Class type should have a FQ name: " + classifier)
|
||||
val fqName = classifier.getFqName().sure { "Class type should have a FQ name: $classifier" }
|
||||
|
||||
val classData = mapKotlinClass(fqName) ?: c.moduleClassResolver.resolveClass(classifier)
|
||||
|
||||
@@ -219,7 +223,7 @@ class LazyJavaTypeResolver(
|
||||
return typeParameters.map { p -> TypeProjectionImpl(ErrorUtils.createErrorType(p.getName().asString())) }
|
||||
}
|
||||
var howTheProjectionIsUsed = if (attr.howThisTypeIsUsed == SUPERTYPE) SUPERTYPE_ARGUMENT else TYPE_ARGUMENT
|
||||
return javaType.getTypeArguments().withIndices().map {
|
||||
return javaType.getTypeArguments().withIndex().map {
|
||||
javaTypeParameter ->
|
||||
val (i, t) = javaTypeParameter
|
||||
val parameter = if (i >= typeParameters.size())
|
||||
|
||||
@@ -16,12 +16,4 @@
|
||||
|
||||
package org.jetbrains.kotlin.utils
|
||||
|
||||
public fun <T : Any> T?.sure(message: String): T = this ?: throw AssertionError(message)
|
||||
|
||||
fun <T> T.printAndReturn(message: String = ""): T {
|
||||
if (!message.isEmpty()) {
|
||||
println("$message:")
|
||||
}
|
||||
println(this)
|
||||
return this
|
||||
}
|
||||
public inline fun <T : Any> T?.sure(message: () -> String): T = this ?: throw AssertionError(message())
|
||||
|
||||
@@ -16,24 +16,26 @@
|
||||
|
||||
package org.jetbrains.eval4j.jdi
|
||||
|
||||
import org.jetbrains.eval4j.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.*
|
||||
import com.sun.jdi
|
||||
import org.jetbrains.eval4j.*
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_STATIC
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
|
||||
public fun makeInitialFrame(methodNode: MethodNode, arguments: List<Value>): Frame<Value> {
|
||||
val isStatic = (methodNode.access and ACC_STATIC) != 0
|
||||
|
||||
val params = Type.getArgumentTypes(methodNode.desc)
|
||||
assert(arguments.size() == (if (isStatic) params.size else params.size + 1), "Wrong number of arguments for $methodNode: $arguments")
|
||||
assert(arguments.size() == (if (isStatic) params.size() else params.size() + 1)) {
|
||||
"Wrong number of arguments for $methodNode: $arguments"
|
||||
}
|
||||
|
||||
val frame = Frame<Value>(methodNode.maxLocals, methodNode.maxStack)
|
||||
frame.setReturn(makeNotInitializedValue(Type.getReturnType(methodNode.desc)))
|
||||
|
||||
var index = 0
|
||||
for ((i, arg) in arguments.withIndices()) {
|
||||
for ((i, arg) in arguments.withIndex()) {
|
||||
frame.setLocal(index++, arg)
|
||||
if (arg.getSize() == 2) {
|
||||
frame.setLocal(index++, NOT_A_VALUE)
|
||||
@@ -49,8 +51,6 @@ public fun makeInitialFrame(methodNode: MethodNode, arguments: List<Value>): Fra
|
||||
|
||||
class JDIFailureException(message: String?, cause: Throwable? = null): RuntimeException(message, cause)
|
||||
|
||||
fun <T: Any> T?.sure(message: String? = null): T = this ?: throw JDIFailureException(message)
|
||||
|
||||
public fun jdi.ObjectReference?.asValue(): ObjectValue {
|
||||
return when (this) {
|
||||
null -> NULL_VALUE
|
||||
|
||||
+12
-12
@@ -16,24 +16,24 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.decompiler.navigation
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.roots.OrderRootType
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiClass
|
||||
import org.jetbrains.kotlin.psi.JetClass
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.fail
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.psi.JetClassOrObject
|
||||
import org.jetbrains.kotlin.asJava.LightClassUtil
|
||||
import kotlin.test.assertTrue
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.KotlinLightClassForDecompiledDeclaration
|
||||
import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.psi.JetClass
|
||||
import org.jetbrains.kotlin.psi.JetClassOrObject
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.fail
|
||||
|
||||
public class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() {
|
||||
public fun testJdkClass() {
|
||||
@@ -69,7 +69,7 @@ public class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() {
|
||||
val psiFile = getPsiManager().findFile(vf)!!
|
||||
val indexOf = psiFile.getText()!!.indexOf(referenceText)
|
||||
val reference = psiFile.findReferenceAt(indexOf)
|
||||
return reference.sure("Couldn't find reference").resolve().sure("Couldn't resolve reference").getNavigationElement()!!
|
||||
return reference.sure { "Couldn't find reference" }.resolve().sure { "Couldn't resolve reference" }.getNavigationElement()!!
|
||||
}
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor {
|
||||
|
||||
@@ -555,6 +555,7 @@ private class GeneratedJvmClass (
|
||||
sourceFiles: Collection<File>,
|
||||
outputFile: File
|
||||
) : GeneratedFile(target, sourceFiles, outputFile) {
|
||||
val outputClass = LocalFileKotlinClass.create(outputFile).sure(
|
||||
"Couldn't load KotlinClass from $outputFile; it may happen because class doesn't have valid Kotlin annotations")
|
||||
val outputClass = LocalFileKotlinClass.create(outputFile).sure {
|
||||
"Couldn't load KotlinClass from $outputFile; it may happen because class doesn't have valid Kotlin annotations"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,33 +18,23 @@ package org.jetbrains.kotlin.js.inline
|
||||
|
||||
import com.google.dart.compiler.backend.js.ast.*
|
||||
import com.google.dart.compiler.backend.js.ast.metadata.inlineStrategy
|
||||
import com.google.dart.compiler.common.SourceInfoImpl
|
||||
import com.google.gwt.dev.js.JsAstMapper
|
||||
import com.google.gwt.dev.js.ThrowExceptionOnErrorReporter
|
||||
import com.google.gwt.dev.js.parserExceptions.AbortParsingException
|
||||
import com.google.gwt.dev.js.parserExceptions.JsParserException
|
||||
import com.google.gwt.dev.js.rhino.ErrorReporter
|
||||
import com.google.gwt.dev.js.rhino.EvaluatorException
|
||||
import com.intellij.util.containers.SLRUCache
|
||||
import org.jetbrains.kotlin.builtins.InlineStrategy
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.js.config.LibrarySourcesConfig
|
||||
import org.jetbrains.kotlin.js.inline.util.IdentitySet
|
||||
import org.jetbrains.kotlin.js.inline.util.isCallInvocation
|
||||
import org.jetbrains.kotlin.js.parser.parseFunction
|
||||
import org.jetbrains.kotlin.js.translate.context.Namer
|
||||
import org.jetbrains.kotlin.js.translate.context.TranslationContext
|
||||
import org.jetbrains.kotlin.js.translate.expression.InlineMetadata
|
||||
import org.jetbrains.kotlin.js.translate.reference.CallExpressionTranslator
|
||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
||||
import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.*
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.utils.*
|
||||
|
||||
import com.intellij.util.containers.SLRUCache
|
||||
import java.io.*
|
||||
import java.net.URL
|
||||
import org.jetbrains.kotlin.js.parser.*
|
||||
import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils.getExternalModuleName
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||
import org.jetbrains.kotlin.utils.LibraryUtils
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import java.io.File
|
||||
|
||||
// TODO: add hash checksum to defineModule?
|
||||
/**
|
||||
@@ -94,7 +84,7 @@ public class FunctionReader(private val context: TranslationContext) {
|
||||
|
||||
private val functionCache = object : SLRUCache<CallableDescriptor, JsFunction>(50, 50) {
|
||||
override fun createValue(descriptor: CallableDescriptor): JsFunction =
|
||||
requireNotNull(readFunction(descriptor), "Could not read function: $descriptor")
|
||||
readFunction(descriptor).sure { "Could not read function: $descriptor" }
|
||||
}
|
||||
|
||||
public fun contains(descriptor: CallableDescriptor): Boolean {
|
||||
@@ -109,7 +99,7 @@ public class FunctionReader(private val context: TranslationContext) {
|
||||
if (descriptor !in this) return null
|
||||
|
||||
val moduleName = getExternalModuleName(descriptor)
|
||||
val file = requireNotNull(moduleJsDefinition[moduleName], "Module $moduleName file have not been read")
|
||||
val file = moduleJsDefinition[moduleName].sure { "Module $moduleName file have not been read" }
|
||||
val function = readFunctionFromSource(descriptor, file)
|
||||
function?.markInlineArguments(descriptor)
|
||||
return function
|
||||
|
||||
Reference in New Issue
Block a user