com.intellij.openapi.editor.DefaultLanguageHighlighterColors Java Examples
The following examples show how to use
com.intellij.openapi.editor.DefaultLanguageHighlighterColors.
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: SharpLabHighlightVisitor.java From consulo-unity3d with Apache License 2.0 | 6 votes |
@Override public void visitElement(PsiElement element) { super.visitElement(element); ASTNode node = element.getNode(); if(node != null) { if(node.getElementType() == ShaderLabKeyTokens.VALUE_KEYWORD) { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(node).textAttributes(DefaultLanguageHighlighterColors.MACRO_KEYWORD).create()); } else if(node.getElementType() == ShaderLabKeyTokens.START_KEYWORD) { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(node).textAttributes(DefaultLanguageHighlighterColors.KEYWORD).create()); } } }
Example #2
Source File: SharpLabHighlightVisitor.java From consulo-unity3d with Apache License 2.0 | 6 votes |
@Override public void visitPropertyType(ShaderPropertyTypeElement type) { super.visitPropertyType(type); PsiElement element = type.getTargetElement(); ShaderLabPropertyType shaderLabPropertyType = ShaderLabPropertyType.find(element.getText()); if(shaderLabPropertyType == null) { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(element).descriptionAndTooltip("Wrong type").create()); } else { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(element).textAttributes(DefaultLanguageHighlighterColors.TYPE_ALIAS_NAME).create()); } }
Example #3
Source File: SharpLabHighlightVisitor.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Override @RequiredReadAction public void visitReference(ShaderReference reference) { if(!reference.isSoft()) { PsiElement resolve = reference.resolve(); if(resolve == null) { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(reference.getReferenceElement()).descriptionAndTooltip("'" + reference.getReferenceName() + "' is not " + "resolved").create()); } else { ShaderReference.ResolveKind kind = reference.kind(); TextAttributesKey key = null; switch(kind) { case ATTRIBUTE: key = DefaultLanguageHighlighterColors.METADATA; break; case PROPERTY: key = DefaultLanguageHighlighterColors.INSTANCE_FIELD; break; default: return; } myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(reference.getReferenceElement()).textAttributes(key).create()); } } }
Example #4
Source File: ParameterHintsPresentationManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public void paint(@Nonnull Editor editor, @Nonnull Graphics g, @Nonnull Rectangle r, @Nonnull TextAttributes textAttributes) { if (myText != null && (step > steps || startWidth != 0)) { TextAttributes attributes = editor.getColorsScheme().getAttributes(DefaultLanguageHighlighterColors.INLINE_PARAMETER_HINT); if (attributes != null) { MyFontMetrics fontMetrics = getFontMetrics(editor); Color backgroundColor = attributes.getBackgroundColor(); if (backgroundColor != null) { GraphicsConfig config = GraphicsUtil.setupAAPainting(g); GraphicsUtil.paintWithAlpha(g, BACKGROUND_ALPHA); g.setColor(backgroundColor); int gap = r.height < (fontMetrics.lineHeight + 2) ? 1 : 2; g.fillRoundRect(r.x + 2, r.y + gap, r.width - 4, r.height - gap * 2, 8, 8); config.restore(); } Color foregroundColor = attributes.getForegroundColor(); if (foregroundColor != null) { g.setColor(foregroundColor); g.setFont(getFont(editor)); Shape savedClip = g.getClip(); g.clipRect(r.x + 3, r.y + 2, r.width - 6, r.height - 4); int editorAscent = editor.getAscent(); FontMetrics metrics = fontMetrics.metrics; g.drawString(myText, r.x + 7, r.y + Math.max(editorAscent, (r.height + metrics.getAscent() - metrics.getDescent()) / 2) - 1); g.setClip(savedClip); } } } }
Example #5
Source File: XValueTextRendererImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void renderStringValue(@Nonnull String value, @Nullable String additionalSpecialCharsToHighlight, char quoteChar, int maxLength) { TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DefaultLanguageHighlighterColors.STRING); SimpleTextAttributes attributes = SimpleTextAttributes.fromTextAttributes(textAttributes); myText.append(String.valueOf(quoteChar), attributes); XValuePresentationUtil.renderValue(value, myText, attributes, maxLength, additionalSpecialCharsToHighlight); myText.append(String.valueOf(quoteChar), attributes); }
Example #6
Source File: RainbowHighlighter.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull protected HighlightInfo.Builder getInfoBuilder(int colorIndex, @Nullable TextAttributesKey colorKey) { if (colorKey == null) { colorKey = DefaultLanguageHighlighterColors.LOCAL_VARIABLE; } return HighlightInfo .newHighlightInfo(RAINBOW_ELEMENT) .textAttributes(TextAttributes .fromFlyweight(myColorsScheme .getAttributes(colorKey) .getFlyweight() .withForeground(calculateForeground(colorIndex)))); }
Example #7
Source File: ChunkExtractor.java From consulo with Apache License 2.0 | 5 votes |
public static boolean isHighlightedAsString(TextAttributesKey... keys) { for (TextAttributesKey key : keys) { if (key == DefaultLanguageHighlighterColors.STRING) { return true; } if (key == null) continue; final TextAttributesKey fallbackAttributeKey = key.getFallbackAttributeKey(); if (fallbackAttributeKey != null && isHighlightedAsString(fallbackAttributeKey)) { return true; } } return false; }
Example #8
Source File: ChunkExtractor.java From consulo with Apache License 2.0 | 5 votes |
public static boolean isHighlightedAsComment(TextAttributesKey... keys) { for (TextAttributesKey key : keys) { if (key == DefaultLanguageHighlighterColors.DOC_COMMENT || key == DefaultLanguageHighlighterColors.LINE_COMMENT || key == DefaultLanguageHighlighterColors.BLOCK_COMMENT) { return true; } if (key == null) continue; final TextAttributesKey fallbackAttributeKey = key.getFallbackAttributeKey(); if (fallbackAttributeKey != null && isHighlightedAsComment(fallbackAttributeKey)) { return true; } } return false; }
Example #9
Source File: CSharpHighlightVisitor.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Override @RequiredReadAction public void visit(@Nonnull PsiElement element) { if(element instanceof CSharpPreprocessorReferenceExpressionImpl) { if(((CSharpPreprocessorReferenceExpressionImpl) element).resolve() != null) { myHighlightInfoHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(element).textAttributes(TemplateColors.TEMPLATE_VARIABLE_ATTRIBUTES).create()); } else { myHighlightInfoHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(element).textAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT).create()); } } else if(element instanceof CSharpPreprocessorDefine) { if(((CSharpPreprocessorDefine) element).isUnDef()) { PsiElement varElement = ((CSharpPreprocessorDefine) element).getVarElement(); if(varElement != null) { myHighlightInfoHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(varElement).textAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT).create()); } } else { CSharpPreprocessorVariable variable = ((CSharpPreprocessorDefine) element).getVariable(); if(variable != null) { myHighlightInfoHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(variable.getNameIdentifier()).textAttributes(TemplateColors .TEMPLATE_VARIABLE_ATTRIBUTES).create()); } } } else { element.accept(this); } }
Example #10
Source File: TSColorSettings.java From Custom-Syntax-Highlighter with MIT License | 5 votes |
private static Map<String, TextAttributesKey> createAdditionalHlAttrs() { final Map<String, TextAttributesKey> descriptors = new THashMap<>(); descriptors.put("private", PRIVATE); descriptors.put("class", DefaultLanguageHighlighterColors.CLASS_NAME); return descriptors; }
Example #11
Source File: SharpLabHighlightVisitor.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Override public void visitProperty(ShaderPropertyElement p) { super.visitProperty(p); PsiElement nameIdentifier = p.getNameIdentifier(); if(nameIdentifier != null) { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(nameIdentifier).textAttributes(DefaultLanguageHighlighterColors.INSTANCE_FIELD).create()); } }
Example #12
Source File: SimpleAnnotator.java From intellij-sdk-docs with Apache License 2.0 | 5 votes |
@Override public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) { // Ensure the Psi Element is an expression if (!(element instanceof PsiLiteralExpression)) return; // Ensure the Psi element contains a string that starts with the key and separator PsiLiteralExpression literalExpression = (PsiLiteralExpression) element; String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null; if ((value == null) || !value.startsWith(SIMPLE_PREFIX_STR + SIMPLE_SEPARATOR_STR)) return; // Define the text ranges (start is inclusive, end is exclusive) // "simple:key" // 01234567890 TextRange prefixRange = TextRange.from(element.getTextRange().getStartOffset(), SIMPLE_PREFIX_STR.length() + 1); TextRange separatorRange = TextRange.from(prefixRange.getEndOffset(), SIMPLE_SEPARATOR_STR.length()); TextRange keyRange = new TextRange(separatorRange.getEndOffset(), element.getTextRange().getEndOffset() - 1); // Get the list of properties from the Project String possibleProperties = value.substring(SIMPLE_PREFIX_STR.length() + SIMPLE_SEPARATOR_STR.length()); Project project = element.getProject(); List<SimpleProperty> properties = SimpleUtil.findProperties(project, possibleProperties); // Set the annotations using the text ranges. Annotation keyAnnotation = holder.createInfoAnnotation(prefixRange, null); keyAnnotation.setTextAttributes(DefaultLanguageHighlighterColors.KEYWORD); Annotation separatorAnnotation = holder.createInfoAnnotation(separatorRange, null); separatorAnnotation.setTextAttributes(SimpleSyntaxHighlighter.SEPARATOR); if (properties.isEmpty()) { // No well-formed property found following the key-separator Annotation badProperty = holder.createErrorAnnotation(keyRange, "Unresolved property"); badProperty.setTextAttributes(SimpleSyntaxHighlighter.BAD_CHARACTER); // ** Tutorial step 18.3 - Add a quick fix for the string containing possible properties badProperty.registerFix(new SimpleCreatePropertyQuickFix(possibleProperties)); } else { // Found at least one property Annotation annotation = holder.createInfoAnnotation(keyRange, null); annotation.setTextAttributes(SimpleSyntaxHighlighter.VALUE); } }
Example #13
Source File: DocumentationUtil.java From arma-intellij-plugin with MIT License | 5 votes |
/** * 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); } }
Example #14
Source File: DocumentationUtil.java From arma-intellij-plugin with MIT License | 5 votes |
/** * 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); } }
Example #15
Source File: RTSyntaxHighlighterFactory.java From react-templates-plugin with MIT License | 4 votes |
public RTSyntaxHighlighter() { super(RTLanguage.INSTANCE.getOptionHolder()); myKeysMap.put(JSTokenTypes.AS_KEYWORD, DefaultLanguageHighlighterColors.KEYWORD); myKeysMap.put(JSTokenTypes.IN_KEYWORD, DefaultLanguageHighlighterColors.KEYWORD); // myKeysMap.put(RTTokenTypes.TRACK_BY_KEYWORD, DefaultLanguageHighlighterColors.KEYWORD); }
Example #16
Source File: RTSyntaxHighlighterFactory.java From react-templates-plugin with MIT License | 4 votes |
public RTSyntaxHighlighter() { super(RTLanguage.INSTANCE.getOptionHolder()); myKeysMap.put(JSTokenTypes.AS_KEYWORD, DefaultLanguageHighlighterColors.KEYWORD); myKeysMap.put(JSTokenTypes.IN_KEYWORD, DefaultLanguageHighlighterColors.KEYWORD); // myKeysMap.put(RTTokenTypes.TRACK_BY_KEYWORD, DefaultLanguageHighlighterColors.KEYWORD); }
Example #17
Source File: XValueTextRendererBase.java From consulo with Apache License 2.0 | 4 votes |
@Override public void renderNumericValue(@Nonnull String value) { renderRawValue(value, DefaultLanguageHighlighterColors.NUMBER); }
Example #18
Source File: XValueTextRendererBase.java From consulo with Apache License 2.0 | 4 votes |
@Override public void renderKeywordValue(@Nonnull String value) { renderRawValue(value, DefaultLanguageHighlighterColors.KEYWORD); }
Example #19
Source File: JavaColorSettings.java From Custom-Syntax-Highlighter with MIT License | 4 votes |
private static Map<String, TextAttributesKey> createAdditionalHlAttrs() { final Map<String, TextAttributesKey> descriptors = new THashMap<>(); descriptors.put("field", ObjectUtils.notNull(TextAttributesKey.find("INSTANCE_FIELD_ATTRIBUTES"), DefaultLanguageHighlighterColors.INSTANCE_FIELD)); descriptors.put("unusedField", CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES); descriptors.put("error", CodeInsightColors.ERRORS_ATTRIBUTES); descriptors.put("warning", CodeInsightColors.WARNINGS_ATTRIBUTES); descriptors.put("weak_warning", CodeInsightColors.WEAK_WARNING_ATTRIBUTES); descriptors.put("server_problems", CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING); descriptors.put("server_duplicate", CodeInsightColors.DUPLICATE_FROM_SERVER); descriptors.put("unknownType", CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES); descriptors.put("localVar", ObjectUtils.notNull(TextAttributesKey.find("LOCAL_VARIABLE_ATTRIBUTES"), DefaultLanguageHighlighterColors.LOCAL_VARIABLE)); descriptors.put("reassignedLocalVar", ObjectUtils.notNull(TextAttributesKey.find("REASSIGNED_LOCAL_VARIABLE_ATTRIBUTES"), DefaultLanguageHighlighterColors.REASSIGNED_LOCAL_VARIABLE)); descriptors.put("reassignedParameter", ObjectUtils.notNull(TextAttributesKey.find("REASSIGNED_PARAMETER_ATTRIBUTES);"), DefaultLanguageHighlighterColors.REASSIGNED_PARAMETER)); descriptors.put("implicitAnonymousParameter", ObjectUtils.notNull(TextAttributesKey.find("IMPLICIT_ANONYMOUS_CLASS_PARAMETER_ATTRIBUTES);"), DefaultLanguageHighlighterColors.CLASS_NAME)); descriptors.put("static", ObjectUtils.notNull(TextAttributesKey.find("STATIC_FIELD_ATTRIBUTES);"), DefaultLanguageHighlighterColors.STATIC_FIELD)); descriptors.put("static_final", ObjectUtils.notNull(TextAttributesKey.find("STATIC_FINAL_FIELD_ATTRIBUTES);"), DefaultLanguageHighlighterColors.STATIC_FIELD)); descriptors.put("deprecated", CodeInsightColors.DEPRECATED_ATTRIBUTES); descriptors.put("for_removal", CodeInsightColors.MARKED_FOR_REMOVAL_ATTRIBUTES); descriptors.put("constructorCall", ObjectUtils.notNull(TextAttributesKey.find("CONSTRUCTOR_CALL_ATTRIBUTES);"), DefaultLanguageHighlighterColors.FUNCTION_CALL)); descriptors.put("constructorDeclaration", ObjectUtils.notNull(TextAttributesKey.find("CONSTRUCTOR_DECLARATION_ATTRIBUTES);"), DefaultLanguageHighlighterColors.FUNCTION_DECLARATION)); descriptors.put("methodCall", ObjectUtils.notNull(TextAttributesKey.find("METHOD_CALL_ATTRIBUTES);"), DefaultLanguageHighlighterColors.FUNCTION_CALL)); descriptors.put("methodDeclaration", ObjectUtils.notNull(TextAttributesKey.find("METHOD_DECLARATION_ATTRIBUTES);"), DefaultLanguageHighlighterColors.FUNCTION_DECLARATION)); descriptors.put("static_method", ObjectUtils.notNull(TextAttributesKey.find("STATIC_METHOD_ATTRIBUTES);"), DefaultLanguageHighlighterColors.STATIC_METHOD)); descriptors.put("abstract_method", ObjectUtils.notNull(TextAttributesKey.find("ABSTRACT_METHOD_ATTRIBUTES);"), DefaultLanguageHighlighterColors.FUNCTION_CALL)); descriptors.put("inherited_method", ObjectUtils.notNull(TextAttributesKey.find("INHERITED_METHOD_ATTRIBUTES);"), DefaultLanguageHighlighterColors.FUNCTION_CALL)); descriptors.put("param", ObjectUtils.notNull(TextAttributesKey.find("PARAMETER_ATTRIBUTES);"), DefaultLanguageHighlighterColors.PARAMETER)); descriptors.put("lambda_param", ObjectUtils.notNull(TextAttributesKey.find("LAMBDA_PARAMETER_ATTRIBUTES);"), DefaultLanguageHighlighterColors.PARAMETER)); descriptors.put("class", ObjectUtils.notNull(TextAttributesKey.find("CLASS_NAME_ATTRIBUTES);"), DefaultLanguageHighlighterColors.CLASS_NAME)); descriptors.put("anonymousClass", ObjectUtils.notNull(TextAttributesKey.find("ANONYMOUS_CLASS_NAME_ATTRIBUTES);"), DefaultLanguageHighlighterColors.CLASS_NAME)); descriptors.put("typeParameter", ObjectUtils.notNull(TextAttributesKey.find("TYPE_PARAMETER_NAME_ATTRIBUTES);"), DefaultLanguageHighlighterColors.PARAMETER)); descriptors.put("abstractClass", ObjectUtils.notNull(TextAttributesKey.find("ABSTRACT_CLASS_NAME_ATTRIBUTES);"), DefaultLanguageHighlighterColors.CLASS_NAME)); descriptors.put("interface", ObjectUtils.notNull(TextAttributesKey.find("INTERFACE_NAME_ATTRIBUTES);"), DefaultLanguageHighlighterColors.INTERFACE_NAME)); descriptors.put("enum", ObjectUtils.notNull(TextAttributesKey.find("ENUM_NAME_ATTRIBUTES);"), DefaultLanguageHighlighterColors.CLASS_NAME)); descriptors.put("annotationName", ObjectUtils.notNull(TextAttributesKey.find("ANNOTATION_NAME_ATTRIBUTES);"), DefaultLanguageHighlighterColors.METADATA)); descriptors.put("annotationAttributeName", ObjectUtils.notNull(TextAttributesKey.find("ANNOTATION_ATTRIBUTE_NAME_ATTRIBUTES);"), DefaultLanguageHighlighterColors.METADATA)); descriptors.put("javadocTagValue", ObjectUtils.notNull(TextAttributesKey.find("DOC_COMMENT_TAG_VALUE);"), DefaultLanguageHighlighterColors.DOC_COMMENT_TAG_VALUE)); descriptors.put("instanceFinalField", ObjectUtils.notNull(TextAttributesKey.find("INSTANCE_FINAL_FIELD_ATTRIBUTES);"), DefaultLanguageHighlighterColors.INSTANCE_FIELD)); descriptors.put("staticallyConstImported", ObjectUtils.notNull(TextAttributesKey.find("STATIC_FINAL_FIELD_IMPORTED_ATTRIBUTES);"), DefaultLanguageHighlighterColors.STATIC_FIELD)); descriptors.put("staticallyImported", ObjectUtils.notNull(TextAttributesKey.find("STATIC_FIELD_IMPORTED_ATTRIBUTES);"), DefaultLanguageHighlighterColors.STATIC_FIELD)); descriptors.put("static_imported_method", ObjectUtils.notNull(TextAttributesKey.find("STATIC_METHOD_CALL_IMPORTED_ATTRIBUTES);"), DefaultLanguageHighlighterColors.STATIC_METHOD)); descriptors.put("keyword", JavaColorSettings.JAVA_KEYWORD); descriptors.put("this", JavaColorSettings.THIS_SUPER); descriptors.put("sf", JavaColorSettings.STATIC_FINAL); descriptors.put("modifier", JavaColorSettings.MODIFIER); return descriptors; }