public void showParameterInfo(@NotNull PsiElement element, CreateParameterInfoContext context) { ResolveResult[] variants = ResolveResult.EMPTY_ARRAY; if (element instanceof PsiPolyVariantReference) { variants = ((PsiPolyVariantReference) element).multiResolve(true); if (variants.length != 0) { context.setItemsToShow( ContainerUtil.map2Array( variants, CfmlFunctionDescription.class, new Function<ResolveResult, CfmlFunctionDescription>() { public CfmlFunctionDescription fun(ResolveResult resolveResult) { final PsiElement element1 = resolveResult.getElement(); if (CfmlPsiUtil.isFunctionDefinition(element1)) { CfmlFunction function = CfmlPsiUtil.getFunctionDefinition(element1); if (function != null) { return function.getFunctionInfo(); } } else if (element1 instanceof PsiMethod) { PsiMethod function = (PsiMethod) element1; CfmlFunctionDescription javaMethodDescr = new CfmlFunctionDescription( function.getName(), function.getReturnType().getPresentableText()); final PsiParameter[] psiParameters = function.getParameterList().getParameters(); final int paramsNum = psiParameters.length; for (int i = 0; i < paramsNum; i++) { PsiParameter psiParameter = psiParameters[i]; javaMethodDescr.addParameter( new CfmlFunctionDescription.CfmlParameterDescription( psiParameter.getName(), psiParameter.getType().getPresentableText(), true)); } return javaMethodDescr; } return null; } })); context.showHint(element, element.getTextRange().getStartOffset(), this); return; } } if (element instanceof CfmlReferenceExpression) { String functionName = element.getText().toLowerCase(); if (ArrayUtil.find( CfmlLangInfo.getInstance(element.getProject()).getPredefinedFunctionsLowCase(), functionName) != -1) { context.setItemsToShow( new Object[] { CfmlLangInfo.getInstance(element.getProject()) .getFunctionParameters() .get(functionName) }); context.showHint(element, element.getTextRange().getStartOffset(), this); } } }
private static boolean isEmbraced(@Nullable PsiElement element, int offset) { if (element == null) { return false; } ASTNode node = element.getNode(); if (node == null) { return false; } final ASTNode lbrace = node.findChildByType(CfscriptTokenTypes.L_BRACKET); final ASTNode rbrace = node.findChildByType(CfscriptTokenTypes.R_BRACKET); if (lbrace == null || rbrace == null) { return false; } return lbrace.getStartOffset() < offset && rbrace.getStartOffset() >= offset; }