Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 2 additions & 34 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ os:
- linux
# - osx
julia:
- 0.6
- 0.7
- '1.0'
- 1.1
Expand All @@ -14,36 +13,5 @@ notifications:
git:
depth: 99999999

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
#matrix:
# allow_failures:
# - julia: nightly

## uncomment and modify the following lines to manually install system packages
#addons:
# apt: # apt-get for linux
# packages:
# - gfortran
#before_script: # homebrew for mac
# - if [ $TRAVIS_OS_NAME = osx ]; then brew install gcc; fi

install:
- ci/install.jl

script:
# Ignore "Warning: `using A: B`" from julia 0.7:
- if [ "$TRAVIS_JULIA_VERSION" = "0.7" ];
then
depwarn=yes;
else
depwarn=error;
fi
- echo "$depwarn"
- ci/test.jl --depwarn="$depwarn"

after_success:
# push coverage results to Coveralls
- julia --color=yes -e 'cd(Pkg.dir("InteractiveCodeSearch")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia --color=yes -e 'cd(Pkg.dir("InteractiveCodeSearch")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
coveralls: true
codecov: true
29 changes: 0 additions & 29 deletions ci/install.jl

This file was deleted.

10 changes: 0 additions & 10 deletions ci/test.jl

This file was deleted.

75 changes: 14 additions & 61 deletions src/InteractiveCodeSearch.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
__precompile__()

"""
# InteractiveCodeSearch.jl --- Interactively search Julia code

Expand Down Expand Up @@ -44,44 +42,17 @@ using InteractiveCodeSearch
module InteractiveCodeSearch
export @search, @searchmethods

import Pkg
using Base
using Base: IOError
using InteractiveUtils: edit, gen_call_with_extracted_types, methodswith

@static if VERSION < v"0.7-"
const IOError = Base.UVError
const Nothing = Void
const findall = find
const occursin = ismatch
const _readandwrite = readandwrite
const fetch = wait
names(x; all=false) = Base.names(x, all)
methodswith(args...; supertypes=false) =
Base.methodswith(args..., supertypes)
macro info(x)
:(info($(esc(x))))
end
macro warn(x)
:(warn($(esc(x))))
end
using Base: gen_call_with_extracted_types
@eval module Sys
function which(program::AbstractString)
try
strip(readstring(`which $program`))
catch
nothing
end
end
end # module
else
import Pkg
using Base: IOError
using InteractiveUtils: edit, gen_call_with_extracted_types, methodswith
function _readandwrite(cmds)
processes = open(cmds, "r+")
return (processes.out, processes.in, processes)
end
function _readandwrite(cmds)
processes = open(cmds, "r+")
return (processes.out, processes.in, processes)
end


abstract type SearchPolicy end
struct Shallow <: SearchPolicy end
struct Recursive <: SearchPolicy end
Expand All @@ -100,12 +71,8 @@ is_locatable(::Function) = true
is_locatable(t::Type) = !(t <: Vararg)
# https://github.com/JuliaLang/julia/issues/29645

@static if VERSION < v"0.7-"
is_defined_in(_...) = false
else
is_defined_in(child, parent) =
child !== parent && parentmodule(child) === parent
end
is_defined_in(child, parent) =
child !== parent && parentmodule(child) === parent

function list_locatables(p::SearchPolicy, m::Module)
locs = []
Expand Down Expand Up @@ -222,11 +189,6 @@ end
choose_method(methods::T) where T =
_choose_method(Base.IteratorSize(T), methods)

@static if VERSION < v"0.7-"
choose_method(methods::Union{Base.MethodList, AbstractVector}) =
_choose_method(Base.HasLength(), methods)
end

function _choose_method(::Base.HasLength, methods)
if isempty(methods)
@info "No (interesting) method found"
Expand Down Expand Up @@ -446,11 +408,7 @@ macro search(x = :ans, flag = :(:shallow))
# Examples:
# @search 1 * 2
# @search dot([], [])
if VERSION < v"0.7-"
gen_call_with_extracted_types(code_search_typed, x)
else
gen_call_with_extracted_types(__module__, code_search_typed, x)
end
gen_call_with_extracted_types(__module__, code_search_typed, x)
end

code_search_methods(T) = search_methods(methodswith(T; supertypes=true))
Expand Down Expand Up @@ -489,10 +447,7 @@ const preferred_gui = Cmd[
# what else?
]

function need_gui(stdstreams = [
(@static VERSION < v"0.7-" ? STDOUT : stdout),
(@static VERSION < v"0.7-" ? STDIN : stdin),
])
function need_gui(stdstreams = [stdout, stdin])
return !all(isa.(stdstreams, Ref(Base.TTY)))
end

Expand Down Expand Up @@ -568,10 +523,8 @@ function __init__()
maybe_warn_matcher()
end

@static if VERSION >= v"0.7-"
include("taskmanager.jl")
include("history.jl")
include("return.jl")
end
include("taskmanager.jl")
include("history.jl")
include("return.jl")

end # module
8 changes: 2 additions & 6 deletions test/preamble.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
@static if VERSION < v"0.7.0-"
using Base.Test
else
using Test
import Pkg
end
using Test
import Pkg

using InteractiveCodeSearch

Expand Down
6 changes: 2 additions & 4 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ end
@test locs >= Set(Any[ModuleA.a])
locs = Set(list_locatables(Shallow(), ModuleA.ModuleB))
@test locs >= Set(Any[ModuleA.ModuleB.b])
if VERSION >= v"0.7-"
locs = Set(list_locatables(Recursive(), ModuleA))
@test locs >= Set(Any[ModuleA.a, ModuleA.ModuleB.b])
end
locs = Set(list_locatables(Recursive(), ModuleA))
@test locs >= Set(Any[ModuleA.a, ModuleA.ModuleB.b])
end

@testset "module_methods" begin
Expand Down