Skip to content

Commit a5a8f27

Browse files
authored
chore: rename String.Range to Lean.Syntax.Range (#10852)
This PR renames `String.Range` to `Lean.Syntax.Range`, to reflect that it is not part of the standard library.
1 parent efbbb0b commit a5a8f27

File tree

21 files changed

+78
-61
lines changed

21 files changed

+78
-61
lines changed

src/Lean/Data/Lsp/Utf16.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ def leanPosToLspPos (text : FileMap) : Lean.Position → Lsp.Position
8989
def utf8PosToLspPos (text : FileMap) (pos : String.Pos.Raw) : Lsp.Position :=
9090
text.leanPosToLspPos (text.toPosition pos)
9191

92-
/-- Gets the LSP range from a `String.Range`. -/
93-
def utf8RangeToLspRange (text : FileMap) (range : String.Range) : Lsp.Range :=
92+
/-- Gets the LSP range from a `Lean.Syntax.Range`. -/
93+
def utf8RangeToLspRange (text : FileMap) (range : Lean.Syntax.Range) : Lsp.Range :=
9494
{ start := text.utf8PosToLspPos range.start, «end» := text.utf8PosToLspPos range.stop }
9595

9696
/-- Gets the LSP range of syntax `stx`. -/
9797
def lspRangeOfStx? (text : FileMap) (stx : Syntax) (canonicalOnly := false) : Option Lsp.Range :=
9898
text.utf8RangeToLspRange <$> stx.getRange? canonicalOnly
9999

100-
def lspRangeToUtf8Range (text : FileMap) (range : Lsp.Range) : String.Range :=
100+
def lspRangeToUtf8Range (text : FileMap) (range : Lsp.Range) : Lean.Syntax.Range :=
101101
{ start := text.lspPosToUtf8Pos range.start, stop := text.lspPosToUtf8Pos range.end }
102102

103103
end FileMap

src/Lean/DocString/Links.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ environment variable. If this environment variable is not set, a manual root pro
100100
built is used (typically this is the version corresponding to the current release). If no such root
101101
is available, the latest version of the manual is used.
102102
-/
103-
def rewriteManualLinksCore (s : String) : BaseIO (Array (String.Range × String) × String) := do
103+
def rewriteManualLinksCore (s : String) : BaseIO (Array (Lean.Syntax.Range × String) × String) := do
104104
let scheme := "lean-manual://"
105105
let mut out := ""
106106
let mut errors := #[]

src/Lean/Elab/DocString/Builtin.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private def onlyCode [Monad m] [MonadError m] (xs : TSyntaxArray `inline) : m St
122122
else
123123
throwError "Expected precisely 1 code argument"
124124

125-
private def strLitRange [Monad m] [MonadFileMap m] (s : StrLit) : m String.Range := do
125+
private def strLitRange [Monad m] [MonadFileMap m] (s : StrLit) : m Lean.Syntax.Range := do
126126
let pos := (s.raw.getPos? (canonicalOnly := true)).get!
127127
let endPos := s.raw.getTailPos? true |>.get!
128128
return ⟨pos, endPos⟩

src/Lean/Elab/DocString/Builtin/Parsing.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ open Lean.Parser
1313

1414
public section
1515

16-
private def strLitRange [Monad m] [MonadFileMap m] (s : StrLit) : m String.Range := do
16+
private def strLitRange [Monad m] [MonadFileMap m] (s : StrLit) : m Lean.Syntax.Range := do
1717
let pos := (s.raw.getPos? (canonicalOnly := true)).get!
1818
let endPos := s.raw.getTailPos? true |>.get!
1919
return ⟨pos, endPos⟩

src/Lean/Elab/InfoTree/InlayHints.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ open Lean
1616

1717
structure InlayHintLinkLocation where
1818
module : Name
19-
range : String.Range
19+
range : Lean.Syntax.Range
2020

2121
structure InlayHintLabelPart where
2222
value : String
@@ -32,7 +32,7 @@ inductive InlayHintKind where
3232
| parameter
3333

3434
structure InlayHintTextEdit where
35-
range : String.Range
35+
range : Lean.Syntax.Range
3636
newText : String
3737
deriving BEq
3838

src/Lean/Language/Basic.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ inductive SnapshotTask.ReportingRange where
7474
/-- Inherit range from outer task if any, or else the entire file. -/
7575
| inherit
7676
/-- Use given range. -/
77-
| protected some (range : String.Range)
77+
| protected some (range : Lean.Syntax.Range)
7878
/-- Do not mark as being processed. Child nodes are still visited. -/
7979
| skip
8080
deriving Inhabited
@@ -83,7 +83,7 @@ deriving Inhabited
8383
Constructs a reporting range by replacing a missing range with `inherit`, which is a reasonable
8484
default to ensure that a range is shown in all cases.
8585
-/
86-
def SnapshotTask.ReportingRange.ofOptionInheriting : Option String.Range → SnapshotTask.ReportingRange
86+
def SnapshotTask.ReportingRange.ofOptionInheriting : Option Lean.Syntax.Range → SnapshotTask.ReportingRange
8787
| some range => .some range
8888
| none => .inherit
8989

src/Lean/Linter/ConstructorAsVariable.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def constructorNameAsVariable : Linter where
3838
| return
3939

4040
let infoTrees := (← get).infoState.trees.toArray
41-
let warnings : IO.Ref (Std.HashMap String.Range (Syntax × Name × Name)) ← IO.mkRef {}
41+
let warnings : IO.Ref (Std.HashMap Lean.Syntax.Range (Syntax × Name × Name)) ← IO.mkRef {}
4242

4343
for tree in infoTrees do
4444
tree.visitM' (postNode := fun ci info _ => do

src/Lean/Linter/UnusedSimpArgs.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def unusedSimpArgs : Linter where
4646
let some cmdStxRange := cmdStx.getRange? | return
4747

4848
let infoTrees := (← get).infoState.trees.toArray
49-
let masksMap : IO.Ref (Std.HashMap String.Range (Syntax × Array Bool)) ← IO.mkRef {}
49+
let masksMap : IO.Ref (Std.HashMap Lean.Syntax.Range (Syntax × Array Bool)) ← IO.mkRef {}
5050

5151
for tree in infoTrees do
5252
tree.visitM' (postNode := fun ci info _ => do

src/Lean/Linter/UnusedVariables.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ structure References where
369369
the spans for `foo`, `bar`, and `baz`. Global definitions are always treated as used.
370370
(It would be nice to be able to detect unused global definitions but this requires more
371371
information than the linter framework can provide.) -/
372-
constDecls : Std.HashSet String.Range := ∅
372+
constDecls : Std.HashSet Lean.Syntax.Range := ∅
373373
/-- The collection of all local declarations, organized by the span of the declaration.
374374
We collapse all declarations declared at the same position into a single record using
375375
`FVarDefinition.aliases`. -/
376-
fvarDefs : Std.HashMap String.Range FVarDefinition := ∅
376+
fvarDefs : Std.HashMap Lean.Syntax.Range FVarDefinition := ∅
377377
/-- The set of `FVarId`s that are used directly. These may or may not be aliases. -/
378378
fvarUses : Std.HashSet FVarId := ∅
379379
/-- A mapping from alias to original FVarId. We don't guarantee that the value is not itself
@@ -386,7 +386,7 @@ structure References where
386386

387387
/-- Collect information from the `infoTrees` into `References`.
388388
See `References` for more information about the return value. -/
389-
partial def collectReferences (infoTrees : Array Elab.InfoTree) (cmdStxRange : String.Range)
389+
partial def collectReferences (infoTrees : Array Elab.InfoTree) (cmdStxRange : Lean.Syntax.Range)
390390
(linterSets : LinterSets) :
391391
StateRefT References IO Unit := ReaderT.run (r := false) <| go infoTrees none
392392
where

src/Lean/Linter/Util.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The result is `some []` if no `MacroExpansionInfo` was found on the way and
2222
2323
Return the result reversed, s.t. the macro expansion that would be applied to
2424
the original syntax first is the first element of the returned list. -/
25-
def collectMacroExpansions? {m} [Monad m] (range : String.Range) (tree : Elab.InfoTree) : m <| Option <| List Elab.MacroExpansionInfo := do
25+
def collectMacroExpansions? {m} [Monad m] (range : Lean.Syntax.Range) (tree : Elab.InfoTree) : m <| Option <| List Elab.MacroExpansionInfo := do
2626
if let .some <| .some result ← go then
2727
return some result.reverse
2828
else

0 commit comments

Comments
 (0)