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


Java NestingKind.MEMBER屬性代碼示例

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


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

示例1: lookupStaticClass

public TypeElement lookupStaticClass(DeclaredType type, CharSequence className, TypeMirror classType) {
    for (TypeElement clazz : ElementFilter.typesIn(type.asElement().getEnclosedElements())) {
        final Collection<? extends Modifier> modifiers = clazz.getModifiers();

        if (clazz.getNestingKind() != NestingKind.MEMBER
                || !modifiers.contains(Modifier.STATIC)
                || !modifiers.contains(Modifier.PUBLIC)
                || !clazz.getKind().isClass()) {
            continue;
        }

        if (!clazz.getSimpleName().contentEquals(className)) {
            continue;
        }

        if (!types.isAssignable(clazz.asType(), classType)) {
            continue;
        }

        return clazz;
    }

    return null;
}
 
開發者ID:chdir,項目名稱:aidl2,代碼行數:24,代碼來源:AptHelper.java

示例2: validateBeanType

private static TypeElement validateBeanType(TypeElement beanType) {
  if (!hasParameterlessConstructor(beanType)) {
    throw new ValidationException(BEAN_NO_DEFAULT_CONSTRUCTOR, beanType);
  }
  if (beanType.getModifiers().contains(PRIVATE)) {
    throw new ValidationException(NESTING_KIND, beanType);
  }
  if (beanType.getNestingKind() == NestingKind.MEMBER &&
      !beanType.getModifiers().contains(STATIC)) {
    throw new ValidationException(NESTING_KIND, beanType);
  }
  if (beanType.getModifiers().contains(ABSTRACT)) {
    throw new ValidationException(BEAN_ABSTRACT_CLASS, beanType);
  }
  if (!beanType.getTypeParameters().isEmpty()) {
    throw new ValidationException(TYPE_PARAMS_BEAN, beanType);
  }
  return beanType;
}
 
開發者ID:h908714124,項目名稱:zerobuilder,代碼行數:19,代碼來源:ProjectionValidatorB.java

示例3: run

@TriggerTreeKind(Tree.Kind.BLOCK)
public static ErrorDescription run(HintContext ctx) {
    TreePath path = ctx.getPath();
    if (((BlockTree)path.getLeaf()).isStatic()) {
        return null;
    }
    TreePath parentPath = path.getParentPath();
    if (parentPath == null) {
        return null;
    }
    Tree l = parentPath.getLeaf();
    if (!(l instanceof ClassTree)) {
        return null;
    }
    Element el = ctx.getInfo().getTrees().getElement(parentPath);
    if (el == null || !el.getKind().isClass()) {
        return null;
    }
    TypeElement tel = (TypeElement)el;
    // do not suggest for anonymous classes, local classes or members which are not static.
    if (tel.getNestingKind() != NestingKind.TOP_LEVEL && 
        (tel.getNestingKind() != NestingKind.MEMBER || !tel.getModifiers().contains(Modifier.STATIC))) {
        return null;
    }
    InstanceRefFinder finder = new InstanceRefFinder(ctx.getInfo(), path);
    finder.process();
    if (finder.containsInstanceReferences() || finder.containsReferencesToSuper()) {
        return null;
    }
    
    return ErrorDescriptionFactory.forTree(ctx, path, Bundle.TEXT_InitializerCanBeStatic(),
            new MakeInitStatic(TreePathHandle.create(path, ctx.getInfo())).toEditorFix());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:InitializerCanBeStatic.java

示例4: getFlatName

public static String getFlatName(TypeElement classRepresenter) {
    if (classRepresenter.getNestingKind() == NestingKind.MEMBER) {
        return classRepresenter.getEnclosingElement() + "" + classRepresenter.getSimpleName().toString();
    } else {
        return classRepresenter.getQualifiedName().toString();
    }
}
 
開發者ID:intendia-oss,項目名稱:qualifier,代碼行數:7,代碼來源:StaticQualifierMetamodelProcessor.java

示例5: getNestingKind

@DefinedBy(Api.LANGUAGE_MODEL)
public NestingKind getNestingKind() {
    complete();
    if (owner.kind == PCK)
        return NestingKind.TOP_LEVEL;
    else if (name.isEmpty())
        return NestingKind.ANONYMOUS;
    else if (owner.kind == MTH)
        return NestingKind.LOCAL;
    else
        return NestingKind.MEMBER;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:12,代碼來源:Symbol.java

示例6: getNestingKind

@Override
public NestingKind getNestingKind() {
    require(State.FINISHED);
    boolean isTopLevel = enclosingTypeDeclaration == null;
    return isTopLevel
        ? NestingKind.TOP_LEVEL
        : NestingKind.MEMBER;
}
 
開發者ID:cloudkeeper-project,項目名稱:cloudkeeper,代碼行數:8,代碼來源:TypeDeclarationImpl.java

示例7: doCompile

@Override
protected UnitCache<VariableElement> doCompile(FieldDeclaration unit) {
    String unitName = NameUtil.getNodeName(getCompileUnit(), unit);

    TypeMirror type = TypeUtil.toMirror(getCompileUnit(), unit.getType());
    Name name = new StringName(unitName);

    ElementKind kind = ElementKind.FIELD;
    Set<Modifier> modifierSet = ModifierUtil.asSet(unit.getModifiers());

    List<Element> members = new ArrayList<>();
    for(VariableDeclarator var : unit.getVariables()) {
        // TODO:
    }

    VariableElement element = new EmulVariableElement(type, kind, parent, members,
        modifierSet, name, name, NestingKind.MEMBER);

    // Children
    NodeToElementCompiler compiler = new NodeToElementCompiler(getCompileUnit(), element);
    for(Node child : unit.getChildrenNodes()) {
        Element childElem = compiler.compile(child);
        if(childElem != null) {
            members.add(childElem);
        }
    }

    return new UnitCache<>(element);
}
 
開發者ID:BenDol,項目名稱:Databind,代碼行數:29,代碼來源:NodeToVariableElementCompiler.java

示例8: getNestingKind

@Override
public NestingKind getNestingKind() {
	ReferenceBinding refBinding = (ReferenceBinding)_binding;
	if (refBinding.isAnonymousType()) {
		return NestingKind.ANONYMOUS;
	} else if (refBinding.isLocalType()) {
		return NestingKind.LOCAL;
	} else if (refBinding.isMemberType()) {
		return NestingKind.MEMBER;
	}
	return NestingKind.TOP_LEVEL;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:12,代碼來源:TypeElementImpl.java

示例9: matchClass

@Override
public Description matchClass(final ClassTree tree, final VisitorState state) {
  final ClassSymbol currentClass = ASTHelpers.getSymbol(tree);
  if (currentClass == null || !currentClass.hasOuterInstance()) {
    return NO_MATCH;
  }
  if (currentClass.getNestingKind() != NestingKind.MEMBER) {
    // local or anonymous classes can't be static
    return NO_MATCH;
  }
  switch (currentClass.owner.enclClass().getNestingKind()) {
    case TOP_LEVEL:
      break;
    case MEMBER:
      // class is nested inside an inner class, so it can't be static
      if (currentClass.owner.enclClass().hasOuterInstance()) {
        return NO_MATCH;
      }
      break;
    case LOCAL:
    case ANONYMOUS:
      // members of local and anonymous classes can't be static
      return NO_MATCH;
  }
  if (tree.getExtendsClause() != null
      && ASTHelpers.getType(tree.getExtendsClause()).tsym.hasOuterInstance()) {
    return NO_MATCH;
  }
  if (CanBeStaticAnalyzer.referencesOuter(tree, currentClass, state)) {
    return NO_MATCH;
  }
  return describeMatch(tree, SuggestedFixes.addModifiers(tree, state, Modifier.STATIC));
}
 
開發者ID:google,項目名稱:error-prone,代碼行數:33,代碼來源:ClassCanBeStatic.java

示例10: validateEnclosingElement

protected void validateEnclosingElement(Element element) {
    TypeElement typeElement = ElementUtil.toTypeElement(element, env);
    if (typeElement == null) {
        return;
    }
    String simpleName = typeElement.getSimpleName().toString();
    if (simpleName.contains(Constants.BINARY_NAME_DELIMITER)
            || simpleName.contains(Constants.METATYPE_NAME_DELIMITER)) {
        throw new AptException(Message.DOMA4277, env, typeElement,
                new Object[] { typeElement.getQualifiedName() });
    }
    NestingKind nestingKind = typeElement.getNestingKind();
    if (nestingKind == NestingKind.TOP_LEVEL) {
        return;
    } else if (nestingKind == NestingKind.MEMBER) {
        Set<Modifier> modifiers = typeElement.getModifiers();
        if (modifiers.containsAll(Arrays.asList(Modifier.STATIC,
                Modifier.PUBLIC))) {
            validateEnclosingElement(typeElement.getEnclosingElement());
        } else {
            throw new AptException(Message.DOMA4275, env, typeElement,
                    new Object[] { typeElement.getQualifiedName() });
        }
    } else {
        throw new AptException(Message.DOMA4276, env, typeElement,
                new Object[] { typeElement.getQualifiedName() });
    }
}
 
開發者ID:domaframework,項目名稱:doma,代碼行數:28,代碼來源:DomainMetaFactory.java

示例11: validateEnclosingElement

protected void validateEnclosingElement(Element element) {
    TypeElement typeElement = ElementUtil.toTypeElement(element, env);
    if (typeElement == null) {
        return;
    }
    String simpleName = typeElement.getSimpleName().toString();
    if (simpleName.contains(Constants.BINARY_NAME_DELIMITER)
            || simpleName.contains(Constants.METATYPE_NAME_DELIMITER)) {
        throw new AptException(Message.DOMA4417, env, typeElement,
                new Object[] { typeElement.getQualifiedName() });
    }
    NestingKind nestingKind = typeElement.getNestingKind();
    if (nestingKind == NestingKind.TOP_LEVEL) {
        return;
    } else if (nestingKind == NestingKind.MEMBER) {
        Set<Modifier> modifiers = typeElement.getModifiers();
        if (modifiers.containsAll(Arrays.asList(Modifier.STATIC,
                Modifier.PUBLIC))) {
            validateEnclosingElement(typeElement.getEnclosingElement());
        } else {
            throw new AptException(Message.DOMA4415, env, typeElement,
                    new Object[] { typeElement.getQualifiedName() });
        }
    } else {
        throw new AptException(Message.DOMA4416, env, typeElement,
                new Object[] { typeElement.getQualifiedName() });
    }
}
 
開發者ID:domaframework,項目名稱:doma,代碼行數:28,代碼來源:EmbeddableMetaFactory.java

示例12: validateEnclosingElement

protected void validateEnclosingElement(Element element) {
    TypeElement typeElement = ElementUtil.toTypeElement(element, env);
    if (typeElement == null) {
        return;
    }
    String simpleName = typeElement.getSimpleName().toString();
    if (simpleName.contains(Constants.BINARY_NAME_DELIMITER)
            || simpleName.contains(Constants.METATYPE_NAME_DELIMITER)) {
        throw new AptException(Message.DOMA4317, env, typeElement,
                new Object[] { typeElement.getQualifiedName() });
    }
    NestingKind nestingKind = typeElement.getNestingKind();
    if (nestingKind == NestingKind.TOP_LEVEL) {
        return;
    } else if (nestingKind == NestingKind.MEMBER) {
        Set<Modifier> modifiers = typeElement.getModifiers();
        if (modifiers.containsAll(Arrays.asList(Modifier.STATIC,
                Modifier.PUBLIC))) {
            validateEnclosingElement(typeElement.getEnclosingElement());
        } else {
            throw new AptException(Message.DOMA4315, env, typeElement,
                    new Object[] { typeElement.getQualifiedName() });
        }
    } else {
        throw new AptException(Message.DOMA4316, env, typeElement,
                new Object[] { typeElement.getQualifiedName() });
    }
}
 
開發者ID:domaframework,項目名稱:doma,代碼行數:28,代碼來源:EntityMetaFactory.java

示例13: validateEnclosingElement

protected void validateEnclosingElement(Element element) {
    TypeElement typeElement = ElementUtil.toTypeElement(element, env);
    if (typeElement == null) {
        return;
    }
    String simpleName = typeElement.getSimpleName().toString();
    if (simpleName.contains(Constants.BINARY_NAME_DELIMITER)
            || simpleName.contains(Constants.METATYPE_NAME_DELIMITER)) {
        throw new AptException(Message.DOMA4280, env, typeElement,
                new Object[] { typeElement.getQualifiedName() });
    }
    NestingKind nestingKind = typeElement.getNestingKind();
    if (nestingKind == NestingKind.TOP_LEVEL) {
        return;
    } else if (nestingKind == NestingKind.MEMBER) {
        Set<Modifier> modifiers = typeElement.getModifiers();
        if (modifiers.containsAll(Arrays.asList(Modifier.STATIC,
                Modifier.PUBLIC))) {
            validateEnclosingElement(typeElement.getEnclosingElement());
        } else {
            throw new AptException(Message.DOMA4278, env, typeElement,
                    new Object[] { typeElement.getQualifiedName() });
        }
    } else {
        throw new AptException(Message.DOMA4279, env, typeElement,
                new Object[] { typeElement.getQualifiedName() });
    }
}
 
開發者ID:domaframework,項目名稱:doma,代碼行數:28,代碼來源:ExternalDomainMetaFactory.java

示例14: getNestingKind

@Override
public NestingKind getNestingKind() {
  // We'll never need to infer local or anonymous classes, so there are only two options left
  // and we can tell the difference:
  if (getEnclosingElement() instanceof InferredTypeElement) {
    return NestingKind.MEMBER;
  }

  return NestingKind.TOP_LEVEL;
}
 
開發者ID:facebook,項目名稱:buck,代碼行數:10,代碼來源:InferredTypeElement.java

示例15: isAccessibleClass

private static boolean isAccessibleClass(TypeElement te) {
    NestingKind nestingKind = te.getNestingKind();
    return (nestingKind == NestingKind.TOP_LEVEL) || (nestingKind == NestingKind.MEMBER && te.getModifiers().contains(Modifier.STATIC));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:4,代碼來源:LazyTypeCompletionItem.java


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