minor improvment in the hover doc
This commit is contained in:
@@ -192,11 +192,13 @@ func handleMessage(msg *JsonRpcMessage) {
|
|||||||
} else if params.RootPath != "" {
|
} else if params.RootPath != "" {
|
||||||
root = params.RootPath
|
root = params.RootPath
|
||||||
}
|
}
|
||||||
|
|
||||||
if root != "" {
|
if root != "" {
|
||||||
projectRoot = root
|
projectRoot = root
|
||||||
logger.Printf("Scanning workspace: %s\n", root)
|
logger.Printf("Scanning workspace: %s\n", root)
|
||||||
tree.ScanDirectory(root)
|
if err := tree.ScanDirectory(root); err != nil {
|
||||||
|
logger.Printf("ScanDirectory failed: %v\n", err)
|
||||||
|
}
|
||||||
tree.ResolveReferences()
|
tree.ResolveReferences()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,11 +337,11 @@ func runValidation(uri string) {
|
|||||||
|
|
||||||
// Group diagnostics by file
|
// Group diagnostics by file
|
||||||
fileDiags := make(map[string][]LSPDiagnostic)
|
fileDiags := make(map[string][]LSPDiagnostic)
|
||||||
|
|
||||||
// Collect all known files to ensure we clear diagnostics for fixed files
|
// Collect all known files to ensure we clear diagnostics for fixed files
|
||||||
knownFiles := make(map[string]bool)
|
knownFiles := make(map[string]bool)
|
||||||
collectFiles(tree.Root, knownFiles)
|
collectFiles(tree.Root, knownFiles)
|
||||||
|
|
||||||
// Initialize all known files with empty diagnostics
|
// Initialize all known files with empty diagnostics
|
||||||
for f := range knownFiles {
|
for f := range knownFiles {
|
||||||
fileDiags[f] = []LSPDiagnostic{}
|
fileDiags[f] = []LSPDiagnostic{}
|
||||||
@@ -360,7 +362,7 @@ func runValidation(uri string) {
|
|||||||
Message: d.Message,
|
Message: d.Message,
|
||||||
Source: "mdt",
|
Source: "mdt",
|
||||||
}
|
}
|
||||||
|
|
||||||
path := d.File
|
path := d.File
|
||||||
if path != "" {
|
if path != "" {
|
||||||
fileDiags[path] = append(fileDiags[path], diag)
|
fileDiags[path] = append(fileDiags[path], diag)
|
||||||
@@ -373,7 +375,7 @@ func runValidation(uri string) {
|
|||||||
notification := JsonRpcMessage{
|
notification := JsonRpcMessage{
|
||||||
Jsonrpc: "2.0",
|
Jsonrpc: "2.0",
|
||||||
Method: "textDocument/publishDiagnostics",
|
Method: "textDocument/publishDiagnostics",
|
||||||
Params: mustMarshal(PublishDiagnosticsParams{
|
Params: mustMarshal(PublishDiagnosticsParams{
|
||||||
URI: fileURI,
|
URI: fileURI,
|
||||||
Diagnostics: diags,
|
Diagnostics: diags,
|
||||||
}),
|
}),
|
||||||
@@ -412,7 +414,7 @@ func publishParserError(uri string, err error) {
|
|||||||
notification := JsonRpcMessage{
|
notification := JsonRpcMessage{
|
||||||
Jsonrpc: "2.0",
|
Jsonrpc: "2.0",
|
||||||
Method: "textDocument/publishDiagnostics",
|
Method: "textDocument/publishDiagnostics",
|
||||||
Params: mustMarshal(PublishDiagnosticsParams{
|
Params: mustMarshal(PublishDiagnosticsParams{
|
||||||
URI: uri,
|
URI: uri,
|
||||||
Diagnostics: []LSPDiagnostic{diag},
|
Diagnostics: []LSPDiagnostic{diag},
|
||||||
}),
|
}),
|
||||||
@@ -602,13 +604,12 @@ func handleReferences(params ReferenceParams) []Location {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func formatNodeInfo(node *index.ProjectNode) string {
|
func formatNodeInfo(node *index.ProjectNode) string {
|
||||||
class := node.Metadata["Class"]
|
info := ""
|
||||||
if class == "" {
|
if class := node.Metadata["Class"]; class != "" {
|
||||||
class = "Unknown"
|
info = fmt.Sprintf("`%s:%s`\n\n", class, node.RealName[1:])
|
||||||
|
} else {
|
||||||
|
info = fmt.Sprintf("`%s`\n\n", node.RealName)
|
||||||
}
|
}
|
||||||
|
|
||||||
info := fmt.Sprintf("**Object**: `%s`\n\n**Class**: `%s`", node.RealName, class)
|
|
||||||
|
|
||||||
// Check if it's a Signal (has Type or DataSource)
|
// Check if it's a Signal (has Type or DataSource)
|
||||||
typ := node.Metadata["Type"]
|
typ := node.Metadata["Type"]
|
||||||
ds := node.Metadata["DataSource"]
|
ds := node.Metadata["DataSource"]
|
||||||
@@ -700,4 +701,4 @@ func respond(id any, result any) {
|
|||||||
func send(msg any) {
|
func send(msg any) {
|
||||||
body, _ := json.Marshal(msg)
|
body, _ := json.Marshal(msg)
|
||||||
fmt.Printf("Content-Length: %d\r\n\r\n%s", len(body), body)
|
fmt.Printf("Content-Length: %d\r\n\r\n%s", len(body), body)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user