本文整理匯總了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;
}
示例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));
}
}
}
示例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;
}