当前位置:
IT大杂烩
>
生活
> Java开发工具IntelliJ IDEA如何定义语法高亮和颜色设
Java开发工具IntelliJ IDEA如何定义语法高亮和颜色设
www.someabcd.com 网友分享于:Jun 8, 2018 9:22:01 AM
在用户使用Intellij IDEA 的过程中,我们需要对语法的高亮和颜色设置的页面进行定义之后,才能征程的进行使用,下面是具体的操作代码和图例说明。 1 定义syntax highlighter package com.simpleplugin; import com.intellij.lexer.FlexAdapter;import com.intellij.lexer.Lexer;import com.intellij.openapi.editor.SyntaxHighlighterColors;import com.intellij.openapi.editor.colors.TextAttributesKey;import com.intellij.openapi.editor.markup.TextAttributes;import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;import com.intellij.psi.TokenType;import com.intellij.psi.tree.IElementType;import com.simpleplugin.psi.SimpleTypes;import org.jetbrains.annotations.NotNull; import java.awt.*;import java.io.Reader; import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey; public class SimpleSyntaxHighlighter extends SyntaxHighlighterBase { public static final TextAttributesKey SEPARATOR = createTextAttributesKey("SIMPLE_SEPARATOR", SyntaxHighlighterColors.OPERATION_SIGN); public static final TextAttributesKey KEY = createTextAttributesKey("SIMPLE_KEY", SyntaxHighlighterColors.KEYWORD); public static final TextAttributesKey VALUE = http://www.cnblogs.com/depthbomb/p/createTextAttributesKey("SIMPLE_VALUE", SyntaxHighlighterColors.STRING); public static final TextAttributesKey COMMENT = createTextAttributesKey("SIMPLE_COMMENT", SyntaxHighlighterColors.LINE_COMMENT); static final TextAttributesKey BAD_CHARACTER = createTextAttributesKey("SIMPLE_BAD_CHARACTER", new TextAttributes(Color.RED, null, null, null, Font.BOLD)); private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER}; private static final TextAttributesKey[] SEPARATOR_KEYS = new TextAttributesKey[]{SEPARATOR}; private static final TextAttributesKey[] KEY_KEYS = new TextAttributesKey[]{KEY}; private static final TextAttributesKey[] VALUE_KEYS = new TextAttributesKey[]{VALUE}; private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
发布此文章仅为传递网友分享,不代表本站观点,若侵权请联系我们删除,本站将不对此承担任何责任。