本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.equals方法的具體用法?Java ITypeBinding.equals怎麽用?Java ITypeBinding.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.equals方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filterSubtypeExceptions
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static List<ITypeBinding> filterSubtypeExceptions(ITypeBinding[] exceptions) {
List<ITypeBinding> filteredExceptions = new ArrayList<>();
filteredExceptions.addAll(Arrays.asList(exceptions));
for (Iterator<ITypeBinding> subtypeIterator = filteredExceptions.iterator(); subtypeIterator.hasNext();) {
ITypeBinding iTypeBinding = subtypeIterator.next();
for (Iterator<ITypeBinding> supertypeIterator = filteredExceptions.iterator(); supertypeIterator.hasNext();) {
ITypeBinding superTypeBinding = supertypeIterator.next();
if (!iTypeBinding.equals(superTypeBinding) && iTypeBinding.isSubTypeCompatible(superTypeBinding)) {
subtypeIterator.remove();
break;
}
}
}
return filteredExceptions;
}
示例2: compare
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
@Override
public int compare(IMethodBinding firstMethodBinding, IMethodBinding secondMethodBinding) {
if (firstMethodBinding == null || secondMethodBinding == null) {
return 0;
}
ITypeBinding firstMethodType= firstMethodBinding.getDeclaringClass();
ITypeBinding secondMethodType= secondMethodBinding.getDeclaringClass();
if (firstMethodType.equals(secondMethodType)) {
return compareInTheSameType(firstMethodBinding, secondMethodBinding);
}
if (firstMethodType.equals(fTypeBinding)) {
return 1;
}
if (secondMethodType.equals(fTypeBinding)) {
return -1;
}
ITypeBinding type= fTypeBinding;
int count= 0, firstCount= -1, secondCount= -1;
while ((type= type.getSuperclass()) != null) {
if (firstMethodType.equals(type)) {
firstCount= count;
}
if (secondMethodType.equals(type)) {
secondCount= count;
}
count++;
}
if (firstCount != -1 && secondCount != -1) {
return (firstCount - secondCount);
}
if (firstCount != -1 && secondCount == -1) {
return 1;
}
if (firstCount == -1 && secondCount != -1) {
return -1;
}
ITypeBinding[] interfaces= fTypeBinding.getInterfaces();
for (int i= 0; i < interfaces.length; i++) {
if (firstMethodType.equals(interfaces[i])) {
return 1;
}
if (secondMethodType.equals(interfaces[i])) {
return -1;
}
}
return 0;
}
示例3: findValidDuplicates
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private List<SnippetFinder.Match> findValidDuplicates(ASTNode startNode) {
List<Match> duplicates = SnippetFinder.perform(startNode, fAnalyzer.getSelectedNodes());
List<SnippetFinder.Match> validDuplicates = new ArrayList<>();
for (Match duplicate : duplicates) {
if (duplicate != null && !duplicate.isInvalidNode()) {
try {
ASTNode[] nodes = duplicate.getNodes();
int duplicateStart = nodes[0].getStartPosition();
ASTNode lastNode = nodes[nodes.length - 1];
int duplicateEnd = lastNode.getStartPosition() + lastNode.getLength();
int duplicateLength = duplicateEnd - duplicateStart;
ExtractMethodAnalyzer analyzer = new ExtractMethodAnalyzer(fCUnit, Selection.createFromStartLength(duplicateStart, duplicateLength));
fRoot.accept(analyzer);
RefactoringStatus result = new RefactoringStatus();
result.merge(analyzer.checkInitialConditions(fImportRewriter));
if (!result.hasFatalError()) {
ITypeBinding originalReturnTypeBinding = fAnalyzer.getReturnTypeBinding();
ITypeBinding duplicateReturnTypeBinding = analyzer.getReturnTypeBinding();
if (originalReturnTypeBinding == null && duplicateReturnTypeBinding == null) {
validDuplicates.add(duplicate);
} else if (originalReturnTypeBinding != null && duplicateReturnTypeBinding != null) {
if (!originalReturnTypeBinding.equals(duplicateReturnTypeBinding)) {
if (duplicateReturnTypeBinding.equals(startNode.getAST().resolveWellKnownType("void"))) { //$NON-NLS-1$
// extracted snippet returns non-void and duplicate snippet returns void => OK
validDuplicates.add(duplicate);
}
} else {
IVariableBinding originalReturnValBinding = fAnalyzer.getReturnValue();
IVariableBinding duplicateReturnValBinding = analyzer.getReturnValue();
if (originalReturnValBinding == null && duplicateReturnValBinding == null) {
validDuplicates.add(duplicate);
} else if (originalReturnValBinding != null && duplicateReturnValBinding != null) {
BodyDeclaration originalEnclosingBodyDeclaration = fAnalyzer.getEnclosingBodyDeclaration();
BodyDeclaration duplicateEnclosingBodyDeclaration = analyzer.getEnclosingBodyDeclaration();
VariableDeclaration originalReturnNode = ASTNodes.findVariableDeclaration(originalReturnValBinding, originalEnclosingBodyDeclaration);
VariableDeclaration duplicateReturnNode = ASTNodes.findVariableDeclaration(duplicateReturnValBinding, duplicateEnclosingBodyDeclaration);
if (originalReturnNode != null && duplicateReturnNode != null) {
boolean matches;
if (!fAnalyzer.getSelection().covers(originalReturnNode) && !analyzer.getSelection().covers(duplicateReturnNode)) {
// returned variables are defined outside of the selection => always OK
matches = true;
} else {
matches = matchesLocationInEnclosingBodyDecl(originalEnclosingBodyDeclaration, duplicateEnclosingBodyDeclaration, originalReturnNode, duplicateReturnNode);
}
if (matches) {
validDuplicates.add(duplicate);
}
}
}
}
}
}
} catch (CoreException e) {
// consider as invalid duplicate
}
}
}
return validDuplicates;
}