Example usage for org.eclipse.jdt.internal.core SourceMapper mapSource

List of usage examples for org.eclipse.jdt.internal.core SourceMapper mapSource

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core SourceMapper mapSource.

Prototype

public synchronized ISourceRange mapSource(NamedMember typeOrModule, char[] contents, IBinaryType info, 
        IJavaElement elementToFind) 

Source Link

Document

Maps the given source code to the given binary type and its children.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MatchLocator.java

License:Open Source License

protected void reportBinaryMemberDeclaration(IResource resource, IMember binaryMember,
        Binding binaryMemberBinding, IBinaryType info, int accuracy) throws CoreException {
    ClassFile classFile = (ClassFile) binaryMember.getClassFile();
    ISourceRange range = classFile.isOpen() ? binaryMember.getNameRange() : SourceMapper.UNKNOWN_RANGE;
    if (range.getOffset() == -1) {
        BinaryType type = (BinaryType) classFile.getType();
        String sourceFileName = type.sourceFileName(info);
        if (sourceFileName != null) {
            SourceMapper mapper = classFile.getSourceMapper();
            if (mapper != null) {
                char[] contents = mapper.findSource(type, sourceFileName);
                if (contents != null)
                    range = mapper.mapSource(type, contents, info, binaryMember);
            }/*from w ww.j  a  va2 s  .co m*/
        }
    }
    if (resource == null)
        resource = this.currentPossibleMatch.resource;
    SearchMatch match = newDeclarationMatch(binaryMember, binaryMemberBinding, accuracy, range.getOffset(),
            range.getLength(), getParticipant(), resource);
    report(match);
}