当前位置: 首页>>代码示例>>Java>>正文


Java PsiDocParamRef类代码示例

本文整理汇总了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();
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ConvertToInstanceMethodProcessor.java

示例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();
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:ConvertToInstanceMethodProcessor.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:JavaDocCompletionContributor.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:JavaDocLocalInspectionBase.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JavaDocCompletionContributor.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JavadocTypedHandler.java

示例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);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:40,代码来源:IntroduceParameterObjectProcessor.java

示例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()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:JavadocTypedHandler.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:JavaDocumentationProvider.java

示例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()));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:45,代码来源:JavadocTypedHandler.java

示例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);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:57,代码来源:JavaDocumentationProvider.java


注:本文中的com.intellij.psi.impl.source.javadoc.PsiDocParamRef类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。