use of com.intellij.coldFusion.model.info.CfmlFunctionDescription in project intellij-plugins by JetBrains.
the class CfmlParameterInfoHandler method showParameterInfo.
public void showParameterInfo(@NotNull PsiElement element, @NotNull 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, 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);
}
}
}
use of com.intellij.coldFusion.model.info.CfmlFunctionDescription in project intellij-plugins by JetBrains.
the class CfmlArgumentNameReference method getVariants.
@NotNull
@Override
public Object[] getVariants() {
Collection<LookupElement> result = new LinkedList<>();
Object[] superResult = ArrayUtil.EMPTY_OBJECT_ARRAY;
String functionName = getFunctionName();
if (CfmlUtil.isPredefinedFunction(functionName, getProject())) {
CfmlFunctionDescription cfmlFunctionDescription = CfmlLangInfo.getInstance(getProject()).getFunctionParameters().get(functionName.toLowerCase());
for (CfmlFunctionDescription.CfmlParameterDescription param : cfmlFunctionDescription.getParameters()) {
result.add(TailTypeDecorator.withTail(LookupElementBuilder.create(param.getName()).withCaseSensitivity(false), TailType.createSimpleTailType('=')));
}
} else {
CfmlArgumentList parentArgumentsList = PsiTreeUtil.getParentOfType(this, CfmlArgumentList.class);
if (parentArgumentsList != null) {
CfmlExpression[] arguments = parentArgumentsList.getArguments();
if (arguments.length == 1) {
result.add(LookupElementBuilder.create("argumentCollection").withCaseSensitivity(false));
}
}
}
PsiElement nextSibling = getNextSibling();
while (nextSibling instanceof PsiWhiteSpace) {
nextSibling = nextSibling.getNextSibling();
}
if (nextSibling != null && nextSibling.getNode().getElementType() != CfmlTokenTypes.ASSIGN) {
superResult = super.getVariants();
}
CfmlParameter[] functionParameters = getFunctionParameters();
if (functionParameters != null) {
for (CfmlParameter param : functionParameters) {
result.add(CfmlLookUpItemUtil.namedElementToLookupItem(param, null));
}
}
if (!result.isEmpty() || superResult.length > 0) {
return ArrayUtil.mergeArrays(superResult, ContainerUtil.map2Array(result, Object.class, (Function<LookupElement, Object>) lookupElement -> lookupElement));
}
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
use of com.intellij.coldFusion.model.info.CfmlFunctionDescription in project intellij-plugins by JetBrains.
the class CfmlLookUpItemUtil method getFunctionDescription.
public static CfmlFunctionDescription getFunctionDescription(CfmlFunction function) {
PsiType returnType = function.getReturnType();
CfmlFunctionDescription functionInfo = new CfmlFunctionDescription(function.getName(), returnType != null ? returnType.getCanonicalText() : null);
CfmlParameter[] params = function.getParameters();
for (CfmlParameter param : params) {
functionInfo.addParameter(new CfmlFunctionDescription.CfmlParameterDescription(param.getName(), param.getType(), param.isRequired()));
}
return functionInfo;
}
Aggregations