本文整理汇总了Java中org.sonar.api.batch.sensor.highlighting.TypeOfText.STRING属性的典型用法代码示例。如果您正苦于以下问题:Java TypeOfText.STRING属性的具体用法?Java TypeOfText.STRING怎么用?Java TypeOfText.STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.sonar.api.batch.sensor.highlighting.TypeOfText
的用法示例。
在下文中一共展示了TypeOfText.STRING属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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.VALUE)) {
token = ((ValueTree) tree).value();
code = TypeOfText.STRING;
} else if (tree.is(Tree.Kind.TOKEN)) {
highlightComments((InternalSyntaxToken) tree);
}
if (token != null) {
highlight(token, code);
}
}
示例2: 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);
}
}
示例3: 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;
}
}
示例4: visitNode
@Override
public void visitNode(Tree tree) {
List<SyntaxToken> tokens = new ArrayList<>();
TypeOfText code = null;
if (tree.is(Tree.Kind.TAG)) {
tokens.add(((TagTree) tree).prefix());
tokens.add(((TagTree) tree).value());
code = TypeOfText.ANNOTATION;
} else if (tree.is(
Tree.Kind.FEATURE_PREFIX,
Tree.Kind.BACKGROUND_PREFIX,
Tree.Kind.SCENARIO_PREFIX,
Tree.Kind.SCENARIO_OUTLINE_PREFIX,
Tree.Kind.EXAMPLES_PREFIX,
Tree.Kind.STEP_PREFIX)) {
tokens.add(((PrefixTree) tree).keyword());
code = TypeOfText.KEYWORD;
} else if (tree.is(Tree.Kind.NAME)) {
tokens.add(((NameTree) tree).value());
code = TypeOfText.STRING;
} else if (tree.is(Tree.Kind.LANGUAGE_DECLARATION)) {
tokens.add(((LanguageDeclarationTree) tree).value());
code = TypeOfText.ANNOTATION;
} else if (tree.is(Tree.Kind.TOKEN)) {
highlightComments((InternalSyntaxToken) tree);
}
for (SyntaxToken token : tokens) {
highlight(token, code);
}
}
示例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);
}
}