Skip to content

Commit

Permalink
[SERVER] Drop old hover provider
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyTy committed Jun 21, 2024
1 parent 62b8f0d commit 5085724
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 26 deletions.
3 changes: 2 additions & 1 deletion source/data/nodes.hexa
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// The Hexa Compiler
// Copyright (C) 2021-2023 Oleh Petrenko
// Copyright (C) 2021-2024 Oleh Petrenko
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
Expand All @@ -14,6 +14,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

/// Node position info
// TODO rename to NodePosition or NodeSpan or NodeAt
class NodeData {
new (atLine, atColumn, atFile) {
line = atLine
Expand Down
3 changes: 2 additions & 1 deletion source/data/project.hexa
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// The Hexa Compiler
// Copyright (C) 2021-2022 Oleh Petrenko
// Copyright (C) 2021-2024 Oleh Petrenko
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -32,6 +32,7 @@ class Project {
let typeDecorators: [NodeType : [Decorator]] = [:]
let mapNames: [Node : Node] = [:]
let mapModules: [Node : Module] = [:]
// TODO rename to spans or at or span
let data: [Node : NodeData] = [:]
let hints: [Hint] = []
// TODO Defines to Map Enums Bool String Int Float in the Project
Expand Down
28 changes: 4 additions & 24 deletions source/server.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class Server {
continue
}

var nearest: Node? = null // mod.nodes[0]
var nearest: Node? = null

// TODO not object, just args
fun checkSpan(span Any, node Node) {
Expand All @@ -268,9 +268,11 @@ 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
var width = 'class '.length + NodeType.stringify(className).length
let data: NodeData? = typecheckProject.data.get(node)
if let data = data {
Expand Down Expand Up @@ -324,7 +326,7 @@ class Server {
}

case Block(el):
var width = 2 //'fun '.length + (name ?? '').length
var width = '{}'.length
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 All @@ -347,28 +349,6 @@ class Server {
checkNode(node)
// TODO break when last span yy > line
}
var nearest: Node? = null // mod.nodes[0]
for node in mod.nodes {
let data: NodeData? = typecheckProject.data.get(node)
if let data = data {
var offset = 0
var width = 0

switch node {
case Class(t, _):
width = 'class '.length + NodeType.stringify(t).length
}

if
line == data.line,
character >= data.column + offset,
character < data.column + offset + width
{
nearest = node
break
}
}
}

// TODO support hover over decorators
if let nearest = nearest {
Expand Down

0 comments on commit 5085724

Please sign in to comment.