当前位置: 首页>>代码示例>>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;未经允许,请勿转载。