本文整理汇总了Java中org.eclipse.jdt.internal.core.util.Util.localTypeName方法的典型用法代码示例。如果您正苦于以下问题:Java Util.localTypeName方法的具体用法?Java Util.localTypeName怎么用?Java Util.localTypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.core.util.Util
的用法示例。
在下文中一共展示了Util.localTypeName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeName
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
public String getTypeName() {
// Internal class file name doesn't contain ".class" file extension
int lastDollar = this.name.lastIndexOf('$');
return lastDollar > -1 ? Util.localTypeName(this.name, lastDollar, this.name.length()) : this.name;
}
示例2: getDeclaringType
import org.eclipse.jdt.internal.core.util.Util; //导入方法依赖的package包/类
public IType getDeclaringType() {
IClassFile classFile = getClassFile();
if (classFile.isOpen()) {
try {
char[] enclosingTypeName = ((IBinaryType) getElementInfo()).getEnclosingTypeName();
if (enclosingTypeName == null) {
return null;
}
enclosingTypeName = ClassFile.unqualifiedName(enclosingTypeName);
// workaround problem with class files compiled with javac 1.1.*
// that return a non-null enclosing type name for local types defined in anonymous (e.g. A$1$B)
if (classFile.getElementName().length() > enclosingTypeName.length+1
&& Character.isDigit(classFile.getElementName().charAt(enclosingTypeName.length+1))) {
return null;
}
return getPackageFragment().getClassFile(new String(enclosingTypeName) + SUFFIX_STRING_class).getType();
} catch (JavaModelException npe) {
return null;
}
} else {
// cannot access .class file without opening it
// and getDeclaringType() is supposed to be a handle-only method,
// so default to assuming $ is an enclosing type separator
String classFileName = classFile.getElementName();
int lastDollar = -1;
for (int i = 0, length = classFileName.length(); i < length; i++) {
char c = classFileName.charAt(i);
if (Character.isDigit(c) && lastDollar == i-1) {
// anonymous or local type
return null;
} else if (c == '$') {
lastDollar = i;
}
}
if (lastDollar == -1) {
return null;
} else {
String enclosingName = classFileName.substring(0, lastDollar);
String enclosingClassFileName = enclosingName + SUFFIX_STRING_class;
return
new BinaryType(
(JavaElement)getPackageFragment().getClassFile(enclosingClassFileName),
Util.localTypeName(enclosingName, enclosingName.lastIndexOf('$'), enclosingName.length()));
}
}
}