当前位置: 首页>>代码示例>>Java>>正文


Java TypeOfText.CONSTANT属性代码示例

本文整理汇总了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);
  }
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:17,代码来源:LessSyntaxHighlighterVisitor.java

示例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);
  }
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:21,代码来源:ScssSyntaxHighlighterVisitor.java

示例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);
  }
}
 
开发者ID:racodond,项目名称:sonar-json-plugin,代码行数:22,代码来源:SyntaxHighlighterVisitor.java

示例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;
  }
}
 
开发者ID:SonarSource,项目名称:sonar-dotnet-shared-library,代码行数:31,代码来源:HighlightImporter.java

示例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);
  }
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:41,代码来源:CssSyntaxHighlighterVisitor.java


注:本文中的org.sonar.api.batch.sensor.highlighting.TypeOfText.CONSTANT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。