Java Code Examples for com.intellij.lang.annotation.AnnotationHolder#createInfoAnnotation()
The following examples show how to use
com.intellij.lang.annotation.AnnotationHolder#createInfoAnnotation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BashAnnotator.java From BashSupport with Apache License 2.0 | 6 votes |
private void annotateWord(PsiElement bashWord, AnnotationHolder annotationHolder) { //we have to mark the remapped tokens (which are words now) to have the default word formatting. PsiElement child = bashWord.getFirstChild(); while (child != null && false) { if (!noWordHighlightErase.contains(child.getNode().getElementType())) { Annotation annotation = annotationHolder.createInfoAnnotation(child, null); annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); annotation = annotationHolder.createInfoAnnotation(child, null); annotation.setEnforcedTextAttributes(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(HighlighterColors.TEXT)); } child = child.getNextSibling(); } }
Example 2
Source File: SQFControlStructureCommandAnnotator.java From arma-intellij-plugin with MIT License | 6 votes |
@Override public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { if (!(element instanceof SQFCommand)) { return; } SQFCommand command = (SQFCommand) element; switch (command.getCommandName().toLowerCase()) { case "if": //fall case "then": //fall case "else": //fall case "for": //fall case "foreach": //fall case "switch": //fall case "case": //fall case "default": //fall case "while"://fall case "do": { Annotation annotation = holder.createInfoAnnotation(command, ""); annotation.setTextAttributes(SQFSyntaxHighlighter.CONTROL_STRUCTURE_COMMAND); break; } } }
Example 3
Source File: BuckAnnotator.java From buck with Apache License 2.0 | 6 votes |
/** Annotates targets that refer to files relative to this file. */ private boolean annotateStringAsLocalFile( BuckSimpleExpression targetExpression, String targetValue, AnnotationHolder annotationHolder) { Optional<VirtualFile> targetFile = Optional.of(targetExpression) .map(PsiElement::getContainingFile) .map(PsiFile::getVirtualFile) .map(VirtualFile::getParent) .map(dir -> dir.findFileByRelativePath(targetValue)) .filter(VirtualFile::exists); if (!targetFile.isPresent()) { return false; } Annotation annotation = annotationHolder.createInfoAnnotation(targetExpression, targetFile.get().getPath()); annotation.setTextAttributes(BuckSyntaxHighlighter.BUCK_FILE_NAME); return true; }
Example 4
Source File: BcfgAnnotator.java From buck with Apache License 2.0 | 6 votes |
private void annotateInlineFile( @NotNull BcfgInline bcfgInline, @NotNull AnnotationHolder holder) { Optional<Path> path = bcfgInline.getPath(); if (!path.isPresent()) { holder.createErrorAnnotation( bcfgInline.getFilePath(), "Cannot parse " + bcfgInline.getFilePath().getText() + " as a file path."); } else if (path.get().toFile().exists()) { holder .createInfoAnnotation(bcfgInline.getFilePath(), path.get().toString()) .setTextAttributes(BuckSyntaxHighlighter.BUCK_FILE_NAME); } else { if (bcfgInline.isRequired()) { holder .createErrorAnnotation(bcfgInline.getFilePath(), "Required file missing") .setTextAttributes(BuckSyntaxHighlighter.BUCK_INVALID_TARGET); } else { holder.createInfoAnnotation(bcfgInline.getFilePath(), "Optional file missing"); } } }
Example 5
Source File: LSPAnnotator.java From lsp4intellij with Apache License 2.0 | 6 votes |
@Nullable protected Annotation createAnnotation(Editor editor, AnnotationHolder holder, Diagnostic diagnostic) { final int start = DocumentUtils.LSPPosToOffset(editor, diagnostic.getRange().getStart()); final int end = DocumentUtils.LSPPosToOffset(editor, diagnostic.getRange().getEnd()); if (start >= end) { return null; } final TextRange textRange = new TextRange(start, end); switch (diagnostic.getSeverity()) { // TODO: Use 'newAnnotation'; 'create*Annotation' methods are deprecated. case Error: return holder.createErrorAnnotation(textRange, diagnostic.getMessage()); case Warning: return holder.createWarningAnnotation(textRange, diagnostic.getMessage()); case Information: return holder.createInfoAnnotation(textRange, diagnostic.getMessage()); default: return holder.createWeakWarningAnnotation(textRange, diagnostic.getMessage()); } }
Example 6
Source File: WebReferencesAnnotatorBase.java From consulo with Apache License 2.0 | 5 votes |
@Override public void apply(@Nonnull PsiFile file, MyInfo[] infos, @Nonnull AnnotationHolder holder) { if (infos.length == 0) { return; } final HighlightDisplayLevel displayLevel = getHighlightDisplayLevel(file); for (MyInfo info : infos) { if (!info.myResult) { final PsiElement element = info.myAnchor.retrieve(); if (element != null) { final int start = element.getTextRange().getStartOffset(); final TextRange range = new TextRange(start + info.myRangeInElement.getStartOffset(), start + info.myRangeInElement.getEndOffset()); final String message = getErrorMessage(info.myUrl); final Annotation annotation; if (displayLevel == HighlightDisplayLevel.ERROR) { annotation = holder.createErrorAnnotation(range, message); } else if (displayLevel == HighlightDisplayLevel.WARNING) { annotation = holder.createWarningAnnotation(range, message); } else if (displayLevel == HighlightDisplayLevel.WEAK_WARNING) { annotation = holder.createInfoAnnotation(range, message); } else { annotation = holder.createWarningAnnotation(range, message); } for (IntentionAction action : getQuickFixes()) { annotation.registerFix(action); } } } } }
Example 7
Source File: BashAnnotator.java From BashSupport with Apache License 2.0 | 5 votes |
private void highlightKeywordTokens(@NotNull PsiElement element, @NotNull AnnotationHolder annotationHolder) { ASTNode node = element.getNode(); if (node == null) { return; } IElementType elementType = node.getElementType(); boolean isKeyword = elementType == BashTokenTypes.IN_KEYWORD_REMAPPED || elementType == BashTokenTypes.WORD && "!".equals(element.getText()); if (isKeyword) { Annotation annotation = annotationHolder.createInfoAnnotation(element, null); annotation.setTextAttributes(BashSyntaxHighlighter.KEYWORD); } }
Example 8
Source File: BashAnnotator.java From BashSupport with Apache License 2.0 | 5 votes |
private void annotateHereDoc(BashHereDoc element, AnnotationHolder annotationHolder) { final Annotation annotation = annotationHolder.createInfoAnnotation(element, null); annotation.setTextAttributes(BashSyntaxHighlighter.HERE_DOC); annotation.setNeedsUpdateOnTyping(false); if (element.isEvaluatingVariables()) { highlightVariables(element, annotationHolder); } }
Example 9
Source File: SQFMagicVarColorizerAnnotator.java From arma-intellij-plugin with MIT License | 5 votes |
@Override public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { if (element instanceof SQFVariable) { SQFVariable var = (SQFVariable) element; if (var.isMagicVar()) { Annotation a = holder.createInfoAnnotation(TextRange.from(element.getTextOffset(), var.getTextLength()), null); a.setTextAttributes(SQFSyntaxHighlighter.MAGIC_VAR); } } }
Example 10
Source File: BashAnnotator.java From BashSupport with Apache License 2.0 | 5 votes |
private void annotateBinaryData(BashBinaryDataElement element, AnnotationHolder annotationHolder) { Annotation annotation = annotationHolder.createInfoAnnotation(element, null); annotation.setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); annotation = annotationHolder.createInfoAnnotation(element, null); annotation.setTextAttributes(BashSyntaxHighlighter.BINARY_DATA); annotation.setNeedsUpdateOnTyping(false); }
Example 11
Source File: CamelEndpointAnnotator.java From camel-idea-plugin with Apache License 2.0 | 5 votes |
private void extractSetValue(EndpointValidationResult result, Set<String> validationSet, String fromElement, PsiElement element, AnnotationHolder holder, CamelAnnotatorEndpointMessage msg, boolean lenient) { if (validationSet != null && (lenient || !result.isSuccess())) { for (String entry : validationSet) { String propertyValue = entry; int startIdxQueryParameters = fromElement.indexOf("?" + propertyValue); startIdxQueryParameters = (startIdxQueryParameters == -1) ? fromElement.indexOf("&" + propertyValue) : fromElement.indexOf("?"); int propertyIdx = fromElement.indexOf(propertyValue, startIdxQueryParameters); int propertyLength = propertyValue.length(); propertyIdx = getIdeaUtils().isJavaLanguage(element) || getIdeaUtils().isXmlLanguage(element) ? propertyIdx + 1 : propertyIdx; TextRange range = new TextRange(element.getTextRange().getStartOffset() + propertyIdx, element.getTextRange().getStartOffset() + propertyIdx + propertyLength); if (msg.isInfoLevel()) { holder.createInfoAnnotation(range, summaryMessage(result, propertyValue, msg)); } else if (msg.isWarnLevel()) { holder.createWarningAnnotation(range, summaryMessage(result, propertyValue, msg)); } else { holder.createErrorAnnotation(range, summaryMessage(result, propertyValue, msg)); } } } }
Example 12
Source File: SQFMagicVarColorizerAnnotator.java From arma-intellij-plugin with MIT License | 5 votes |
@Override public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { if (element instanceof SQFVariable) { SQFVariable var = (SQFVariable) element; if (var.isMagicVar()) { Annotation a = holder.createInfoAnnotation(TextRange.from(element.getTextOffset(), var.getTextLength()), null); a.setTextAttributes(SQFSyntaxHighlighter.MAGIC_VAR); } } }
Example 13
Source File: BashAnnotator.java From BashSupport with Apache License 2.0 | 5 votes |
private void annotateVarDef(BashVarDef bashVarDef, AnnotationHolder annotationHolder) { final PsiElement identifier = bashVarDef.findAssignmentWord(); if (identifier != null) { final Annotation annotation = annotationHolder.createInfoAnnotation(identifier, null); annotation.setTextAttributes(BashSyntaxHighlighter.VAR_DEF); } }
Example 14
Source File: FlutterEditorAnnotator.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void attachIcon(final PsiElement element, AnnotationHolder holder, Icon icon) { try { final Annotation annotation = holder.createInfoAnnotation(element, null); annotation.setGutterIconRenderer(new FlutterIconRenderer(icon, element)); } catch (Exception ignored) { } }
Example 15
Source File: VariableHighlightAnnotator.java From bamboo-soy with Apache License 2.0 | 5 votes |
@Override public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { if (element instanceof SoyVariableReferenceIdentifier || element instanceof SoyVariableDefinitionIdentifier || element instanceof SoyParamDefinitionIdentifier) { Annotation annotation = holder.createInfoAnnotation(element, null); annotation.setTextAttributes(SoySyntaxHighlighter.VARIABLE); } }
Example 16
Source File: BashAnnotator.java From BashSupport with Apache License 2.0 | 4 votes |
private void annotateRedirectExpression(BashRedirectExpr element, AnnotationHolder annotationHolder) { Annotation annotation = annotationHolder.createInfoAnnotation(element, null); annotation.setTextAttributes(BashSyntaxHighlighter.REDIRECTION); }
Example 17
Source File: BashAnnotator.java From BashSupport with Apache License 2.0 | 4 votes |
private void annotateHereDocEnd(PsiElement element, AnnotationHolder annotationHolder) { final Annotation annotation = annotationHolder.createInfoAnnotation(element, null); annotation.setTextAttributes(BashSyntaxHighlighter.HERE_DOC_END); }
Example 18
Source File: BashAnnotator.java From BashSupport with Apache License 2.0 | 4 votes |
private void annotateHereDocStart(PsiElement element, AnnotationHolder annotationHolder) { final Annotation annotation = annotationHolder.createInfoAnnotation(element, null); annotation.setTextAttributes(BashSyntaxHighlighter.HERE_DOC_START); }
Example 19
Source File: ThriftColorAnnotator.java From intellij-thrift with Apache License 2.0 | 4 votes |
private void annotateKeyword(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { final Annotation annotation = holder.createInfoAnnotation(element, null); annotation.setTextAttributes(TextAttributesKey.find(ThriftSyntaxHighlighterColors.THRIFT_KEYWORD)); }
Example 20
Source File: NASMAnnotator.java From JetBrains-NASM-Language with MIT License | 4 votes |
private void highlightTextRange(int startOffset, int length, @NotNull TextAttributesKey textAttributes, @NotNull AnnotationHolder holder) { TextRange range = new TextRange(startOffset, startOffset + length); Annotation annotation = holder.createInfoAnnotation(range, null); annotation.setTextAttributes(textAttributes); }