當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。