本文整理汇总了Java中org.eclipse.jdt.core.dom.IPackageBinding类的典型用法代码示例。如果您正苦于以下问题:Java IPackageBinding类的具体用法?Java IPackageBinding怎么用?Java IPackageBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPackageBinding类属于org.eclipse.jdt.core.dom包,在下文中一共展示了IPackageBinding类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:23,代码来源:ModelUtils.java
示例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);
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:StubUtility2.java
示例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;
}
开发者ID:markus1978,项目名称:srcrepo,代码行数:20,代码来源:JDTDelegateBindingFactory.java
示例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();
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:Bindings.java
示例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;
}
开发者ID:Sellegit,项目名称:j2objc,代码行数:11,代码来源:GeneratedTypeBinding.java
示例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);
}
开发者ID:Sellegit,项目名称:j2objc,代码行数:14,代码来源:GeneratedTypeBinding.java
示例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();
}
开发者ID:Sellegit,项目名称:j2objc,代码行数:40,代码来源:NameTable.java
示例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();
}
开发者ID:eclipse,项目名称:che,代码行数:13,代码来源:Bindings.java
示例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;
}
}
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:8,代码来源:ModelUtils.java
示例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();
}
}
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:29,代码来源:AbstractSourceExporter.java
示例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;
}
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:28,代码来源:MoveStaticMemberAnalyzer.java
示例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;
}
开发者ID:awltech,项目名称:eclipse-optimus,代码行数:29,代码来源:ImportsGenerationVisitor.java
示例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);
}
}
}
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:47,代码来源:StubUtility2.java
示例14: getPackageBinding
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
public IPackageBinding getPackageBinding() {
return packageBinding;
}
开发者ID:Sellegit,项目名称:j2objc,代码行数:4,代码来源:PackageDeclaration.java
示例15: getPackage
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
@Override
public IPackageBinding getPackage() {
return packageBinding;
}
开发者ID:Sellegit,项目名称:j2objc,代码行数:5,代码来源:GeneratedTypeBinding.java
示例16: getPackage
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
@Override
public IPackageBinding getPackage() {
return new GeneratedPackageBinding(clazz.getPackage().getName());
}
开发者ID:Sellegit,项目名称:j2objc,代码行数:5,代码来源:ClassTypeBinding.java
示例17: getPackage
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
@Override
public IPackageBinding getPackage() {
return null;
}
开发者ID:Sellegit,项目名称:j2objc,代码行数:5,代码来源:AbstractTypeBinding.java
示例18: 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);
}
}
if (Modifier.isAbstract(curr.getModifiers())) {
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);
}
}
开发者ID:eclipse,项目名称:che,代码行数:54,代码来源:StubUtility2.java
示例19: ensureNamespaceFromPackageBinding
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
public Namespace ensureNamespaceFromPackageBinding(IPackageBinding binding) {
return ensureNamespaceNamed(binding.getName());
}
开发者ID:feenkcom,项目名称:jdt2famix,代码行数:4,代码来源:InJavaImporter.java
示例20: performFieldRewrite
import org.eclipse.jdt.core.dom.IPackageBinding; //导入依赖的package包/类
private FieldDeclaration performFieldRewrite(IType type, ParameterObjectFactory pof, RefactoringStatus status) throws CoreException {
fBaseCURewrite= new CompilationUnitRewrite(type.getCompilationUnit());
SimpleName name= (SimpleName) NodeFinder.perform(fBaseCURewrite.getRoot(), type.getNameRange());
TypeDeclaration typeNode= (TypeDeclaration) ASTNodes.getParent(name, ASTNode.TYPE_DECLARATION);
ASTRewrite rewrite= fBaseCURewrite.getASTRewrite();
int modifier= Modifier.PRIVATE;
TextEditGroup removeFieldGroup= fBaseCURewrite.createGroupDescription(RefactoringCoreMessages.ExtractClassRefactoring_group_remove_field);
FieldDeclaration lastField= null;
initializeDeclaration(typeNode);
for (Iterator<FieldInfo> iter= fVariables.values().iterator(); iter.hasNext();) {
FieldInfo pi= iter.next();
if (isCreateField(pi)) {
VariableDeclarationFragment vdf= pi.declaration;
FieldDeclaration parent= (FieldDeclaration) vdf.getParent();
if (lastField == null)
lastField= parent;
else if (lastField.getStartPosition() < parent.getStartPosition())
lastField= parent;
ListRewrite listRewrite= rewrite.getListRewrite(parent, FieldDeclaration.FRAGMENTS_PROPERTY);
removeNode(vdf, removeFieldGroup, fBaseCURewrite);
if (listRewrite.getRewrittenList().size() == 0) {
removeNode(parent, removeFieldGroup, fBaseCURewrite);
}
if (fDescriptor.isCreateTopLevel()) {
IVariableBinding binding= vdf.resolveBinding();
ITypeRoot typeRoot= fBaseCURewrite.getCu();
if (binding == null || binding.getType() == null){
status.addFatalError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_fatal_error_cannot_resolve_binding, BasicElementLabels.getJavaElementName(pi.name)), JavaStatusContext.create(typeRoot, vdf));
} else {
ITypeBinding typeBinding= binding.getType();
if (Modifier.isPrivate(typeBinding.getModifiers())){
status.addError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_error_referencing_private_class, BasicElementLabels.getJavaElementName(typeBinding.getName())), JavaStatusContext.create(typeRoot, vdf));
} else if (Modifier.isProtected(typeBinding.getModifiers())){
ITypeBinding declaringClass= typeBinding.getDeclaringClass();
if (declaringClass != null) {
IPackageBinding package1= declaringClass.getPackage();
if (package1 != null && !fDescriptor.getPackage().equals(package1.getName())){
status.addError(Messages.format(RefactoringCoreMessages.ExtractClassRefactoring_error_referencing_protected_class, new String[] {BasicElementLabels.getJavaElementName(typeBinding.getName()), BasicElementLabels.getJavaElementName(fDescriptor.getPackage())}), JavaStatusContext.create(typeRoot, vdf));
}
}
}
}
}
Expression initializer= vdf.getInitializer();
if (initializer != null)
pi.initializer= initializer;
int modifiers= parent.getModifiers();
if (!MemberVisibilityAdjustor.hasLowerVisibility(modifiers, modifier)){
modifier= modifiers;
}
}
}
FieldDeclaration fieldDeclaration= createParameterObjectField(pof, typeNode, modifier);
ListRewrite bodyDeclList= rewrite.getListRewrite(typeNode, TypeDeclaration.BODY_DECLARATIONS_PROPERTY);
if (lastField != null)
bodyDeclList.insertAfter(fieldDeclaration, lastField, null);
else
bodyDeclList.insertFirst(fieldDeclaration, null);
return fieldDeclaration;
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:63,代码来源:ExtractClassRefactoring.java
注:本文中的org.eclipse.jdt.core.dom.IPackageBinding类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论