List of usage examples for org.eclipse.jdt.internal.compiler.ast ReferenceExpression getMethodBinding
@Override
public org.eclipse.jdt.internal.compiler.lookup.MethodBinding getMethodBinding()
From source file:org.eclipse.che.jdt.internal.core.search.indexing.SourceIndexer.java
License:Open Source License
public void indexResolvedDocument() { try {/*w w w . j a va 2 s . c o m*/ if (DEBUG) System.out.println(new String(this.cud.compilationResult.fileName) + ':'); for (int i = 0, length = this.cud.functionalExpressionsCount; i < length; i++) { FunctionalExpression expression = this.cud.functionalExpressions[i]; if (expression instanceof LambdaExpression) { LambdaExpression lambdaExpression = (LambdaExpression) expression; if (lambdaExpression.binding != null && lambdaExpression.binding.isValidBinding()) { final char[] superinterface = lambdaExpression.resolvedType.sourceName(); if (DEBUG) { System.out.println('\t' + new String(superinterface) + '.' + new String(lambdaExpression.descriptor.selector) + "-> {}"); //$NON-NLS-1$ } SourceIndexer.this.addIndexEntry(IIndexConstants.METHOD_DECL, MethodPattern.createIndexKey(lambdaExpression.descriptor.selector, lambdaExpression.descriptor.parameters.length)); addClassDeclaration(0, // most entries are blank, that is fine, since lambda type/method cannot be searched. CharOperation.NO_CHAR, // package name ONE_ZERO, ONE_ZERO_CHAR, // enclosing types. CharOperation.NO_CHAR, // super class new char[][] { superinterface }, CharOperation.NO_CHAR_CHAR, true); // not primary. } else { if (DEBUG) System.out.println("\tnull/bad binding in lambda"); //$NON-NLS-1$ } } else { ReferenceExpression referenceExpression = (ReferenceExpression) expression; if (referenceExpression.isArrayConstructorReference()) continue; MethodBinding binding = referenceExpression.getMethodBinding(); if (binding != null && binding.isValidBinding()) { if (DEBUG) { System.out .println('\t' + new String(referenceExpression.resolvedType.sourceName()) + "::" //$NON-NLS-1$ + new String(referenceExpression.descriptor.selector) + " == " + new String(binding.declaringClass.sourceName()) + '.' + //$NON-NLS-1$ new String(binding.selector)); } if (referenceExpression.isMethodReference()) SourceIndexer.this.addMethodReference(binding.selector, binding.parameters.length); else SourceIndexer.this.addConstructorReference(binding.declaringClass.sourceName(), binding.parameters.length); } else { if (DEBUG) System.out.println("\tnull/bad binding in reference expression"); //$NON-NLS-1$ } } } } catch (Exception e) { if (JobManager.VERBOSE) { e.printStackTrace(); } } }
From source file:org.eclipse.che.jdt.internal.core.search.matching.MethodLocator.java
License:Open Source License
protected int resolveLevel(ReferenceExpression referenceExpression) { MethodBinding method = referenceExpression.getMethodBinding(); if (method == null || !method.isValidBinding()) return INACCURATE_MATCH; int methodLevel = matchMethod(method, false); if (methodLevel == IMPOSSIBLE_MATCH) { if (method != method.original()) methodLevel = matchMethod(method.original(), false); if (methodLevel == IMPOSSIBLE_MATCH) return IMPOSSIBLE_MATCH; method = method.original();//from www.ja va 2s . c o m } // receiver type if (this.pattern.declaringSimpleName == null && this.pattern.declaringQualification == null) return methodLevel; // since any declaring class will do int declaringLevel = resolveLevelForType(this.pattern.declaringSimpleName, this.pattern.declaringQualification, method.declaringClass); return (methodLevel & MATCH_LEVEL_MASK) > (declaringLevel & MATCH_LEVEL_MASK) ? declaringLevel : methodLevel; // return the weaker match }