private static List<String> getOuterClassesNames(ClassDescriptor cd) { ArrayList<String> result = new ArrayList<String>(); while (cd.getContainingDeclaration() instanceof ClassifierDescriptor) { result.add(cd.getName().getName()); cd = (ClassDescriptor) cd.getContainingDeclaration(); } return result; }
private static JetValueArgumentList findCall(CreateParameterInfoContext context) { // todo: calls to this constructors, when we will have auxiliary constructors PsiFile file = context.getFile(); if (!(file instanceof JetFile)) return null; PsiElement element = file.findElementAt(context.getOffset()); while (element != null && !(element instanceof JetValueArgumentList)) { element = element.getParent(); } if (element == null) return null; JetValueArgumentList argumentList = (JetValueArgumentList) element; JetCallElement callExpression; if (element.getParent() instanceof JetCallElement) { callExpression = (JetCallElement) element.getParent(); } else { return null; } BindingContext bindingContext = AnalyzeSingleFileUtil.getContextForSingleFile((JetFile) file); JetExpression calleeExpression = callExpression.getCalleeExpression(); if (calleeExpression == null) return null; JetSimpleNameExpression refExpression = null; if (calleeExpression instanceof JetSimpleNameExpression) { refExpression = (JetSimpleNameExpression) calleeExpression; } else if (calleeExpression instanceof JetConstructorCalleeExpression) { JetConstructorCalleeExpression constructorCalleeExpression = (JetConstructorCalleeExpression) calleeExpression; if (constructorCalleeExpression.getConstructorReferenceExpression() instanceof JetSimpleNameExpression) { refExpression = (JetSimpleNameExpression) constructorCalleeExpression.getConstructorReferenceExpression(); } } if (refExpression != null) { JetScope scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, refExpression); DeclarationDescriptor placeDescriptor = null; if (scope != null) { placeDescriptor = scope.getContainingDeclaration(); } Collection<DeclarationDescriptor> variants = TipsManager.getReferenceVariants(refExpression, bindingContext); Name refName = refExpression.getReferencedNameAsName(); PsiReference[] references = refExpression.getReferences(); if (references.length == 0) return null; ArrayList<DeclarationDescriptor> itemsToShow = new ArrayList<DeclarationDescriptor>(); for (DeclarationDescriptor variant : variants) { if (variant instanceof FunctionDescriptor) { FunctionDescriptor functionDescriptor = (FunctionDescriptor) variant; if (functionDescriptor.getName().equals(refName)) { // todo: renamed functions? if (placeDescriptor != null && !JetVisibilityChecker.isVisible(placeDescriptor, functionDescriptor)) continue; itemsToShow.add(functionDescriptor); } } else if (variant instanceof ClassDescriptor) { ClassDescriptor classDescriptor = (ClassDescriptor) variant; if (classDescriptor.getName().equals(refName)) { // todo: renamed classes? for (ConstructorDescriptor constructorDescriptor : classDescriptor.getConstructors()) { if (placeDescriptor != null && !JetVisibilityChecker.isVisible(placeDescriptor, constructorDescriptor)) continue; itemsToShow.add(constructorDescriptor); } } } } context.setItemsToShow(ArrayUtil.toObjectArray(itemsToShow)); return argumentList; } return null; }