當前位置: 首頁>>代碼示例>>Java>>正文


Java ElementKind.INSTANCE_INIT屬性代碼示例

本文整理匯總了Java中javax.lang.model.element.ElementKind.INSTANCE_INIT屬性的典型用法代碼示例。如果您正苦於以下問題:Java ElementKind.INSTANCE_INIT屬性的具體用法?Java ElementKind.INSTANCE_INIT怎麽用?Java ElementKind.INSTANCE_INIT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.lang.model.element.ElementKind的用法示例。


在下文中一共展示了ElementKind.INSTANCE_INIT屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getGroupId

/**
 * Returns the group number of the class member. Elements with the same
 * number form a group. Groups with lower numbers should be positioned
 * higher in the class member list.
 * @param tree the member tree
 * @return the group number
 * @since 0.96
 */
public int getGroupId(Tree tree) {
    ElementKind kind = ElementKind.OTHER;
    Set<Modifier> modifiers = null;
    switch (tree.getKind()) {
        case ANNOTATION_TYPE:
        case CLASS:
        case ENUM:
        case INTERFACE:
            kind = ElementKind.CLASS;
            modifiers = ((ClassTree)tree).getModifiers().getFlags();
            break;
        case METHOD:
            MethodTree mt = (MethodTree)tree;
            if (mt.getName().contentEquals("<init>")) { //NOI18N
                kind = ElementKind.CONSTRUCTOR;
            } else {
                kind = ElementKind.METHOD;
            }
            modifiers = mt.getModifiers().getFlags();
            break;
        case VARIABLE:
            kind = ElementKind.FIELD;
            modifiers = ((VariableTree)tree).getModifiers().getFlags();
            break;
        case BLOCK:
            kind = ((BlockTree)tree).isStatic() ? ElementKind.STATIC_INIT : ElementKind.INSTANCE_INIT;
            break;
    }
    for (Info info : infos) {
        if (info.check(kind, modifiers))
            return info.groupId;
    }
    return infos.length;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:42,代碼來源:CodeStyle.java

示例2: getIconName

private static String getIconName( ElementKind kind, String typeName, String extension, Collection<Modifier> modifiers ) {
    
    StringBuffer fileName = new StringBuffer( typeName );
    
    if ( modifiers.contains( Modifier.STATIC ) ) {
        fileName.append( "Static" );                        //NOI18N
    }
    if ( modifiers.contains( Modifier.ABSTRACT ) ) {
        fileName.append( "Abstract" );                        //NOI18N
    }
    if ( modifiers.contains( Modifier.DEFAULT ) ) {
        fileName.append( "Default" );                        //NOI18N
    }
    if (kind == ElementKind.STATIC_INIT || kind == ElementKind.INSTANCE_INIT) {
        return fileName.append(extension).toString();
    }
    if ( modifiers.contains( Modifier.PUBLIC ) ) {
        return fileName.append( "Public" ).append( extension ).toString();      //NOI18N
    }
    if ( modifiers.contains( Modifier.PROTECTED ) ) {
        return fileName.append( "Protected" ).append( extension ).toString();   //NOI18N
    }
    if ( modifiers.contains( Modifier.PRIVATE ) ) {
        return fileName.append( "Private" ).append( extension ).toString();     //NOI18N
    }
    return fileName.append( "Package" ).append( extension ).toString();         //NOI18N
                    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:Icons.java

示例3: getKind

@DefinedBy(Api.LANGUAGE_MODEL)
public ElementKind getKind() {
    if (name == name.table.names.init)
        return ElementKind.CONSTRUCTOR;
    else if (name == name.table.names.clinit)
        return ElementKind.STATIC_INIT;
    else if ((flags() & BLOCK) != 0)
        return isStatic() ? ElementKind.STATIC_INIT : ElementKind.INSTANCE_INIT;
    else
        return ElementKind.METHOD;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:Symbol.java

示例4: processMember

private void processMember(Element member) {
  if ((member.getKind() == ElementKind.FIELD
      || member.getKind() == ElementKind.METHOD)
      && !memberNames.add(memberPath(member))) {
    reporter.withElement(member)
        .error("Duplicate member name '%s'. Encoding has limitation so that any duplicate method names are not supported,"
            + " even when allowed by JLS: methods cannot have overloads here."
            + " @Encoding.Naming annotation could be used so that actually generated methods might have the same name"
            + " if they are not conflicting as per JLS overload rules",
            member.getSimpleName());
    return;
  }

  if (member.getKind() == ElementKind.FIELD) {
    if (processField((VariableElement) member))
      return;
  }
  if (member.getKind() == ElementKind.METHOD) {
    if (!Ascii.isLowerCase(member.getSimpleName().charAt(0))) {
      reporter.withElement(member)
          .warning("Methods not starting with lowercase ascii letter might not work properly",
              member.getSimpleName());
    }
    if (processMethod((ExecutableElement) member))
      return;
  }
  if (member.getKind() == ElementKind.CLASS) {
    if (processClass((TypeElement) member))
      return;
  }
  if (member.getKind() == ElementKind.INSTANCE_INIT) {
    return;
  }

  if (member.getSimpleName().contentEquals("<init>")) {
    return;
  }

  reporter.withElement(member)
      .warning("Unrecognized encoding member '%s' will be ignored", member.getSimpleName());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:41,代碼來源:Encodings.java

示例5: processClass

private boolean processClass(TypeElement type) {
  if (BuilderMirror.isPresent(type)) {
    this.typeBuilder = type;

    if (!typeParams.equals(getTypeParameterNames(type))
        || !type.getModifiers().contains(Modifier.STATIC)) {
      reporter.withElement(type)
          .error("@Encoding.Builder class '%s' should be static with"
              + " the same type parameters as encoding type: %s",
              type.getSimpleName(),
              typesReader.parameters);

      return true;
    }

    for (Element member : type.getEnclosedElements()) {
      if ((member.getKind() == ElementKind.FIELD
          || member.getKind() == ElementKind.METHOD)
          && !memberNames.add(memberPath(member))) {
        reporter.withElement(member)
            .error(memberPath(member)
                + ": Duplicate builder member name '%s'."
                + " Encoding has limitation so that any duplicate method names are not supported,"
                + " even when allowed by JLS: methods cannot have overloads here."
                + " @Encoding.Naming annotation could be used so that actually generated methods might have the same name"
                + " if they are not conflicting as per JLS overload rules",
                member.getSimpleName());
        continue;
      }

      if (member.getKind() == ElementKind.FIELD) {
        if (processBuilderField((VariableElement) member))
          continue;
      }

      if (member.getKind() == ElementKind.METHOD) {
        if (processBuilderMethod((ExecutableElement) member))
          continue;
      }

      if (member.getKind() == ElementKind.INSTANCE_INIT) {
        continue;
      }

      if (member.getSimpleName().contentEquals("<init>")) {
        continue;
      }

      reporter.withElement(member)
          .warning("Unrecognized Builder member '%s' will be ignored", member.getSimpleName());
    }
    return true;
  }
  return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:55,代碼來源:Encodings.java

示例6: isStaticOrInstanceInit

public boolean isStaticOrInstanceInit() {
    return getKind() == ElementKind.STATIC_INIT ||
            getKind() == ElementKind.INSTANCE_INIT;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:Symbol.java


注:本文中的javax.lang.model.element.ElementKind.INSTANCE_INIT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。