org.eclipse.jdt.core.dom.TypeDeclaration#superInterfaceTypes ( )源码实例Demo

下面列出了org.eclipse.jdt.core.dom.TypeDeclaration#superInterfaceTypes ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@SuppressWarnings("unchecked")
private static ITypeBinding getOwnerTypeBinding(
    TypeDeclaration uiBinderSubtype) {
  List<Type> superInterfaces = uiBinderSubtype.superInterfaceTypes();
  for (Type superInterface : superInterfaces) {
    ITypeBinding binding = superInterface.resolveBinding();
    if (binding != null) {
      if (binding.getErasure().getQualifiedName().equals(
          UiBinderConstants.UI_BINDER_TYPE_NAME)) {
        if (superInterface instanceof ParameterizedType) {
          ParameterizedType uiBinderType = (ParameterizedType) superInterface;
          List<Type> typeArgs = uiBinderType.typeArguments();
          if (typeArgs.size() == 2) {
            Type ownerType = typeArgs.get(1);
            return ownerType.resolveBinding();
          }
        }
      }
    }
  }
  return null;
}
 
源代码2 项目: SimFix   文件: TypeParseVisitor.java
public boolean visit(TypeDeclaration node) {
	Pair<String, String> clazzAndMethodName = NodeUtils.getTypeDecAndMethodDec(node.getName());
	String clazz = clazzAndMethodName.getFirst();
	AST ast = AST.newAST(AST.JLS8);
	Type type = ast.newSimpleType(ast.newSimpleName(clazz));
	ProjectInfo.addFieldType(clazz, "THIS", type);
	Type suType = node.getSuperclassType();
	if(suType != null){
		ProjectInfo.addFieldType(clazz, "SUPER", suType);
		ProjectInfo.addSuperClass(clazz, suType.toString());
	}
	
	List<Object> sInterfaces = node.superInterfaceTypes();
	if(sInterfaces != null){
		for(Object object : sInterfaces){
			if(object instanceof Type){
				Type interfaceType = (Type) object;
				ProjectInfo.addSuperInterface(clazz, interfaceType.toString());
			}
		}
	}
	
	FieldDeclaration fields[] = node.getFields();
	for (FieldDeclaration f : fields) {
		for (Object o : f.fragments()) {
			VariableDeclarationFragment vdf = (VariableDeclarationFragment) o;
			Type tmpType = f.getType();
			if(vdf.getExtraDimensions() > 0){
				tmpType = ast.newArrayType((Type) ASTNode.copySubtree(ast, tmpType), vdf.getExtraDimensions());
			}
			ProjectInfo.addFieldType(clazz, vdf.getName().toString(), tmpType);
		}
	}
	return true;
}
 
源代码3 项目: SnowGraph   文件: JavaASTVisitor.java
private boolean visitInterface(TypeDeclaration node) {

        InterfaceInfo interfaceInfo = new InterfaceInfo();
        interfaceInfo.name = node.getName().getFullyQualifiedName();
        interfaceInfo.fullName = NameResolver.getFullName(node);
        interfaceInfo.visibility = getVisibility(node);
        List<Type> superInterfaceList = node.superInterfaceTypes();
        for (Type superInterface : superInterfaceList)
            interfaceInfo.superInterfaceTypeList.add(NameResolver.getFullName(superInterface));
        if (node.getJavadoc() != null)
            interfaceInfo.comment = sourceContent.substring(node.getJavadoc().getStartPosition(), node.getJavadoc().getStartPosition() + node.getJavadoc().getLength());
        interfaceInfo.content = sourceContent.substring(node.getStartPosition(), node.getStartPosition() + node.getLength());
        elementInfoPool.interfaceInfoMap.put(interfaceInfo.fullName, interfaceInfo);

        MethodDeclaration[] methodDeclarations = node.getMethods();
        for (MethodDeclaration methodDeclaration : methodDeclarations) {
            MethodInfo methodInfo = createMethodInfo(methodDeclaration, interfaceInfo.fullName);
            elementInfoPool.methodInfoMap.put(methodInfo.hashName(), methodInfo);
        }

        FieldDeclaration[] fieldDeclarations = node.getFields();
        for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
            List<FieldInfo> fieldInfos = createFieldInfos(fieldDeclaration, interfaceInfo.fullName);
            for (FieldInfo fieldInfo : fieldInfos)
                elementInfoPool.fieldInfoMap.put(fieldInfo.hashName(), fieldInfo);
        }
        return true;
    }
 
源代码4 项目: SnowGraph   文件: JavaASTVisitor.java
private boolean visitClass(TypeDeclaration node) {

        ClassInfo classInfo = new ClassInfo();
        classInfo.name = node.getName().getFullyQualifiedName();
        classInfo.fullName = NameResolver.getFullName(node);
        classInfo.visibility = getVisibility(node);
        classInfo.isAbstract = isAbstract(node);
        classInfo.isFinal = isFinal(node);
        classInfo.superClassType = node.getSuperclassType() == null ? "java.lang.Object" : NameResolver.getFullName(node.getSuperclassType());
        List<Type> superInterfaceList = node.superInterfaceTypes();
        for (Type superInterface : superInterfaceList)
            classInfo.superInterfaceTypeList.add(NameResolver.getFullName(superInterface));
        if (node.getJavadoc() != null)
            classInfo.comment = sourceContent.substring(node.getJavadoc().getStartPosition(), node.getJavadoc().getStartPosition() + node.getJavadoc().getLength());
        classInfo.content = sourceContent.substring(node.getStartPosition(), node.getStartPosition() + node.getLength());
        elementInfoPool.classInfoMap.put(classInfo.fullName, classInfo);

        MethodDeclaration[] methodDeclarations = node.getMethods();
        for (MethodDeclaration methodDeclaration : methodDeclarations) {
            MethodInfo methodInfo = createMethodInfo(methodDeclaration, classInfo.fullName);
            elementInfoPool.methodInfoMap.put(methodInfo.hashName(), methodInfo);
        }

        FieldDeclaration[] fieldDeclarations = node.getFields();
        for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
            List<FieldInfo> fieldInfos = createFieldInfos(fieldDeclaration, classInfo.fullName);
            for (FieldInfo fieldInfo : fieldInfos)
                elementInfoPool.fieldInfoMap.put(fieldInfo.hashName(), fieldInfo);
        }
        return true;
    }
 
源代码5 项目: api-mining   文件: JavaTypeHierarchyExtractor.java
@Override
public boolean visit(final TypeDeclaration node) {
	for (final Object supType : node.superInterfaceTypes()) {
		Type superType = (Type) supType;
		if (superType.isParameterizedType()) {
			superType = ((ParameterizedType) superType).getType();
		}
		final String qName = superType.resolveBinding().getErasure()
				.getQualifiedName();
		if (className.isEmpty()) {
			addTypes(qName, currentPackageName + "." + node.getName());
		} else {
			addTypes(qName, className.peek() + "." + node.getName());
		}
	}

	Type superclassType = node.getSuperclassType();
	if (superclassType != null) {
		if (superclassType.isParameterizedType()) {
			superclassType = ((ParameterizedType) superclassType)
					.getType();
		}
		addTypes(superclassType.resolveBinding().getQualifiedName(),
				currentPackageName + "." + node.getName());
	}

	if (className.isEmpty()) {
		className.push(currentPackageName + "."
				+ node.getName().getIdentifier());
		importedNames.put(node.getName().getIdentifier(),
				currentPackageName + "."
						+ node.getName().getIdentifier());
	} else {
		className.push(className.peek() + "."
				+ node.getName().getIdentifier());
		importedNames
				.put(node.getName().getIdentifier(), className.peek()
						+ "." + node.getName().getIdentifier());
	}
	return true;
}
 
源代码6 项目: tassal   文件: JavaTypeHierarchyExtractor.java
@Override
public boolean visit(final TypeDeclaration node) {
	for (final Object supType : node.superInterfaceTypes()) {
		Type superType = (Type) supType;
		if (superType.isParameterizedType()) {
			superType = ((ParameterizedType) superType).getType();
		}
		final String qName = superType.resolveBinding().getErasure()
				.getQualifiedName();
		if (className.isEmpty()) {
			addTypes(qName, currentPackageName + "." + node.getName());
		} else {
			addTypes(qName, className.peek() + "." + node.getName());
		}
	}

	Type superclassType = node.getSuperclassType();
	if (superclassType != null) {
		if (superclassType.isParameterizedType()) {
			superclassType = ((ParameterizedType) superclassType)
					.getType();
		}
		addTypes(superclassType.resolveBinding().getQualifiedName(),
				currentPackageName + "." + node.getName());
	}

	if (className.isEmpty()) {
		className.push(currentPackageName + "."
				+ node.getName().getIdentifier());
		importedNames.put(node.getName().getIdentifier(),
				currentPackageName + "."
						+ node.getName().getIdentifier());
	} else {
		className.push(className.peek() + "."
				+ node.getName().getIdentifier());
		importedNames
				.put(node.getName().getIdentifier(), className.peek()
						+ "." + node.getName().getIdentifier());
	}
	return true;
}
 
@Override
public boolean visit(final TypeDeclaration node) {
	for (final Object supType : node.superInterfaceTypes()) {
		Type superType = (Type) supType;
		if (superType.isParameterizedType()) {
			superType = ((ParameterizedType) superType).getType();
		}
		final String qName = superType.resolveBinding().getErasure()
				.getQualifiedName();
		if (className.isEmpty()) {
			addTypes(qName, currentPackageName + "." + node.getName());
		} else {
			addTypes(qName, className.peek() + "." + node.getName());
		}
	}

	Type superclassType = node.getSuperclassType();
	if (superclassType != null) {
		if (superclassType.isParameterizedType()) {
			superclassType = ((ParameterizedType) superclassType)
					.getType();
		}
		addTypes(superclassType.resolveBinding().getQualifiedName(),
				currentPackageName + "." + node.getName());
	}

	if (className.isEmpty()) {
		className.push(currentPackageName + "."
				+ node.getName().getIdentifier());
		importedNames.put(node.getName().getIdentifier(),
				currentPackageName + "."
						+ node.getName().getIdentifier());
	} else {
		className.push(className.peek() + "."
				+ node.getName().getIdentifier());
		importedNames
				.put(node.getName().getIdentifier(), className.peek()
						+ "." + node.getName().getIdentifier());
	}
	return true;
}