Cleanup in idea plugin modules, idea-analysis
This commit is contained in:
+1
-1
@@ -164,7 +164,7 @@ public class IDELightClassGenerationSupport(private val project: Project) : Ligh
|
|||||||
|
|
||||||
val lightClasses = ArrayList<PsiClass>()
|
val lightClasses = ArrayList<PsiClass>()
|
||||||
lightClasses.add(lightClassForFacade)
|
lightClasses.add(lightClassForFacade)
|
||||||
if (facadeFiles.size() > 1) {
|
if (facadeFiles.size > 1) {
|
||||||
lightClasses.addAll(facadeFiles.map {
|
lightClasses.addAll(facadeFiles.map {
|
||||||
FakeLightClassForFileOfPackage(lightClassForFacade, it)
|
FakeLightClassForFileOfPackage(lightClassForFacade, it)
|
||||||
})
|
})
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.asJava.KotlinCodeBlockModificationListener
|
|||||||
public class KotlinOutOfBlockCompletionModificationTracker() : SimpleModificationTracker() {
|
public class KotlinOutOfBlockCompletionModificationTracker() : SimpleModificationTracker() {
|
||||||
companion object {
|
companion object {
|
||||||
public fun getInstance(project: Project): KotlinOutOfBlockCompletionModificationTracker
|
public fun getInstance(project: Project): KotlinOutOfBlockCompletionModificationTracker
|
||||||
= ServiceManager.getService(project, javaClass<KotlinOutOfBlockCompletionModificationTracker>())!!
|
= ServiceManager.getService(project, KotlinOutOfBlockCompletionModificationTracker::class.java)!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -60,7 +60,7 @@ internal class PerFileAnalysisCache(val file: KtFile, val componentProvider: Com
|
|||||||
descendantsOfCurrent.add(current)
|
descendantsOfCurrent.add(current)
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.keySet().removeAll(toRemove)
|
cache.keys.removeAll(toRemove)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -109,18 +109,18 @@ internal class PerFileAnalysisCache(val file: KtFile, val componentProvider: Com
|
|||||||
|
|
||||||
private object KotlinResolveDataProvider {
|
private object KotlinResolveDataProvider {
|
||||||
private val topmostElementTypes = arrayOf<Class<out PsiElement?>?>(
|
private val topmostElementTypes = arrayOf<Class<out PsiElement?>?>(
|
||||||
javaClass<KtNamedFunction>(),
|
KtNamedFunction::class.java,
|
||||||
javaClass<KtAnonymousInitializer>(),
|
KtAnonymousInitializer::class.java,
|
||||||
javaClass<KtProperty>(),
|
KtProperty::class.java,
|
||||||
javaClass<KtImportDirective>(),
|
KtImportDirective::class.java,
|
||||||
javaClass<KtPackageDirective>(),
|
KtPackageDirective::class.java,
|
||||||
javaClass<KtCodeFragment>(),
|
KtCodeFragment::class.java,
|
||||||
// TODO: Non-analyzable so far, add more granular analysis
|
// TODO: Non-analyzable so far, add more granular analysis
|
||||||
javaClass<KtAnnotationEntry>(),
|
KtAnnotationEntry::class.java,
|
||||||
javaClass<KtTypeConstraint>(),
|
KtTypeConstraint::class.java,
|
||||||
javaClass<KtSuperTypeList>(),
|
KtSuperTypeList::class.java,
|
||||||
javaClass<KtTypeParameter>(),
|
KtTypeParameter::class.java,
|
||||||
javaClass<KtParameter>()
|
KtParameter::class.java
|
||||||
)
|
)
|
||||||
|
|
||||||
fun findAnalyzableParent(element: KtElement): KtElement {
|
fun findAnalyzableParent(element: KtElement): KtElement {
|
||||||
@@ -134,12 +134,12 @@ private object KotlinResolveDataProvider {
|
|||||||
is KtTypeConstraint,
|
is KtTypeConstraint,
|
||||||
is KtSuperTypeList,
|
is KtSuperTypeList,
|
||||||
is KtTypeParameter,
|
is KtTypeParameter,
|
||||||
is KtParameter -> PsiTreeUtil.getParentOfType(topmostElement, javaClass<KtClassOrObject>(), javaClass<KtCallableDeclaration>())
|
is KtParameter -> PsiTreeUtil.getParentOfType(topmostElement, KtClassOrObject::class.java, KtCallableDeclaration::class.java)
|
||||||
else -> topmostElement
|
else -> topmostElement
|
||||||
}
|
}
|
||||||
return analyzableElement
|
return analyzableElement
|
||||||
// if none of the above worked, take the outermost declaration
|
// if none of the above worked, take the outermost declaration
|
||||||
?: PsiTreeUtil.getTopmostParentOfType(element, javaClass<KtDeclaration>())
|
?: PsiTreeUtil.getTopmostParentOfType(element, KtDeclaration::class.java)
|
||||||
// if even that didn't work, take the whole file
|
// if even that didn't work, take the whole file
|
||||||
?: element.getContainingKtFile()
|
?: element.getContainingKtFile()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ fun createModuleResolverProvider(
|
|||||||
val allModuleInfos = collectAllModuleInfosFromIdeaModel(project).toHashSet()
|
val allModuleInfos = collectAllModuleInfosFromIdeaModel(project).toHashSet()
|
||||||
|
|
||||||
val syntheticFilesByModule = syntheticFiles.groupBy { it.getModuleInfo() }
|
val syntheticFilesByModule = syntheticFiles.groupBy { it.getModuleInfo() }
|
||||||
val syntheticFilesModules = syntheticFilesByModule.keySet()
|
val syntheticFilesModules = syntheticFilesByModule.keys
|
||||||
allModuleInfos.addAll(syntheticFilesModules)
|
allModuleInfos.addAll(syntheticFilesModules)
|
||||||
|
|
||||||
val modulesToCreateResolversFor = allModuleInfos.filter(moduleFilter)
|
val modulesToCreateResolversFor = allModuleInfos.filter(moduleFilter)
|
||||||
|
|||||||
+1
-1
@@ -98,7 +98,7 @@ internal class ResolutionFacadeImpl(
|
|||||||
get() = projectFacade.findModuleDescriptor(moduleInfo)
|
get() = projectFacade.findModuleDescriptor(moduleInfo)
|
||||||
|
|
||||||
override fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode): BindingContext {
|
override fun analyze(element: KtElement, bodyResolveMode: BodyResolveMode): BindingContext {
|
||||||
val resolveElementCache = getFrontendService(element, javaClass<ResolveElementCache>())
|
val resolveElementCache = getFrontendService(element, ResolveElementCache::class.java)
|
||||||
return resolveElementCache.resolveToElement(element, bodyResolveMode)
|
return resolveElementCache.resolveToElement(element, bodyResolveMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ private class ExceptionTrackerWithProcessCanceledReport() : ExceptionTracker() {
|
|||||||
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val LOG = Logger.getInstance(javaClass<ExceptionTrackerWithProcessCanceledReport>())
|
val LOG = Logger.getInstance(ExceptionTrackerWithProcessCanceledReport::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,7 @@ public fun performDelayedShortening(project: Project) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val LOG = Logger.getInstance(javaClass<Project>().getCanonicalName())
|
private val LOG = Logger.getInstance(Project::class.java.getCanonicalName())
|
||||||
|
|
||||||
public fun prepareElementsToShorten(project: Project) {
|
public fun prepareElementsToShorten(project: Project) {
|
||||||
val elementsToShorten = project.elementsToShorten
|
val elementsToShorten = project.elementsToShorten
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import com.intellij.openapi.util.SimpleModificationTracker
|
|||||||
class ModuleTypeCacheManager private constructor(project: Project) {
|
class ModuleTypeCacheManager private constructor(project: Project) {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<ModuleTypeCacheManager>())
|
fun getInstance(project: Project) = ServiceManager.getService(project, ModuleTypeCacheManager::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val vfsModificationTracker = VfsModificationTracker(project)
|
private val vfsModificationTracker = VfsModificationTracker(project)
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ open class KtDecompiledFile(
|
|||||||
|
|
||||||
private fun DeclarationDescriptor.findElementForDescriptor(): KtDeclaration? {
|
private fun DeclarationDescriptor.findElementForDescriptor(): KtDeclaration? {
|
||||||
return decompiledText.get().renderedDescriptorsToRange[descriptorToKey(this)]?.let { range ->
|
return decompiledText.get().renderedDescriptorsToRange[descriptorToKey(this)]?.let { range ->
|
||||||
PsiTreeUtil.findElementOfClassAtRange(this@KtDecompiledFile, range.getStartOffset(), range.getEndOffset(), javaClass<KtDeclaration>())
|
PsiTreeUtil.findElementOfClassAtRange(this@KtDecompiledFile, range.getStartOffset(), range.getEndOffset(), KtDeclaration::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -107,7 +107,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
|||||||
val typeArgumentsListStub = KotlinPlaceHolderStubImpl<KtTypeArgumentList>(typeStub, KtStubElementTypes.TYPE_ARGUMENT_LIST)
|
val typeArgumentsListStub = KotlinPlaceHolderStubImpl<KtTypeArgumentList>(typeStub, KtStubElementTypes.TYPE_ARGUMENT_LIST)
|
||||||
typeArgumentProtoList.forEach { typeArgumentProto ->
|
typeArgumentProtoList.forEach { typeArgumentProto ->
|
||||||
val projectionKind = typeArgumentProto.projection.toProjectionKind()
|
val projectionKind = typeArgumentProto.projection.toProjectionKind()
|
||||||
val typeProjection = KotlinTypeProjectionStubImpl(typeArgumentsListStub, projectionKind.ordinal())
|
val typeProjection = KotlinTypeProjectionStubImpl(typeArgumentsListStub, projectionKind.ordinal)
|
||||||
if (projectionKind != KtProjectionKind.STAR) {
|
if (projectionKind != KtProjectionKind.STAR) {
|
||||||
val modifierKeywordToken = projectionKind.token as? KtModifierKeywordToken
|
val modifierKeywordToken = projectionKind.token as? KtModifierKeywordToken
|
||||||
createModifierListStub(typeProjection, modifierKeywordToken.singletonOrEmptyList())
|
createModifierListStub(typeProjection, modifierKeywordToken.singletonOrEmptyList())
|
||||||
@@ -135,7 +135,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
|||||||
|
|
||||||
val parameterList = KotlinPlaceHolderStubImpl<KtParameterList>(functionType, KtStubElementTypes.VALUE_PARAMETER_LIST)
|
val parameterList = KotlinPlaceHolderStubImpl<KtParameterList>(functionType, KtStubElementTypes.VALUE_PARAMETER_LIST)
|
||||||
val typeArgumentsWithoutReceiverAndReturnType
|
val typeArgumentsWithoutReceiverAndReturnType
|
||||||
= typeArgumentList.subList(if (isExtensionFunctionType) 1 else 0, typeArgumentList.size() - 1)
|
= typeArgumentList.subList(if (isExtensionFunctionType) 1 else 0, typeArgumentList.size - 1)
|
||||||
typeArgumentsWithoutReceiverAndReturnType.forEach { argument ->
|
typeArgumentsWithoutReceiverAndReturnType.forEach { argument ->
|
||||||
val parameter = KotlinParameterStubImpl(
|
val parameter = KotlinParameterStubImpl(
|
||||||
parameterList, fqName = null, name = null, isMutable = false, hasValOrVar = false, hasDefaultValue = false
|
parameterList, fqName = null, name = null, isMutable = false, hasValOrVar = false, hasDefaultValue = false
|
||||||
|
|||||||
+2
-2
@@ -107,7 +107,7 @@ public fun buildDecompiledText(
|
|||||||
// descriptor instanceof PropertyDescriptor
|
// descriptor instanceof PropertyDescriptor
|
||||||
builder.append(" ").append(DECOMPILED_CODE_COMMENT)
|
builder.append(" ").append(DECOMPILED_CODE_COMMENT)
|
||||||
}
|
}
|
||||||
endOffset = builder.length()
|
endOffset = builder.length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (descriptor is ClassDescriptor && !isEnumEntry(descriptor)) {
|
else if (descriptor is ClassDescriptor && !isEnumEntry(descriptor)) {
|
||||||
@@ -160,7 +160,7 @@ public fun buildDecompiledText(
|
|||||||
}
|
}
|
||||||
|
|
||||||
builder.append(indent).append("}")
|
builder.append(indent).append("}")
|
||||||
endOffset = builder.length()
|
endOffset = builder.length
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.append("\n")
|
builder.append("\n")
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
|||||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
public class OperatorToFunctionIntention : SelfTargetingIntention<KtExpression>(javaClass(), "Replace overloaded operator with function call") {
|
public class OperatorToFunctionIntention : SelfTargetingIntention<KtExpression>(KtExpression::class.java, "Replace overloaded operator with function call") {
|
||||||
companion object {
|
companion object {
|
||||||
private fun isApplicablePrefix(element: KtPrefixExpression, caretOffset: Int): Boolean {
|
private fun isApplicablePrefix(element: KtPrefixExpression, caretOffset: Int): Boolean {
|
||||||
val opRef = element.getOperationReference()
|
val opRef = element.getOperationReference()
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class KDocElementFactory(val project: Project) {
|
|||||||
public fun createKDocFromText(text: String): KDoc {
|
public fun createKDocFromText(text: String): KDoc {
|
||||||
val fileText = text + " fun foo { }"
|
val fileText = text + " fun foo { }"
|
||||||
val function = KtPsiFactory(project).createDeclaration<KtFunction>(fileText)
|
val function = KtPsiFactory(project).createDeclaration<KtFunction>(fileText)
|
||||||
return PsiTreeUtil.findChildOfType(function, javaClass<KDoc>())!!
|
return PsiTreeUtil.findChildOfType(function, KDoc::class.java)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun createNameFromText(text: String): KDocName {
|
public fun createNameFromText(text: String): KDocName {
|
||||||
|
|||||||
@@ -204,19 +204,19 @@ public class ResolveElementCache(
|
|||||||
private fun findElementOfAdditionalResolve(element: KtElement): KtElement? {
|
private fun findElementOfAdditionalResolve(element: KtElement): KtElement? {
|
||||||
val elementOfAdditionalResolve = KtPsiUtil.getTopmostParentOfTypes(
|
val elementOfAdditionalResolve = KtPsiUtil.getTopmostParentOfTypes(
|
||||||
element,
|
element,
|
||||||
javaClass<KtNamedFunction>(),
|
KtNamedFunction::class.java,
|
||||||
javaClass<KtAnonymousInitializer>(),
|
KtAnonymousInitializer::class.java,
|
||||||
javaClass<KtSecondaryConstructor>(),
|
KtSecondaryConstructor::class.java,
|
||||||
javaClass<KtProperty>(),
|
KtProperty::class.java,
|
||||||
javaClass<KtParameter>(),
|
KtParameter::class.java,
|
||||||
javaClass<KtSuperTypeList>(),
|
KtSuperTypeList::class.java,
|
||||||
javaClass<KtInitializerList>(),
|
KtInitializerList::class.java,
|
||||||
javaClass<KtImportList>(),
|
KtImportList::class.java,
|
||||||
javaClass<KtAnnotationEntry>(),
|
KtAnnotationEntry::class.java,
|
||||||
javaClass<KtTypeParameter>(),
|
KtTypeParameter::class.java,
|
||||||
javaClass<KtTypeConstraint>(),
|
KtTypeConstraint::class.java,
|
||||||
javaClass<KtPackageDirective>(),
|
KtPackageDirective::class.java,
|
||||||
javaClass<KtCodeFragment>()) as KtElement?
|
KtCodeFragment::class.java) as KtElement?
|
||||||
|
|
||||||
when (elementOfAdditionalResolve) {
|
when (elementOfAdditionalResolve) {
|
||||||
null -> {
|
null -> {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class QuickFixes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
public fun getInstance(): QuickFixes = ServiceManager.getService(javaClass<QuickFixes>())
|
public fun getInstance(): QuickFixes = ServiceManager.getService(QuickFixes::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -27,11 +27,11 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
public class KotlinReferenceContributor() : PsiReferenceContributor() {
|
public class KotlinReferenceContributor() : PsiReferenceContributor() {
|
||||||
public override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {
|
public override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {
|
||||||
with(registrar) {
|
with(registrar) {
|
||||||
registerProvider(javaClass<KtSimpleNameExpression>()) {
|
registerProvider(KtSimpleNameExpression::class.java) {
|
||||||
KtSimpleNameReference(it)
|
KtSimpleNameReference(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMultiProvider(javaClass<KtNameReferenceExpression>()) {
|
registerMultiProvider(KtNameReferenceExpression::class.java) {
|
||||||
if (it.getReferencedNameElementType() != KtTokens.IDENTIFIER) return@registerMultiProvider emptyArray()
|
if (it.getReferencedNameElementType() != KtTokens.IDENTIFIER) return@registerMultiProvider emptyArray()
|
||||||
|
|
||||||
when (it.readWriteAccess(useResolveForReadWrite = false)) {
|
when (it.readWriteAccess(useResolveForReadWrite = false)) {
|
||||||
@@ -41,31 +41,31 @@ public class KotlinReferenceContributor() : PsiReferenceContributor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProvider(javaClass<KtConstructorDelegationReferenceExpression>()) {
|
registerProvider(KtConstructorDelegationReferenceExpression::class.java) {
|
||||||
KtConstructorDelegationReference(it)
|
KtConstructorDelegationReference(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProvider(javaClass<KtCallExpression>()) {
|
registerProvider(KtCallExpression::class.java) {
|
||||||
KtInvokeFunctionReference(it)
|
KtInvokeFunctionReference(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProvider(javaClass<KtArrayAccessExpression>()) {
|
registerProvider(KtArrayAccessExpression::class.java) {
|
||||||
KtArrayAccessReference(it)
|
KtArrayAccessReference(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProvider(javaClass<KtForExpression>()) {
|
registerProvider(KtForExpression::class.java) {
|
||||||
KtForLoopInReference(it)
|
KtForLoopInReference(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProvider(javaClass<KtPropertyDelegate>()) {
|
registerProvider(KtPropertyDelegate::class.java) {
|
||||||
KtPropertyDelegationMethodsReference(it)
|
KtPropertyDelegationMethodsReference(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProvider(javaClass<KtDestructuringDeclaration>()) {
|
registerProvider(KtDestructuringDeclaration::class.java) {
|
||||||
KtDestructuringDeclarationReference(it)
|
KtDestructuringDeclarationReference(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
registerProvider(javaClass<KDocName>()) {
|
registerProvider(KDocName::class.java) {
|
||||||
KDocReference(it)
|
KDocReference(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public abstract class AbstractKtReference<T : KtElement>(element: T)
|
|||||||
|
|
||||||
override fun resolve(): PsiElement? {
|
override fun resolve(): PsiElement? {
|
||||||
val psiElements = resolveToPsiElements()
|
val psiElements = resolveToPsiElements()
|
||||||
if (psiElements.size() == 1) {
|
if (psiElements.size == 1) {
|
||||||
return psiElements.iterator().next()
|
return psiElements.iterator().next()
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
|||||||
+1
-1
@@ -159,7 +159,7 @@ class KtSimpleNameReference(expression: KtSimpleNameExpression) : KtSimpleRefere
|
|||||||
if (shorteningMode == ShorteningMode.NO_SHORTENING) return newExpression
|
if (shorteningMode == ShorteningMode.NO_SHORTENING) return newExpression
|
||||||
|
|
||||||
val needToShorten =
|
val needToShorten =
|
||||||
PsiTreeUtil.getParentOfType(expression, javaClass<KtImportDirective>(), javaClass<KtPackageDirective>()) == null
|
PsiTreeUtil.getParentOfType(expression, KtImportDirective::class.java, KtPackageDirective::class.java) == null
|
||||||
if (needToShorten) {
|
if (needToShorten) {
|
||||||
if (shorteningMode == ShorteningMode.FORCED_SHORTENING) {
|
if (shorteningMode == ShorteningMode.FORCED_SHORTENING) {
|
||||||
ShortenReferences.DEFAULT.process(newQualifiedElement)
|
ShortenReferences.DEFAULT.process(newQualifiedElement)
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public fun PsiReference.matchesTarget(candidateTarget: PsiElement): Boolean {
|
|||||||
}
|
}
|
||||||
if ((parent as? PsiNewExpression)?.resolveConstructor()?.unwrapped == unwrappedCandidate) return true
|
if ((parent as? PsiNewExpression)?.resolveConstructor()?.unwrapped == unwrappedCandidate) return true
|
||||||
}
|
}
|
||||||
if (this is PsiJavaCodeReferenceElement && candidateTarget is KtObjectDeclaration && unwrappedTargets.size() == 1) {
|
if (this is PsiJavaCodeReferenceElement && candidateTarget is KtObjectDeclaration && unwrappedTargets.size == 1) {
|
||||||
val referredClass = unwrappedTargets.first()
|
val referredClass = unwrappedTargets.first()
|
||||||
if (referredClass is KtClass && candidateTarget in referredClass.getCompanionObjects()) {
|
if (referredClass is KtClass && candidateTarget in referredClass.getCompanionObjects()) {
|
||||||
if (getParent() is PsiImportStaticStatement) return true
|
if (getParent() is PsiImportStaticStatement) return true
|
||||||
@@ -173,7 +173,7 @@ public fun KtExpression.readWriteAccess(useResolveForReadWrite: Boolean): Refere
|
|||||||
val bindingContext = assignment.analyze(BodyResolveMode.PARTIAL)
|
val bindingContext = assignment.analyze(BodyResolveMode.PARTIAL)
|
||||||
val resolvedCall = assignment.getResolvedCall(bindingContext) ?: return ReferenceAccess.READ_WRITE
|
val resolvedCall = assignment.getResolvedCall(bindingContext) ?: return ReferenceAccess.READ_WRITE
|
||||||
if (!resolvedCall.isReallySuccess()) return ReferenceAccess.READ_WRITE
|
if (!resolvedCall.isReallySuccess()) return ReferenceAccess.READ_WRITE
|
||||||
return if (resolvedCall.resultingDescriptor.name in OperatorConventions.ASSIGNMENT_OPERATIONS.values())
|
return if (resolvedCall.resultingDescriptor.name in OperatorConventions.ASSIGNMENT_OPERATIONS.values)
|
||||||
ReferenceAccess.READ
|
ReferenceAccess.READ
|
||||||
else
|
else
|
||||||
ReferenceAccess.READ_WRITE
|
ReferenceAccess.READ_WRITE
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ public class KotlinIndexPatternBuilder: IndexPatternBuilder {
|
|||||||
override fun getCommentStartDelta(tokenType: IElementType?): Int = 0
|
override fun getCommentStartDelta(tokenType: IElementType?): Int = 0
|
||||||
|
|
||||||
override fun getCommentEndDelta(tokenType: IElementType?): Int = when(tokenType) {
|
override fun getCommentEndDelta(tokenType: IElementType?): Int = when(tokenType) {
|
||||||
KtTokens.BLOCK_COMMENT -> "*/".length()
|
KtTokens.BLOCK_COMMENT -> "*/".length
|
||||||
else -> 0
|
else -> 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class KotlinFilterLexer(private val occurrenceConsumer: OccurrenceConsumer): Bas
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tokenType != TokenType.WHITE_SPACE && tokenType !in commentTokens) {
|
if (tokenType != TokenType.WHITE_SPACE && tokenType !in commentTokens) {
|
||||||
if (prevTokens.size() == MAX_PREV_TOKENS) {
|
if (prevTokens.size == MAX_PREV_TOKENS) {
|
||||||
prevTokens.removeLast()
|
prevTokens.removeLast()
|
||||||
}
|
}
|
||||||
prevTokens.addFirst(tokenType)
|
prevTokens.addFirst(tokenType)
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ public object KotlinPsiMethodOverridersSearch : HierarchySearch<PsiMethod>(PsiMe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return classToMethod.values()
|
return classToMethod.values
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isApplicable(request: HierarchySearchRequest<PsiMethod>): Boolean =
|
override fun isApplicable(request: HierarchySearchRequest<PsiMethod>): Boolean =
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ import org.jetbrains.kotlin.util.OperatorNameConventions
|
|||||||
|
|
||||||
public val ALL_SEARCHABLE_OPERATIONS: ImmutableSet<KtToken> = ImmutableSet
|
public val ALL_SEARCHABLE_OPERATIONS: ImmutableSet<KtToken> = ImmutableSet
|
||||||
.builder<KtToken>()
|
.builder<KtToken>()
|
||||||
.addAll(UNARY_OPERATION_NAMES.keySet())
|
.addAll(UNARY_OPERATION_NAMES.keys)
|
||||||
.addAll(BINARY_OPERATION_NAMES.keySet())
|
.addAll(BINARY_OPERATION_NAMES.keys)
|
||||||
.addAll(ASSIGNMENT_OPERATIONS.keySet())
|
.addAll(ASSIGNMENT_OPERATIONS.keys)
|
||||||
.addAll(COMPARISON_OPERATIONS)
|
.addAll(COMPARISON_OPERATIONS)
|
||||||
.addAll(EQUALS_OPERATIONS)
|
.addAll(EQUALS_OPERATIONS)
|
||||||
.addAll(IDENTITY_EQUALS_OPERATIONS)
|
.addAll(IDENTITY_EQUALS_OPERATIONS)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ private fun <TDeclaration : KtCallableDeclaration> KtTypeElement.index(declarati
|
|||||||
is KtNullableType -> getInnerType()?.index(declaration, sink)
|
is KtNullableType -> getInnerType()?.index(declaration, sink)
|
||||||
|
|
||||||
is KtFunctionType -> {
|
is KtFunctionType -> {
|
||||||
val arity = getParameters().size() + (if (getReceiverTypeReference() != null) 1 else 0)
|
val arity = getParameters().size + (if (getReceiverTypeReference() != null) 1 else 0)
|
||||||
occurrence("Function$arity")
|
occurrence("Function$arity")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ public class KotlinTopLevelExtensionsByReceiverTypeIndex private constructor() :
|
|||||||
= super.get(s, project, KotlinSourceFilterScope.sourcesAndLibraries(scope, project))
|
= super.get(s, project, KotlinSourceFilterScope.sourcesAndLibraries(scope, project))
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val KEY = KotlinIndexUtil.createIndexKey<String, KtCallableDeclaration>(javaClass<KotlinTopLevelExtensionsByReceiverTypeIndex>())
|
private val KEY = KotlinIndexUtil.createIndexKey<String, KtCallableDeclaration>(KotlinTopLevelExtensionsByReceiverTypeIndex::class.java)
|
||||||
private val SEPARATOR = '\n'
|
private val SEPARATOR = '\n'
|
||||||
|
|
||||||
public val INSTANCE: KotlinTopLevelExtensionsByReceiverTypeIndex = KotlinTopLevelExtensionsByReceiverTypeIndex()
|
public val INSTANCE: KotlinTopLevelExtensionsByReceiverTypeIndex = KotlinTopLevelExtensionsByReceiverTypeIndex()
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public object PackageIndexUtil {
|
|||||||
): Boolean {
|
): Boolean {
|
||||||
var result = false
|
var result = false
|
||||||
StubIndex.getInstance().processElements<String, KtFile>(
|
StubIndex.getInstance().processElements<String, KtFile>(
|
||||||
KotlinExactPackagesIndex.getInstance().getKey(), packageFqName.asString(), project, searchScope, javaClass<KtFile>()
|
KotlinExactPackagesIndex.getInstance().getKey(), packageFqName.asString(), project, searchScope, KtFile::class.java
|
||||||
) {
|
) {
|
||||||
result = true
|
result = true
|
||||||
false
|
false
|
||||||
|
|||||||
+2
-2
@@ -67,7 +67,7 @@ public class SubpackagesIndexService(private val project: Project) {
|
|||||||
fun getSubpackages(fqName: FqName, scope: GlobalSearchScope, nameFilter: (Name) -> Boolean): Collection<FqName> {
|
fun getSubpackages(fqName: FqName, scope: GlobalSearchScope, nameFilter: (Name) -> Boolean): Collection<FqName> {
|
||||||
val possibleFilesFqNames = fqNameByPrefix[fqName]
|
val possibleFilesFqNames = fqNameByPrefix[fqName]
|
||||||
val existingSubPackagesShortNames = HashSet<Name>()
|
val existingSubPackagesShortNames = HashSet<Name>()
|
||||||
val len = fqName.pathSegments().size()
|
val len = fqName.pathSegments().size
|
||||||
for (filesFqName in possibleFilesFqNames) {
|
for (filesFqName in possibleFilesFqNames) {
|
||||||
val candidateSubPackageShortName = filesFqName.pathSegments()[len]
|
val candidateSubPackageShortName = filesFqName.pathSegments()[len]
|
||||||
if (candidateSubPackageShortName in existingSubPackagesShortNames || !nameFilter(candidateSubPackageShortName)) continue
|
if (candidateSubPackageShortName in existingSubPackagesShortNames || !nameFilter(candidateSubPackageShortName)) continue
|
||||||
@@ -84,7 +84,7 @@ public class SubpackagesIndexService(private val project: Project) {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
public fun getInstance(project: Project): SubpackagesIndex {
|
public fun getInstance(project: Project): SubpackagesIndex {
|
||||||
return ServiceManager.getService(project, javaClass<SubpackagesIndexService>())!!.cachedValue.getValue()!!
|
return ServiceManager.getService(project, SubpackagesIndexService::class.java)!!.cachedValue.getValue()!!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ abstract class ImportInsertHelper {
|
|||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
public fun getInstance(project: Project): ImportInsertHelper
|
public fun getInstance(project: Project): ImportInsertHelper
|
||||||
= ServiceManager.getService<ImportInsertHelper>(project, javaClass<ImportInsertHelper>())
|
= ServiceManager.getService<ImportInsertHelper>(project, ImportInsertHelper::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import java.util.*
|
|||||||
|
|
||||||
public object PsiPrecedences {
|
public object PsiPrecedences {
|
||||||
|
|
||||||
private val LOG = Logger.getInstance(javaClass<PsiPrecedences>())
|
private val LOG = Logger.getInstance(PsiPrecedences::class.java)
|
||||||
|
|
||||||
private val precedence: Map<IElementType, Int>
|
private val precedence: Map<IElementType, Int>
|
||||||
init {
|
init {
|
||||||
@@ -40,8 +40,8 @@ public object PsiPrecedences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public val PRECEDENCE_OF_ATOMIC_EXPRESSION: Int = -1
|
public val PRECEDENCE_OF_ATOMIC_EXPRESSION: Int = -1
|
||||||
public val PRECEDENCE_OF_PREFIX_EXPRESSION: Int = PREFIX.ordinal()
|
public val PRECEDENCE_OF_PREFIX_EXPRESSION: Int = PREFIX.ordinal
|
||||||
public val PRECEDENCE_OF_POSTFIX_EXPRESSION: Int = POSTFIX.ordinal()
|
public val PRECEDENCE_OF_POSTFIX_EXPRESSION: Int = POSTFIX.ordinal
|
||||||
|
|
||||||
public fun getPrecedence(expression: KtExpression): Int {
|
public fun getPrecedence(expression: KtExpression): Int {
|
||||||
return when (expression) {
|
return when (expression) {
|
||||||
@@ -54,7 +54,7 @@ public object PsiPrecedences {
|
|||||||
val precedenceNumber = precedence[operation]
|
val precedenceNumber = precedence[operation]
|
||||||
if (precedenceNumber == null) {
|
if (precedenceNumber == null) {
|
||||||
LOG.error("No precedence for operation: " + operation)
|
LOG.error("No precedence for operation: " + operation)
|
||||||
precedence.size()
|
precedence.size
|
||||||
}
|
}
|
||||||
else precedenceNumber
|
else precedenceNumber
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D
|
|||||||
|
|
||||||
private fun dropNestedElements(elements: List<KtElement>): LinkedHashSet<KtElement> {
|
private fun dropNestedElements(elements: List<KtElement>): LinkedHashSet<KtElement> {
|
||||||
val elementSet = elements.toSet()
|
val elementSet = elements.toSet()
|
||||||
val newElements = LinkedHashSet<KtElement>(elementSet.size())
|
val newElements = LinkedHashSet<KtElement>(elementSet.size)
|
||||||
for (element in elementSet) {
|
for (element in elementSet) {
|
||||||
if (!element.parents.any { it in elementSet }) {
|
if (!element.parents.any { it in elementSet }) {
|
||||||
newElements.add(element)
|
newElements.add(element)
|
||||||
@@ -337,7 +337,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D
|
|||||||
|
|
||||||
if (PsiTreeUtil.getParentOfType(
|
if (PsiTreeUtil.getParentOfType(
|
||||||
qualifiedExpression,
|
qualifiedExpression,
|
||||||
javaClass<KtImportDirective>(), javaClass<KtPackageDirective>()) != null) return true
|
KtImportDirective::class.java, KtPackageDirective::class.java) != null) return true
|
||||||
|
|
||||||
val selector = qualifiedExpression.getSelectorExpression() ?: return false
|
val selector = qualifiedExpression.getSelectorExpression() ?: return false
|
||||||
val callee = selector.getCalleeExpressionIfAny() as? KtReferenceExpression ?: return false
|
val callee = selector.getCalleeExpressionIfAny() as? KtReferenceExpression ?: return false
|
||||||
@@ -441,7 +441,7 @@ public class ShortenReferences(val options: (KtElement) -> Options = { Options.D
|
|||||||
|
|
||||||
if (PsiTreeUtil.getParentOfType(
|
if (PsiTreeUtil.getParentOfType(
|
||||||
qualifiedExpression,
|
qualifiedExpression,
|
||||||
javaClass<KtImportDirective>(), javaClass<KtPackageDirective>()) != null) return false
|
KtImportDirective::class.java, KtPackageDirective::class.java) != null) return false
|
||||||
|
|
||||||
val receiverTarget = receiver.singleTarget(bindingContext) ?: return false
|
val receiverTarget = receiver.singleTarget(bindingContext) ?: return false
|
||||||
if (receiverTarget !is ClassDescriptor) return false
|
if (receiverTarget !is ClassDescriptor) return false
|
||||||
|
|||||||
+3
-3
@@ -38,8 +38,8 @@ public class IDEVirtualFileFinder(private val scope: GlobalSearchScope) : Virtua
|
|||||||
val files = FileBasedIndex.getInstance().getContainingFiles<FqName, Void>(key, classId.asSingleFqName(), scope)
|
val files = FileBasedIndex.getInstance().getContainingFiles<FqName, Void>(key, classId.asSingleFqName(), scope)
|
||||||
if (files.isEmpty()) return null
|
if (files.isEmpty()) return null
|
||||||
|
|
||||||
if (files.size() > 1) {
|
if (files.size > 1) {
|
||||||
LOG.warn("There are " + files.size() + " classes with same fqName: " + classId + " found.")
|
LOG.warn("There are " + files.size + " classes with same fqName: " + classId + " found.")
|
||||||
}
|
}
|
||||||
return files.iterator().next()
|
return files.iterator().next()
|
||||||
}
|
}
|
||||||
@@ -47,6 +47,6 @@ public class IDEVirtualFileFinder(private val scope: GlobalSearchScope) : Virtua
|
|||||||
override fun findVirtualFileWithHeader(classId: ClassId): VirtualFile? = findVirtualFileWithHeader(classId, KotlinClassFileIndex.KEY)
|
override fun findVirtualFileWithHeader(classId: ClassId): VirtualFile? = findVirtualFileWithHeader(classId, KotlinClassFileIndex.KEY)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val LOG = Logger.getInstance(javaClass<IDEVirtualFileFinder>())
|
private val LOG = Logger.getInstance(IDEVirtualFileFinder::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ public interface JsVirtualFileFinder : VirtualFileFinder {
|
|||||||
public object SERVICE {
|
public object SERVICE {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
public fun getInstance(project: Project): JsVirtualFileFinder =
|
public fun getInstance(project: Project): JsVirtualFileFinder =
|
||||||
ServiceManager.getService(project, javaClass<JsVirtualFileFinderFactory>()).create(GlobalSearchScope.allScope(project))
|
ServiceManager.getService(project, JsVirtualFileFinderFactory::class.java).create(GlobalSearchScope.allScope(project))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -27,6 +27,6 @@ public interface JsVirtualFileFinderFactory : VirtualFileFinderFactory {
|
|||||||
public object SERVICE {
|
public object SERVICE {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
public fun getInstance(project: Project): JsVirtualFileFinderFactory =
|
public fun getInstance(project: Project): JsVirtualFileFinderFactory =
|
||||||
ServiceManager.getService(project, javaClass<JsVirtualFileFinderFactory>())
|
ServiceManager.getService(project, JsVirtualFileFinderFactory::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ private fun findVirtualFileWithHeader(classId: ClassId, key: ID<FqName, Void>, s
|
|||||||
val files = FileBasedIndex.getInstance().getContainingFiles<FqName, Void>(key, classId.asSingleFqName(), scope)
|
val files = FileBasedIndex.getInstance().getContainingFiles<FqName, Void>(key, classId.asSingleFqName(), scope)
|
||||||
if (files.isEmpty()) return null
|
if (files.isEmpty()) return null
|
||||||
|
|
||||||
if (files.size() > 1) {
|
if (files.size > 1) {
|
||||||
logger.warn("There are " + files.size() + " classes with same fqName: " + classId + " found.")
|
logger.warn("There are " + files.size + " classes with same fqName: " + classId + " found.")
|
||||||
}
|
}
|
||||||
return files.iterator().next()
|
return files.iterator().next()
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ public class JsIDEVirtualFileFinder(private val scope: GlobalSearchScope) : JsVi
|
|||||||
findVirtualFileWithHeader(classId, KotlinJavaScriptMetaFileIndex.KEY, scope, LOG)
|
findVirtualFileWithHeader(classId, KotlinJavaScriptMetaFileIndex.KEY, scope, LOG)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val LOG = Logger.getInstance(javaClass<JsIDEVirtualFileFinder>())
|
private val LOG = Logger.getInstance(JsIDEVirtualFileFinder::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public class JvmIDEVirtualFileFinder(private val scope: GlobalSearchScope) : Vir
|
|||||||
findVirtualFileWithHeader(classId, KotlinClassFileIndex.KEY, scope, LOG)
|
findVirtualFileWithHeader(classId, KotlinClassFileIndex.KEY, scope, LOG)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val LOG = Logger.getInstance(javaClass<JvmIDEVirtualFileFinder>())
|
private val LOG = Logger.getInstance(JvmIDEVirtualFileFinder::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -27,7 +27,7 @@ import java.io.DataOutput
|
|||||||
|
|
||||||
public object KotlinModuleMappingIndex : FileBasedIndexExtension<String, PackageParts>() {
|
public object KotlinModuleMappingIndex : FileBasedIndexExtension<String, PackageParts>() {
|
||||||
|
|
||||||
private val classOfIndex = javaClass<KotlinModuleMappingIndex>().getCanonicalName()
|
private val classOfIndex = KotlinModuleMappingIndex::class.java.getCanonicalName()
|
||||||
|
|
||||||
public val KEY: ID<String, PackageParts> = ID.create(classOfIndex)
|
public val KEY: ID<String, PackageParts> = ID.create(classOfIndex)
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public object KotlinModuleMappingIndex : FileBasedIndexExtension<String, Package
|
|||||||
|
|
||||||
override fun save(out: DataOutput, value: PackageParts?) {
|
override fun save(out: DataOutput, value: PackageParts?) {
|
||||||
out.writeUTF(value!!.packageFqName)
|
out.writeUTF(value!!.packageFqName)
|
||||||
out.writeInt(value.parts.size())
|
out.writeInt(value.parts.size)
|
||||||
value.parts.forEach { out.writeUTF(it) }
|
value.parts.forEach { out.writeUTF(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user