本文整理汇总了Java中org.sonar.api.batch.sensor.highlighting.TypeOfText.CONSTANT属性的典型用法代码示例。如果您正苦于以下问题:Java TypeOfText.CONSTANT属性的具体用法?Java TypeOfText.CONSTANT怎么用?Java TypeOfText.CONSTANT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.sonar.api.batch.sensor.highlighting.TypeOfText
的用法示例。
在下文中一共展示了TypeOfText.CONSTANT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitNode
@Override
public void visitNode(Tree tree) {
super.visitNode(tree);
List<SyntaxToken> tokens = new ArrayList<>();
TypeOfText code = null;
if (tree.is(Tree.Kind.LESS_VARIABLE)) {
tokens.add(((LessVariableTree) tree).variable().value());
tokens.add(((LessVariableTree) tree).variablePrefix());
code = TypeOfText.CONSTANT;
}
for (SyntaxToken token : tokens) {
highlight(token, code);
}
}
示例2: visitNode
@Override
public void visitNode(Tree tree) {
super.visitNode(tree);
List<SyntaxToken> tokens = new ArrayList<>();
TypeOfText code = null;
if (tree.is(Tree.Kind.SCSS_VARIABLE)) {
tokens.add(((ScssVariableTree) tree).name().value());
tokens.add(((ScssVariableTree) tree).prefix());
code = TypeOfText.CONSTANT;
} else if (tree.is(Tree.Kind.SCSS_DIRECTIVE)) {
tokens.add(((ScssDirectiveTree) tree).at());
tokens.add(((ScssDirectiveTree) tree).name());
code = TypeOfText.ANNOTATION;
}
for (SyntaxToken token : tokens) {
highlight(token, code);
}
}
示例3: visitNode
@Override
public void visitNode(Tree tree) {
SyntaxToken token = null;
TypeOfText code = null;
if (tree.is(Tree.Kind.KEY)) {
token = ((KeyTree) tree).value();
code = TypeOfText.KEYWORD;
} else if (tree.is(Tree.Kind.STRING)) {
token = ((LiteralTree) tree).value();
code = TypeOfText.STRING;
} else if (tree.is(Tree.Kind.FALSE, Tree.Kind.TRUE, Tree.Kind.NULL, Tree.Kind.NUMBER)) {
token = ((LiteralTree) tree).value();
code = TypeOfText.CONSTANT;
}
if (token != null) {
highlight(token, code);
}
}
示例4: toType
@CheckForNull
private static TypeOfText toType(SonarAnalyzer.TokenType tokenType) {
// Note:
// TypeOfText.ANNOTATION -> like a type in C#, so received as DECLARATION_NAME
// TypeOfText.STRUCTURED_COMMENT -> not colored differently in C#, so received as COMMENT
// TypeOfText.PREPROCESS_DIRECTIVE -> received as KEYWORD
switch (tokenType) {
case NUMERIC_LITERAL:
return TypeOfText.CONSTANT;
case COMMENT:
return TypeOfText.COMMENT;
case KEYWORD:
return TypeOfText.KEYWORD;
case TYPE_NAME:
return TypeOfText.KEYWORD_LIGHT;
case STRING_LITERAL:
return TypeOfText.STRING;
case UNRECOGNIZED:
// generated by protobuf
case UNKNOWN:
default:
// do not color
return null;
}
}
示例5: visitNode
@Override
public void visitNode(Tree tree) {
List<SyntaxToken> tokens = new ArrayList<>();
TypeOfText code = null;
if (tree.is(Tree.Kind.STRING)) {
tokens.add(((StringTree) tree).value());
code = TypeOfText.STRING;
} else if (tree.is(Tree.Kind.PROPERTY)) {
tokens.add(((PropertyTree) tree).property().value());
code = TypeOfText.CONSTANT;
} else if (tree.is(Tree.Kind.VARIABLE)) {
tokens.add(((VariableTree) tree).variable().value());
tokens.add(((VariableTree) tree).variablePrefix());
code = TypeOfText.CONSTANT;
} else if (tree.is(Tree.Kind.CLASS_SELECTOR)) {
tokens.add(((ClassSelectorTree) tree).className().value());
tokens.add(((ClassSelectorTree) tree).dot());
code = TypeOfText.KEYWORD_LIGHT;
} else if (tree.is(Tree.Kind.ID_SELECTOR)) {
tokens.add(((IdSelectorTree) tree).identifier().value());
tokens.add(((IdSelectorTree) tree).hashSymbol());
code = TypeOfText.KEYWORD_LIGHT;
} else if (tree.is(Tree.Kind.AT_KEYWORD)) {
tokens.add(((AtKeywordTree) tree).keyword().value());
tokens.add(((AtKeywordTree) tree).atSymbol());
code = TypeOfText.PREPROCESS_DIRECTIVE;
} else if (tree.is(Tree.Kind.TOKEN)) {
highlightComments((InternalSyntaxToken) tree);
}
for (SyntaxToken token : tokens) {
highlight(token, code);
}
}