當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。