示例#1
0
        public Task <LocationOrLocationLinks> Handle(DefinitionParams request, CancellationToken cancellationToken)
        {
            var hash = Hash.StringHash(request.TextDocument.Uri.GetFileSystemPath());

            TreeSitter.FindDefinition(hash, request.Position.Line, request.Position.Character, out var defHash, out var origin, out var target, out var selection);

            if (defHash != 0)
            {
                LocationLink link = new LocationLink();
                link.TargetUri            = DocumentUri.FromFileSystemPath(hashNamer.hashToName[defHash]);
                link.OriginSelectionRange = ConvertRange(origin);
                link.TargetRange          = ConvertRange(target);
                link.TargetSelectionRange = ConvertRange(selection);
                LocationOrLocationLinks ll = new LocationOrLocationLinks(link);
                return(Task.FromResult(ll));
            }

            return(Task.FromResult(new LocationOrLocationLinks()));
        }
示例#2
0
 public LocationOrLocationLink(LocationLink locationLink)
 {
     Location     = null;
     LocationLink = locationLink;
 }