本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.getBinaryName方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.getBinaryName方法的具體用法?Java ITypeBinding.getBinaryName怎麽用?Java ITypeBinding.getBinaryName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.getBinaryName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSimpleName
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static String getSimpleName(ITypeBinding itb) {
if (itb.isNested()) {
if (itb.isAnonymous()) {
String binname = itb.getBinaryName();
int index = binname.indexOf('$');
String name = binname.substring(index + 1, binname.length());
return getSimpleName(itb.getDeclaringClass()) + "#" + name;
} else {
return getSimpleName(itb.getDeclaringClass()) + "#"
+ itb.getName();
}
} else {
return itb.getName();
}
}
示例2: getClassfile
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static IFile getClassfile(ITypeBinding typeBinding) throws CoreException {
// bug 191943
IType type = (IType) typeBinding.getJavaElement();
if (type == null || type.getCompilationUnit() == null || type.getJavaProject() == null || ProjectsManager.DEFAULT_PROJECT_NAME.equals(type.getJavaProject().getProject().getName())) {
return null;
}
IRegion region = JavaCore.newRegion();
region.add(type.getCompilationUnit());
String name = typeBinding.getBinaryName();
if (name != null) {
int packStart = name.lastIndexOf('.');
if (packStart != -1) {
name = name.substring(packStart + 1);
}
} else {
throw new CoreException(new Status(IStatus.ERROR, JavaLanguageServerPlugin.PLUGIN_ID, CorrectionMessages.SerialVersionHashOperation_error_classnotfound));
}
name += ".class"; //$NON-NLS-1$
IResource[] classFiles = JavaCore.getGeneratedResources(region, false);
for (int i = 0; i < classFiles.length; i++) {
IResource resource = classFiles[i];
if (resource.getType() == IResource.FILE && resource.getName().equals(name) && resource.exists()) {
try (InputStream contents = ((IFile) resource).getContents()) {
} catch (Exception e) {
continue;
}
return (IFile) resource;
}
}
return null;
// throw new CoreException(new Status(IStatus.ERROR, JavaLanguageServerPlugin.PLUGIN_ID, CorrectionMessages.SerialVersionHashOperation_error_classnotfound));
}