Skip to content

Commit

Permalink
[SERVER] Nested hovers
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyTy committed Jun 21, 2024
1 parent 5085724 commit 5f237ff
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions source/server.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,10 @@ class Server {
}
}

// TODO cache access to `typecheckProject.data`
fun checkNode(node Node) {
switch node {
case Class(className, extend, implement, fields, external, kind):
// TODO instead of slow `NodeType.stringify` just extact string value of name
// TODO instead of slow `NodeType.stringify` just extract string value of name
var width = 'class '.length + NodeType.stringify(className).length
let data: NodeData? = typecheckProject.data.get(node)
if let data = data {
Expand Down Expand Up @@ -325,6 +324,40 @@ class Server {
checkNode(initializer)
}

case While(reason, e, pre):
checkNode(reason)
checkNode(e)

case If(condition, then, otherwise, ternary):
// TODO
if let initializer = condition[0] {
checkNode(initializer)
}
checkNode(then)
if let initializer = otherwise {
checkNode(initializer)
}

case For(iterator, over, statement, range):
checkNode(over)
checkNode(statement)
if let initializer = range {
checkNode(initializer)
}

case Call(e, args, argNames):
// TODO hover on ()
checkNode(e)
for arg in args {
// TODO argNames too
checkNode(arg)
}

case Binop(left, op, right):
// TODO hover on op (span is between left.xy and right.xy)
checkNode(left)
checkNode(right)

case Block(el):
var width = '{}'.length
let data: NodeData? = typecheckProject.data.get(node)
Expand All @@ -336,8 +369,14 @@ class Server {
checkNode(e)
}

case Switch(inputs, expressions, guards, patterns):
for e in patterns {
checkNode(e)
}

case _:
var width = Node.stringify(node).length
// TODO use Map syntax `data[node]`
let data: NodeData? = typecheckProject.data.get(node)
if let data = data {
checkSpan({y:data.line,x:data.column,xx:data.column + width,yy:data.line}, node)
Expand Down Expand Up @@ -374,6 +413,8 @@ class Server {
// TODO docs etc
code = 'var ' + name
case Ident(name, params /* TODO */):
// TODO
code = Node.stringify(nearest)
if let parent = main.typecheckProjectTyper.parents.get(nearest) {
switch parent {
case Var(name, _, _, const):
Expand All @@ -393,6 +434,9 @@ class Server {
+ '](:' + line + ')'
typeOf = null
}
} else {
// TODO
code = Node.stringify(nearest)
}
case Bool(value):
// TODO BOOl doc
Expand Down

0 comments on commit 5f237ff

Please sign in to comment.