mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 07:25:27 +02:00
refactor(hosts): Improve hosts structure
This commit is contained in:
parent
48bbb0f68b
commit
5cbf5be8ad
@ -2,7 +2,7 @@ package analyzer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"config-lsp/handlers/hosts"
|
"config-lsp/handlers/hosts"
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
"config-lsp/handlers/hosts/ast"
|
||||||
"config-lsp/handlers/hosts/indexes"
|
"config-lsp/handlers/hosts/indexes"
|
||||||
"config-lsp/handlers/hosts/shared"
|
"config-lsp/handlers/hosts/shared"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
@ -1,7 +1,7 @@
|
|||||||
package analyzer
|
package analyzer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
"config-lsp/handlers/hosts/ast"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
@ -3,7 +3,7 @@ package analyzer
|
|||||||
import (
|
import (
|
||||||
"config-lsp/common"
|
"config-lsp/common"
|
||||||
"config-lsp/handlers/hosts"
|
"config-lsp/handlers/hosts"
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
"config-lsp/handlers/hosts/ast"
|
||||||
"config-lsp/handlers/hosts/indexes"
|
"config-lsp/handlers/hosts/indexes"
|
||||||
"config-lsp/handlers/hosts/shared"
|
"config-lsp/handlers/hosts/shared"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
@ -1,7 +1,7 @@
|
|||||||
package analyzer
|
package analyzer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
"config-lsp/handlers/hosts/ast"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
@ -3,8 +3,8 @@ package analyzer
|
|||||||
import (
|
import (
|
||||||
"config-lsp/common"
|
"config-lsp/common"
|
||||||
docvalues "config-lsp/doc-values"
|
docvalues "config-lsp/doc-values"
|
||||||
|
"config-lsp/handlers/hosts/ast"
|
||||||
"config-lsp/handlers/hosts/fields"
|
"config-lsp/handlers/hosts/fields"
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
@ -3,7 +3,7 @@ package ast
|
|||||||
import (
|
import (
|
||||||
"config-lsp/common"
|
"config-lsp/common"
|
||||||
docvalues "config-lsp/doc-values"
|
docvalues "config-lsp/doc-values"
|
||||||
"config-lsp/handlers/hosts/parser"
|
parser2 "config-lsp/handlers/hosts/ast/parser"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/antlr4-go/antlr/v4"
|
"github.com/antlr4-go/antlr/v4"
|
||||||
@ -14,18 +14,18 @@ type hostsListenerContext struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type hostsParserListener struct {
|
type hostsParserListener struct {
|
||||||
*parser.BaseHostsListener
|
*parser2.BaseHostsListener
|
||||||
Parser *HostsParser
|
Parser *HostsParser
|
||||||
Errors []common.LSPError
|
Errors []common.LSPError
|
||||||
hostsContext hostsListenerContext
|
hostsContext hostsListenerContext
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *hostsParserListener) EnterComment(ctx *parser.CommentContext) {
|
func (s *hostsParserListener) EnterComment(ctx *parser2.CommentContext) {
|
||||||
line := uint32(s.hostsContext.line)
|
line := uint32(s.hostsContext.line)
|
||||||
s.Parser.CommentLines[line] = struct{}{}
|
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 := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
|
||||||
location.ChangeBothLines(s.hostsContext.line)
|
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 := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
|
||||||
location.ChangeBothLines(s.hostsContext.line)
|
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 := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
|
||||||
location.ChangeBothLines(s.hostsContext.line)
|
location.ChangeBothLines(s.hostsContext.line)
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ func (s *hostsParserListener) EnterHostname(ctx *parser.HostnameContext) {
|
|||||||
s.Parser.Tree.Entries[location.Start.Line] = entry
|
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 := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
|
||||||
location.ChangeBothLines(s.hostsContext.line)
|
location.ChangeBothLines(s.hostsContext.line)
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ func (s *hostsParserListener) EnterAliases(ctx *parser.AliasesContext) {
|
|||||||
entry.Aliases = aliases
|
entry.Aliases = aliases
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *hostsParserListener) EnterAlias(ctx *parser.AliasContext) {
|
func (s *hostsParserListener) EnterAlias(ctx *parser2.AliasContext) {
|
||||||
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
|
location := common.CharacterRangeFromCtx(ctx.BaseParserRuleContext)
|
||||||
location.ChangeBothLines(s.hostsContext.line)
|
location.ChangeBothLines(s.hostsContext.line)
|
||||||
|
|
@ -2,7 +2,7 @@ package ast
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"config-lsp/common"
|
"config-lsp/common"
|
||||||
"config-lsp/handlers/hosts/parser"
|
parser2 "config-lsp/handlers/hosts/ast/parser"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ func (p *HostsParser) parseStatement(
|
|||||||
stream := antlr.NewInputStream(input)
|
stream := antlr.NewInputStream(input)
|
||||||
|
|
||||||
errorListener := createErrorListener(line)
|
errorListener := createErrorListener(line)
|
||||||
lexer := parser.NewHostsLexer(stream)
|
lexer := parser2.NewHostsLexer(stream)
|
||||||
lexer.RemoveErrorListeners()
|
lexer.RemoveErrorListeners()
|
||||||
lexer.AddErrorListener(&errorListener)
|
lexer.AddErrorListener(&errorListener)
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ func (p *HostsParser) parseStatement(
|
|||||||
|
|
||||||
errorListener = createErrorListener(line)
|
errorListener = createErrorListener(line)
|
||||||
tokenStream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)
|
tokenStream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel)
|
||||||
antlrParser := parser.NewHostsParser(tokenStream)
|
antlrParser := parser2.NewHostsParser(tokenStream)
|
||||||
antlrParser.RemoveErrorListeners()
|
antlrParser.RemoveErrorListeners()
|
||||||
antlrParser.AddErrorListener(&errorListener)
|
antlrParser.AddErrorListener(&errorListener)
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
"config-lsp/handlers/hosts/ast"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -2,7 +2,7 @@ package handlers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"config-lsp/handlers/hosts"
|
"config-lsp/handlers/hosts"
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
"config-lsp/handlers/hosts/ast"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package indexes
|
package indexes
|
||||||
|
|
||||||
import "config-lsp/handlers/hosts/shared"
|
import (
|
||||||
|
"config-lsp/handlers/hosts/shared"
|
||||||
|
)
|
||||||
|
|
||||||
type HostsIndexes struct {
|
type HostsIndexes struct {
|
||||||
Resolver *Resolver
|
Resolver *Resolver
|
||||||
|
@ -3,7 +3,7 @@ package lsp
|
|||||||
import (
|
import (
|
||||||
"config-lsp/common"
|
"config-lsp/common"
|
||||||
"config-lsp/handlers/hosts"
|
"config-lsp/handlers/hosts"
|
||||||
"config-lsp/handlers/hosts/handlers/analyzer"
|
"config-lsp/handlers/hosts/analyzer"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
||||||
|
|
||||||
"github.com/tliron/glsp"
|
"github.com/tliron/glsp"
|
||||||
|
@ -3,8 +3,8 @@ package lsp
|
|||||||
import (
|
import (
|
||||||
"config-lsp/common"
|
"config-lsp/common"
|
||||||
"config-lsp/handlers/hosts"
|
"config-lsp/handlers/hosts"
|
||||||
"config-lsp/handlers/hosts/handlers/analyzer"
|
"config-lsp/handlers/hosts/analyzer"
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
"config-lsp/handlers/hosts/ast"
|
||||||
"config-lsp/handlers/hosts/indexes"
|
"config-lsp/handlers/hosts/indexes"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ package lsp
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"config-lsp/handlers/hosts"
|
"config-lsp/handlers/hosts"
|
||||||
|
"config-lsp/handlers/hosts/ast"
|
||||||
"config-lsp/handlers/hosts/fields"
|
"config-lsp/handlers/hosts/fields"
|
||||||
"config-lsp/handlers/hosts/handlers"
|
"config-lsp/handlers/hosts/handlers"
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/tliron/glsp"
|
"github.com/tliron/glsp"
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package hosts
|
package hosts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"config-lsp/handlers/hosts/handlers/ast"
|
"config-lsp/handlers/hosts/ast"
|
||||||
"config-lsp/handlers/hosts/indexes"
|
"config-lsp/handlers/hosts/indexes"
|
||||||
|
|
||||||
protocol "github.com/tliron/glsp/protocol_3_16"
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user