本文整理匯總了Java中com.intellij.lang.annotation.Annotation.setTextAttributes方法的典型用法代碼示例。如果您正苦於以下問題:Java Annotation.setTextAttributes方法的具體用法?Java Annotation.setTextAttributes怎麽用?Java Annotation.setTextAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.lang.annotation.Annotation
的用法示例。
在下文中一共展示了Annotation.setTextAttributes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitDocTag
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void visitDocTag(LuaDocTag e) {
super.visitDocTag(e);
LuaDocSyntaxHighlighter highlighter = new LuaDocSyntaxHighlighter();
PsiElement element = e.getFirstChild();
while (element != null) {
if (element instanceof ASTNode) {
ASTNode astNode = (ASTNode) element;
TextAttributesKey[] keys = highlighter.getTokenHighlights(astNode.getElementType());
for (TextAttributesKey key : keys) {
final Annotation a = myHolder.createInfoAnnotation(element, null);
a.setTextAttributes(key);
}
}
element = element.getNextSibling();
}
}
示例2: visitIdentifier
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
public void visitIdentifier(LuaIdentifier id) {
if ((id != null) && id instanceof LuaGlobal) {
addSemanticHighlight(id, LuaHighlightingData.GLOBAL_VAR);
return;
}
if (id instanceof LuaFieldIdentifier) {
addSemanticHighlight(id, LuaHighlightingData.FIELD);
return;
}
if (id instanceof LuaUpvalueIdentifier) {
addSemanticHighlight(id, LuaHighlightingData.UPVAL);
} else if (id instanceof LuaLocalIdentifier) {
PsiReference reference = id.getReference();
if (reference != null) {
PsiElement resolved = reference.resolve();
if (resolved instanceof LuaParameter)
return;
}
final Annotation annotation = myHolder.createInfoAnnotation(id, null);
annotation.setTextAttributes(LuaHighlightingData.LOCAL_VAR);
}
}
示例3: annotate
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (!(element instanceof SQFCommand)) {
return;
}
SQFCommand command = (SQFCommand) element;
switch (command.getCommandName().toLowerCase()) {
case "if": //fall
case "then": //fall
case "else": //fall
case "for": //fall
case "foreach": //fall
case "switch": //fall
case "case": //fall
case "default": //fall
case "while"://fall
case "do": {
Annotation annotation = holder.createInfoAnnotation(command, "");
annotation.setTextAttributes(SQFSyntaxHighlighter.CONTROL_STRUCTURE_COMMAND);
break;
}
}
}
開發者ID:kayler-renslow,項目名稱:arma-intellij-plugin,代碼行數:24,代碼來源:SQFControlStructureCommandAnnotator.java
示例4: visitPyReferenceExpression
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void visitPyReferenceExpression(PyReferenceExpression node) {
final String name = node.getName();
if (name == null) return;
final boolean highlightedAsAttribute = highlightAsAttribute(node, name);
if (!highlightedAsAttribute && PyBuiltinCache.isInBuiltins(node)) {
final Annotation ann;
final PsiElement parent = node.getParent();
if (parent instanceof PyDecorator) {
// don't mark the entire decorator, only mark the "@", else we'll conflict with deco annotator
ann = getHolder().createInfoAnnotation(parent.getFirstChild(), null); // first child is there, or we'd not parse as deco
}
else {
ann = getHolder().createInfoAnnotation(node, null);
}
ann.setTextAttributes(PyHighlighter.PY_BUILTIN_NAME);
}
}
示例5: highlightAsAttribute
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
/**
* Try to highlight a node as a class attribute.
*
* @param node what to work with
* @return true iff the node was highlighted.
*/
private boolean highlightAsAttribute(@NotNull PyQualifiedExpression node, @NotNull String name) {
final LanguageLevel languageLevel = LanguageLevel.forElement(node);
if (PyNames.UnderscoredAttributes.contains(name) || PyNames.getBuiltinMethods(languageLevel).containsKey(name)) {
// things like __len__: foo.__len__ or class Foo: ... __len__ = my_len_impl
if (node.isQualified() || ScopeUtil.getScopeOwner(node) instanceof PyClass) {
final ASTNode astNode = node.getNode();
if (astNode != null) {
final ASTNode tgt = astNode.findChildByType(PyTokenTypes.IDENTIFIER); // only the id, not all qualifiers subtree
if (tgt != null) {
final Annotation ann = getHolder().createInfoAnnotation(tgt, null);
ann.setTextAttributes(PyHighlighter.PY_PREDEFINED_USAGE);
return true;
}
}
}
}
return false;
}
示例6: annotateDocStringStmt
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
private void annotateDocStringStmt(final PyStringLiteralExpression stmt) {
if (stmt != null) {
final DocStringFormat format = DocStringUtil.getConfiguredDocStringFormat(stmt);
final String[] tags;
if (format == DocStringFormat.EPYTEXT) {
tags = EpydocString.ALL_TAGS;
}
else if (format == DocStringFormat.REST) {
tags = SphinxDocString.ALL_TAGS;
}
else {
return;
}
int pos = 0;
while (true) {
TextRange textRange = DocStringReferenceProvider.findNextTag(stmt.getText(), pos, tags);
if (textRange == null) break;
Annotation annotation = getHolder().createInfoAnnotation(textRange.shiftRight(stmt.getTextRange().getStartOffset()), null);
annotation.setTextAttributes(PyHighlighter.PY_DOC_COMMENT_TAG);
pos = textRange.getEndOffset();
}
}
}
示例7: visitReturnStatement
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
public void visitReturnStatement(LuaReturnStatement stat) {
super.visitReturnStatement(stat);
if (stat.isTailCall()) {
final Annotation a = myHolder.createInfoAnnotation(stat, null);
a.setTextAttributes(LuaHighlightingData.TAIL_CALL);
}
}
示例8: highlightReference
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
private void highlightReference(PsiReference ref, PsiElement e) {
if (e instanceof LuaParameter) {
final Annotation a = myHolder.createInfoAnnotation((PsiElement)ref, null);
a.setTextAttributes(LuaHighlightingData.PARAMETER);
}
// else if (e instanceof LuaIdentifier) {
// LuaIdentifier id = (LuaIdentifier) e;
// TextAttributesKey attributesKey = null;
//
// if (id instanceof LuaGlobal) {
// attributesKey = LuaHighlightingData.GLOBAL_VAR;
// } else if (id instanceof LuaLocal && !id.getText().equals("...")) {
// attributesKey = LuaHighlightingData.LOCAL_VAR;
// } else if (id instanceof LuaFieldIdentifier) {
// attributesKey = LuaHighlightingData.FIELD;
// }
//
// if (attributesKey != null) {
// final Annotation annotation = myHolder.createInfoAnnotation(ref.getElement(), null);
// annotation.setTextAttributes(attributesKey);
// }
// if (ref.getElement() instanceof LuaUpvalueIdentifier) {
// final Annotation a = myHolder.createInfoAnnotation((PsiElement) ref, null);
// a.setTextAttributes(LuaHighlightingData.UPVAL);
// }
// }
}
示例9: visitDeclarationExpression
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
public void visitDeclarationExpression(LuaDeclarationExpression dec) {
if (!(dec.getContext() instanceof LuaParameter)) {
final Annotation a = myHolder.createInfoAnnotation(dec, null);
if (dec instanceof LuaLocalDeclarationImpl) a.setTextAttributes(LuaHighlightingData.LOCAL_VAR);
else if (dec instanceof LuaGlobalDeclarationImpl) a.setTextAttributes(LuaHighlightingData.GLOBAL_VAR);
}
}
示例10: visitPyKeywordArgument
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void visitPyKeywordArgument(PyKeywordArgument node) {
ASTNode keywordNode = node.getKeywordNode();
if (keywordNode != null) {
Annotation annotation = getHolder().createInfoAnnotation(keywordNode, null);
annotation.setTextAttributes(PyHighlighter.PY_KEYWORD_ARGUMENT);
}
}
示例11: visitParameter
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void visitParameter(Parameter node) {
FunctionStatement function = PsiTreeUtil.getParentOfType(node, FunctionStatement.class);
if (function != null) {
PsiElement anchor = node.hasDefaultValue() ? node.getFirstChild() : node;
final Annotation annotation = getHolder().createInfoAnnotation(anchor, null);
annotation.setTextAttributes(BuildSyntaxHighlighter.BUILD_PARAMETER);
}
}
示例12: visitPyParameter
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void visitPyParameter(PyParameter node) {
PyFunction function = PsiTreeUtil.getParentOfType(node, PyFunction.class);
if (function != null) {
Annotation annotation = getHolder().createInfoAnnotation(node, null);
annotation.setTextAttributes(node.isSelf() ? PyHighlighter.PY_SELF_PARAMETER : PyHighlighter.PY_PARAMETER);
}
}
示例13: annotate
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof SQFVariable) {
SQFVariable var = (SQFVariable) element;
if (var.isMagicVar()) {
Annotation a = holder.createInfoAnnotation(TextRange.from(element.getTextOffset(), var.getTextLength()), null);
a.setTextAttributes(SQFSyntaxHighlighter.MAGIC_VAR);
}
}
}
示例14: visitReferenceExpression
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void visitReferenceExpression(ReferenceExpression node) {
ASTNode nameNode = node.getNameElement();
if (nameNode != null
&& BuiltInNamesProvider.getBuiltInNames(node.getProject()).contains(nameNode.getText())) {
Annotation annotation = getHolder().createInfoAnnotation(nameNode, null);
annotation.setTextAttributes(BuildSyntaxHighlighter.BUILD_BUILTIN_NAME);
}
super.visitReferenceExpression(node);
}
示例15: annotate
import com.intellij.lang.annotation.Annotation; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof PsiDocTag) {
String name = ((PsiDocTag)element).getName();
if ("param".equals(name)) {
PsiDocTagValue tagValue = ((PsiDocTag)element).getValueElement();
if (tagValue != null) {
Annotation annotation = holder.createInfoAnnotation(tagValue, null);
annotation.setTextAttributes(JavaHighlightingColors.DOC_COMMENT_TAG_VALUE);
}
}
}
}