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


Java Flag类代码示例

本文整理汇总了Java中com.sun.tools.javac.code.Flags.Flag的典型用法代码示例。如果您正苦于以下问题:Java Flag类的具体用法?Java Flag怎么用?Java Flag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Flag类属于com.sun.tools.javac.code.Flags包,在下文中一共展示了Flag类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createReplacementMethodModifiers

import com.sun.tools.javac.code.Flags.Flag; //导入依赖的package包/类
private String createReplacementMethodModifiers(VisitorState state, JCModifiers modifiers) {
  ImmutableList.Builder<String> modifierStringsBuilder =
      ImmutableList.<String>builder().add("@Multibinds");

  for (JCAnnotation annotation : modifiers.annotations) {
    Name annotationQualifiedName = ASTHelpers.getSymbol(annotation).getQualifiedName();
    if (!(annotationQualifiedName.contentEquals("dagger.Provides")
        || annotationQualifiedName.contentEquals("dagger.producers.Produces")
        || annotationQualifiedName.contentEquals("dagger.multibindings.ElementsIntoSet"))) {
      modifierStringsBuilder.add(state.getSourceForNode(annotation));
    }
  }

  EnumSet<Flag> methodFlags = Flags.asFlagSet(modifiers.flags);
  methodFlags.remove(Flags.Flag.STATIC);
  methodFlags.remove(Flags.Flag.FINAL);
  methodFlags.add(Flags.Flag.ABSTRACT);

  for (Flag flag : methodFlags) {
    modifierStringsBuilder.add(flag.toString());
  }

  return Joiner.on(' ').join(modifierStringsBuilder.build());
}
 
开发者ID:google,项目名称:error-prone,代码行数:25,代码来源:EmptySetMultibindingContributions.java

示例2: createReplacementClassModifiers

import com.sun.tools.javac.code.Flags.Flag; //导入依赖的package包/类
private String createReplacementClassModifiers(
    VisitorState state, JCModifiers enclosingClassModifiers) {
  ImmutableList.Builder<String> classModifierStringsBuilder = ImmutableList.builder();

  for (JCAnnotation annotation : enclosingClassModifiers.annotations) {
    classModifierStringsBuilder.add(state.getSourceForNode(annotation));
  }

  EnumSet<Flag> classFlags = Flags.asFlagSet(enclosingClassModifiers.flags);
  classFlags.remove(Flags.Flag.FINAL);
  classFlags.add(Flags.Flag.ABSTRACT);
  for (Flag flag : classFlags) {
    classModifierStringsBuilder.add(flag.toString());
  }

  return Joiner.on(' ').join(classModifierStringsBuilder.build());
}
 
开发者ID:google,项目名称:error-prone,代码行数:18,代码来源:EmptySetMultibindingContributions.java

示例3: convertMethodToBinds

import com.sun.tools.javac.code.Flags.Flag; //导入依赖的package包/类
private SuggestedFix.Builder convertMethodToBinds(MethodTree method, VisitorState state) {
  SuggestedFix.Builder fix = SuggestedFix.builder();

  JCModifiers modifiers = ((JCMethodDecl) method).getModifiers();
  ImmutableList.Builder<String> modifierStringsBuilder =
      ImmutableList.<String>builder().add("@Binds");

  for (JCAnnotation annotation : modifiers.annotations) {
    Name annotationQualifiedName = getSymbol(annotation).getQualifiedName();
    if (annotationQualifiedName.contentEquals(PROVIDES_CLASS_NAME)
        || annotationQualifiedName.contentEquals(PRODUCES_CLASS_NAME)) {
      List<JCExpression> arguments = annotation.getArguments();
      if (!arguments.isEmpty()) {
        JCExpression argument = Iterables.getOnlyElement(arguments);
        checkState(argument.getKind().equals(ASSIGNMENT));
        JCAssign assignment = (JCAssign) argument;
        checkState(getSymbol(assignment.getVariable()).getSimpleName().contentEquals("type"));
        String typeName = getSymbol(assignment.getExpression()).getSimpleName().toString();
        switch (typeName) {
          case "SET":
            modifierStringsBuilder.add("@IntoSet");
            fix.addImport(INTO_SET_CLASS_NAME);
            break;
          case "SET_VALUES":
            modifierStringsBuilder.add("@ElementsIntoSet");
            fix.addImport(ELEMENTS_INTO_SET_CLASS_NAME);
            break;
          case "MAP":
            modifierStringsBuilder.add("@IntoMap");
            fix.addImport(INTO_MAP_CLASS_NAME);
            break;
          default:
            throw new AssertionError("Unknown type name: " + typeName);
        }
      }
    } else {
      modifierStringsBuilder.add(state.getSourceForNode(annotation));
    }
  }

  EnumSet<Flag> methodFlags = Flags.asFlagSet(modifiers.flags);
  methodFlags.remove(Flags.Flag.STATIC);
  methodFlags.remove(Flags.Flag.FINAL);
  methodFlags.add(Flags.Flag.ABSTRACT);

  for (Flag flag : methodFlags) {
    modifierStringsBuilder.add(flag.toString());
  }

  fix.replace(modifiers, Joiner.on(' ').join(modifierStringsBuilder.build()));
  fix.replace(method.getBody(), ";");
  return fix;
}
 
开发者ID:google,项目名称:error-prone,代码行数:54,代码来源:UseBinds.java


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