racket / racket/drracket

syncheck:add-definition-target does not use syncheck:find-source-object

Open
#485 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
516
Forks
103
PR merge metrics
No merged PRs in 30d

Description

IIUC syncheck-annotations<%> methods are supposed to follow the protocol of calling syncheck:find-source-object -- giving it the opportunity to skip the annotation, or return a value it desires. For example it could choose to return the original syntax object, or, it could return just syntax-source. Anyway, it gets to choose.

This should return #f if the source of this syntax object is uninteresting for annotations (if, for example, the only interesting annotations are those in the original file and this is a syntax object introduced by a macro and thus has a source location from some other file).

Otherwise, it should return some (non-#f) value that will then be passed to one of the other methods below as a source-obj argument.

However syncheck:add-definition-target seems to ignore this and hard wire syntax-source, which seems wrong. For example, I'd like it to be the full syntax object.

Should it be changed:

;; add-definition-target : syntax[(sequence of identifiers)] (listof symbol) -> void
(define (add-definition-target stx mods phase-level)
  (when mods
    (define defs-text (current-annotations))
    (for ([id (in-list (syntax->list stx))])
-     (define source (syntax-source id))
+     (define source (find-source-editor id))
      (define ib (identifier-binding id phase-level))
      (when (and (list? ib)
                 source
                 defs-text
                 (syntax-position id)
                 (syntax-span id))
        (let* ([pos-left (- (syntax-position id) 1)]
               [pos-right (+ pos-left (syntax-span id))])
          (send defs-text syncheck:add-definition-target
                source
                pos-left
                pos-right
                (list-ref ib 1)
                mods))))))

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at syncheck:add-definition-target and read the linked syncheck-annotations protocol, especially syncheck:find-source-object. Trace how the source value is selected and passed to syncheck:add-definition-target, including the #f skip behavior; done means the method follows the documented protocol and can use the chosen source object.

Written by the indexing model from the issue text.

Assessment

Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.