當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassOrInterfaceDeclaration.getExtendedTypes方法代碼示例

本文整理匯總了Java中com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.getExtendedTypes方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassOrInterfaceDeclaration.getExtendedTypes方法的具體用法?Java ClassOrInterfaceDeclaration.getExtendedTypes怎麽用?Java ClassOrInterfaceDeclaration.getExtendedTypes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.javaparser.ast.body.ClassOrInterfaceDeclaration的用法示例。


在下文中一共展示了ClassOrInterfaceDeclaration.getExtendedTypes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getTypeName

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
protected String getTypeName(CompilationUnit compilationUnit, int index) {
    ClassOrInterfaceDeclaration type = (ClassOrInterfaceDeclaration) compilationUnit.getType(0);
    NodeList<ClassOrInterfaceType> extendedTypes = type.getExtendedTypes();
    ClassOrInterfaceType extendedType = extendedTypes.get(index);
    String typeSimpleName = extendedType.getName().getIdentifier();
    Optional<ClassOrInterfaceType> scope = extendedType.getScope();
    String typeName;
    if (scope.isPresent()) {
        String typePackageName = scope.get().toString();
        typeName = String.format("%s.%s", typePackageName, typeSimpleName);
    } else {
        typeName = typeSimpleName;
    }
    return typeName;
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:17,代碼來源:Extends.java

示例2: calculate

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
public void calculate(ClassOrInterfaceDeclaration classOrInterfaceDeclaration, CompilationUnit compilationUnit) {
    List<ClassOrInterfaceType> extendedTypes = classOrInterfaceDeclaration.getExtendedTypes();
    for (ClassOrInterfaceType extendedType : extendedTypes) {
        String extendedTypeName = extendedType.getNameAsString();
        String extendedTypePackageName = extendedType
                .findCompilationUnit()
                .flatMap(CompilationUnit::getPackageDeclaration)
                .flatMap(pkg -> Optional.of(pkg.getNameAsString())).orElse("???");

        if (typeDao.exist(extendedTypeName, extendedTypePackageName)) { // JDK interfaces are not indexed
            int extendedInterfaceId = typeDao.getId(extendedTypeName, extendedTypePackageName);
            int interfaceId = typeDao.getId(classOrInterfaceDeclaration.getNameAsString(), compilationUnit.getPackageDeclaration().get().getNameAsString());
            extendsDao.save(new Extends(interfaceId, extendedInterfaceId));
        }
    }
}
 
開發者ID:benas,項目名稱:jql,代碼行數:17,代碼來源:ExtendsRelationCalculator.java

示例3: getNumberOfTypes

import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration; //導入方法依賴的package包/類
@Override
protected int getNumberOfTypes(CompilationUnit compilationUnit) {
    TypeDeclaration<?> typeDeclaration = compilationUnit.getType(0);
    if (typeDeclaration instanceof ClassOrInterfaceDeclaration) {
        ClassOrInterfaceDeclaration type = (ClassOrInterfaceDeclaration) compilationUnit.getType(0);
        NodeList<ClassOrInterfaceType> extendedTypes = type.getExtendedTypes();
        return extendedTypes.size();
    }

    // If typeDeclaration is not ClassOrInterfaceDeclaration, then it is
    // EnumDeclaration or AnnotationDeclaration, and none of them have
    // a getExtendedTypes operation

    return 0;
}
 
開發者ID:paypal,項目名稱:butterfly,代碼行數:16,代碼來源:Extends.java


注:本文中的com.github.javaparser.ast.body.ClassOrInterfaceDeclaration.getExtendedTypes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。