@Override public CharSequence extractReturnType(ExecutableElement executableElement) { if (executableElement instanceof ExecutableElementImpl) { Binding binding = ((ExecutableElementImpl) executableElement)._binding; if (binding instanceof MethodBinding) { MethodBinding methodBinding = (MethodBinding) binding; @Nullable AbstractMethodDeclaration sourceMethod = methodBinding.sourceMethod(); if (sourceMethod != null) { CharSequence rawType = getRawType(methodBinding); char[] content = sourceMethod.compilationResult.compilationUnit.getContents(); int sourceEnd = methodBinding.sourceStart();// intentionaly int sourceStart = scanForTheSourceStart(content, sourceEnd); char[] methodTest = Arrays.copyOfRange(content, sourceStart, sourceEnd); Entry<String, List<String>> extracted = SourceTypes.extract(String.valueOf(methodTest)); return SourceTypes.stringify( Maps.immutableEntry(rawType.toString(), extracted.getValue())); } } } return UNABLE_TO_EXTRACT; }
@SuppressWarnings("squid:S1168") protected static char[] getParamName(MethodBinding b, int paramIndex) { if (b.parameterNames.length > paramIndex) { return b.parameterNames[paramIndex]; } AbstractMethodDeclaration sourceMethod = b.sourceMethod(); if (sourceMethod != null && sourceMethod.arguments.length > paramIndex) { return sourceMethod.arguments[paramIndex].name; } // if no parameter name info is in the class file return null; }
@Override public void consumeScope(int scopeNumber) { if (this.scope == null) { if (this.methodBinding == null) return; this.scope = this.methodBinding.sourceMethod().scope; } if (scopeNumber >= this.scope.subscopeCount) return; // malformed key this.scope = (BlockScope) this.scope.subscopes[scopeNumber]; }
public void consumeScope(int scopeNumber) { if (this.scope == null) { if (this.methodBinding == null) return; this.scope = this.methodBinding.sourceMethod().scope; } if (scopeNumber >= this.scope.subscopeCount) return; // malformed key this.scope = (BlockScope) this.scope.subscopes[scopeNumber]; }
public void consumeScope(int scopeNumber) { if (this.scope == null) { if (this.methodBinding == null) return; this.scope = this.methodBinding.sourceMethod().scope; } if (scopeNumber >= this.scope.subscopeCount) return; // malformed key this.scope = (BlockScope) this.scope.subscopes[scopeNumber]; }
public final int sourceStart() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceStart(); return 0; } return method.sourceStart; }
public final int sourceEnd() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceEnd(); return 0; } return method.sourceEnd; } public AbstractMethodDeclaration sourceMethod() {
public final int sourceEnd() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceEnd(); return 0; } return method.sourceEnd; } public AbstractMethodDeclaration sourceMethod() {
ProblemReporter problemReporter(MethodBinding currentMethod) { ProblemReporter reporter = problemReporter(); if (TypeBinding.equalsEquals(currentMethod.declaringClass, this.type) && currentMethod.sourceMethod() != null) // only report against the currentMethod if its implemented by the type reporter.referenceContext = currentMethod.sourceMethod(); return reporter; }
public final int sourceStart() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceStart(); return 0; } return method.sourceStart; }
ProblemReporter problemReporter(MethodBinding currentMethod) { ProblemReporter reporter = problemReporter(); if (TypeBinding.equalsEquals(currentMethod.declaringClass, this.type) && currentMethod.sourceMethod() != null) // only report against the currentMethod if its implemented by the type reporter.referenceContext = currentMethod.sourceMethod(); return reporter; }
public final int sourceEnd() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceEnd(); return 0; } return method.sourceEnd; } public AbstractMethodDeclaration sourceMethod() {
ProblemReporter problemReporter(MethodBinding currentMethod) { ProblemReporter reporter = problemReporter(); if (TypeBinding.equalsEquals(currentMethod.declaringClass, this.type) && currentMethod.sourceMethod() != null) // only report against the currentMethod if its implemented by the type reporter.referenceContext = currentMethod.sourceMethod(); return reporter; }
public final int sourceStart() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceStart(); return 0; } return method.sourceStart; }
public final int sourceEnd() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceEnd(); return 0; } return method.sourceEnd; } public AbstractMethodDeclaration sourceMethod() {
public final int sourceStart() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceStart(); return 0; } return method.sourceStart; }
public final int sourceStart() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceStart(); return 0; } return method.sourceStart; }
public final int sourceEnd() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceEnd(); return 0; } return method.sourceEnd; } public AbstractMethodDeclaration sourceMethod() {
public final int sourceStart() { AbstractMethodDeclaration method = sourceMethod(); if (method == null) { if (this.declaringClass instanceof SourceTypeBinding) return ((SourceTypeBinding) this.declaringClass).sourceStart(); return 0; } return method.sourceStart; }
protected int getSourcePosition(MethodBinding mb) { MethodBinding methodBinding = SpiWithJdtUtils.nvl(mb.original(), mb); if (methodBinding == null) { return UNKNOWN_SOURCE_POS; } AbstractMethodDeclaration decl = methodBinding.sourceMethod(); if (decl == null) { return UNKNOWN_SOURCE_POS; } return decl.declarationSourceStart; }