本文整理匯總了Java中com.intellij.openapi.editor.DefaultLanguageHighlighterColors類的典型用法代碼示例。如果您正苦於以下問題:Java DefaultLanguageHighlighterColors類的具體用法?Java DefaultLanguageHighlighterColors怎麽用?Java DefaultLanguageHighlighterColors使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DefaultLanguageHighlighterColors類屬於com.intellij.openapi.editor包,在下文中一共展示了DefaultLanguageHighlighterColors類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitElement
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
@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());
}
}
}
示例2: testUpgradeFromVer141
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
/**
* Check that the attributes missing in a custom scheme with a version prior to 142 are explicitly added with fallback enabled,
* not taken from parent scheme.
*
* @throws Exception
*/
public void testUpgradeFromVer141() throws Exception {
TextAttributesKey constKey = DefaultLanguageHighlighterColors.CONSTANT;
TextAttributesKey fallbackKey = constKey.getFallbackAttributeKey();
assertNotNull(fallbackKey);
EditorColorsScheme scheme = loadScheme(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<scheme name=\"Test\" version=\"141\" parent_scheme=\"Default\">\n" +
// Some 'attributes' section is required for the upgrade procedure to work.
"<attributes>" +
" <option name=\"TEXT\">\n" +
" <value>\n" +
" option name=\"FOREGROUND\" value=\"ffaaaa\" />\n" +
" </value>\n" +
" </option>" +
"</attributes>" +
"</scheme>\n"
);
TextAttributes constAttrs = scheme.getAttributes(constKey);
TextAttributes fallbackAttrs = scheme.getAttributes(fallbackKey);
assertSame(fallbackAttrs, constAttrs);
}
示例3: annotateVarExpansion
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
/**
*
* @param psiElement
* @param annotationHolder
*/
void annotateVarExpansion(PsiElement psiElement, AnnotationHolder annotationHolder) {
// Annotate variable expansion
if(psiElement instanceof CMakeArgument) {
String argtext = psiElement.getText();
int pos = psiElement.getTextRange().getStartOffset();
while(argtext.matches(".*\\$\\{.*\\}.*")) {
int vstart = argtext.indexOf("${");
int vend = argtext.indexOf("}");
TextRange range = new TextRange(pos+vstart, pos+vend+1);
Annotation annotation = annotationHolder.createInfoAnnotation(range, null);
annotation.setTextAttributes(DefaultLanguageHighlighterColors.CONSTANT);
argtext = argtext.substring(vend+1);
pos+=vend+1;
}
}
}
示例4: visitPropertyType
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
@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());
}
}
示例5: annotate
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof RobotKeyword) {
RobotKeyword robotKeyword = (RobotKeyword) element;
RobotKeywordReference ref = new RobotKeywordReference(robotKeyword);
ResolveResult[] resolveResults = ref.multiResolve(false);
if (resolveResults.length <= 0) {
String normalKeywordName = RobotPsiUtil.normalizeKeywordForIndex(robotKeyword.getText());
if (RobotBuiltInKeywords.isBuiltInKeyword(normalKeywordName)) {
Annotation annotation = holder.createInfoAnnotation(robotKeyword, "Built-in Robot Keyword");
annotation.setTextAttributes(DefaultLanguageHighlighterColors.GLOBAL_VARIABLE);
} else {
if (RobotConfigurable.isHighlightInvalidKeywords(element.getProject())) {
holder.createErrorAnnotation(robotKeyword,
String.format("No Keyword found with name \"%s\"", robotKeyword.getText()));
}
}
}
} else if (element instanceof RobotGenericSettingName) {
if (RobotConfigurable.isHighlightInvalidKeywords(element.getProject())) {
holder.createErrorAnnotation(element,
String.format("No Robot Setting exists with name \"%s\"", element.getText()));
}
}
}
示例6: getAttributesKey
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
private static TextAttributesKey getAttributesKey(PsiElement element)
{
if(element instanceof ThriftService || element instanceof ThriftUnion || element instanceof ThriftStruct || element instanceof
ThriftException || element instanceof ThriftEnum || element instanceof ThriftSenum)
{
return DefaultLanguageHighlighterColors.CLASS_NAME;
}
else if(element instanceof ThriftTypedef)
{
return DefaultLanguageHighlighterColors.TYPE_ALIAS_NAME;
}
else if(element instanceof ThriftConst || element instanceof ThriftEnumField)
{
return DefaultLanguageHighlighterColors.STATIC_FIELD;
}
else if(element instanceof ThriftField)
{
if(element.getParent() instanceof ThriftThrows)
{
return DefaultLanguageHighlighterColors.LOCAL_VARIABLE;
}
return DefaultLanguageHighlighterColors.INSTANCE_FIELD;
}
return null;
}
示例7: getHighlighter
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
@NotNull
@Override
public SyntaxHighlighter getHighlighter()
{
return new CfsSyntaxHighlighter(CfsLanguage.INSTANCE.findVersionByClass(IndexCfsLanguageVersion.class))
{
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType elementType)
{
if(elementType == CfsTokens.TEXT)
{
return pack(DefaultLanguageHighlighterColors.STRING);
}
return super.getTokenHighlights(elementType);
}
};
}
示例8: getTokenHighlights
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
@NotNull
@Override
public TextAttributesKey[] getTokenHighlights(IElementType elementType)
{
if(MsilTokenSets._KEYWORDS.contains(elementType))
{
return pack(DefaultLanguageHighlighterColors.MACRO_KEYWORD);
}
else if(MsilTokenSets.COMMENTS.contains(elementType))
{
return pack(DefaultLanguageHighlighterColors.LINE_COMMENT);
}
else if(MsilTokenSets.KEYWORDS.contains(elementType))
{
return pack(DefaultLanguageHighlighterColors.KEYWORD);
}
else if(elementType == MsilTokens.STRING_LITERAL)
{
return pack(DefaultLanguageHighlighterColors.STRING);
}
else if(elementType == MsilTokens.NUMBER_LITERAL || elementType == MsilTokens.HEX_NUMBER_LITERAL || elementType == MsilTokens.DOUBLE_LITERAL)
{
return pack(DefaultLanguageHighlighterColors.NUMBER);
}
return new TextAttributesKey[0];
}
示例9: annotateDocumentationWithArmaPluginTags
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的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);
}
}
示例10: testSaveNoInheritanceAndDefaults
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
public void testSaveNoInheritanceAndDefaults() throws Exception {
TextAttributes identifierAttrs = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME)
.getAttributes(DefaultLanguageHighlighterColors.IDENTIFIER);
TextAttributes declarationAttrs = identifierAttrs.clone();
Pair<EditorColorsScheme, TextAttributes> result =
doTestWriteRead(DefaultLanguageHighlighterColors.FUNCTION_DECLARATION, declarationAttrs);
TextAttributes fallbackAttrs = result.first.getAttributes(
DefaultLanguageHighlighterColors.FUNCTION_DECLARATION.getFallbackAttributeKey()
);
assertEquals(result.second, fallbackAttrs);
assertNotSame(result.second, fallbackAttrs);
}
示例11: renderStringValue
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
@Override
public void renderStringValue(@NotNull String value, @Nullable String additionalSpecialCharsToHighlight, int maxLength) {
TextAttributes textAttributes = DebuggerUIUtil.getColorScheme().getAttributes(DefaultLanguageHighlighterColors.STRING);
SimpleTextAttributes attributes = SimpleTextAttributes.fromTextAttributes(textAttributes);
myText.append("\"", attributes);
XValuePresentationUtil.renderValue(value, myText, attributes, maxLength, additionalSpecialCharsToHighlight);
myText.append("\"", attributes);
}
示例12: getAttributesKey
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
@NotNull
@Override
public TextAttributesKey[] getAttributesKey(Token t) {
switch (t.getType()) {
case STGLexer.DOC_COMMENT:
return COMMENT_KEYS;
case STGLexer.LINE_COMMENT:
return COMMENT_KEYS;
case STGLexer.BLOCK_COMMENT:
return COMMENT_KEYS;
case STGLexer.ID:
return new TextAttributesKey[]{STGroup_TEMPLATE_NAME};
case STGLexer.DELIMITERS:
case STGLexer.IMPORT:
case STGLexer.DEFAULT:
case STGLexer.KEY:
case STGLexer.VALUE:
case STGLexer.FIRST:
case STGLexer.LAST:
case STGLexer.REST:
case STGLexer.TRUNC:
case STGLexer.STRIP:
case STGLexer.TRIM:
case STGLexer.LENGTH:
case STGLexer.STRLEN:
case STGLexer.REVERSE:
case STGLexer.GROUP:
case STGLexer.WRAP:
case STGLexer.ANCHOR:
case STGLexer.SEPARATOR:
return new TextAttributesKey[]{DefaultLanguageHighlighterColors.KEYWORD};
case Token.INVALID_TYPE:
return new TextAttributesKey[]{HighlighterColors.BAD_CHARACTER};
default:
return EMPTY;
}
}
示例13: getAttributesKey
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
@NotNull
@Override
public TextAttributesKey[] getAttributesKey(Token t) {
int tokenType = t.getType();
TextAttributesKey key;
switch ( tokenType ) {
case STLexer.IF:
case STLexer.ELSE:
case STLexer.REGION_END:
case STLexer.TRUE:
case STLexer.FALSE:
case STLexer.ELSEIF:
case STLexer.ENDIF:
case STLexer.SUPER:
key = DefaultLanguageHighlighterColors.KEYWORD;
break;
case STLexer.ID:
key = ST_ID;
break;
case STLexer.STRING:
case STLexer.TEXT:
key = STGroup_TEMPLATE_TEXT;
break;
case STLexer.COMMENT:
key = DefaultLanguageHighlighterColors.LINE_COMMENT;
break;
case STLexer.ERROR_TYPE :
key = HighlighterColors.BAD_CHARACTER;
break;
default:
return EMPTY;
}
return new TextAttributesKey[]{key};
}
示例14: annotateLogicalOperators
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
/**
* Annotates logical and equality operators
* @param psiElement
* @param annotationHolder
*/
void annotateLogicalOperators(PsiElement psiElement, AnnotationHolder annotationHolder) {
// Annotate logical operators
if(psiElement instanceof CMakeArgument
&& (psiElement.getText().contains("NOT")
|| psiElement.getText().contains("AND")
|| psiElement.getText().contains("OR")
|| psiElement.getText().contains("STREQUAL"))
){
TextRange range = new TextRange(psiElement.getTextRange().getStartOffset(),
psiElement.getTextRange().getStartOffset() + psiElement.getTextRange().getLength());
Annotation annotation = annotationHolder.createInfoAnnotation(range, null);
annotation.setTextAttributes(DefaultLanguageHighlighterColors.OPERATION_SIGN);
}
}
示例15: annotateLogicalConstants
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors; //導入依賴的package包/類
/**
* Annotates logical constants
* @param psiElement
* @param annotationHolder
*/
void annotateLogicalConstants(PsiElement psiElement, AnnotationHolder annotationHolder) {
// Annotate logical constants
if(psiElement instanceof CMakeArgument
&& (psiElement.getText().contains("ON")
|| psiElement.getText().contains("OFF")
|| psiElement.getText().contains("TRUE")
||psiElement.getText().contains("FALSE") )
){
TextRange range = new TextRange(psiElement.getTextRange().getStartOffset(),
psiElement.getTextRange().getStartOffset() + psiElement.getTextRange().getLength());
Annotation annotation = annotationHolder.createInfoAnnotation(range, null);
annotation.setTextAttributes(DefaultLanguageHighlighterColors.CONSTANT);
}
}