@@ -11,6 +11,7 @@ import (
11
11
"github.com/DDP-Projekt/DDPLS/log"
12
12
"github.com/DDP-Projekt/Kompilierer/src/ast"
13
13
"github.com/DDP-Projekt/Kompilierer/src/ddppath"
14
+ "github.com/DDP-Projekt/Kompilierer/src/ddptypes"
14
15
"github.com/DDP-Projekt/Kompilierer/src/token"
15
16
"github.com/tliron/glsp"
16
17
protocol "github.com/tliron/glsp/protocol_3_16"
@@ -190,16 +191,50 @@ func (h *hoverVisitor) VisitStructLiteral(e *ast.StructLiteral) ast.VisitResult
190
191
191
192
// TODO: list all public decls
192
193
func (h * hoverVisitor ) VisitImportStmt (stmt * ast.ImportStmt ) ast.VisitResult {
193
- if stmt .Module == nil || stmt . Module . Comment == nil {
194
+ if stmt .Module == nil {
194
195
return ast .VisitBreak
195
196
}
196
197
197
- comment := trimComment (stmt .Module .Comment )
198
+ comment := getCommentDisplayString (stmt .Module .Comment )
199
+
200
+ variableSection := strings.Builder {}
201
+ functionSection := strings.Builder {}
202
+ structSection := strings.Builder {}
203
+
204
+ for _ , decl := range stmt .Module .PublicDecls {
205
+ switch decl := decl .(type ) {
206
+ case * ast.VarDecl :
207
+ switch decl .Type .Gender () {
208
+ case ddptypes .MASKULIN :
209
+ variableSection .WriteString ("Den " )
210
+ case ddptypes .FEMININ :
211
+ variableSection .WriteString ("Die " )
212
+ case ddptypes .NEUTRUM :
213
+ variableSection .WriteString ("Das " )
214
+ }
215
+
216
+ variableSection .WriteString (decl .Type .String () + " " + decl .Name () + ".\n " )
217
+ case * ast.FuncDecl :
218
+ functionSection .WriteString (fmt .Sprintf ("Die Funktion %s.\n " , decl .Name ()))
219
+ case * ast.StructDecl :
220
+ structSection .WriteString (fmt .Sprintf ("Die Kombination %s.\n " , decl .Name ()))
221
+ }
222
+ }
223
+
224
+ result := fmt .Sprintf (
225
+ "%s\n \n %s deklariert:\n \n ```ddp\n %s\n %s\n %s\n ```\n " ,
226
+ comment ,
227
+ h .getHoverFilePath (stmt .Module .FileName ),
228
+ structSection .String (),
229
+ variableSection .String (),
230
+ functionSection .String (),
231
+ )
232
+
198
233
pRange := helper .ToProtocolRange (stmt .GetRange ())
199
234
h .hover = & protocol.Hover {
200
235
Contents : protocol.MarkupContent {
201
- Kind : protocol .MarkupKindPlainText ,
202
- Value : comment ,
236
+ Kind : protocol .MarkupKindMarkdown ,
237
+ Value : result ,
203
238
},
204
239
Range : & pRange ,
205
240
}
0 commit comments