本文整理汇总了Java中org.eclipse.jdt.core.dom.Name.getFullyQualifiedName方法的典型用法代码示例。如果您正苦于以下问题:Java Name.getFullyQualifiedName方法的具体用法?Java Name.getFullyQualifiedName怎么用?Java Name.getFullyQualifiedName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.Name
的用法示例。
在下文中一共展示了Name.getFullyQualifiedName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFullName
import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
/**
* Evaluates fully qualified name of the Name object.
*/
private static String getFullName(Name name) {
// check if the root node is a CompilationUnit
if (name.getRoot().getClass() != CompilationUnit.class) {
// cannot resolve a full name, CompilationUnit root node is missing
return name.getFullyQualifiedName();
}
// get the root node
CompilationUnit root = (CompilationUnit) name.getRoot();
// check if the name is declared in the same file
TypeDeclVisitor tdVisitor = new TypeDeclVisitor(name.getFullyQualifiedName());
root.accept(tdVisitor);
if (tdVisitor.getFound()) {
// the name is the use of the TypeDeclaration in the same file
return getFullName(tdVisitor.getTypeDecl());
}
// check if the name is declared in the same package or imported
PckgImprtVisitor piVisitor = new PckgImprtVisitor(name.getFullyQualifiedName());
root.accept(piVisitor);
if (piVisitor.getFound()) {
// the name is declared in the same package or imported
return piVisitor.getFullName();
}
// could be a class from the java.lang (String) or a param name (T, E,...)
return name.getFullyQualifiedName();
}
示例2: hasNullAnnotation
import org.eclipse.jdt.core.dom.Name; //导入方法依赖的package包/类
private static boolean hasNullAnnotation(MethodDeclaration decl) {
List<IExtendedModifier> modifiers = decl.modifiers();
String nonnull =
NullAnnotationsFix.getNonNullAnnotationName(decl.resolveBinding().getJavaElement(), false);
String nullable =
NullAnnotationsFix.getNullableAnnotationName(decl.resolveBinding().getJavaElement(), false);
for (Object mod : modifiers) {
if (mod instanceof Annotation) {
Name annotationName = ((Annotation) mod).getTypeName();
String fullyQualifiedName = annotationName.getFullyQualifiedName();
if (annotationName.isSimpleName()
? nonnull.endsWith(fullyQualifiedName)
: fullyQualifiedName.equals(nonnull)) return true;
if (annotationName.isSimpleName()
? nullable.endsWith(fullyQualifiedName)
: fullyQualifiedName.equals(nullable)) return true;
}
}
return false;
}