本文整理汇总了Java中com.intellij.psi.impl.source.javadoc.PsiDocParamRef类的典型用法代码示例。如果您正苦于以下问题:Java PsiDocParamRef类的具体用法?Java PsiDocParamRef怎么用?Java PsiDocParamRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiDocParamRef类属于com.intellij.psi.impl.source.javadoc包,在下文中一共展示了PsiDocParamRef类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processParameterUsage
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
private void processParameterUsage(ParameterUsageInfo usage) throws IncorrectOperationException {
final PsiReference reference = usage.getReferenceExpression();
if (reference instanceof PsiReferenceExpression) {
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)reference;
PsiElement parent = referenceExpression.getParent();
if (parent instanceof PsiReferenceExpression && sameUnqualified(parent)) {
referenceExpression.delete();
}
else {
final PsiExpression expression =
JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory().createExpressionFromText("this", null);
referenceExpression.replace(expression);
}
} else {
final PsiElement element = reference.getElement();
if (element instanceof PsiDocParamRef) {
element.getParent().delete();
}
}
}
示例2: processParameterUsage
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
private void processParameterUsage(ParameterUsageInfo usage) throws IncorrectOperationException {
final PsiReference reference = usage.getReferenceExpression();
if (reference instanceof PsiReferenceExpression) {
final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)reference;
if (referenceExpression.getParent() instanceof PsiReferenceExpression) {
// todo: check for correctness
referenceExpression.delete();
}
else {
final PsiExpression expression =
JavaPsiFacade.getInstance(myMethod.getProject()).getElementFactory().createExpressionFromText("this", null);
referenceExpression.replace(expression);
}
} else {
final PsiElement element = reference.getElement();
if (element instanceof PsiDocParamRef) {
element.getParent().delete();
}
}
}
示例3: getDocTagParam
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
private static PsiParameter getDocTagParam(PsiElement tag)
{
if(tag instanceof PsiDocTag && "param".equals(((PsiDocTag) tag).getName()))
{
PsiDocTagValue value = ((PsiDocTag) tag).getValueElement();
if(value instanceof PsiDocParamRef)
{
final PsiReference psiReference = value.getReference();
PsiElement target = psiReference != null ? psiReference.resolve() : null;
if(target instanceof PsiParameter)
{
return (PsiParameter) target;
}
}
}
return null;
}
示例4: isFound
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
public static boolean isFound(final PsiDocTag[] tags, final PsiElement param) {
for (PsiDocTag tag : tags) {
if ("param".equals(tag.getName())) {
PsiDocTagValue value = tag.getValueElement();
if (value instanceof PsiDocParamRef) {
PsiDocParamRef paramRef = (PsiDocParamRef)value;
final PsiReference psiReference = paramRef.getReference();
if (psiReference != null && psiReference.isReferenceTo(param)) {
return true;
}
}
}
}
return false;
}
示例5: getDocTagParam
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
private static PsiParameter getDocTagParam(PsiElement tag) {
if (tag instanceof PsiDocTag && "param".equals(((PsiDocTag)tag).getName())) {
PsiDocTagValue value = ((PsiDocTag)tag).getValueElement();
if (value instanceof PsiDocParamRef) {
final PsiReference psiReference = value.getReference();
PsiElement target = psiReference != null ? psiReference.resolve() : null;
if (target instanceof PsiParameter) {
return (PsiParameter)target;
}
}
}
return null;
}
示例6: getDocumentingParameter
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
@Nullable
private static PsiElement getDocumentingParameter(PsiDocTag tag) {
for (PsiElement element : tag.getChildren()) {
if (element instanceof PsiDocParamRef) {
return element;
}
}
return null;
}
示例7: fixJavadocForConstructor
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
private void fixJavadocForConstructor(PsiClass psiClass) {
final PsiDocComment docComment = method.getDocComment();
if (docComment != null) {
final List<PsiDocTag> mergedTags = new ArrayList<PsiDocTag>();
final PsiDocTag[] paramTags = docComment.findTagsByName("param");
for (PsiDocTag paramTag : paramTags) {
final PsiElement[] dataElements = paramTag.getDataElements();
if (dataElements.length > 0) {
if (dataElements[0] instanceof PsiDocParamRef) {
final PsiReference reference = dataElements[0].getReference();
if (reference != null) {
final PsiElement resolve = reference.resolve();
if (resolve instanceof PsiParameter) {
final int parameterIndex = method.getParameterList().getParameterIndex((PsiParameter)resolve);
if (ArrayUtil.find(paramsToMerge, parameterIndex) < 0) continue;
}
}
}
mergedTags.add((PsiDocTag)paramTag.copy());
}
}
PsiMethod compatibleParamObjectConstructor = null;
if (myExistingClassCompatibleConstructor != null && myExistingClassCompatibleConstructor.getDocComment() == null) {
compatibleParamObjectConstructor = myExistingClassCompatibleConstructor;
} else if (!myUseExistingClass){
compatibleParamObjectConstructor = psiClass.getConstructors()[0];
}
if (compatibleParamObjectConstructor != null) {
PsiDocComment psiDocComment = JavaPsiFacade.getElementFactory(myProject).createDocCommentFromText("/**\n*/");
psiDocComment = (PsiDocComment)compatibleParamObjectConstructor.addBefore(psiDocComment, compatibleParamObjectConstructor.getFirstChild());
for (PsiDocTag tag : mergedTags) {
psiDocComment.add(tag);
}
}
}
}
示例8: isAppropriatePlace
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
private static boolean isAppropriatePlace(Editor editor, PsiFile file) {
FileViewProvider provider = file.getViewProvider();
int offset = editor.getCaretModel().getOffset();
final PsiElement elementAtCaret;
if (offset < editor.getDocument().getTextLength()) {
elementAtCaret = provider.findElementAt(offset);
}
else {
elementAtCaret = provider.findElementAt(editor.getDocument().getTextLength() - 1);
}
PsiElement element = elementAtCaret;
while(element instanceof PsiWhiteSpace || element != null && containsOnlyWhiteSpaces(element.getText())) {
element = element.getPrevSibling();
}
if (element == null) {
return false;
}
if (element instanceof PsiDocParamRef) {
element = element.getParent();
}
if (element instanceof PsiDocTag) {
PsiDocTag tag = (PsiDocTag)element;
if ("param".equals(tag.getName()) && isTypeParamBracketClosedAfterParamTag(tag, offset)) {
return false;
}
}
// The contents of inline tags is not HTML, so the paired tag completion isn't appropriate there.
if (PsiTreeUtil.getParentOfType(element, PsiInlineDocTag.class, false) != null) {
return false;
}
ASTNode node = element.getNode();
return node != null
&& (JavaDocTokenType.ALL_JAVADOC_TOKENS.contains(node.getElementType())
|| JavaDocElementType.ALL_JAVADOC_ELEMENTS.contains(node.getElementType()));
}
示例9: generateParametersTakingDocFromSuperMethods
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
public static void generateParametersTakingDocFromSuperMethods(Project project,
StringBuilder builder,
CodeDocumentationAwareCommenter commenter, PsiMethod psiMethod) {
final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
final Map<String, String> param2Description = new HashMap<String, String>();
final PsiMethod[] superMethods = psiMethod.findSuperMethods();
for (PsiMethod superMethod : superMethods) {
final PsiDocComment comment = superMethod.getDocComment();
if (comment != null) {
final PsiDocTag[] params = comment.findTagsByName("param");
for (PsiDocTag param : params) {
final PsiElement[] dataElements = param.getDataElements();
if (dataElements != null) {
String paramName = null;
for (PsiElement dataElement : dataElements) {
if (dataElement instanceof PsiDocParamRef) {
//noinspection ConstantConditions
paramName = dataElement.getReference().getCanonicalText();
break;
}
}
if (paramName != null) {
param2Description.put(paramName, param.getText());
}
}
}
}
}
for (PsiParameter parameter : parameters) {
String description = param2Description.get(parameter.getName());
if (description != null) {
builder.append(CodeDocumentationUtil.createDocCommentLine("", project, commenter));
if (description.indexOf('\n') > -1) description = description.substring(0, description.lastIndexOf('\n'));
builder.append(description);
}
else {
builder.append(CodeDocumentationUtil.createDocCommentLine(PARAM_TAG, project, commenter));
builder.append(parameter.getName());
}
builder.append(LINE_SEPARATOR);
}
}
示例10: isAppropriatePlace
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
private static boolean isAppropriatePlace(Editor editor, PsiFile file) {
FileViewProvider provider = file.getViewProvider();
int offset = editor.getCaretModel().getOffset();
final PsiElement elementAtCaret;
if (offset < editor.getDocument().getTextLength()) {
elementAtCaret = provider.findElementAt(offset);
}
else {
elementAtCaret = provider.findElementAt(editor.getDocument().getTextLength() - 1);
}
PsiElement element = elementAtCaret;
while(element instanceof PsiWhiteSpace) {
element = element.getPrevSibling();
}
if (element == null) {
return false;
}
if (element instanceof PsiDocParamRef) {
element = element.getParent();
}
if (element instanceof PsiDocTag) {
// We don't want to provide closing tag for the type parameters, i.e. at situations like the one below:
// /**
// * @param <T>[caret]
// */
PsiDocTag tag = (PsiDocTag)element;
if ("param".equals(tag.getName())) {
final PsiDocTagValue value = tag.getValueElement();
if (value == null || value.getTextRange().getEndOffset() == offset) {
return false;
}
}
}
ASTNode node = element.getNode();
return node != null
&& (JavaDocTokenType.ALL_JAVADOC_TOKENS.contains(node.getElementType())
|| JavaDocElementType.ALL_JAVADOC_ELEMENTS.contains(node.getElementType()));
}
示例11: generateParametersTakingDocFromSuperMethods
import com.intellij.psi.impl.source.javadoc.PsiDocParamRef; //导入依赖的package包/类
public static void generateParametersTakingDocFromSuperMethods(Project project, StringBuilder builder, CodeDocumentationAwareCommenter commenter, PsiMethod psiMethod)
{
final PsiParameter[] parameters = psiMethod.getParameterList().getParameters();
final Map<String, String> param2Description = new HashMap<>();
final PsiMethod[] superMethods = psiMethod.findSuperMethods();
for(PsiMethod superMethod : superMethods)
{
final PsiDocComment comment = superMethod.getDocComment();
if(comment != null)
{
final PsiDocTag[] params = comment.findTagsByName("param");
for(PsiDocTag param : params)
{
final PsiElement[] dataElements = param.getDataElements();
if(dataElements != null)
{
String paramName = null;
for(PsiElement dataElement : dataElements)
{
if(dataElement instanceof PsiDocParamRef)
{
//noinspection ConstantConditions
paramName = dataElement.getReference().getCanonicalText();
break;
}
}
if(paramName != null)
{
param2Description.put(paramName, param.getText());
}
}
}
}
}
for(PsiParameter parameter : parameters)
{
String description = param2Description.get(parameter.getName());
if(description != null)
{
builder.append(CodeDocumentationUtil.createDocCommentLine("", project, commenter));
if(description.indexOf('\n') > -1)
{
description = description.substring(0, description.lastIndexOf('\n'));
}
builder.append(description);
}
else
{
builder.append(CodeDocumentationUtil.createDocCommentLine(PARAM_TAG, project, commenter));
builder.append(parameter.getName());
}
builder.append(LINE_SEPARATOR);
}
}