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


Java ElementKind.FIELD属性代码示例

本文整理汇总了Java中javax.lang.model.element.ElementKind.FIELD属性的典型用法代码示例。如果您正苦于以下问题:Java ElementKind.FIELD属性的具体用法?Java ElementKind.FIELD怎么用?Java ElementKind.FIELD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.lang.model.element.ElementKind的用法示例。


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

示例1: getMethodToFieldNameMap

private Map<ExecutableElement, String> getMethodToFieldNameMap(RoundEnvironment roundEnvironment) {
    final Map<ExecutableElement, String> methodToFieldNameMap = new HashMap<>();

    for (Element byElement : roundEnvironment.getElementsAnnotatedWith(By.class)) {
        if (byElement.getKind() != ElementKind.FIELD) {
            continue;
        }
        VariableElement byField = (VariableElement) byElement;
        for (Element element : typeUtils.asElement(byField.asType()).getEnclosedElements()) {
            if (element.getKind() != ElementKind.METHOD) {
                continue;
            }
            ExecutableElement method = (ExecutableElement) element;
            methodToFieldNameMap.put(method, byField.getSimpleName().toString());
        }
    }

    return methodToFieldNameMap;
}
 
开发者ID:srym,项目名称:cuckoo,代码行数:19,代码来源:DelegationProcessor.java

示例2: handlerElement

public Map<String, ClassEntity> handlerElement(RoundEnvironment env, BaseProcessor processor) {
    this.env = env;
    for (Class<? extends Annotation> support : processor.getSupportedAnnotations()) {
        for (Element element : env.getElementsAnnotatedWith(support)) {
            if (element.getKind() == ElementKind.FIELD){
                handlerField((VariableElement) element);
            }
            if (element.getKind() == ElementKind.METHOD){
                handlerMethod((ExecutableElement) element);
            }
            if (element.getKind() == ElementKind.CLASS) {
                handlerClass((TypeElement) element);
            }
        }
    }
    return classEntityMap;
}
 
开发者ID:simplezhli,项目名称:RxPay,代码行数:17,代码来源:EntityHandler.java

示例3: setMethodOrFieldName

public void setMethodOrFieldName(String clazz, String method, String field) {
    disableUpdates = true;
    updateMembers();
    for (int i = 0; i < cbMember.getItemCount(); i++) {
        Object o = cbMember.getItemAt(i);
        MemberDescription desc = (MemberDescription)o;
        if (method != null) {
            if (desc.kind == ElementKind.METHOD && desc.name.equals(method)) {
                cbMember.setSelectedIndex(i);
                break;
            }
        } else if (field != null) {
            if (desc.kind == ElementKind.FIELD && desc.name.equals(method)) {
                cbMember.setSelectedIndex(i);
                break;
            }
        }
    }
    disableUpdates = false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:JShellOptions2.java

示例4: handleCurrentAccess

private void handleCurrentAccess() {
    if (lValueDereference) {
        return;
    }
    Element e = info.getTrees().getElement(getCurrentPath());

    if (e != null && SUPPORTED_VARIABLES.contains(e.getKind())) {
        VariableElement ve = (VariableElement) e;
        State prevState = variable2State.get(ve);
        
        if (LOCAL_VARIABLES.contains(e.getKind())) {
            addUse2Values(getCurrentPath().getLeaf(), prevState);
        } else if (e.getKind() == ElementKind.FIELD && (prevState == null || prevState.hasUnassigned()) && !finalCandidates.contains(ve)) {
            usedWhileUndefined.add(ve);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:Flow.java

示例5: enumerateFieldElements

private static void enumerateFieldElements( @Nonnull final TypeElement element,
                                            @Nonnull final Map<String, VariableElement> fields )
{
  final TypeMirror superclass = element.getSuperclass();
  if ( TypeKind.NONE != superclass.getKind() )
  {
    enumerateFieldElements( (TypeElement) ( (DeclaredType) superclass ).asElement(), fields );
  }
  for ( final Element member : element.getEnclosedElements() )
  {
    if ( member.getKind() == ElementKind.FIELD )
    {
      fields.put( member.getSimpleName().toString(), (VariableElement) member );
    }
  }
}
 
开发者ID:arez,项目名称:arez,代码行数:16,代码来源:ProcessorUtil.java

示例6: testFieldSignatureFromElement

public void testFieldSignatureFromElement () throws Exception {
InputStream in = this.prepareData(TEST_CLASS);
try {
    JavacTask jt = prepareJavac ();
    Elements elements = jt.getElements();
    TypeElement be = elements.getTypeElement(TEST_CLASS);
    ClassFile cf = new ClassFile (in, true);
    String className = cf.getName().getInternalName().replace('/','.');	    //NOI18N
    List<? extends Element> members = be.getEnclosedElements();
    for (Element e : members) {
	if (e.getKind() == ElementKind.FIELD) {
	    String[] msig = ClassFileUtil.createFieldDescriptor((VariableElement) e);
	    assertEquals (className,msig[0]);
	    assertEquals (e.getSimpleName().toString(),msig[1]);
	    Variable v = cf.getVariable (e.getSimpleName().toString());		    
	    assertNotNull (v);		    
	    assertEquals (v.getDescriptor(), msig[2]);
	}
    }
} finally {
    in.close ();
}
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CompromiseSATest.java

示例7: enumerateFields

private static void enumerateFields( @Nonnull final TypeElement scope,
                                     @Nonnull final Types typeUtils,
                                     @Nonnull final TypeElement element,
                                     @Nonnull final Map<String, TypeMirror> fields )
{
  final TypeMirror superclass = element.getSuperclass();
  if ( TypeKind.NONE != superclass.getKind() )
  {
    enumerateFields( scope, typeUtils, (TypeElement) ( (DeclaredType) superclass ).asElement(), fields );
  }
  for ( final Element member : element.getEnclosedElements() )
  {
    if ( member.getKind() == ElementKind.FIELD )
    {
      final TypeMirror fieldType = typeUtils.asMemberOf( (DeclaredType) scope.asType(), member );
      fields.put( member.getSimpleName().toString(), fieldType );
    }
  }
}
 
开发者ID:react4j,项目名称:react4j,代码行数:19,代码来源:ProcessorUtil.java

示例8: inferNaming

private Naming inferNaming(Element element, EnumSet<Tag> tags, AtomicReference<StandardNaming> standardNaming) {
  Optional<NamingMirror> namingAnnotation = NamingMirror.find(element);
  if (namingAnnotation.isPresent()) {
    try {
      NamingMirror mirror = namingAnnotation.get();
      Naming naming = Naming.from(mirror.value());
      if (mirror.depluralize()) {
        tags.add(Tag.DEPLURALIZE);
      }
      standardNaming.set(mirror.standard());
      return naming;
    } catch (IllegalArgumentException ex) {
      reporter.withElement(element)
          .annotationNamed(NamingMirror.simpleName())
          .error(ex.getMessage());
    }
  }
  if (element.getKind() == ElementKind.FIELD
      || (element.getKind() == ElementKind.METHOD
      && (element.getModifiers().contains(Modifier.PRIVATE) || tags.contains(Tag.PRIVATE)))) {
    return helperNaming(element.getSimpleName());
  }
  if (tags.contains(Tag.INIT) || tags.contains(Tag.COPY)) {
    return Naming.identity();
  }
  String encodedMethodName = element.getSimpleName().toString();
  return Naming.from("*" + Naming.Usage.CAPITALIZED.apply(encodedMethodName));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:Encodings.java

示例9: getParamModels

private List<ActivityIntentModel.ParamModel> getParamModels(TypeElement typeElement) {
    List<ActivityIntentModel.ParamModel> paramModels = new ArrayList<>();

    List<? extends Element> list = typeElement.getEnclosedElements();
    if (list == null) {
        return paramModels;
    }
    for (Element paramElement : list) {
        IntentParam intentParam = paramElement.getAnnotation(IntentParam.class); //AnnotationMirror mirror = e.getAnnotationMirrors().get(0);
        if (intentParam != null) {
            if (paramElement.getKind() != ElementKind.FIELD || paramElement.getModifiers() == null || !paramElement.getModifiers().contains(Modifier.STATIC)) {
                messager.printMessage(Diagnostic.Kind.ERROR, "IntentParam can only be applied to STATIC FIELD");
                continue;
            }
            messager.printMessage(Diagnostic.Kind.NOTE, "   IntentParam annotated element:" + paramElement.getSimpleName());

            ActivityIntentModel.ParamModel paramModel = new ActivityIntentModel.ParamModel();
            paramModel.fieldName = paramElement.getSimpleName().toString();
            //TypeMirror fieldType = e.asType();
            //paramModel.type = fieldType;
            paramModel.type = intentParam.type();
            paramModel.generatedPropName = intentParam.name();
            paramModel.qualifiedClassName = typeElement.getQualifiedName().toString();
            paramModels.add(paramModel);

        }
    }

    return paramModels;

}
 
开发者ID:daawa,项目名称:auto-nav,代码行数:31,代码来源:NavProcessor.java

示例10: accept

public boolean accept(Element e, TypeMirror type) {
    
    if (e.getKind() != ElementKind.FIELD) {
        return false;
    } else {
        if( e.getSimpleName().toString().equals(fieldName) ) {
             return true;
        }
    }
    
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:JPAEditorUtil.java

示例11: BindViewIdField

public BindViewIdField(Element element) throws IllegalArgumentException {
    // 判断是否是成员变量
    if (element.getKind() != ElementKind.FIELD) {
        throw new IllegalArgumentException(String.format("Only field can be annotated with @%s", bindViewIdFieldClassName));
    }
    mVariableElement = (VariableElement) element;
    // 获取注解和id值
    BindViewId bindViewId = mVariableElement.getAnnotation(BindViewId.class);
    mResId = bindViewId.value();
    if (mResId < 0) {
        throw new IllegalArgumentException(String.format("value() in %s for field %s is not valid",
                bindViewIdFieldClassName, mVariableElement.getSimpleName()));
    }
}
 
开发者ID:wangzailfm,项目名称:ImitateButterKnife,代码行数:14,代码来源:BindViewIdField.java

示例12: checkAnnotationValid

private boolean checkAnnotationValid(Element element, Class clz) {
    if (element.getKind() != ElementKind.FIELD) {
        error(element, "%s must be declared on a field", clz.getSimpleName());
        return false;
    }

    if (element.getModifiers().contains(Modifier.PRIVATE)) {
        error(element, "%s must not be declared private", element.getSimpleName());
        return false;
    }

    return true;
}
 
开发者ID:hanhailong,项目名称:CompileAnnotationDemo,代码行数:13,代码来源:CIProcessor.java

示例13: tryResolveIdentifier

private static boolean tryResolveIdentifier(CompilationInfo info, TreePath place, 
        TypeMirror expectedType, Set<Element> resolved, String ident) {
    SourcePositions[] positions = new SourcePositions[1];
    ExpressionTree et = info.getTreeUtilities().parseExpression(ident, positions);
    TypeMirror unqType = info.getTreeUtilities().attributeTree(et, info.getTrees().getScope(place));
    Element e = info.getTrees().getElement(new TreePath(place, et));
    if (!Utilities.isValidType(unqType) || e == null || 
            (e.getKind() != ElementKind.FIELD && e.getKind() != ElementKind.ENUM_CONSTANT)) {
        return false;
    }
    if (!resolved.add(e)) {
        return false;
    }
    return info.getTypes().isAssignable(unqType, expectedType);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:Tiny.java

示例14: visitAssignment

@Override
public Void visitAssignment(AssignmentTree node, Void p) {
    exprBundleName = null;
    Void d = super.visitAssignment(node, p);
    if (exprBundleName != null) {
        Element dest = info.getTrees().getElement(getCurrentPath());
        if (dest != null && (dest.getKind() == ElementKind.LOCAL_VARIABLE || dest.getKind() == ElementKind.FIELD)) {
            variableBundles.put(dest, exprBundleName);
        }
    }
    return d;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ResourceStringFoldProvider.java

示例15: visitIdentifier

@Override
public Boolean visitIdentifier(IdentifierTree node, Element p) {
    Element current = info.getTrees().getElement(getCurrentPath());
    if (newName==null) {
        if (current !=null && current.equals(p)) {
            result = true;
        }
    } else if (current != null && current.getKind() == ElementKind.FIELD && node.getName().toString().equals(newName)) {
        result = true;
    }
    return super.visitIdentifier(node, p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:LocalVarScanner.java


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