mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
refactor(hosts): Improve hosts structure
This commit is contained in:
parent
48bbb0f68b
commit
5cbf5be8ad
@ -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"
|
@ -1,7 +1,7 @@
|
||||
package analyzer
|
||||
|
||||
import (
|
||||
"config-lsp/handlers/hosts/handlers/ast"
|
||||
"config-lsp/handlers/hosts/ast"
|
||||
"config-lsp/utils"
|
||||
"net"
|
||||
"testing"
|
@ -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"
|
@ -1,7 +1,7 @@
|
||||
package analyzer
|
||||
|
||||
import (
|
||||
"config-lsp/handlers/hosts/handlers/ast"
|
||||
"config-lsp/handlers/hosts/ast"
|
||||
"config-lsp/utils"
|
||||
"testing"
|
||||
)
|
@ -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"
|
||||
)
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"config-lsp/handlers/hosts/handlers/ast"
|
||||
"config-lsp/handlers/hosts/ast"
|
||||
"config-lsp/utils"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
@ -2,7 +2,7 @@ package handlers
|
||||
|
||||
import (
|
||||
"config-lsp/handlers/hosts"
|
||||
"config-lsp/handlers/hosts/handlers/ast"
|
||||
"config-lsp/handlers/hosts/ast"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package indexes
|
||||
|
||||
import "config-lsp/handlers/hosts/shared"
|
||||
import (
|
||||
"config-lsp/handlers/hosts/shared"
|
||||
)
|
||||
|
||||
type HostsIndexes struct {
|
||||
Resolver *Resolver
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user