本文整理汇总了Java中org.eclipse.jdt.core.dom.IPackageBinding类的典型用法代码示例。如果您正苦于以下问题:Java IPackageBinding类的具体用法?Java IPackageBinding怎么用?Java IPackageBinding使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IPackageBinding类属于org.eclipse.jdt.core.dom包,在下文中一共展示了IPackageBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findModelNameInTopPackage
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
/**
* @return an empty optional if the given package binding is not the top
* package of a JtxtUML model; otherwise an optional of the name of
* the model (the name is the name of the package if not specified)
*/
public static Optional<String> findModelNameInTopPackage(IPackageBinding packageBinding) {
List<IAnnotationBinding> annots = Stream.of(packageBinding.getAnnotations())
.filter(a -> a.getAnnotationType().getQualifiedName().equals(Model.class.getCanonicalName()))
.collect(Collectors.toList());
if (annots.size() == 1) {
Optional<String> name = Stream.of(annots.get(0).getDeclaredMemberValuePairs())
.filter(p -> p.getName().equals("value")).map(p -> (String) p.getValue()).findAny();
if (name.isPresent()) {
return name;
} else {
return Optional.of(packageBinding.getName());
}
}
return Optional.empty();
}
示例2: findUnimplementedInterfaceMethods
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
private static void findUnimplementedInterfaceMethods(ITypeBinding typeBinding, HashSet<ITypeBinding> visited, ArrayList<IMethodBinding> allMethods, IPackageBinding currPack, ArrayList<IMethodBinding> toImplement) {
if (visited.add(typeBinding)) {
IMethodBinding[] typeMethods= typeBinding.getDeclaredMethods();
for (int i= 0; i < typeMethods.length; i++) {
IMethodBinding curr= typeMethods[i];
IMethodBinding impl= findMethodBinding(curr, allMethods);
if (impl == null || !Bindings.isVisibleInHierarchy(impl, currPack)) {
if (impl != null)
allMethods.remove(impl);
toImplement.add(curr);
allMethods.add(curr);
}
}
ITypeBinding[] superInterfaces= typeBinding.getInterfaces();
for (int i= 0; i < superInterfaces.length; i++)
findUnimplementedInterfaceMethods(superInterfaces[i], visited, allMethods, currPack, toImplement);
}
}
示例3: getBinding
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
private Binding getBinding(final IBinding binding) {
Binding result = null;
if (binding instanceof IMethodBinding) {
result = getMethodBinding((IMethodBinding) binding);
} else if (binding instanceof ITypeBinding) {
result = getClassBinding((ITypeBinding) binding, false);
} else if (binding instanceof IPackageBinding) {
result = getPackageBinding((IPackageBinding) binding);
} else if (binding instanceof IVariableBinding && ((IVariableBinding) binding).isField()) {
result = getFieldBinding((IVariableBinding) binding);
} else if (binding instanceof IVariableBinding && !((IVariableBinding) binding).isField()) {
result = getVariableBinding((IVariableBinding) binding);
}
return result;
}
示例4: isVisibleInHierarchy
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
public static boolean isVisibleInHierarchy(IMethodBinding member, IPackageBinding pack) {
int otherflags= member.getModifiers();
ITypeBinding declaringType= member.getDeclaringClass();
if (Modifier.isPublic(otherflags) || Modifier.isProtected(otherflags) || (declaringType != null && declaringType.isInterface())) {
return true;
} else if (Modifier.isPrivate(otherflags)) {
return false;
}
return declaringType != null && pack == declaringType.getPackage();
}
示例5: GeneratedTypeBinding
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
public GeneratedTypeBinding(
String name, IPackageBinding packageBinding, ITypeBinding superClass, boolean isInterface,
ITypeBinding componentType, ITypeBinding declaringClass) {
this.name = name;
this.packageBinding = packageBinding;
this.superClass = superClass;
this.isInterface = isInterface;
this.componentType = componentType;
this.declaringClass = declaringClass;
}
示例6: newTypeBinding
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
/**
* Creates a new non-array type, extracting the package from the provided name.
*/
public static GeneratedTypeBinding newTypeBinding(
String name, ITypeBinding superClass, boolean isInterface) {
int idx = name.lastIndexOf('.');
IPackageBinding packageBinding = null;
if (idx >= 0) {
packageBinding = new GeneratedPackageBinding(name.substring(0, idx));
name = name.substring(idx + 1);
}
return new GeneratedTypeBinding(name, packageBinding, superClass, isInterface, null);
}
示例7: getFullNameInner
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
private static String getFullNameInner(ITypeBinding binding) {
binding = Types.mapType(binding.getErasure()); // Make sure type variables aren't included.
ITypeBinding outerBinding = binding.getDeclaringClass();
if (binding.isLocal() && !binding.isAnonymous()) {
String binaryName = binding.getBinaryName();
int innerClassIndex = binaryName.lastIndexOf(binding.getName());
while (innerClassIndex > 0 && binaryName.charAt(innerClassIndex - 1) != '$') {
--innerClassIndex;
}
return getFullNameInner(outerBinding) + '_' + binaryName.substring(innerClassIndex);
}
if (outerBinding != null) {
String baseName = getFullNameInner(outerBinding) + '_' + getName(binding);
return (outerBinding.isEnum() && binding.isAnonymous()) ? baseName : baseName;
}
String name = binding.getQualifiedName();
// Use ObjectiveCType annotation, if it exists.
IAnnotationBinding annotation = BindingUtil.getAnnotation(binding, ObjectiveCName.class);
if (annotation != null) {
return (String) BindingUtil.getAnnotationValue(annotation, "value");
}
// Use mapping file entry, if it exists.
if (Options.getClassMappings().containsKey(name)) {
return Options.getClassMappings().get(name);
}
// Annotation-based mapping
String annoName = BindingUtil.extractMappingName(binding);
if (annoName != null) {
return annoName;
}
// Use camel-cased package+class name.
IPackageBinding pkg = binding.getPackage();
String pkgName = pkg != null ? getPrefix(pkg) : "";
return pkgName + binding.getName();
}
示例8: isVisibleInHierarchy
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
public static boolean isVisibleInHierarchy(IMethodBinding member, IPackageBinding pack) {
int otherflags = member.getModifiers();
ITypeBinding declaringType = member.getDeclaringClass();
if (Modifier.isPublic(otherflags)
|| Modifier.isProtected(otherflags)
|| (declaringType != null && declaringType.isInterface())) {
return true;
} else if (Modifier.isPrivate(otherflags)) {
return false;
}
return declaringType != null && pack == declaringType.getPackage();
}
示例9: getPackageBinding
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
private static IPackageBinding getPackageBinding(CompilationUnit cu) {
try {
return cu.getPackage().resolveBinding();
} catch (NullPointerException e) {
return null;
}
}
示例10: getModelOf
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
@Override
public ModelId getModelOf(Class<?> element, ElementExporter elementExporter) throws ElementExportationException {
try {
Package ownPackage = element.getPackage();
if (ownPackage.getAnnotation(Model.class) != null) {
return new ModelIdImpl(ownPackage.getName());
}
String ownPackageName = ownPackage.getName();
IJavaProject javaProject = ProjectUtils.findJavaProject(elementExporter.getSourceProjectName());
Stream<ICompilationUnit> stream = PackageUtils.findAllPackageFragmentsAsStream(javaProject)
.filter(p -> ownPackageName.startsWith(p.getElementName() + "."))
.map(pf -> pf.getCompilationUnit(PackageUtils.PACKAGE_INFO)).filter(ICompilationUnit::exists);
String topPackageName = Stream.of(SharedUtils.parseICompilationUnitStream(stream, javaProject))
.map(CompilationUnit::getPackage).filter(Objects::nonNull).map(PackageDeclaration::resolveBinding)
.filter(Objects::nonNull).filter(pb -> ModelUtils.findModelNameInTopPackage(pb).isPresent())
.map(IPackageBinding::getName).findFirst().get();
return new ModelIdImpl(topPackageName);
} catch (NotFoundException | JavaModelException | IOException | NoSuchElementException e) {
e.printStackTrace();
throw new ElementExportationException();
}
}
示例11: rewriteName
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
private void rewriteName(Name name, ITypeBinding type) {
AST creator= name.getAST();
boolean fullyQualified= false;
if (name instanceof QualifiedName) {
SimpleName left= ASTNodes.getLeftMostSimpleName(name);
if (left.resolveBinding() instanceof IPackageBinding)
fullyQualified= true;
}
if (fullyQualified) {
fCuRewrite.getASTRewrite().replace(
name,
ASTNodeFactory.newName(creator, type.getQualifiedName()),
fCuRewrite.createGroupDescription(REFERENCE_UPDATE));
fCuRewrite.getImportRemover().registerRemovedNode(name);
} else {
ImportRewriteContext context= new ContextSensitiveImportRewriteContext(name, fCuRewrite.getImportRewrite());
Type result= fCuRewrite.getImportRewrite().addImport(type, fCuRewrite.getAST(), context);
fCuRewrite.getImportRemover().registerAddedImport(type.getQualifiedName());
Name n= ASTNodeFactory.newName(fCuRewrite.getAST(), ASTFlattener.asString(result));
fCuRewrite.getASTRewrite().replace(
name,
n,
fCuRewrite.createGroupDescription(REFERENCE_UPDATE));
fCuRewrite.getImportRemover().registerRemovedNode(name);
fNeedsImport= true;
}
}
示例12: visit
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
@Override
public boolean visit(CompilationUnit node) {
if(node.getPackage() != null && node.getPackage().getName() != null) {
this.currentPackageName = node.getPackage().getName().getFullyQualifiedName();
} else {
this.currentPackageName = "";
}
// Prefills the list with the imports that already exist in the list.
for (Object o : node.imports()) {
ImportDeclaration declaration = (ImportDeclaration) o;
IBinding resolvedBinding = declaration.resolveBinding();
if (resolvedBinding instanceof ITypeBinding) {
ITypeBinding resolvedTypeBinding = (ITypeBinding) resolvedBinding;
if (resolvedTypeBinding != null && !resolvedTypeBinding.isRecovered()) {
resolvedTypeBinding = resolvedTypeBinding.getErasure();
String typeName = resolvedTypeBinding.getName();
IPackageBinding packageBinding = resolvedTypeBinding.getPackage();
if (packageBinding != null) {
String packageName = packageBinding.getName();
this.typesToPackageBinding.put(typeName, packageName);
}
}
}
}
return true;
}
示例13: findUnimplementedInterfaceMethods
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
private static void findUnimplementedInterfaceMethods(ITypeBinding typeBinding, HashSet<ITypeBinding> visited,
ArrayList<IMethodBinding> allMethods, IPackageBinding currPack, ArrayList<IMethodBinding> toImplement) {
if (visited.add(typeBinding)) {
IMethodBinding[] typeMethods= typeBinding.getDeclaredMethods();
nextMethod: for (int i= 0; i < typeMethods.length; i++) {
IMethodBinding curr= typeMethods[i];
for (Iterator<IMethodBinding> allIter= allMethods.iterator(); allIter.hasNext();) {
IMethodBinding oneMethod= allIter.next();
if (Bindings.isSubsignature(oneMethod, curr)) {
// We've already seen a method that is a subsignature of curr.
if (!Bindings.isSubsignature(curr, oneMethod)) {
// oneMethod is a true subsignature of curr; let's go with oneMethod
continue nextMethod;
}
// Subsignatures are equivalent.
// Check visibility and return types ('getErasure()' tries to achieve effect of "rename type variables")
if (Bindings.isVisibleInHierarchy(oneMethod, currPack)
&& oneMethod.getReturnType().getErasure().isSubTypeCompatible(curr.getReturnType().getErasure())) {
// oneMethod is visible and curr doesn't have a stricter return type; let's go with oneMethod
continue nextMethod;
}
// curr is stricter than oneMethod, so let's remove oneMethod
allIter.remove();
toImplement.remove(oneMethod);
} else if (Bindings.isSubsignature(curr, oneMethod)) {
// curr is a true subsignature of oneMethod. Let's remove oneMethod.
allIter.remove();
toImplement.remove(oneMethod);
}
}
int modifiers= curr.getModifiers();
if (!Modifier.isStatic(modifiers)) {
allMethods.add(curr);
if (Modifier.isAbstract(modifiers)) {
toImplement.add(curr);
}
}
}
ITypeBinding[] superInterfaces= typeBinding.getInterfaces();
for (int i= 0; i < superInterfaces.length; i++) {
findUnimplementedInterfaceMethods(superInterfaces[i], visited, allMethods, currPack, toImplement);
}
}
}
示例14: getPackageBinding
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
public IPackageBinding getPackageBinding() {
return packageBinding;
}
示例15: getPackage
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
@Override
public IPackageBinding getPackage() {
return packageBinding;
}