Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add usings to names in REPL completions. #42094

Merged
merged 4 commits into from
May 27, 2024

Conversation

NHDaly
Copy link
Member

@NHDaly NHDaly commented Sep 2, 2021

Add usings to names in REPL completions.

Follow up to #42092, rest of #36529.

This enables the REPL to use the names imported via usings in completions.

@NHDaly NHDaly requested a review from aviatesk September 2, 2021 18:36
@NHDaly
Copy link
Member Author

NHDaly commented Sep 2, 2021

Actually, @aviatesk - i'm not sure if this PR is right... Can you expand on what you meant in your comment?:
#36529 (comment)

What are situations that don't work like you expect, and how would you want them to change?

I'm going to downgrade this PR to a draft, since i'm not sure what the desired behavior actually is... please feel free to commit directly to the PR and change it however you'd like!! 😁

@aviatesk
Copy link
Member

aviatesk commented Sep 3, 2021

Thanks for taking the initiative on this @NHDaly !
I added several test cases that can benefit from your PR #42092, all of which should not work on master. I hope they explain the possible improvements.

@ViralBShah
Copy link
Member

Merge?

append!(suggestions, filtered_mod_names(p, mod, name, true, true))
else
append!(suggestions, filtered_mod_names(p, mod, name, true, false))
# special case `Core` and `Base` bindings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these not show up via usings=true normally? I guess I don't really know how names works

@vtjnash
Copy link
Member

vtjnash commented Nov 3, 2023

Note that this doesn't merge into master, but into that other PR (which should be merged first instead)

@aviatesk
Copy link
Member

@KnutAM
Copy link
Contributor

KnutAM commented Feb 29, 2024

I was about to open an issue, but I guess this falls under the same?

module A
    module B
        struct C end
    end
end
julia> import .A.B.<tab>┌ Error: Error in the keymap
│   exception =
│    UndefVarError: `out` not defined
│    Stacktrace:

(Works fine on 1.9 though)

Full stack trace and versioninfo
julia> import .A.B.┌ Error: Error in the keymap
│   exception =
│    UndefVarError: `out` not defined
│    Stacktrace:
│      [1] complete_identifiers!(suggestions::Vector{REPL.REPLCompletions.Completion}, ffunc::Any, context_module::Module, string::String, name::String, pos::Int64, dotpos::Int64, startpos::Int64; comp_keywords::Bool)
│        @ REPL.REPLCompletions C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPLCompletions.jl:1055
│      [2] complete_identifiers!
│        @ C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPLCompletions.jl:983 [inlined]
│      [3] completions(string::String, pos::Int64, context_module::Module, shift::Bool)
│        @ REPL.REPLCompletions C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPLCompletions.jl:1299
│      [4] complete_line(c::REPL.REPLCompletionProvider, s::REPL.LineEdit.PromptState, mod::Module)
│        @ REPL C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:545
│      [5] complete_line(s::REPL.LineEdit.PromptState, repeats::Int64, mod::Module)
│        @ REPL.LineEdit C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:376
│      [6] complete_line(s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:367
│      [7] edit_tab(s::REPL.LineEdit.MIState, jump_spaces::Bool, delete_trailing::Bool)
│        @ REPL.LineEdit C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2320
│      [8] edit_tab
│        @ C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2320 [inlined]
│      [9] (::REPL.LineEdit.var"#114#170")(::REPL.LineEdit.MIState, ::Any, ::Vararg{Any})
│        @ REPL.LineEdit C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2366
│     [10] #invokelatest#2
│        @ .\essentials.jl:892 [inlined]
│     [11] invokelatest
│        @ .\essentials.jl:889 [inlined]
│     [12] (::REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#114#170", String})(s::Any, p::Any)
│        @ REPL.LineEdit C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:1612
│     [13] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2749
│     [14] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2651
│     [15] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│        @ REPL C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:1312
│     [16] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│        @ REPL C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:386
└ @ REPL.LineEdit C:\Users\meyer\.julia\juliaup\julia-1.10.1+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\LineEdit.jl:2751

# Versioninfo
Julia Version 1.10.1
Commit 7790d6f064 (2024-02-13 20:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Environment:
  JULIA_PKG_OFFLINE = false
  JULIA_PKG_USE_CLI_GIT = true

@aviatesk
Copy link
Member

That's a separate issue. We need to backport #53273 to v1.10.

@aviatesk aviatesk marked this pull request as ready for review May 27, 2024 15:11
@aviatesk aviatesk force-pushed the nhd/REPL-completions-usings branch from 322adfd to 6dfdc91 Compare May 27, 2024 15:11
@aviatesk aviatesk merged commit eb14cb5 into nhd/names-usings May 27, 2024
2 of 3 checks passed
@aviatesk aviatesk deleted the nhd/REPL-completions-usings branch May 27, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants