summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar FrigoEU <simon.van.casteren@gmail.com>2019-08-01 09:57:46 +0200
committerGravatar FrigoEU <simon.van.casteren@gmail.com>2019-08-01 09:57:46 +0200
commit9e2b026fea11ae89a53d4fc1c674ef8e43b2c2ce (patch)
tree71528a1c22330d42f3b4de83b0579728438605c4
parent80e7bb6165a5ad6517b35f301228f56b58eef39c (diff)
Added file check to typeOf and always add Top and Basis to env in typeOf
-rw-r--r--src/compiler.sml22
-rw-r--r--src/mod_db.sml7
2 files changed, 18 insertions, 11 deletions
diff --git a/src/compiler.sml b/src/compiler.sml
index 46a035ee..51cf20e1 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -1781,11 +1781,13 @@ fun moduleOf fname =
end
end
-fun isPosIn row col span =
+fun isPosIn file row col span =
let
val start = #first span
val end_ = #last span
in
+ (String.isSuffix file (#file span))
+ andalso
((#line start < row) orelse
(#line start = row) andalso (#char start <= col))
andalso
@@ -1827,10 +1829,10 @@ fun getTypeAt file row col =
NONE => Print.PD.string ("ERROR: No module found: " ^ moduleOf file)
| SOME (decl, deps) =>
let
- (* TODO Top is not always found as a dep *)
val () = ElabUtilPos.mliftConInCon := ElabEnv.mliftConInCon
(* Adding dependencies to environment *)
- val env = List.foldl (fn (d, e) => ElabEnv.declBinds e d)
+ val env = List.foldl (fn (d, e) =>
+ ElabEnv.declBinds e d)
ElabEnv.empty
deps
(* Adding previous declarations to environment *)
@@ -1850,31 +1852,31 @@ fun getTypeAt file row col =
val (atPosition, env) =
ElabUtilPos.Decl.foldB
{ kind = fn (env, (k, span), acc) =>
- if isPosIn row col span andalso isSmallerThan span (getSpan acc)
+ if isPosIn file row col span andalso isSmallerThan span (getSpan acc)
then (Kind (k, span), env)
else acc ,
con = fn (env, (k, span), acc) =>
- if isPosIn row col span andalso isSmallerThan span (getSpan acc)
+ if isPosIn file row col span andalso isSmallerThan span (getSpan acc)
then (Con (k, span), env)
else acc,
exp = fn (env, (k, span), acc) =>
- if isPosIn row col span andalso isSmallerThan span (getSpan acc)
+ if isPosIn file row col span andalso isSmallerThan span (getSpan acc)
then (Exp (k, span), env)
else acc,
sgn_item = fn (env, (k, span), acc) =>
- if isPosIn row col span andalso isSmallerThan span (getSpan acc)
+ if isPosIn file row col span andalso isSmallerThan span (getSpan acc)
then (Sgn_item (k, span), env)
else acc,
sgn = fn (env, (k, span), acc) =>
- if isPosIn row col span andalso isSmallerThan span (getSpan acc)
+ if isPosIn file row col span andalso isSmallerThan span (getSpan acc)
then (Sgn (k, span), env)
else acc,
str = fn (env, (k, span), acc) =>
- if isPosIn row col span andalso isSmallerThan span (getSpan acc)
+ if isPosIn file row col span andalso isSmallerThan span (getSpan acc)
then (Str (k, span), env)
else acc,
decl = fn (env, (k, span), acc) =>
- if isPosIn row col span andalso isSmallerThan span (getSpan acc)
+ if isPosIn file row col span andalso isSmallerThan span (getSpan acc)
then (Decl (k, span), env)
else acc,
bind = fn (env, binder) =>
diff --git a/src/mod_db.sml b/src/mod_db.sml
index fdf6d5ab..57d85195 100644
--- a/src/mod_db.sml
+++ b/src/mod_db.sml
@@ -214,7 +214,12 @@ fun lookupForTooling name =
SOME (#Decl m, List.map (fn a => #Decl a)
(List.mapPartial
(fn d => SM.find (!byName, d))
- (SS.listItems (#Deps m))))
+ (* Clumsy way of adding Basis and Top without adding doubles *)
+ (["Basis", "Top"]
+ @
+ (List.filter
+ (fn x => x <> "Basis" andalso x <> "Top")
+ (SS.listItems (#Deps m))))))
val byNameBackup = ref (!byName)
val byIdBackup = ref (!byId)