cleaned up
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package index
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/marte-dev/marte-dev-tools/internal/parser"
|
||||
@@ -319,7 +321,9 @@ type QueryResult struct {
|
||||
}
|
||||
|
||||
func (pt *ProjectTree) Query(file string, line, col int) *QueryResult {
|
||||
fmt.Fprintf(os.Stderr, "File: %s:%d:%d\n", file, line, col)
|
||||
for i := range pt.References {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", pt.Root.Name)
|
||||
ref := &pt.References[i]
|
||||
if ref.File == file {
|
||||
if line == ref.Position.Line && col >= ref.Position.Column && col < ref.Position.Column+len(ref.Name) {
|
||||
|
||||
@@ -148,9 +148,16 @@ func handleMessage(msg *JsonRpcMessage) {
|
||||
case "textDocument/hover":
|
||||
var params HoverParams
|
||||
if err := json.Unmarshal(msg.Params, ¶ms); err == nil {
|
||||
fmt.Fprintf(os.Stderr, "Hover: %s:%d\n", params.TextDocument.URI, params.Position.Line)
|
||||
res := handleHover(params)
|
||||
if res != nil {
|
||||
fmt.Fprintf(os.Stderr, "Res: %v\n", res.Contents)
|
||||
} else {
|
||||
fmt.Fprint(os.Stderr, "Res: NIL\n")
|
||||
}
|
||||
respond(msg.ID, res)
|
||||
} else {
|
||||
fmt.Fprint(os.Stderr, "not recovered hover parameters\n")
|
||||
respond(msg.ID, nil)
|
||||
}
|
||||
}
|
||||
@@ -191,6 +198,7 @@ func handleHover(params HoverParams) *Hover {
|
||||
|
||||
res := tree.Query(path, line, col)
|
||||
if res == nil {
|
||||
fmt.Fprint(os.Stderr, "No object/node/reference found\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
## CLI Commands
|
||||
|
||||
The executable should support the following subcommands:
|
||||
|
||||
- `lsp`: Starts the Language Server Protocol server.
|
||||
- `build`: Merges files with the same base namespace into a single output.
|
||||
- `check`: Runs diagnostics and validations on the configuration files.
|
||||
@@ -18,6 +19,7 @@ The executable should support the following subcommands:
|
||||
## LSP Features
|
||||
|
||||
The LSP server should provide the following capabilities:
|
||||
|
||||
- **Diagnostics**: Report syntax errors and validation issues.
|
||||
- **Hover Documentation**:
|
||||
- **Objects**: Display `CLASS::Name` and any associated docstrings.
|
||||
@@ -73,7 +75,7 @@ The LSP server should provide the following capabilities:
|
||||
### Semantics
|
||||
|
||||
- **Nodes (`+` / `$`)**: The prefixes `+` and `$` indicate that the node represents an object.
|
||||
- **Constraint**: These nodes *must* contain a field named `Class` within their subnode definition.
|
||||
- **Constraint**: These nodes _must_ contain a field named `Class` within their subnode definition.
|
||||
- **Signals**: Signals are considered nodes but **not** objects. They do not require a `Class` field.
|
||||
- **Pragmas (`//!`)**: Used to suppress specific diagnostics. The developer can use these to explain why a rule is being ignored.
|
||||
- **Structure**: A configuration is composed by one or more definitions.
|
||||
@@ -81,6 +83,7 @@ The LSP server should provide the following capabilities:
|
||||
### Core MARTe Classes
|
||||
|
||||
MARTe configurations typically involve several main categories of objects:
|
||||
|
||||
- **State Machine (`StateMachine`)**: Defines state machines and transition logic.
|
||||
- **Real-Time Application (`RealTimeApplication`)**: Defines a real-time application, including its data sources, functions, states, and scheduler.
|
||||
- **Data Source**: Multiple classes used to define input and/or output signal sources.
|
||||
@@ -122,6 +125,7 @@ MARTe configurations typically involve several main categories of objects:
|
||||
### Object Indexing & References
|
||||
|
||||
The tool must build an index of the configuration to support LSP features and validations:
|
||||
|
||||
- **GAMs**: Referenced in `$APPLICATION.States.$STATE_NAME.Threads.$THREAD_NAME.Functions` (where `$APPLICATION` is a `RealTimeApplication` node).
|
||||
- **Signals**: Referenced within the `InputSignals` and `OutputSignals` sub-nodes of a GAM.
|
||||
- **DataSources**: Referenced within the `DataSource` field of a signal reference/definition.
|
||||
@@ -146,6 +150,7 @@ The tool must build an index of the configuration to support LSP features and va
|
||||
### Formatting Rules
|
||||
|
||||
The `fmt` command must format the code according to the following rules:
|
||||
|
||||
- **Indentation**: 2 spaces per indentation level.
|
||||
- **Assignment**: 1 space before and after the `=` operator (e.g., `Field = Value`).
|
||||
- **Comments**:
|
||||
|
||||
Reference in New Issue
Block a user