-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6b4849
commit 29e3c26
Showing
14 changed files
with
90 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
import ImportGraph.Cli | ||
import ImportGraph.Imports | ||
import ImportGraph.Lean.List | ||
import ImportGraph.Lean.NameMap | ||
import ImportGraph.Lean.Process | ||
import ImportGraph.Lean.TermUnsafe | ||
import ImportGraph.Name | ||
import ImportGraph.CurrentModule | ||
import ImportGraph.Lean.Name | ||
import ImportGraph.RequiredModules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/- | ||
Copyright (c) 2023 Jon Eugster. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Jon Eugster | ||
-/ | ||
import Lean.Data.Name | ||
import Lean.CoreM | ||
import Std.Data.HashMap.Basic | ||
import Std.Lean.Name | ||
import Std.Lean.SMap | ||
|
||
namespace Lean.Name | ||
|
||
open Lean Meta Elab | ||
open Std | ||
|
||
/-- Note: copied from `Mathlib.Lean.Name` -/ | ||
private def isBlackListed (declName : Name) : CoreM Bool := do | ||
if declName.toString.startsWith "Lean" then return true | ||
let env ← getEnv | ||
pure $ declName.isInternalDetail | ||
|| isAuxRecursor env declName | ||
|| isNoConfusion env declName | ||
<||> isRec declName <||> isMatcher declName | ||
|
||
/-- | ||
Retrieve all names in the environment satisfying a predicate. | ||
Note: copied from `Mathlib.Lean.Name` | ||
-/ | ||
def allNames (p : Name → Bool) : CoreM (Array Name) := do | ||
(← getEnv).constants.foldM (init := #[]) fun names n _ => do | ||
if p n && !(← isBlackListed n) then | ||
return names.push n | ||
else | ||
return names | ||
|
||
/-- | ||
Retrieve all names in the environment satisfying a predicate, | ||
gathered together into a `HashMap` according to the module they are defined in. | ||
Note: copied from `Mathlib.Lean.Name` | ||
-/ | ||
def allNamesByModule (p : Name → Bool) : CoreM (Std.HashMap Name (Array Name)) := do | ||
(← getEnv).constants.foldM (init := Std.HashMap.empty) fun names n _ => do | ||
if p n && !(← isBlackListed n) then | ||
let some m ← findModuleOf? n | return names | ||
-- TODO use `Std.HashMap.modify` when we bump Std4 (or `alter` if that is written). | ||
match names.find? m with | ||
| some others => return names.insert m (others.push n) | ||
| none => return names.insert m #[n] | ||
else | ||
return names | ||
|
||
/-- Returns the very first part of a name: for `ImportGraph.Lean.NameMap` it | ||
returns `ImportGraph`. | ||
-/ | ||
def getModule (name : Name) (s := "") : Name := | ||
match name with | ||
| .anonymous => s | ||
| .num _ _ => panic s!"panic in `getModule`: did not expect numerical name: {name}." | ||
| .str pre s => getModule pre s |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.