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


Java TypeDeclaration.getSuperclassType方法代码示例

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


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

示例1: getAllSuperTypes

import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
public List getAllSuperTypes(TypeDeclaration typeDeclaration) {
	List list = new ArrayList();

	Type superclassType = typeDeclaration.getSuperclassType();
	if (superclassType != null) {
		list.add(superclassType);
	}

	List superInterfaceTypes = typeDeclaration.superInterfaceTypes();

	for (Iterator itSuperInterfacesIterator = superInterfaceTypes.iterator(); itSuperInterfacesIterator.hasNext();) {
		Object next = itSuperInterfacesIterator.next();
		if (next instanceof SimpleType) {
			list.add(next);
		}
	}
	return list;
}
 
开发者ID:aroog,项目名称:code,代码行数:19,代码来源:SaveAnnotations.java

示例2: hasConstructor

import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
public static boolean hasConstructor(TypeDeclaration typeDecl, Map<ast.Type, TypeDeclaration> types,
		QualifiedClassName cThis) {
	boolean hasConstr = false;
	if (!hasFieldInitializers(typeDecl))
		hasConstr = true;
	else {
		for (MethodDeclaration md : typeDecl.getMethods()) {
			if (md.isConstructor())
				hasConstr = true;
		}
	}
	Type superclassType = typeDecl.getSuperclassType();
	if (superclassType == null)
		return hasConstr;
	if (superclassType.resolveBinding().getQualifiedName().equals(Utils.JAVA_LANG_OBJECT))
		return hasConstr;
	TypeDeclaration superTypeDecl = types.get(new QualifiedClassName(superclassType.resolveBinding(), cThis)
			.getType());
	if (superTypeDecl != null) {
		hasConstr = hasConstr && hasConstructor(superTypeDecl, types, cThis);
	}
	return hasConstr;

}
 
开发者ID:aroog,项目名称:code,代码行数:25,代码来源:AuxJudgements.java

示例3: mBody

import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
/**
 * returns all method declarations in a type, and its supertype recursively.
 * call MethodDeclaration.getBody() to get the body of the method. TODO:
 * actual/formal substitution
 * */
public static Set<MethodDeclaration> mBody(TypeDeclaration typeDecl, TypeHierarchy hierarchy,
		Map<ast.Type, TypeDeclaration> types, QualifiedClassName cThis) {
	Set<MethodDeclaration> returnSet = new HashSet<MethodDeclaration>();
	for (MethodDeclaration md : typeDecl.getMethods()) {
		returnSet.add(md);
	}
	Type superclassType = typeDecl.getSuperclassType();
	if (superclassType == null)
		return returnSet;
	if (superclassType.resolveBinding().getQualifiedName().equals(Utils.JAVA_LANG_OBJECT))
		return returnSet;

	TypeDeclaration superTypeDecl = types.get(new QualifiedClassName(superclassType.resolveBinding(), cThis)
			.getType());
	if (superTypeDecl != null) {
		Set<MethodDeclaration> auxSet = mBody(superTypeDecl, hierarchy, types, cThis);
		returnSet.addAll(auxSet);
		// TODO: here you don't want to add OverrideMethod
		// TODO: find a way to uniquely identify methods: define mtype.
	}
	return returnSet;
}
 
开发者ID:aroog,项目名称:code,代码行数:28,代码来源:AuxJudgements.java

示例4: fieldBody

import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
/**
 * returns all field bodies declared in a type, and its supertype,
 * recursively TODO: actual/formal substitution
 * */
public static Set<FieldDeclaration> fieldBody(TypeDeclaration typeDecl, TypeHierarchy hierarchy,
		Map<ast.Type, TypeDeclaration> types, QualifiedClassName cThis) {
	Set<FieldDeclaration> returnSet = new HashSet<FieldDeclaration>();
	for (FieldDeclaration fd : typeDecl.getFields())
		returnSet.add(fd);
	Type superclassType = typeDecl.getSuperclassType();
	if (superclassType == null)
		return returnSet;
	if (superclassType.resolveBinding().getQualifiedName().equals(Utils.JAVA_LANG_OBJECT))
		return returnSet;

	TypeDeclaration superTypeDecl = types.get(new QualifiedClassName(superclassType.resolveBinding(), cThis)
			.getType());
	if (superTypeDecl != null) {
		Set<FieldDeclaration> auxSet = fieldBody(superTypeDecl, hierarchy, types, cThis);
		returnSet.addAll(auxSet);
	}
	return returnSet;
}
 
开发者ID:aroog,项目名称:code,代码行数:24,代码来源:AuxJudgements.java

示例5: visit

import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
public boolean visit(TypeDeclaration typeDeclaration) {
    List<Type> supertypes = new ArrayList<Type>();
    Type superclass = typeDeclaration.getSuperclassType();
    if (superclass != null) {
        supertypes.add(superclass);
    }
    supertypes.addAll(typeDeclaration.superInterfaceTypes());
    RastNode sdType = visitTypeDeclaration(typeDeclaration, supertypes, typeDeclaration.isInterface() ? NodeTypes.INTERFACE_DECLARATION : NodeTypes.CLASS_DECLARATION);
    containerStack.push(sdType);
    if (typeDeclaration.isInterface()) {
    	sdType.addStereotypes(Stereotype.ABSTRACT);
    }
    return true;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:15,代码来源:BindingsRecoveryAstVisitor.java

示例6: visit

import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
public boolean visit(TypeDeclaration typeDeclaration) {
    List<Type> supertypes = new ArrayList<Type>();
    Type superclass = typeDeclaration.getSuperclassType();
    if (superclass != null) {
        supertypes.add(superclass);
    }
    supertypes.addAll(typeDeclaration.superInterfaceTypes());
    SDType sdType = visitTypeDeclaration(typeDeclaration, supertypes);
    containerStack.push(sdType);
    sdType.setIsInterface(typeDeclaration.isInterface());
    return true;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:13,代码来源:BindingsRecoveryAstVisitor.java

示例7: visitClass

import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
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;
    }
 
开发者ID:linzeqipku,项目名称:SnowGraph,代码行数:32,代码来源:JavaASTVisitor.java

示例8: parse

import org.eclipse.jdt.core.dom.TypeDeclaration; //导入方法依赖的package包/类
public static ClassBean parse(TypeDeclaration pClassNode) {
    int numberOfGetterOrSetter = 0;

    // Instantiate the bean
    ClassBean classBean = new ClassBean();

    if (pClassNode.getSuperclassType() != null) {
        classBean.setSuperclass(pClassNode.getSuperclassType().toString());
    } else {
        classBean.setSuperclass(null);
    }

    // Set the name
    classBean.setName(pClassNode.getName().toString());

    // Get the instance variable nodes 
    Collection<FieldDeclaration> instanceVariableNodes = new ArrayList<>();
    pClassNode.accept(new InstanceVariableVisitor(instanceVariableNodes));

    classBean.setTextContent(pClassNode.toString());

    Pattern newLine = Pattern.compile("\n");
    String[] lines = newLine.split(pClassNode.toString());

    classBean.setLOC(lines.length);

    // Get the instance variable beans from the instance variable nodes
    Collection<InstanceVariableBean> instanceVariableBeans = new ArrayList<>();
    for (FieldDeclaration instanceVariableNode : instanceVariableNodes) {
        instanceVariableBeans.add(InstanceVariableParser.parse(instanceVariableNode));
    }

    // Set the collection of instance variables
    classBean.setInstanceVariables(instanceVariableBeans);

    // Get the method nodes
    Collection<MethodDeclaration> methodNodes = new ArrayList<>();
    pClassNode.accept(new MethodVisitor(methodNodes));

    // Get the method beans from the method nodes
    Collection<MethodBean> methodBeans = new ArrayList<>();
    for (MethodDeclaration methodNode : methodNodes) {

        if ((methodNode.getName().toString().contains("get") || (methodNode.getName().toString().contains("set")))) {
            if (methodNode.parameters().isEmpty()) {
                numberOfGetterOrSetter++;
            }
        }

        methodBeans.add(MethodParser.parse(methodNode, instanceVariableBeans));
    }

    classBean.setNumberOfGetterAndSetter(numberOfGetterOrSetter);

    // Iterate over the collection of methods
    for (MethodBean classMethod : methodBeans) {

        // Instantiate a collection of class-defined invocations
        Collection<MethodBean> definedInvocations = new ArrayList<>();

        // Get the method invocations
        Collection<MethodBean> classMethodInvocations = classMethod.getMethodCalls();

        // Iterate over the collection of method invocations
        for (MethodBean classMethodInvocation : classMethodInvocations) {
            definedInvocations.add(classMethodInvocation);
        }

        // Set the class-defined invocations
        classMethod.setMethodCalls(definedInvocations);
    }

    // Set the collection of methods
    classBean.setMethods(methodBeans);

    return classBean;

}
 
开发者ID:fpalomba,项目名称:aDoctor,代码行数:79,代码来源:ClassParser.java


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