refactor(hosts): Improve hosts structure

This commit is contained in:
Myzel394 2024-08-29 22:51:39 +02:00
parent 48bbb0f68b
commit 5cbf5be8ad
No known key found for this signature in database
GPG Key ID: DEC4AAB876F73185
31 changed files with 26 additions and 25 deletions

View File

@ -2,7 +2,7 @@ package analyzer
import (
"config-lsp/handlers/hosts"
"config-lsp/handlers/hosts/handlers/ast"
"config-lsp/handlers/hosts/ast"
"config-lsp/handlers/hosts/indexes"
"config-lsp/handlers/hosts/shared"
"config-lsp/utils"

View File

@ -1,7 +1,7 @@
package analyzer
import (
"config-lsp/handlers/hosts/handlers/ast"
"config-lsp/handlers/hosts/ast"
"config-lsp/utils"
"net"
"testing"

View File

@ -3,7 +3,7 @@ package analyzer
import (
"config-lsp/common"
"config-lsp/handlers/hosts"
"config-lsp/handlers/hosts/handlers/ast"
"config-lsp/handlers/hosts/ast"
"config-lsp/handlers/hosts/indexes"
"config-lsp/handlers/hosts/shared"
"config-lsp/utils"

View File

@ -1,7 +1,7 @@
package analyzer
import (
"config-lsp/handlers/hosts/handlers/ast"
"config-lsp/handlers/hosts/ast"
"config-lsp/utils"
"testing"
)

View File

@ -3,8 +3,8 @@ package analyzer
import (
"config-lsp/common"
docvalues "config-lsp/doc-values"
"config-lsp/handlers/hosts/ast"
"config-lsp/handlers/hosts/fields"
"config-lsp/handlers/hosts/handlers/ast"
"config-lsp/utils"
"errors"
)

View File

@ -3,7 +3,7 @@ package ast
import (
"config-lsp/common"
docvalues "config-lsp/doc-values"
"config-lsp/handlers/hosts/parser"
parser2 "config-lsp/handlers/hosts/ast/parser"
"net"
"github.com/antlr4-go/antlr/v4"
@ -14,18 +14,18 @@ type hostsListenerContext struct {
}
type hostsParserListener struct {
*parser.BaseHostsListener
*parser2.BaseHostsListener
Parser *HostsParser
Errors []common.LSPError
hostsContext hostsListenerContext
}
func (s *hostsParserListener) EnterComment(ctx *parser.CommentContext) {
func (s *hostsParserListener) EnterComment(ctx *parser2.CommentContext) {
line := uint32(s.hostsContext.line)
s.Parser.CommentLines[line] = struct{}{}
}
func (s *hostsParserListener) EnterEntry(ctx *parser.EntryContext) {
func (s *hostsParserListener) EnterEntry(ctx *parser2.EntryContext) {
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
location.ChangeBothLines(s.hostsContext.line)
@ -34,7 +34,7 @@ func (s *hostsParserListener) EnterEntry(ctx *parser.EntryContext) {
}
}
func (s *hostsParserListener) EnterIpAddress(ctx *parser.IpAddressContext) {
func (s *hostsParserListener) EnterIpAddress(ctx *parser2.IpAddressContext) {
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
location.ChangeBothLines(s.hostsContext.line)
@ -65,7 +65,7 @@ func (s *hostsParserListener) EnterIpAddress(ctx *parser.IpAddressContext) {
}
}
func (s *hostsParserListener) EnterHostname(ctx *parser.HostnameContext) {
func (s *hostsParserListener) EnterHostname(ctx *parser2.HostnameContext) {
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
location.ChangeBothLines(s.hostsContext.line)
@ -79,7 +79,7 @@ func (s *hostsParserListener) EnterHostname(ctx *parser.HostnameContext) {
s.Parser.Tree.Entries[location.Start.Line] = entry
}
func (s *hostsParserListener) EnterAliases(ctx *parser.AliasesContext) {
func (s *hostsParserListener) EnterAliases(ctx *parser2.AliasesContext) {
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
location.ChangeBothLines(s.hostsContext.line)
@ -90,7 +90,7 @@ func (s *hostsParserListener) EnterAliases(ctx *parser.AliasesContext) {
entry.Aliases = aliases
}
func (s *hostsParserListener) EnterAlias(ctx *parser.AliasContext) {
func (s *hostsParserListener) EnterAlias(ctx *parser2.AliasContext) {
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
location.ChangeBothLines(s.hostsContext.line)

View File

@ -2,7 +2,7 @@ package ast
import (
"config-lsp/common"
"config-lsp/handlers/hosts/parser"
parser2 "config-lsp/handlers/hosts/ast/parser"
"config-lsp/utils"
"regexp"
@ -26,7 +26,7 @@ func (p *HostsParser) parseStatement(
stream := antlr.NewInputStream(input)
errorListener := createErrorListener(line)
lexer := parser.NewHostsLexer(stream)
lexer := parser2.NewHostsLexer(stream)
lexer.RemoveErrorListeners()
lexer.AddErrorListener(&errorListener)
@ -34,7 +34,7 @@ func (p *HostsParser) parseStatement(
errorListener = createErrorListener(line)
tokenStream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)
antlrParser := parser.NewHostsParser(tokenStream)
antlrParser := parser2.NewHostsParser(tokenStream)
antlrParser.RemoveErrorListeners()
antlrParser.AddErrorListener(&errorListener)

View File

@ -1,7 +1,7 @@
package handlers
import (
"config-lsp/handlers/hosts/handlers/ast"
"config-lsp/handlers/hosts/ast"
"config-lsp/utils"
"fmt"
"strings"

View File

@ -2,7 +2,7 @@ package handlers
import (
"config-lsp/handlers/hosts"
"config-lsp/handlers/hosts/handlers/ast"
"config-lsp/handlers/hosts/ast"
"fmt"
)

View File

@ -1,6 +1,8 @@
package indexes
import "config-lsp/handlers/hosts/shared"
import (
"config-lsp/handlers/hosts/shared"
)
type HostsIndexes struct {
Resolver *Resolver

View File

@ -3,7 +3,7 @@ package lsp
import (
"config-lsp/common"
"config-lsp/handlers/hosts"
"config-lsp/handlers/hosts/handlers/analyzer"
"config-lsp/handlers/hosts/analyzer"
"config-lsp/utils"
"github.com/tliron/glsp"

View File

@ -3,8 +3,8 @@ package lsp
import (
"config-lsp/common"
"config-lsp/handlers/hosts"
"config-lsp/handlers/hosts/handlers/analyzer"
"config-lsp/handlers/hosts/handlers/ast"
"config-lsp/handlers/hosts/analyzer"
"config-lsp/handlers/hosts/ast"
"config-lsp/handlers/hosts/indexes"
"config-lsp/utils"

View File

@ -2,9 +2,9 @@ package lsp
import (
"config-lsp/handlers/hosts"
"config-lsp/handlers/hosts/ast"
"config-lsp/handlers/hosts/fields"
"config-lsp/handlers/hosts/handlers"
"config-lsp/handlers/hosts/handlers/ast"
"strings"
"github.com/tliron/glsp"

View File

@ -1,9 +1,8 @@
package hosts
import (
"config-lsp/handlers/hosts/handlers/ast"
"config-lsp/handlers/hosts/ast"
"config-lsp/handlers/hosts/indexes"
protocol "github.com/tliron/glsp/protocol_3_16"
)