Example usage for org.eclipse.jdt.core.dom MethodDeclaration getLocationInParent

List of usage examples for org.eclipse.jdt.core.dom MethodDeclaration getLocationInParent

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom MethodDeclaration getLocationInParent.

Prototype

public final StructuralPropertyDescriptor getLocationInParent() 

Source Link

Document

Returns the location of this node within its parent, or null if this is a root node.

Usage

From source file:org.jboss.tools.ws.jaxrs.ui.contentassist.MemberDeclarationVisitor.java

License:Open Source License

@Override
public boolean visit(MethodDeclaration node) {
    if (sourceOverview == null) {
        try {//  w ww .ja v a 2s  .  com
            ISourceRange sourceRange = member.getSourceRange();
            int memberStartPosition = sourceRange.getOffset();
            int memberEndPosition = memberStartPosition + sourceRange.getLength();
            int nodeStartPosition = node.getStartPosition();
            if (memberStartPosition <= nodeStartPosition && nodeStartPosition <= memberEndPosition) {
                Javadoc javaDoc = node.getJavadoc();
                Block body = node.getBody();
                node.getLocationInParent();
                int beginIndex = (javaDoc != null) ? (javaDoc.getStartPosition() + javaDoc.getLength())
                        : member.getSourceRange().getOffset();
                sourceOverview = member.getCompilationUnit().getSource()
                        .substring(beginIndex, body.getStartPosition()).trim();
            }
        } catch (JavaModelException e) {
            Logger.warn("Failed to visit node", e);
        }
    }
    return super.visit(node);
}