Search in sources :

Example 1 with GrDocMethodParameter

use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParameter in project intellij-community by JetBrains.

the class GrDocMethodParamsImpl method getParameterTypes.

@Override
public PsiType[] getParameterTypes() {
    ArrayList<PsiType> types = new ArrayList<>();
    PsiManagerEx manager = getManager();
    GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
    PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
    for (GrDocMethodParameter parameter : getParameters()) {
        GrDocReferenceElement typeElement = parameter.getTypeElement();
        try {
            PsiType type = factory.createTypeFromText(typeElement.getText(), this);
            type = TypesUtil.boxPrimitiveType(type, manager, scope);
            types.add(type);
        } catch (IncorrectOperationException e) {
            LOG.info(e);
            types.add(null);
        }
    }
    return types.toArray(PsiType.createArray(types.size()));
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) GrDocReferenceElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement) ArrayList(java.util.ArrayList) PsiElementFactory(com.intellij.psi.PsiElementFactory) IncorrectOperationException(com.intellij.util.IncorrectOperationException) GrDocMethodParameter(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParameter) PsiType(com.intellij.psi.PsiType) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx)

Example 2 with GrDocMethodParameter

use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParameter in project intellij-community by JetBrains.

the class GroovyDocMethodHandler method shortenParamterReferences.

private static int shortenParamterReferences(InsertionContext context, int startOffset, PsiMethod method, StringBuffer buffer) {
    Document document = context.getEditor().getDocument();
    int offset = startOffset + method.getName().length();
    String paramText = buffer.toString();
    document.insertString(offset, paramText);
    int endOffset = offset + paramText.length();
    final Project project = context.getProject();
    PsiDocumentManager.getInstance(project).commitDocument(document);
    PsiReference ref = context.getFile().findReferenceAt(startOffset);
    if (ref instanceof GrDocMethodReference) {
        GrDocMethodReference methodReference = (GrDocMethodReference) ref;
        GrDocMethodParams list = methodReference.getParameterList();
        for (GrDocMethodParameter parameter : list.getParameters()) {
            JavaCodeStyleManager.getInstance(project).shortenClassReferences(parameter);
        }
        endOffset = methodReference.getTextRange().getEndOffset() + 1;
    }
    return endOffset;
}
Also used : Project(com.intellij.openapi.project.Project) GrDocMethodParams(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParams) Document(com.intellij.openapi.editor.Document) GrDocMethodParameter(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParameter) GrDocMethodReference(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodReference)

Aggregations

GrDocMethodParameter (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParameter)2 Document (com.intellij.openapi.editor.Document)1 Project (com.intellij.openapi.project.Project)1 PsiElementFactory (com.intellij.psi.PsiElementFactory)1 PsiType (com.intellij.psi.PsiType)1 PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 ArrayList (java.util.ArrayList)1 GrDocMethodParams (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParams)1 GrDocMethodReference (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodReference)1 GrDocReferenceElement (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement)1