private static boolean checkName(String name, List<IMethodBinding> usedNames) { for (Iterator<IMethodBinding> iter = usedNames.iterator(); iter.hasNext();) { IMethodBinding method = iter.next(); String selector = method.getName(); if (selector.equals(name)) { return true; } } return false; }
private static boolean checkName(String name, List usedNames, IType type) { for (Iterator iter= usedNames.iterator(); iter.hasNext(); ) { IMethodBinding method= (IMethodBinding)iter.next(); String selector= method.getName(); if (selector.equals(name)) { return true; } } return false; }
private static <T extends IBinding> boolean contains(List<T> inheritedFields, T member) { for (Iterator<T> iterator= inheritedFields.iterator(); iterator.hasNext();) { T object= iterator.next(); if (object instanceof IVariableBinding && member instanceof IVariableBinding) if (((IVariableBinding) object).getName().equals(((IVariableBinding) member).getName())) return true; if (object instanceof IMethodBinding && member instanceof IMethodBinding) if (((IMethodBinding) object).getName().equals(((IMethodBinding) member).getName())) return true; } return false; }
private String getSignature(IMethodBinding binding) { StringBuilder buf= new StringBuilder(binding.getName()).append('('); ITypeBinding[] parameterTypes= binding.getParameterTypes(); for (int i= 0; i < parameterTypes.length; i++) { buf.append(parameterTypes[i].getTypeDeclaration().getName()); } buf.append(')'); return buf.toString(); }
public static String qualifiedSignature(IMethodBinding binding) { StringBuffer buf = new StringBuffer(); buf.append(qualifiedName(binding.getDeclaringClass())).append(".").append(binding.getName()).append("("); ITypeBinding[] parameterTypes = binding.getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { if (i != 0) buf.append(","); buf.append(qualifiedName(parameterTypes[i])); } buf.append(")"); return buf.toString(); }
protected SimpleName getNewName(ASTRewrite rewrite) { AST ast= rewrite.getAST(); SimpleName nameNode= ast.newSimpleName(fMethod.getName()); return nameNode; }
@Override protected SimpleName getNewName(ASTRewrite rewrite) { AST ast= rewrite.getAST(); SimpleName nameNode= ast.newSimpleName(fMethod.getName()); return nameNode; }
@Override protected SimpleName getNewName(ASTRewrite rewrite) { AST ast= rewrite.getAST(); SimpleName nameNode= ast.newSimpleName(fMethod.getName()); return nameNode; }
public static String qualifiedName(IMethodBinding binding) { return qualifiedName(binding.getDeclaringClass()) + "." + binding.getName(); }
private String computeMethodName(IMethodBinding binding, Configuration.MemberMapping mapping) { if (isStaticVoidMain(binding)) return "Main"; String name = isNameMapping(mapping) ? mapping.name : binding.getName(); return methodName(name); }
public ToStringInfo(ITypeBinding typeBinding) { IMethodBinding[] declaredMethods= typeBinding.getDeclaredMethods(); for (int i= 0; i < declaredMethods.length; i++) { if (declaredMethods[i].getName().equals(METHODNAME_TO_STRING) && declaredMethods[i].getParameterTypes().length == 0) { this.foundToString= true; if (Modifier.isFinal(declaredMethods[i].getModifiers())) this.foundFinalToString= true; } } } }
private boolean isSpecialCloneInvocation(IMethodBinding methodBinding, Expression receiver) { return fAssumeCloneReturnsSameType && "clone".equals(methodBinding.getName()) //$NON-NLS-1$ && methodBinding.getParameterTypes().length == 0 && receiver != null && receiver.resolveTypeBinding() != methodBinding.getMethodDeclaration().getReturnType(); }
private boolean isSpecialCloneInvocation(IMethodBinding methodBinding, Expression receiver) { return fAssumeCloneReturnsSameType && "clone".equals(methodBinding.getName()) //$NON-NLS-1$ && methodBinding.getParameterTypes().length == 0 && receiver != null && receiver.resolveTypeBinding() != methodBinding.getMethodDeclaration().getReturnType(); }
private boolean isSpecialCloneInvocation(IMethodBinding methodBinding, Expression receiver) { return fAssumeCloneReturnsSameType && "clone".equals(methodBinding.getName()) //$NON-NLS-1$ && methodBinding.getParameterTypes().length == 0 && receiver != null && receiver.resolveTypeBinding() != methodBinding.getMethodDeclaration().getReturnType(); }
private static boolean hasConflict(int startPosition, IMethodBinding referredMethodBinding, int flags, CompilationUnit cu) { ScopeAnalyzer analyzer = new ScopeAnalyzer(cu); IBinding[] declarationsInScope = analyzer.getDeclarationsInScope(startPosition, flags); for (int i = 0; i < declarationsInScope.length; i++) { IBinding decl = declarationsInScope[i]; if (decl.getName().equals(referredMethodBinding.getName()) && !referredMethodBinding.getMethodDeclaration().isEqualTo(decl)) { return true; } } return false; }
private static boolean hasConflict(int startPosition, IMethodBinding referredMethodBinding, int flags, CompilationUnit cu) { ScopeAnalyzer analyzer= new ScopeAnalyzer(cu); IBinding[] declarationsInScope= analyzer.getDeclarationsInScope(startPosition, flags); for (int i= 0; i < declarationsInScope.length; i++) { IBinding decl= declarationsInScope[i]; if (decl.getName().equals(referredMethodBinding.getName()) && !referredMethodBinding.getMethodDeclaration().isEqualTo(decl)) return true; } return false; }
private String getMethodName(IMethodBinding binding) { String argumentList = ""; ITypeBinding[] args = binding.getParameterTypes(); for(ITypeBinding arg : args) { argumentList += arg.getName(); } String method = binding.getDeclaringClass().getQualifiedName() + "." + binding.getName() + "/" + binding.getTypeArguments().length + "[" + argumentList + "]"; return method; }
public static boolean isStaticMethodImport(ImportDeclaration imp, IMethodBinding method) { final IBinding binding = imp.resolveBinding(); switch (binding.getKind()) { case IBinding.TYPE: return imp.isOnDemand() && method.getDeclaringClass() == binding; case IBinding.METHOD: IMethodBinding bound = (IMethodBinding) binding; return bound.getDeclaringClass() == method.getDeclaringClass() && binding.getName().equals(method.getMethodDeclaration().getName()); } return false; }
private Configuration.MemberMapping mappingForInvocation(ASTNode node, IMethodBinding binding) { Configuration.MemberMapping mapping = effectiveMappingFor(binding); if (null == mapping) { if (isIndexer(binding)) { mapping = new MemberMapping(null, MemberKind.Indexer); } else if (isTaggedMethodInvocation(binding, SharpenAnnotations.SHARPEN_EVENT)) { mapping = new MemberMapping(binding.getName(), MemberKind.Property); } else if (isTaggedMethodInvocation(binding, SharpenAnnotations.SHARPEN_PROPERTY)) { mapping = new MemberMapping(propertyName(binding), MemberKind.Property); } } return mapping; }
private boolean hasAddedStaticImport(SimpleName name) { IBinding binding= name.resolveBinding(); if (binding instanceof IVariableBinding) { IVariableBinding variable= (IVariableBinding) binding; return hasAddedStaticImport(variable.getDeclaringClass().getQualifiedName(), variable.getName(), true); } else if (binding instanceof IMethodBinding) { IMethodBinding method= (IMethodBinding) binding; return hasAddedStaticImport(method.getDeclaringClass().getQualifiedName(), method.getName(), false); } return false; }