Source:
<code>private static String getSignature(PsiElement element) { if (element instanceof GoTypeSpec) { String name = ((GoTypeSpec)element).getName(); return StringUtil.isNotEmpty(name) ? "type " + name : ""; } if (element instanceof GoConstDefinition) { if (element.getParent() instanceof GoConstSpec) { GoConstSpec spec = (GoConstSpec) element.getParent(); StringBuilder result = new StringBuilder("const "); <START> result.append(StringUtil.join(spec.getConstDefinitionList(), ELEMENT_TO_TEXT_FUNC, ", ") + " "); <END> if (spec.getType() != null) { result.append(getTypePresentation(spec.getType())); } if (spec.getAssign() != null) { result.append(" " + spec.getAssign().getText() + " "); } result.append(StringUtil.join(spec.getExpressionList(), ELEMENT_TO_TEXT_FUNC, ",")); return result.toString(); } } if (!(element instanceof GoSignatureOwner)) return ""; PsiElement identifier = null; if (element instanceof GoNamedSignatureOwner) { identifier = ((GoNamedSignatureOwner)element).getIdentifier(); } GoSignature signature = ((GoSignatureOwner)element).getSignature(); if (identifier == null && signature == null) { return ""; } StringBuilder builder = new StringBuilder("func ").append(identifier != null ? identifier.getText() : "").append('('); if (signature != null) { builder.append(getParametersAsString(signature.getParameters())); } builder.append(')'); GoResult result = signature != null ? signature.getResult() : null; GoParameters parameters = result != null ? result.getParameters() : null; GoType type = result != null ? result.getType() : null; if (parameters != null) { String signatureParameters = getParametersAsString(parameters); if (!signatureParameters.isEmpty()) { builder.append(" (").append(signatureParameters).append(')'); } } else if (type != null) { builder.append(' ').append(getTypePresentation(type)); } return builder.toString(); }</code><technical_language>reuse GoPsiImplUtil.GET_TEXT_FUNCTION</technical_language>

Target:
private static String getSignature(PsiElement element) { if (element instanceof GoTypeSpec) { String name = ((GoTypeSpec)element).getName(); return StringUtil.isNotEmpty(name) ? "type " + name : ""; } if (element instanceof GoConstDefinition) { if (element.getParent() instanceof GoConstSpec) { GoConstSpec spec = (GoConstSpec) element.getParent(); StringBuilder result = new StringBuilder(); result.append(StringUtil.join(spec.getConstDefinitionList(), GoPsiImplUtil.GET_TEXT_FUNCTION, ",")); result.append(" "); result.append(getTypePresentation(spec.getType())); if (spec.getAssign() != null) { result.append(" "); result.append(spec.getAssign().getText()); result.append(" "); } result.append(StringUtil.join(spec.getExpressionList(), GoPsiImplUtil.GET_TEXT_FUNCTION, ",")); return result.toString(); } } if (!(element instanceof GoSignatureOwner)) return ""; PsiElement identifier = null; if (element instanceof GoNamedSignatureOwner) { identifier = ((GoNamedSignatureOwner)element).getIdentifier(); } GoSignature signature = ((GoSignatureOwner)element).getSignature(); if (identifier == null && signature == null) { return ""; } StringBuilder builder = new StringBuilder("func ").append(identifier != null ? identifier.getText() : "").append('('); if (signature != null) { builder.append(getParametersAsString(signature.getParameters())); } builder.append(')'); GoResult result = signature != null ? signature.getResult() : null; GoParameters parameters = result != null ? result.getParameters() : null; GoType type = result != null ? result.getType() : null; if (parameters != null) { String signatureParameters = getParametersAsString(parameters); if (!signatureParameters.isEmpty()) { builder.append(" (").append(signatureParameters).append(')'); } } else if (type != null) { builder.append(' ').append(getTypePresentation(type)); } return builder.toString(); }