private void annotateNumber(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { Annotation annotation = holder.createInfoAnnotation(element, null); annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.NUMBER); } }
private static void setHighlighting(@NotNull PsiElement element, @NotNull AnnotationHolder holder, @NotNull TextAttributesKey key) { holder.createInfoAnnotation(element, null).setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); String description = ApplicationManager.getApplication().isUnitTestMode() ? key.getExternalName() : null; holder.createInfoAnnotation(element, description).setTextAttributes(key); }
private void highlightTypeError(@NotNull PsiElement element, @NotNull String message, @NotNull AnnotationHolder annotationHolder) { annotationHolder.createErrorAnnotation(element, message); }
/** * Highlights `textRange` with the given `textAttributesKey`. * * @param textRange textRange in the document to highlight * @param annotationHolder the container which receives annotations created by the plugin. * @param textAttributesKey text attributes to apply to the `node`. */ private void highlight(@NotNull final TextRange textRange, @NotNull AnnotationHolder annotationHolder, @NotNull final TextAttributesKey textAttributesKey) { annotationHolder.createInfoAnnotation(textRange, null).setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); annotationHolder.createInfoAnnotation(textRange, null).setEnforcedTextAttributes(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(textAttributesKey)); }
@Override public void annotate(@NotNull PsiElement psiElement, @NotNull com.intellij.lang.annotation.AnnotationHolder annotationHolder) { if (psiElement instanceof ErlangAtom) { ErlangAtom erlangAtom = (ErlangAtom) psiElement; String name = erlangAtom.getName(); if (name.startsWith(ELIXIR_ALIAS_PREFIX)) { Project project = psiElement.getProject(); Collection<NamedElement> namedElementCollection = StubIndex.getElements( ModularName.KEY, name, project, GlobalSearchScope.allScope(project), NamedElement.class ); if (namedElementCollection.size() > 0) { TextRange textRange = psiElement.getTextRange(); String unprefixedName = name.substring(ELIXIR_ALIAS_PREFIX.length(), name.length()); Annotation annotation = annotationHolder.createInfoAnnotation(textRange, "Resolves to Elixir Module " + unprefixedName); annotation.setTextAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT); } else { TextRange textRange = psiElement.getTextRange(); annotationHolder.createErrorAnnotation(textRange, "Unresolved Elixir Module"); } } } } }
private void annotateText(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { Annotation annotation = holder.createInfoAnnotation(element, null); annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.STRING); }
/** * Highlights `textRange` with the given `textAttributesKey`. * * @param textRange textRange in the document to highlight * @param annotationHolder the container which receives annotations created by the plugin. * @param textAttributesKey text attributes to apply to the `node`. */ private void highlight(@NotNull final TextRange textRange, @NotNull AnnotationHolder annotationHolder, @NotNull final TextAttributesKey textAttributesKey) { annotationHolder.createInfoAnnotation(textRange, null) .setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); annotationHolder.createInfoAnnotation(textRange, null) .setEnforcedTextAttributes( EditorColorsManager.getInstance().getGlobalScheme().getAttributes(textAttributesKey) ); } }
private static void checkSelfReference(@NotNull GoReferenceExpression o, PsiElement definition, AnnotationHolder holder) { GoExpression value = null; if (definition instanceof GoVarDefinition) { value = ((GoVarDefinition)definition).getValue(); } else if (definition instanceof GoConstDefinition) { value = ((GoConstDefinition)definition).getValue(); } if (value != null && value.equals(GoPsiImplUtil.getNonStrictTopmostParentOfType(o, GoExpression.class))) { holder.createErrorAnnotation(o, "Cyclic definition detected"); } }
private void annotateInlineCode(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { Annotation annotation = holder.createInfoAnnotation(element, null); annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.DOCUMENTATION_INLINE_CODE); }
/** * Highlights `textRange` with the given `textAttributesKey`. * * @param textRange textRange in the document to highlight * @param annotationHolder the container which receives annotations created by the plugin. * @param textAttributesKey text attributes to apply to the `node`. */ private void highlight(@NotNull final TextRange textRange, @NotNull AnnotationHolder annotationHolder, @NotNull final TextAttributesKey textAttributesKey) { annotationHolder.createInfoAnnotation(textRange, null) .setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); annotationHolder.createInfoAnnotation(textRange, null) .setEnforcedTextAttributes( EditorColorsManager.getInstance().getGlobalScheme().getAttributes(textAttributesKey) ); } }
if (baseType instanceof GoArrayOrSliceType) { if (list.isEmpty()) { holder.createErrorAnnotation(call, "Missing len argument to make"); return; holder.createErrorAnnotation(call, "Too many arguments to make"); return; holder.createErrorAnnotation(call, "Too many arguments to make"); return; if (!(isIntegerConvertibleType(expressionBaseType) || isCType(type))) { String argName = i == 0 ? "size" : "capacity"; holder.createErrorAnnotation(expression, "Non-integer " + argName + " argument to make");
private void annotateStringLiteralTemplateEnd(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { Annotation annotation = holder.createInfoAnnotation(element, null); annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.TEMPLATE_LANGUAGE_COLOR); }
/** * Highlights `textRange` with the given `textAttributesKey`. * * @param textRange textRange in the document to highlight * @param annotationHolder the container which receives annotations created by the plugin. * @param textAttributesKey text attributes to apply to the `node`. */ private void highlight(@NotNull final TextRange textRange, @NotNull AnnotationHolder annotationHolder, @NotNull final TextAttributesKey textAttributesKey) { annotationHolder.createInfoAnnotation(textRange, null) .setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); annotationHolder.createInfoAnnotation(textRange, null) .setEnforcedTextAttributes( EditorColorsManager.getInstance().getGlobalScheme().getAttributes(textAttributesKey) ); } }
private void visitUsage(@NotNull final AtNonNumericOperation atNonNumericOperation) { highlight( atNonNumericOperation.getTextRange(), holder, ElixirSyntaxHighlighter.MODULE_ATTRIBUTE ); if (!Companion.isNonReferencing(atNonNumericOperation)) { PsiReference reference = atNonNumericOperation.getReference(); if (reference != null && reference.resolve() == null) { holder.createErrorAnnotation(atNonNumericOperation, "Unresolved module attribute"); } } } }
private void annotateKeyword(@NotNull PsiElement element, @NotNull AnnotationHolder holder, @NotNull TextAttributesKey textAttributesKey, boolean excludeEndChar) { TextRange textRange = element.getTextRange(); TextRange newTextRange = new TextRange(textRange.getStartOffset(), textRange.getEndOffset() - (excludeEndChar ? 1 : 0)); Annotation annotation = holder.createInfoAnnotation(newTextRange, null); annotation.setTextAttributes(textAttributesKey); }
/** * Highlights `textRange` with the given `textAttributesKey`. * * @param textRange textRange in the document to highlight * @param annotationHolder the container which receives annotations created by the plugin. * @param textAttributesKey text attributes to apply to the `node`. */ private void highlight(@NotNull final TextRange textRange, @NotNull AnnotationHolder annotationHolder, @NotNull final TextAttributesKey textAttributesKey) { annotationHolder.createInfoAnnotation(textRange, null) .setEnforcedTextAttributes(TextAttributes.ERASE_MARKER); annotationHolder.createInfoAnnotation(textRange, null) .setEnforcedTextAttributes( EditorColorsManager.getInstance().getGlobalScheme().getAttributes(textAttributesKey) ); } }
private static void checkCapCall(@NotNull GoCallExpr capCall, @NotNull AnnotationHolder holder) { List<GoExpression> exprs = capCall.getArgumentList().getExpressionList(); if (exprs.size() != 1) return; GoExpression first = ContainerUtil.getFirstItem(exprs); //noinspection ConstantConditions GoType exprType = first.getGoType(null); // todo: context if (exprType == null) return; GoType baseType = GoPsiImplUtil.unwrapPointerIfNeeded(exprType.getUnderlyingType()); if (baseType instanceof GoArrayOrSliceType || baseType instanceof GoChannelType) return; holder.createErrorAnnotation(first, "Invalid argument for cap"); }
private void annotateTemplateStart(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { TextRange textRange = element.getTextRange(); TextRange newTextRange = new TextRange(textRange.getEndOffset() - 1, textRange.getEndOffset()); Annotation annotation = holder.createInfoAnnotation(newTextRange, null); annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.STRING); }
private void annotateKeyword(@NotNull PsiElement element, @NotNull AnnotationHolder holder, boolean excludeEndChar) { TextRange textRange = element.getTextRange(); TextRange newTextRange = new TextRange(textRange.getStartOffset(), textRange.getEndOffset() - (excludeEndChar ? 1 : 0)); Annotation annotation = holder.createInfoAnnotation(newTextRange, null); annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.KEYWORD); }
private void annotateExpressionTemplateStart(@NotNull PsiElement element, @NotNull AnnotationHolder holder) { TextRange textRange = element.getTextRange(); TextRange newTextRange = new TextRange(textRange.getEndOffset() - 2, textRange.getEndOffset()); Annotation annotation = holder.createInfoAnnotation(newTextRange, null); annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.TEMPLATE_LANGUAGE_COLOR); if (textRange.getEndOffset() - 2 > textRange.getStartOffset()) { newTextRange = new TextRange(textRange.getStartOffset(), textRange.getEndOffset() - 2); annotation = holder.createInfoAnnotation(newTextRange, null); annotation.setTextAttributes(BallerinaSyntaxHighlightingColors.STRING); } }