@NotNull @Override public Collection<PsiClass> getPackageClasses( @NotNull FqName packageFqName, @NotNull GlobalSearchScope scope) { List<PsiClass> result = new ArrayList<PsiClass>(); List<KotlinLightPackageClassInfo> packageClassesInfos = findPackageClassesInfos(packageFqName, scope); for (KotlinLightPackageClassInfo info : packageClassesInfos) { List<JetFile> files = PackagePartClassUtils.getPackageFilesWithCallables(info.getFiles()); if (files.isEmpty()) continue; IdeaModuleInfo moduleInfo = info.getModuleInfo(); if (moduleInfo instanceof ModuleSourceInfo) { KotlinLightClassForPackage lightClass = KotlinLightClassForPackage.Factory.create( psiManager, packageFqName, moduleInfo.contentScope(), files); if (lightClass == null) continue; result.add(lightClass); if (files.size() > 1) { for (JetFile file : files) { result.add(new FakeLightClassForFileOfPackage(psiManager, lightClass, file)); } } } else { PsiClass clsClass = getLightClassForDecompiledPackage(packageFqName, files); if (clsClass != null) { result.add(clsClass); } } } return result; }
@Nullable private KtNamedDeclaration[] getVariables(Expression[] params, ExpressionContext context) { if (params.length != 0) return null; Project project = context.getProject(); PsiDocumentManager.getInstance(project).commitAllDocuments(); PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(context.getEditor().getDocument()); if (!(psiFile instanceof KtFile)) return null; KtExpression contextExpression = findContextExpression(psiFile, context.getStartOffset()); if (contextExpression == null) return null; ResolutionFacade resolutionFacade = ResolutionUtils.getResolutionFacade(contextExpression); BindingContext bindingContext = resolutionFacade.analyze(contextExpression, BodyResolveMode.FULL); LexicalScope scope = ScopeUtils.getResolutionScope(contextExpression, bindingContext, resolutionFacade); IterableTypesDetector detector = resolutionFacade.getIdeService(IterableTypesDetection.class).createDetector(scope); DataFlowInfo dataFlowInfo = BindingContextUtilsKt.getDataFlowInfo(bindingContext, contextExpression); List<VariableDescriptor> filteredDescriptors = new ArrayList<VariableDescriptor>(); for (DeclarationDescriptor declarationDescriptor : getAllVariables(scope)) { if (declarationDescriptor instanceof VariableDescriptor) { VariableDescriptor variableDescriptor = (VariableDescriptor) declarationDescriptor; if (variableDescriptor.getExtensionReceiverParameter() != null && ExtensionUtils.substituteExtensionIfCallableWithImplicitReceiver( variableDescriptor, scope, bindingContext, dataFlowInfo) .isEmpty()) { continue; } if (isSuitable(variableDescriptor, project, detector)) { filteredDescriptors.add(variableDescriptor); } } } List<KtNamedDeclaration> declarations = new ArrayList<KtNamedDeclaration>(); for (DeclarationDescriptor declarationDescriptor : filteredDescriptors) { PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(declarationDescriptor); assert declaration == null || declaration instanceof PsiNamedElement; if (declaration instanceof KtProperty || declaration instanceof KtParameter) { declarations.add((KtNamedDeclaration) declaration); } } return declarations.toArray(new KtNamedDeclaration[declarations.size()]); }
public void leaveTemps() { FrameMap frameMap = codegen.getFrameMap(); List<ParameterInfo> infos = invocationParamBuilder.listAllParams(); for (ListIterator<? extends ParameterInfo> iterator = infos.listIterator(infos.size()); iterator.hasPrevious(); ) { ParameterInfo param = iterator.previous(); if (!param.isSkippedOrRemapped()) { frameMap.leaveTemp(param.type); } } }
@Nullable private static PsiClass getLightClassForDecompiledPackage( @NotNull FqName packageFqName, @NotNull List<JetFile> filesWithCallables) { JetFile firstFile = filesWithCallables.iterator().next(); if (firstFile.isCompiled()) { if (filesWithCallables.size() > 1) { LOG.error("Several files with callables for package: " + packageFqName); } return createLightClassForDecompiledKotlinFile(firstFile); } return null; }
@Override public void putHiddenParams() { List<JvmMethodParameterSignature> valueParameters = jvmSignature.getValueParameters(); if (!isStaticMethod(functionDescriptor, context)) { invocationParamBuilder.addNextParameter(AsmTypes.OBJECT_TYPE, false, null); } for (JvmMethodParameterSignature param : valueParameters) { if (param.getKind() == JvmMethodParameterKind.VALUE) { break; } invocationParamBuilder.addNextParameter(param.getAsmType(), false, null); } List<ParameterInfo> infos = invocationParamBuilder.listNotCaptured(); putParameterOnStack(infos.toArray(new ParameterInfo[infos.size()])); }