@@ -84,10 +84,10 @@ instance : Language.ToSnapshotTree HeaderProcessedSnapshot where
84
84
/-- State before elaboration of a mutual definition. -/
85
85
structure DefParsed where
86
86
/--
87
- Input substring uniquely identifying header elaboration result given the same `Environment`.
88
- If missing, results should never be reused .
87
+ Unstructured syntax object comprising the full "header" of the definition from the modifiers
88
+ (incl. docstring) up to the value, used for determining header elaboration reuse .
89
89
-/
90
- headerSubstr? : Option Substring
90
+ fullHeaderRef : Syntax
91
91
/-- Elaboration result, unless fatal exception occurred. -/
92
92
headerProcessedSnap : SnapshotTask (Option HeaderProcessedSnapshot)
93
93
deriving Nonempty
@@ -106,6 +106,11 @@ end Snapshots
106
106
structure DefView where
107
107
kind : DefKind
108
108
ref : Syntax
109
+ /--
110
+ An unstructured syntax object that comprises the "header" of the definition, i.e. everything up
111
+ to the value. Used as a more specific ref for header elaboration.
112
+ -/
113
+ headerRef : Syntax
109
114
modifiers : Modifiers
110
115
declId : Syntax
111
116
binders : Syntax
@@ -132,20 +137,20 @@ def mkDefViewOfAbbrev (modifiers : Modifiers) (stx : Syntax) : DefView :=
132
137
let (binders, type) := expandOptDeclSig stx[2 ]
133
138
let modifiers := modifiers.addAttribute { name := `inline }
134
139
let modifiers := modifiers.addAttribute { name := `reducible }
135
- { ref := stx, kind := DefKind.abbrev, modifiers,
140
+ { ref := stx, headerRef := mkNullNode stx.getArgs[: 3 ], kind := DefKind.abbrev, modifiers,
136
141
declId := stx[1 ], binders, type? := type, value := stx[3 ] }
137
142
138
143
def mkDefViewOfDef (modifiers : Modifiers) (stx : Syntax) : DefView :=
139
144
-- leading_parser "def " >> declId >> optDeclSig >> declVal >> optDefDeriving
140
145
let (binders, type) := expandOptDeclSig stx[2 ]
141
146
let deriving ? := if stx[4 ].isNone then none else some stx[4 ][1 ].getSepArgs
142
- { ref := stx, kind := DefKind.def, modifiers,
147
+ { ref := stx, headerRef := mkNullNode stx.getArgs[: 3 ], kind := DefKind.def, modifiers,
143
148
declId := stx[1 ], binders, type? := type, value := stx[3 ], deriving ? }
144
149
145
150
def mkDefViewOfTheorem (modifiers : Modifiers) (stx : Syntax) : DefView :=
146
151
-- leading_parser "theorem " >> declId >> declSig >> declVal
147
152
let (binders, type) := expandDeclSig stx[2 ]
148
- { ref := stx, kind := DefKind.theorem, modifiers,
153
+ { ref := stx, headerRef := mkNullNode stx.getArgs[: 3 ], kind := DefKind.theorem, modifiers,
149
154
declId := stx[1 ], binders, type? := some type, value := stx[3 ] }
150
155
151
156
def mkDefViewOfInstance (modifiers : Modifiers) (stx : Syntax) : CommandElabM DefView := do
@@ -166,7 +171,7 @@ def mkDefViewOfInstance (modifiers : Modifiers) (stx : Syntax) : CommandElabM De
166
171
trace[Elab.instance.mkInstanceName] "generated {(← getCurrNamespace) ++ id}"
167
172
pure <| mkNode ``Parser.Command.declId #[mkIdentFrom stx id, mkNullNode]
168
173
return {
169
- ref := stx, kind := DefKind.def, modifiers := modifiers,
174
+ ref := stx, headerRef := mkNullNode stx.getArgs[: 5 ], kind := DefKind.def, modifiers := modifiers,
170
175
declId := declId, binders := binders, type? := type, value := stx[5 ]
171
176
}
172
177
@@ -179,7 +184,7 @@ def mkDefViewOfOpaque (modifiers : Modifiers) (stx : Syntax) : CommandElabM DefV
179
184
let val ← if modifiers.isUnsafe then `(default_or_ofNonempty% unsafe ) else `(default_or_ofNonempty%)
180
185
`(Parser.Command.declValSimple| := $val)
181
186
return {
182
- ref := stx, kind := DefKind.opaque, modifiers := modifiers,
187
+ ref := stx, headerRef := mkNullNode stx.getArgs[: 3 ], kind := DefKind.opaque, modifiers := modifiers,
183
188
declId := stx[1 ], binders := binders, type? := some type, value := val
184
189
}
185
190
@@ -188,7 +193,7 @@ def mkDefViewOfExample (modifiers : Modifiers) (stx : Syntax) : DefView :=
188
193
let (binders, type) := expandOptDeclSig stx[1 ]
189
194
let id := mkIdentFrom stx `_example
190
195
let declId := mkNode ``Parser.Command.declId #[id, mkNullNode]
191
- { ref := stx, kind := DefKind.example, modifiers := modifiers,
196
+ { ref := stx, headerRef := mkNullNode stx.getArgs[: 2 ], kind := DefKind.example, modifiers := modifiers,
192
197
declId := declId, binders := binders, type? := type, value := stx[2 ] }
193
198
194
199
def isDefLike (stx : Syntax) : Bool :=
0 commit comments