use of org.jetbrains.plugins.groovy.lang.psi.api.statements.GrNamedArgumentSearchVisitor in project intellij-community by JetBrains.
the class GrMethodBaseImpl method getNamedParameters.
@Override
@NotNull
public Map<String, NamedArgumentDescriptor> getNamedParameters() {
final GrMethodStub stub = getStub();
if (stub != null) {
String[] namedParameters = stub.getNamedParameters();
if (namedParameters.length == 0)
return Collections.emptyMap();
Map<String, NamedArgumentDescriptor> result = ContainerUtil.newHashMap();
for (String parameter : namedParameters) {
result.put(parameter, GrNamedArgumentSearchVisitor.CODE_NAMED_ARGUMENTS_DESCR);
}
return result;
}
GrOpenBlock body = getBlock();
if (body == null)
return Collections.emptyMap();
GrParameter[] parameters = getParameters();
if (parameters.length == 0)
return Collections.emptyMap();
GrParameter firstParameter = parameters[0];
PsiType type = firstParameter.getTypeGroovy();
GrTypeElement typeElement = firstParameter.getTypeElementGroovy();
if (type != null && typeElement != null && type.getPresentableText() != null && !type.getPresentableText().endsWith("Map")) {
return Collections.emptyMap();
}
GrNamedArgumentSearchVisitor visitor = new GrNamedArgumentSearchVisitor(firstParameter.getNameIdentifierGroovy().getText());
body.accept(visitor);
return visitor.getResult();
}
Aggregations