mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
94 lines
2.5 KiB
Go
94 lines
2.5 KiB
Go
package analyzer
|
|
|
|
import (
|
|
"config-lsp/common"
|
|
"config-lsp/handlers/fstab/ast"
|
|
|
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
|
)
|
|
|
|
func analyzeFieldAreFilled(
|
|
ctx *analyzerContext,
|
|
) {
|
|
it := ctx.document.Config.Entries.Iterator()
|
|
for it.Next() {
|
|
entry := it.Value().(*ast.FstabEntry)
|
|
|
|
if entry.Fields.Spec == nil || entry.Fields.Spec.Value.Value == "" {
|
|
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
|
Range: protocol.Range{
|
|
Start: protocol.Position{
|
|
Line: entry.Fields.Start.Line,
|
|
Character: 0,
|
|
},
|
|
End: protocol.Position{
|
|
Line: entry.Fields.Start.Line,
|
|
Character: 0,
|
|
},
|
|
},
|
|
Message: "The spec field is missing",
|
|
Severity: &common.SeverityError,
|
|
})
|
|
|
|
continue
|
|
}
|
|
|
|
if entry.Fields.MountPoint == nil || entry.Fields.MountPoint.Value.Value == "" {
|
|
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
|
Range: protocol.Range{
|
|
Start: protocol.Position{
|
|
Line: entry.Fields.Start.Line,
|
|
Character: entry.Fields.Spec.End.Character,
|
|
},
|
|
End: protocol.Position{
|
|
Line: entry.Fields.Start.Line,
|
|
Character: entry.Fields.Spec.End.Character,
|
|
},
|
|
},
|
|
Message: "The mount point field is missing",
|
|
Severity: &common.SeverityError,
|
|
})
|
|
|
|
continue
|
|
}
|
|
|
|
if entry.Fields.FilesystemType == nil || entry.Fields.FilesystemType.Value.Value == "" {
|
|
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
|
Range: protocol.Range{
|
|
Start: protocol.Position{
|
|
Line: entry.Fields.Start.Line,
|
|
Character: entry.Fields.MountPoint.End.Character,
|
|
},
|
|
End: protocol.Position{
|
|
Line: entry.Fields.Start.Line,
|
|
Character: entry.Fields.MountPoint.End.Character,
|
|
},
|
|
},
|
|
Message: "The file system type field is missing",
|
|
Severity: &common.SeverityError,
|
|
})
|
|
|
|
continue
|
|
}
|
|
|
|
if entry.Fields.Options == nil || entry.Fields.Options.Value.Value == "" {
|
|
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
|
Range: protocol.Range{
|
|
Start: protocol.Position{
|
|
Line: entry.Fields.Start.Line,
|
|
Character: entry.Fields.FilesystemType.End.Character,
|
|
},
|
|
End: protocol.Position{
|
|
Line: entry.Fields.Start.Line,
|
|
Character: entry.Fields.FilesystemType.End.Character,
|
|
},
|
|
},
|
|
Message: `The options field is empty. The usual convention is to use at least "defaults" keyword there.`,
|
|
Severity: &common.SeverityWarning,
|
|
})
|
|
|
|
continue
|
|
}
|
|
}
|
|
}
|