Search in sources :

Example 1 with GrMethodStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub 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();
}
Also used : NamedArgumentDescriptor(org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor) GrTypeElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement) GrNamedArgumentSearchVisitor(org.jetbrains.plugins.groovy.lang.psi.api.statements.GrNamedArgumentSearchVisitor) GrOpenBlock(org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock) GrMethodStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub) GrParameter(org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with GrMethodStub

use of org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub in project intellij-community by JetBrains.

the class GrMethodElementType method deserialize.

@Override
@NotNull
public GrMethodStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
    StringRef ref = dataStream.readName();
    final String[] annNames = GrStubUtils.readStringArray(dataStream);
    String[] namedParameters = GrStubUtils.readStringArray(dataStream);
    String typeText = GrStubUtils.readNullableString(dataStream);
    final byte flags = dataStream.readByte();
    return new GrMethodStub(parentStub, ref, annNames, namedParameters, this, typeText, flags);
}
Also used : StringRef(com.intellij.util.io.StringRef) GrMethodStub(org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)2 GrMethodStub (org.jetbrains.plugins.groovy.lang.psi.stubs.GrMethodStub)2 StringRef (com.intellij.util.io.StringRef)1 NamedArgumentDescriptor (org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor)1 GrNamedArgumentSearchVisitor (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrNamedArgumentSearchVisitor)1 GrOpenBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock)1 GrParameter (org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter)1 GrTypeElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement)1