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


Java AnnotationHolder.createAnnotation方法代码示例

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


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

示例1: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
  if (psiElement instanceof Header) {
    Header header = (Header)psiElement;
    String name = header.getName();
    if (!isValidName(name)) {
      holder.createAnnotation(HighlightSeverity.ERROR, header.getNameElement().getTextRange(), ManifestBundle.message("header.name.invalid"));
    }
    else {
      HeaderParser headerParser = myRepository.getHeaderParser(name);
      if (headerParser != null) {
        headerParser.annotate(header, holder);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:HeaderAnnotator.java

示例2: apply

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, List<MerlinError> annotationResult, @NotNull AnnotationHolder holder) {
    LineNumbering lineNumbering = new LineNumbering(file.getText());
    for (MerlinError error : annotationResult) {
        if (error.start != null) {
            int startOffset = lineNumbering.positionToOffset(error.start);
            int endOffset = lineNumbering.positionToOffset(error.end);
            if (0 < startOffset && 0 < endOffset && startOffset < endOffset) {
                holder.createAnnotation(severities.get(error.type), new TextRangeInterval(startOffset, endOffset), "[merlin] " + error.message);
            }
        }
    }
}
 
开发者ID:reasonml-editor,项目名称:reasonml-idea-plugin,代码行数:14,代码来源:MerlinErrorAnnotator.java

示例3: apply

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, RamlValidationResult annotationResult, @NotNull AnnotationHolder holder)
{
    final List<ErrorNode> errorNodes = annotationResult.getErrorNodes();
    for (ErrorNode errorNode : errorNodes)
    {
        if (file.getVirtualFile().getPath().endsWith(errorNode.getStartPosition().getPath()))
        {
            holder.createAnnotation(HighlightSeverity.ERROR, new TextRange(errorNode.getStartPosition().getIndex(), errorNode.getEndPosition().getIndex()), errorNode.getErrorMessage());
        }
    }

}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:14,代码来源:RamlAnnotator.java

示例4: annotateDocumentationWithArmaPluginTags

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
/**
 * Annotates the given comment so that tags like @command, @bis, and @fnc (Arma Intellij Plugin specific tags) are properly annotated
 *
 * @param annotator the annotator
 * @param comment   the comment
 */
public static void annotateDocumentationWithArmaPluginTags(@NotNull AnnotationHolder annotator, @NotNull PsiComment comment) {
	List<String> allowedTags = new ArrayList<>(3);
	allowedTags.add("command");
	allowedTags.add("bis");
	allowedTags.add("fnc");
	Pattern patternTag = Pattern.compile("@([a-zA-Z]+) ([a-zA-Z_0-9]+)");
	Matcher matcher = patternTag.matcher(comment.getText());
	String tag;
	Annotation annotation;
	int startTag, endTag, startArg, endArg;
	while (matcher.find()) {
		if (matcher.groupCount() < 2) {
			continue;
		}
		tag = matcher.group(1);
		if (!allowedTags.contains(tag)) {
			continue;
		}
		startTag = matcher.start(1);
		endTag = matcher.end(1);
		startArg = matcher.start(2);
		endArg = matcher.end(2);
		annotation = annotator.createAnnotation(HighlightSeverity.INFORMATION, TextRange.create(comment.getTextOffset() + startTag - 1, comment.getTextOffset() + endTag), null);
		annotation.setTextAttributes(DefaultLanguageHighlighterColors.DOC_COMMENT_TAG);
		annotation = annotator.createAnnotation(HighlightSeverity.INFORMATION, TextRange.create(comment.getTextOffset() + startArg, comment.getTextOffset() + endArg), null);
		annotation.setTextAttributes(DefaultLanguageHighlighterColors.DOC_COMMENT_TAG_VALUE);
	}
}
 
开发者ID:kayler-renslow,项目名称:arma-intellij-plugin,代码行数:35,代码来源:DocumentationUtil.java

示例5: createAnnotation

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@NotNull
private Annotation createAnnotation(@NotNull AnnotationHolder holder,
                                    @NotNull String message,
                                    @NotNull TextRange range,
                                    @NotNull HighlightDisplayLevel displayLevel,
                                    @NotNull Issue issue) {
  // Convert from inspection severity to annotation severity
  HighlightSeverity severity;
  if (displayLevel == HighlightDisplayLevel.ERROR) {
    severity = HighlightSeverity.ERROR;
  } else if (displayLevel == HighlightDisplayLevel.WARNING) {
    severity = HighlightSeverity.WARNING;
  } else if (displayLevel == HighlightDisplayLevel.WEAK_WARNING) {
    severity = HighlightSeverity.WEAK_WARNING;
  } else if (displayLevel == HighlightDisplayLevel.INFO) {
    severity = HighlightSeverity.INFO;
  } else {
    severity = HighlightSeverity.WARNING;
  }

  // Attempt to mark up as HTML? Only if available
  Method createHtmlAnnotation = getCreateHtmlAnnotation();
  if (createHtmlAnnotation != null) {
    // Based on LocalInspectionsPass#createHighlightInfo
    String link = " <a "
        +"href=\"#lint/" + issue.getId() + "\""
        + (UIUtil.isUnderDarcula() ? " color=\"7AB4C9\" " : "")
        +">" + DaemonBundle.message("inspection.extended.description")
        +"</a> " + getShowMoreShortCut();
    String tooltip = XmlStringUtil.wrapInHtml(RAW.convertTo(message, HTML) + link);

    try {
      return (Annotation)createHtmlAnnotation.invoke(holder, severity, range, message, tooltip);
    }
    catch (IllegalAccessException ignored) {
      ourCreateHtmlAnnotationMethod = null;
      //noinspection AssignmentToStaticFieldFromInstanceMethod
      ourCreateHtmlAnnotationMethodFailed = true;
    }
    catch (InvocationTargetException e) {
      ourCreateHtmlAnnotationMethod = null;
      //noinspection AssignmentToStaticFieldFromInstanceMethod
      ourCreateHtmlAnnotationMethodFailed = true;
    }
  }

  return holder.createAnnotation(severity, range, message);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:50,代码来源:AndroidLintExternalAnnotator.java


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