use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParams in project intellij-community by JetBrains.
the class GroovyDocParamsSelectioner method select.
@Override
public List<TextRange> select(PsiElement element, CharSequence editorText, int cursorOffset, Editor editor) {
List<TextRange> result = super.select(element, editorText, cursorOffset, editor);
if (element instanceof GrDocMethodParams) {
GrDocMethodParams params = ((GrDocMethodParams) element);
TextRange range = params.getTextRange();
if (range.contains(cursorOffset)) {
PsiElement leftParen = params.getLeftParen();
PsiElement rightParen = params.getRightParen();
int leftOffset = leftParen.getTextOffset();
if (rightParen != null) {
if (leftOffset + 1 < rightParen.getTextOffset()) {
int rightOffset = rightParen.getTextRange().getEndOffset();
range = new TextRange(leftParen.getTextRange().getStartOffset() + 1, rightOffset - 1);
result.add(range);
}
} else {
range = new TextRange(leftParen.getTextRange().getStartOffset() + 1, element.getTextRange().getEndOffset());
result.add(range);
}
}
}
return result;
}
use of org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParams 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;
}
Aggregations