本文整理匯總了Java中com.intellij.openapi.editor.HighlighterColors類的典型用法代碼示例。如果您正苦於以下問題:Java HighlighterColors類的具體用法?Java HighlighterColors怎麽用?Java HighlighterColors使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HighlighterColors類屬於com.intellij.openapi.editor包,在下文中一共展示了HighlighterColors類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTextAttributes
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
/**
* Returns the text attribute key used for highlighting the annotation. If not specified
* explicitly, the key is determined automatically based on the problem highlight type and
* the annotation severity.
*
* @return the text attribute key used for highlighting
*/
@NotNull
public TextAttributesKey getTextAttributes() {
if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey;
if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) {
if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES;
if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES;
if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) {
return CodeInsightColors.ERRORS_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) {
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) {
return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES;
}
return HighlighterColors.NO_HIGHLIGHTING;
}
示例2: testInfoTestAttributes
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
public void testInfoTestAttributes() throws Exception {
LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<Annotator>();
extension.language="TEXT";
extension.implementationClass = TestAnnotator.class.getName();
PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, getTestRootDisposable());
myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()){{initFonts();}};
scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
((EditorEx)myFixture.getEditor()).setColorsScheme(scheme);
myFixture.doHighlighting();
MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
RangeHighlighter[] highlighters = model.getAllHighlighters();
assertEquals(1, highlighters.length);
TextAttributes attributes = highlighters[0].getTextAttributes();
assertNotNull(attributes);
assertNull(attributes.getBackgroundColor());
assertNull(attributes.getForegroundColor());
}
示例3: getTextAttributes
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
/**
* Returns the text attribute key used for highlighting the annotation. If not specified
* explicitly, the key is determined automatically based on the problem highlight type and
* the annotation severity.
*
* @return the text attribute key used for highlighting
*/
public TextAttributesKey getTextAttributes() {
if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey;
if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) {
if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES;
if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES;
if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) {
return CodeInsightColors.ERRORS_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) {
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) {
return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES;
}
return HighlighterColors.TEXT;
}
示例4: getTextAttributes
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
/**
* Returns the text attribute key used for highlighting the annotation. If not specified
* explicitly, the key is determined automatically based on the problem highlight type and
* the annotation severity.
*
* @return the text attribute key used for highlighting
*/
@Nonnull
public TextAttributesKey getTextAttributes() {
if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey;
if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) {
if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES;
if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES;
if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) {
return CodeInsightColors.ERRORS_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) {
return CodeInsightColors.DEPRECATED_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) {
return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES;
}
if (myHighlightType == ProblemHighlightType.LIKE_UNKNOWN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) {
return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES;
}
return HighlighterColors.NO_HIGHLIGHTING;
}
示例5: fromAnnotation
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
@NotNull
static HighlightInfo fromAnnotation(@NotNull Annotation annotation, @Nullable TextRange fixedRange, boolean batchMode) {
final TextAttributes forcedAttributes = annotation.getEnforcedTextAttributes();
TextAttributesKey key = annotation.getTextAttributes();
final TextAttributesKey forcedAttributesKey = forcedAttributes == null ? (key == HighlighterColors.NO_HIGHLIGHTING ? null : key) : null;
HighlightInfo info = new HighlightInfo(forcedAttributes, forcedAttributesKey, convertType(annotation),
fixedRange != null? fixedRange.getStartOffset() : annotation.getStartOffset(),
fixedRange != null? fixedRange.getEndOffset() : annotation.getEndOffset(),
annotation.getMessage(), annotation.getTooltip(),
annotation.getSeverity(), annotation.isAfterEndOfLine(), annotation.needsUpdateOnTyping(), annotation.isFileLevelAnnotation(),
0, annotation.getProblemGroup(), annotation.getGutterIconRenderer());
appendFixes(fixedRange, info, batchMode ? annotation.getBatchFixes() : annotation.getQuickFixes());
return info;
}
示例6: highlightingTypeFromTokenType
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
public static String highlightingTypeFromTokenType(IElementType tokenType, SyntaxHighlighter highlighter) {
TextAttributesKey[] highlights = highlighter.getTokenHighlights(tokenType);
String s = null;
for (int i = highlights.length - 1; i >= 0; i--) {
if (highlights[i] != HighlighterColors.TEXT) {
s = highlights[i].getExternalName();
break;
}
}
return s == null ? HighlighterColors.TEXT.getExternalName() : s;
}
示例7: addHighlToView
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
public void addHighlToView(final Editor view, EditorColorsScheme scheme, final Map<TextAttributesKey,String> displayText) {
// XXX: Hack
if (HighlighterColors.BAD_CHARACTER.equals(myHighlightType)) {
return;
}
final TextAttributes attr = scheme.getAttributes(myHighlightType);
if (attr != null) {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
try {
// IDEA-53203: add ERASE_MARKER for manually defined attributes
view.getMarkupModel().addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX,
TextAttributes.ERASE_MARKER, HighlighterTargetArea.EXACT_RANGE);
RangeHighlighter highlighter = view.getMarkupModel()
.addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, attr,
HighlighterTargetArea.EXACT_RANGE);
final Color errorStripeColor = attr.getErrorStripeColor();
highlighter.setErrorStripeMarkColor(errorStripeColor);
final String tooltip = displayText.get(myHighlightType);
highlighter.setErrorStripeTooltip(tooltip);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
});
}
}
示例8: PyHighlighter
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
/**
* The 'heavy' constructor that initializes everything. PySyntaxHighlighterFactory caches such instances per level.
* @param languageLevel
*/
public PyHighlighter(LanguageLevel languageLevel) {
myLanguageLevel = languageLevel;
keys = new HashMap<IElementType, TextAttributesKey>();
fillMap(keys, PythonDialectsTokenSetProvider.INSTANCE.getKeywordTokens(), PY_KEYWORD);
fillMap(keys, PyTokenTypes.OPERATIONS, PY_OPERATION_SIGN);
keys.put(PyTokenTypes.INTEGER_LITERAL, PY_NUMBER);
keys.put(PyTokenTypes.FLOAT_LITERAL, PY_NUMBER);
keys.put(PyTokenTypes.IMAGINARY_LITERAL, PY_NUMBER);
keys.put(PyTokenTypes.SINGLE_QUOTED_STRING, PY_BYTE_STRING);
keys.put(PyTokenTypes.TRIPLE_QUOTED_STRING, PY_BYTE_STRING);
keys.put(PyTokenTypes.SINGLE_QUOTED_UNICODE, PY_UNICODE_STRING);
keys.put(PyTokenTypes.TRIPLE_QUOTED_UNICODE, PY_UNICODE_STRING);
keys.put(PyTokenTypes.DOCSTRING, PY_DOC_COMMENT);
keys.put(PyTokenTypes.LPAR, PY_PARENTHS);
keys.put(PyTokenTypes.RPAR, PY_PARENTHS);
keys.put(PyTokenTypes.LBRACE, PY_BRACES);
keys.put(PyTokenTypes.RBRACE, PY_BRACES);
keys.put(PyTokenTypes.LBRACKET, PY_BRACKETS);
keys.put(PyTokenTypes.RBRACKET, PY_BRACKETS);
keys.put(PyTokenTypes.COMMA, PY_COMMA);
keys.put(PyTokenTypes.DOT, PY_DOT);
keys.put(PyTokenTypes.END_OF_LINE_COMMENT, PY_LINE_COMMENT);
keys.put(PyTokenTypes.BAD_CHARACTER, HighlighterColors.BAD_CHARACTER);
keys.put(StringEscapesTokenTypes.VALID_STRING_ESCAPE_TOKEN, PY_VALID_STRING_ESCAPE);
keys.put(StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN, PY_INVALID_STRING_ESCAPE);
keys.put(StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN, PY_INVALID_STRING_ESCAPE);
}
示例9: convertAttributes
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
protected TextAttributes convertAttributes(TextAttributesKey[] keys) {
EditorColorsScheme scheme = myScheme;
TextAttributes attrs = scheme.getAttributes(HighlighterColors.TEXT);
for (TextAttributesKey key : keys) {
TextAttributes attrs2 = scheme.getAttributes(key);
if (attrs2 != null) {
attrs = TextAttributes.merge(attrs, attrs2);
}
}
return attrs;
}
示例10: getAttributesKey
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的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;
}
}
示例11: getAttributesKey
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的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};
}
示例12: convertAttributes
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
@NotNull
private TextAttributes convertAttributes(@NotNull TextAttributesKey[] keys) {
TextAttributes attrs = myColorsScheme.getAttributes(HighlighterColors.TEXT);
for (TextAttributesKey key : keys) {
TextAttributes attrs2 = myColorsScheme.getAttributes(key);
if (attrs2 != null) {
attrs = TextAttributes.merge(attrs, attrs2);
}
}
attrs = attrs.clone();
return attrs;
}
示例13: isUsualAttributes
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
private boolean isUsualAttributes(final TextAttributes ta) {
if (myUsualAttributes == null) {
final EditorColorsManager manager = EditorColorsManager.getInstance();
final EditorColorsScheme[] schemes = manager.getAllSchemes();
EditorColorsScheme defaultScheme = schemes[0];
for (EditorColorsScheme scheme : schemes) {
if (manager.isDefaultScheme(scheme)) {
defaultScheme = scheme;
break;
}
}
myUsualAttributes = defaultScheme.getAttributes(HighlighterColors.TEXT);
}
return myUsualAttributes.equals(ta);
}
示例14: convertAttributes
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
protected TextAttributes convertAttributes(@NotNull TextAttributesKey[] keys) {
TextAttributes attrs = myScheme.getAttributes(HighlighterColors.TEXT);
for (TextAttributesKey key : keys) {
TextAttributes attrs2 = myScheme.getAttributes(key);
if (attrs2 != null) {
attrs = TextAttributes.merge(attrs, attrs2);
}
}
return attrs;
}
示例15: convertAttributes
import com.intellij.openapi.editor.HighlighterColors; //導入依賴的package包/類
@Nonnull
private TextAttributes convertAttributes(@Nonnull TextAttributesKey[] keys) {
TextAttributes attrs = myColorsScheme.getAttributes(HighlighterColors.TEXT);
for (TextAttributesKey key : keys) {
TextAttributes attrs2 = myColorsScheme.getAttributes(key);
if (attrs2 != null) {
attrs = TextAttributes.merge(attrs, attrs2);
}
}
attrs = attrs.clone();
return attrs;
}