List of usage examples for org.eclipse.jdt.core.dom IPackageBinding getAnnotations
public IAnnotationBinding[] getAnnotations();
From source file:com.google.devtools.j2objc.util.NameTable.java
License:Open Source License
/** * Return the prefix for a specified package. If a prefix was specified * for the package, then that prefix is returned. Otherwise, a camel-cased * prefix is created from the package name. *//*from www .ja v a 2 s . co m*/ public String getPrefix(IPackageBinding packageBinding) { String packageName = packageBinding.getName(); if (hasPrefix(packageName)) { return prefixMap.get(packageName); } for (IAnnotationBinding annotation : packageBinding.getAnnotations()) { if (annotation.getName().endsWith("ObjectiveCName")) { String prefix = (String) BindingUtil.getAnnotationValue(annotation, "value"); prefixMap.put(packageName, prefix); // Don't return, as there may be a prefix annotation that overrides this value. } } String prefix = getPrefixFromPackageInfoSource(packageBinding); if (prefix == null) { prefix = getPrefixFromPackageInfoClass(packageName); } if (prefix == null) { prefix = camelCaseQualifiedName(packageName); } prefixMap.put(packageName, prefix); return prefix; }
From source file:com.google.devtools.j2objc.util.PackagePrefixes.java
License:Apache License
/** * Return the prefix for a specified package. If a prefix was specified * for the package, then that prefix is returned. Otherwise, a camel-cased * prefix is created from the package name. *///from w ww. jav a2 s . c o m public String getPrefix(IPackageBinding packageBinding) { if (packageBinding == null) { return ""; } String packageName = packageBinding.getName(); if (hasPrefix(packageName)) { return getPrefix(packageName); } for (IAnnotationBinding annotation : packageBinding.getAnnotations()) { if (annotation.getName().endsWith("ObjectiveCName")) { String prefix = (String) BindingUtil.getAnnotationValue(annotation, "value"); addPrefix(packageName, prefix); // Don't return, as there may be a prefix annotation that overrides this value. } } String prefix = getPrefixFromPackageInfoSource(packageName); if (prefix == null) { prefix = getPrefixFromPackageInfoClass(packageName); } if (prefix == null) { prefix = NameTable.camelCaseQualifiedName(packageName); } addPrefix(packageName, prefix); return prefix; }