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


Java TypeSymbol.getEnclosedElements方法代码示例

本文整理汇总了Java中com.sun.tools.javac.code.Symbol.TypeSymbol.getEnclosedElements方法的典型用法代码示例。如果您正苦于以下问题:Java TypeSymbol.getEnclosedElements方法的具体用法?Java TypeSymbol.getEnclosedElements怎么用?Java TypeSymbol.getEnclosedElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.tools.javac.code.Symbol.TypeSymbol的用法示例。


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

示例1: addMethodBindings

import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入方法依赖的package包/类
private void addMethodBindings(List<MethodSig> signatures, ClassType ct, JavacTypes types, Set<String> banList) {
	TypeSymbol tsym = ct.asElement();
	if (tsym == null) return;
	
	for (Symbol member : tsym.getEnclosedElements()) {
		if (member.getKind() != ElementKind.METHOD) continue;
		if (member.isStatic()) continue;
		if (member.isConstructor()) continue;
		ExecutableElement exElem = (ExecutableElement)member;
		if (!exElem.getModifiers().contains(Modifier.PUBLIC)) continue;
		ExecutableType methodType = (ExecutableType) types.asMemberOf(ct, member);
		String sig = printSig(methodType, member.name, types);
		if (!banList.add(sig)) continue; //If add returns false, it was already in there
		boolean isDeprecated = (member.flags() & DEPRECATED) != 0;
		signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem));
	}
	
	if (ct.supertype_field instanceof ClassType) addMethodBindings(signatures, (ClassType) ct.supertype_field, types, banList);
	if (ct.interfaces_field != null) for (Type iface : ct.interfaces_field) {
		if (iface instanceof ClassType) addMethodBindings(signatures, (ClassType) iface, types, banList);
	}
}
 
开发者ID:redundent,项目名称:lombok,代码行数:23,代码来源:HandleDelegate.java

示例2: addMethodBindings

import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入方法依赖的package包/类
public void addMethodBindings(List<MethodSig> signatures, ClassType ct, JavacTypes types, Set<String> banList) throws DelegateRecursion {
	TypeSymbol tsym = ct.asElement();
	if (tsym == null) return;
	
	for (Symbol member : tsym.getEnclosedElements()) {
		for (Compound am : member.getAnnotationMirrors()) {
			String name = null;
			try {
				name = am.type.tsym.flatName().toString();
			} catch (Exception ignore) {}
			
			if ("lombok.Delegate".equals(name) || "lombok.experimental.Delegate".equals(name)) {
				throw new DelegateRecursion(ct.tsym.name.toString(), member.name.toString());
			}
		}
		if (member.getKind() != ElementKind.METHOD) continue;
		if (member.isStatic()) continue;
		if (member.isConstructor()) continue;
		ExecutableElement exElem = (ExecutableElement)member;
		if (!exElem.getModifiers().contains(Modifier.PUBLIC)) continue;
		ExecutableType methodType = (ExecutableType) types.asMemberOf(ct, member);
		String sig = printSig(methodType, member.name, types);
		if (!banList.add(sig)) continue; //If add returns false, it was already in there
		boolean isDeprecated = (member.flags() & DEPRECATED) != 0;
		signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem));
	}
	
	if (ct.supertype_field instanceof ClassType) addMethodBindings(signatures, (ClassType) ct.supertype_field, types, banList);
	if (ct.interfaces_field != null) for (Type iface : ct.interfaces_field) {
		if (iface instanceof ClassType) addMethodBindings(signatures, (ClassType) iface, types, banList);
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:33,代码来源:HandleDelegate.java

示例3: getExtension

import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入方法依赖的package包/类
public Extension getExtension(final JavacNode typeNode, final ClassType extensionMethodProviderType) {
	List<MethodSymbol> extensionMethods = new ArrayList<MethodSymbol>();
	TypeSymbol tsym = extensionMethodProviderType.asElement();
	if (tsym != null) for (Symbol member : tsym.getEnclosedElements()) {
		if (member.getKind() != ElementKind.METHOD) continue;
		MethodSymbol method = (MethodSymbol) member;
		if ((method.flags() & (STATIC | PUBLIC)) == 0) continue;
		if (method.params().isEmpty()) continue;
		extensionMethods.add(method);
	}
	return new Extension(extensionMethods, tsym);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:13,代码来源:HandleExtensionMethod.java

示例4: getExtension

import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入方法依赖的package包/类
private Extension getExtension(final JavacNode typeNode, final ClassType extensionMethodProviderType) {
	List<MethodSymbol> extensionMethods = new ArrayList<MethodSymbol>();
	TypeSymbol tsym = extensionMethodProviderType.asElement();
	if (tsym != null) for (Symbol member : tsym.getEnclosedElements()) {
		if (member.getKind() != ElementKind.METHOD) continue;
		MethodSymbol method = (MethodSymbol) member;
		if ((method.flags() & STATIC) == 0) continue;
		if ((method.flags() & PUBLIC) == 0) continue;
		if (method.params().isEmpty()) continue;
		extensionMethods.add(method);
	}
	return new Extension(extensionMethods, tsym);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:14,代码来源:HandleExtensionMethod.java

示例5: matchClass

import com.sun.tools.javac.code.Symbol.TypeSymbol; //导入方法依赖的package包/类
@Override
public Description matchClass(ClassTree classTree, VisitorState visitorState) {
  List<VariableTree> originalClassMembers =
      classTree
          .getMembers()
          .stream()
          .filter(mem -> mem instanceof VariableTree)
          .map(mem -> (VariableTree) mem)
          .filter(
              mem ->
                  !isSuppressed(ASTHelpers.getSymbol(mem))
                      && !isIgnoredType(mem)
                      && !isStatic(mem))
          .collect(toCollection(ArrayList::new));

  ClassSymbol classSymbol = ASTHelpers.getSymbol(classTree);

  while (!Objects.equals(classSymbol.getSuperclass(), Type.noType)) {
    TypeSymbol parentSymbol = classSymbol.getSuperclass().asElement();
    List<Symbol> parentElements = parentSymbol.getEnclosedElements();

    Map<Name, VarSymbol> parentMembers =
        parentElements
            .stream()
            .filter(mem -> (mem instanceof VarSymbol))
            .map(mem -> (VarSymbol) mem)
            .filter(mem -> (!mem.isPrivate() && !mem.getModifiers().contains(Modifier.STATIC)))
            .collect(Collectors.toMap(Symbol::getSimpleName, mem -> mem));

    checkForHiddenFields(
        originalClassMembers,
        parentMembers,
        parentSymbol.getSimpleName(),
        classTree,
        visitorState);

    classSymbol = (ClassSymbol) parentSymbol;
  }

  return Description.NO_MATCH;
}
 
开发者ID:google,项目名称:error-prone,代码行数:42,代码来源:HidingField.java


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