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


Java JavadocTagInfo.isValidInContext方法代码示例

本文整理汇总了Java中com.intellij.psi.javadoc.JavadocTagInfo.isValidInContext方法的典型用法代码示例。如果您正苦于以下问题:Java JavadocTagInfo.isValidInContext方法的具体用法?Java JavadocTagInfo.isValidInContext怎么用?Java JavadocTagInfo.isValidInContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.javadoc.JavadocTagInfo的用法示例。


在下文中一共展示了JavadocTagInfo.isValidInContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkForPeriodInDoc

import com.intellij.psi.javadoc.JavadocTagInfo; //导入方法依赖的package包/类
private void checkForPeriodInDoc(PsiDocComment docComment,
                                 ArrayList<ProblemDescriptor> problems,
                                 InspectionManager manager, boolean onTheFly) {
  if (IGNORE_JAVADOC_PERIOD) return;
  PsiDocTag[] tags = docComment.getTags();
  int dotIndex = docComment.getText().indexOf('.');
  int tagOffset = 0;
  if (dotIndex >= 0) {      //need to find first valid tag
    final PsiDocCommentOwner owner = PsiTreeUtil.getParentOfType(docComment, PsiDocCommentOwner.class);
    for (PsiDocTag tag : tags) {
      final String tagName = tag.getName();
      final JavadocTagInfo tagInfo = JavadocManager.SERVICE.getInstance(tag.getProject()).getTagInfo(tagName);
      if (tagInfo != null && tagInfo.isValidInContext(owner) && !tagInfo.isInline()) {
        tagOffset = tag.getTextOffset();
        break;
      }
    }
  }

  if (dotIndex == -1 || tagOffset > 0 && dotIndex + docComment.getTextOffset() > tagOffset) {
    problems.add(manager.createProblemDescriptor(docComment.getFirstChild(),
                                                 InspectionsBundle.message("inspection.javadoc.problem.descriptor1"),
                                                 null,
                                                 ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly, false));
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:JavaDocLocalInspection.java

示例2: getTagInfos

import com.intellij.psi.javadoc.JavadocTagInfo; //导入方法依赖的package包/类
@Override
@NotNull
public JavadocTagInfo[] getTagInfos(PsiElement context)
{
	List<JavadocTagInfo> result = new ArrayList<>();

	for(JavadocTagInfo info : myInfos)
	{
		if(info.isValidInContext(context))
		{
			result.add(info);
		}
	}

	return result.toArray(new JavadocTagInfo[result.size()]);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:17,代码来源:JavadocManagerImpl.java

示例3: getTagInfos

import com.intellij.psi.javadoc.JavadocTagInfo; //导入方法依赖的package包/类
@Override
@NotNull
public JavadocTagInfo[] getTagInfos(PsiElement context) {
  List<JavadocTagInfo> result = new ArrayList<JavadocTagInfo>();

  for (JavadocTagInfo info : myInfos) {
    if (info.isValidInContext(context)) {
      result.add(info);
    }
  }

  return result.toArray(new JavadocTagInfo[result.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JavadocManagerImpl.java

示例4: visitRefInDocTag

import com.intellij.psi.javadoc.JavadocTagInfo; //导入方法依赖的package包/类
public static void visitRefInDocTag(final PsiDocTag tag,
		final JavadocManager manager,
		final PsiElement context,
		final ArrayList<ProblemDescriptor> problems,
		final InspectionManager inspectionManager,
		final boolean onTheFly)
{
	final String tagName = tag.getName();
	final PsiDocTagValue value = tag.getValueElement();
	if(value == null)
	{
		return;
	}
	final JavadocTagInfo info = manager.getTagInfo(tagName);
	if(info != null && !info.isValidInContext(context))
	{
		return;
	}
	final String message = info == null || !info.isInline() ? null : info.checkTagValue(value);
	if(message != null)
	{
		problems.add(createDescriptor(value, message, inspectionManager, onTheFly));
	}

	final PsiReference reference = value.getReference();
	if(reference == null)
	{
		return;
	}
	final PsiElement element = reference.resolve();
	if(element != null)
	{
		return;
	}
	final int textOffset = value.getTextOffset();
	if(textOffset == value.getTextRange().getEndOffset())
	{
		return;
	}
	final PsiDocTagValue valueElement = tag.getValueElement();
	if(valueElement == null)
	{
		return;
	}

	final CharSequence paramName = value.getContainingFile().getViewProvider().getContents().subSequence(textOffset, value.getTextRange().getEndOffset());
	final String params = "<code>" + paramName + "</code>";
	final List<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>();
	if(onTheFly && "param".equals(tagName))
	{
		final PsiDocCommentOwner commentOwner = PsiTreeUtil.getParentOfType(tag, PsiDocCommentOwner.class);
		if(commentOwner instanceof PsiMethod)
		{
			final PsiMethod method = (PsiMethod) commentOwner;
			final PsiParameter[] parameters = method.getParameterList().getParameters();
			final PsiDocTag[] tags = tag.getContainingComment().getTags();
			final Set<String> unboundParams = new HashSet<String>();
			for(PsiParameter parameter : parameters)
			{
				if(!JavaDocLocalInspection.isFound(tags, parameter))
				{
					unboundParams.add(parameter.getName());
				}
			}
			if(!unboundParams.isEmpty())
			{
				fixes.add(new RenameReferenceQuickFix(unboundParams));
			}
		}
	}
	fixes.add(new RemoveTagFix(tagName, paramName));

	problems.add(inspectionManager.createProblemDescriptor(valueElement, reference.getRangeInElement(), cannotResolveSymbolMessage(params), ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, onTheFly,
			fixes.toArray(new LocalQuickFix[fixes.size()])));
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:76,代码来源:JavaDocReferenceInspection.java

示例5: getTagValuesProblems

import com.intellij.psi.javadoc.JavadocTagInfo; //导入方法依赖的package包/类
@Nullable
private ArrayList<ProblemDescriptor> getTagValuesProblems(PsiDocCommentOwner context, PsiDocTag[] tags, InspectionManager inspectionManager,
                                                          boolean isOnTheFly) {
  final ArrayList<ProblemDescriptor> problems = new ArrayList<ProblemDescriptor>(2);
  nextTag:
  for (PsiDocTag tag : tags) {
    final JavadocManager manager = JavadocManager.SERVICE.getInstance(tag.getProject());
    String tagName = tag.getName();
    JavadocTagInfo tagInfo = manager.getTagInfo(tagName);

    if (tagInfo == null || !tagInfo.isValidInContext(context)) {
      if (checkTagInfo(inspectionManager, tagInfo, tag, isOnTheFly, problems)) continue nextTag;
    }

    PsiDocTagValue value = tag.getValueElement();
    final JavadocTagInfo info = manager.getTagInfo(tagName);
    if (info != null && !info.isValidInContext(context)) continue;
    String message = info == null ? null : info.checkTagValue(value);

    final PsiReference reference = value != null ? value.getReference() : null;
    if (message == null && reference != null) {
      PsiElement element = reference.resolve();
      if (element == null) {
        final int textOffset = value.getTextOffset();

        if (textOffset == value.getTextRange().getEndOffset()) {
          problems.add(inspectionManager.createProblemDescriptor(tag, InspectionsBundle.message("inspection.javadoc.problem.name.expected"), null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
                                                                 isOnTheFly, true));
        }
      }
    }

    if (message != null) {
      final PsiDocTagValue valueElement = tag.getValueElement();
      if (valueElement == null){
        problems.add(inspectionManager.createProblemDescriptor(tag, InspectionsBundle.message("inspection.javadoc.method.problem.missing.tag.description", "<code>" + tag.getName() + "</code>"), null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
                                                               isOnTheFly, true));
      } else {
        problems.add(createDescriptor(valueElement, message, inspectionManager, isOnTheFly));
      }
    }
    checkInlineTags(inspectionManager, problems, tag.getDataElements(), manager, isOnTheFly);
  }

  return problems.isEmpty() ? null : problems;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:47,代码来源:JavaDocLocalInspection.java


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