Skip to content

Commit

Permalink
Move lexers to lexer package
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Aug 29, 2023
1 parent 2f5bb98 commit d7422d6
Show file tree
Hide file tree
Showing 562 changed files with 597 additions and 595 deletions.
4 changes: 2 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/wakatime/wakatime-cli/pkg/exitcode"
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
"github.com/wakatime/wakatime-cli/pkg/ini"
"github.com/wakatime/wakatime-cli/pkg/language/chroma"
"github.com/wakatime/wakatime-cli/pkg/lexer"
"github.com/wakatime/wakatime-cli/pkg/log"
"github.com/wakatime/wakatime-cli/pkg/offline"
"github.com/wakatime/wakatime-cli/pkg/vipertools"
Expand Down Expand Up @@ -70,7 +70,7 @@ func Run(cmd *cobra.Command, v *viper.Viper) {
}

// register all custom lexers
if err := chroma.RegisterAll(); err != nil {
if err := lexer.RegisterAll(); err != nil {
log.Fatalf("failed to register custom lexers: %s", err)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/language/language_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/wakatime/wakatime-cli/pkg/heartbeat"
"github.com/wakatime/wakatime-cli/pkg/language"
"github.com/wakatime/wakatime-cli/pkg/language/chroma"
"github.com/wakatime/wakatime-cli/pkg/lexer"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestDetect_FSharp_Over_Forth(t *testing.T) {
}

func TestDetect_ChromaTopLanguagesRetrofit(t *testing.T) {
err := chroma.RegisterAll()
err := lexer.RegisterAll()
require.NoError(t, err)

tests := map[string]struct {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"regexp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package chroma_test
package lexer_test

import (
"os"
"testing"

"github.com/wakatime/wakatime-cli/pkg/language/chroma"
"github.com/wakatime/wakatime-cli/pkg/lexer"

"github.com/stretchr/testify/assert"
)
Expand All @@ -28,13 +28,13 @@ func TestActionScript3_AnalyseText(t *testing.T) {
},
}

l := chroma.ActionScript3{}.Lexer()

for name, test := range tests {
t.Run(name, func(t *testing.T) {
data, err := os.ReadFile(test.Filepath)
assert.NoError(t, err)

l := lexer.ActionScript3{}.Lexer()

assert.Equal(t, test.Expected, l.AnalyseText(string(data)))
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/adl.go → pkg/lexer/adl.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/agda.go → pkg/lexer/agda.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/aheui.go → pkg/lexer/aheui.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/alloy.go → pkg/lexer/alloy.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/ampl.go → pkg/lexer/ampl.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/arrow.go → pkg/lexer/arrow.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/aspectj.go → pkg/lexer/aspectj.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"regexp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package chroma_test
package lexer_test

import (
"os"
"testing"

"github.com/wakatime/wakatime-cli/pkg/language/chroma"
"github.com/wakatime/wakatime-cli/pkg/lexer"

"github.com/stretchr/testify/assert"
)
Expand All @@ -24,13 +24,13 @@ func TestAspxCSharp_AnalyseText(t *testing.T) {
},
}

l := chroma.AspxCSharp{}.Lexer()

for name, test := range tests {
t.Run(name, func(t *testing.T) {
data, err := os.ReadFile(test.Filepath)
assert.NoError(t, err)

l := lexer.AspxCSharp{}.Lexer()

assert.Equal(t, test.Expected, l.AnalyseText(string(data)))
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/aspxvb.go → pkg/lexer/aspxvb.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"regexp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package chroma_test
package lexer_test

import (
"os"
"testing"

"github.com/wakatime/wakatime-cli/pkg/language/chroma"
"github.com/wakatime/wakatime-cli/pkg/lexer"

"github.com/stretchr/testify/assert"
)
Expand All @@ -24,13 +24,13 @@ func TestAspxVBNet_AnalyseText(t *testing.T) {
},
}

l := chroma.AspxVBNet{}.Lexer()

for name, test := range tests {
t.Run(name, func(t *testing.T) {
data, err := os.ReadFile(test.Filepath)
assert.NoError(t, err)

l := lexer.AspxVBNet{}.Lexer()

assert.Equal(t, test.Expected, l.AnalyseText(string(data)))
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/augeas.go → pkg/lexer/augeas.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/bare.go → pkg/lexer/bare.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/bbcbasic.go → pkg/lexer/bbcbasic.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"strings"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package chroma_test
package lexer_test

import (
"os"
"testing"

"github.com/wakatime/wakatime-cli/pkg/language/chroma"
"github.com/wakatime/wakatime-cli/pkg/lexer"

"github.com/stretchr/testify/assert"
)
Expand All @@ -24,13 +24,13 @@ func TestBBCBasic_AnalyseText(t *testing.T) {
},
}

l := chroma.BBCBasic{}.Lexer()

for name, test := range tests {
t.Run(name, func(t *testing.T) {
data, err := os.ReadFile(test.Filepath)
assert.NoError(t, err)

l := lexer.BBCBasic{}.Lexer()

assert.Equal(t, test.Expected, l.AnalyseText(string(data)))
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/bbcode.go → pkg/lexer/bbcode.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/bc.go → pkg/lexer/bc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/befunge.go → pkg/lexer/befunge.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/blazor.go → pkg/lexer/blazor.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/blitzmax.go → pkg/lexer/blitzmax.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/boa.go → pkg/lexer/boa.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/boo.go → pkg/lexer/boo.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/boogie.go → pkg/lexer/boogie.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"strings"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package chroma_test
package lexer_test

import (
"os"
"testing"

"github.com/wakatime/wakatime-cli/pkg/language/chroma"
"github.com/wakatime/wakatime-cli/pkg/lexer"

"github.com/stretchr/testify/assert"
)
Expand All @@ -28,13 +28,13 @@ func TestBrainfuck_AnalyseText(t *testing.T) {
},
}

l := chroma.Brainfuck{}.Lexer()

for name, test := range tests {
t.Run(name, func(t *testing.T) {
data, err := os.ReadFile(test.Filepath)
assert.NoError(t, err)

l := lexer.Brainfuck{}.Lexer()

assert.Equal(t, test.Expected, l.AnalyseText(string(data)))
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/bst.go → pkg/lexer/bst.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
2 changes: 1 addition & 1 deletion pkg/language/chroma/bugs.go → pkg/lexer/bugs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"regexp"
Expand Down
6 changes: 3 additions & 3 deletions pkg/language/chroma/bugs_test.go → pkg/lexer/bugs_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package chroma_test
package lexer_test

import (
"os"
"testing"

"github.com/wakatime/wakatime-cli/pkg/language/chroma"
"github.com/wakatime/wakatime-cli/pkg/lexer"

"github.com/stretchr/testify/assert"
)
Expand All @@ -13,7 +13,7 @@ func TestBBUGS_AnalyseText(t *testing.T) {
data, err := os.ReadFile("testdata/bugs_basic.bug")
assert.NoError(t, err)

l := chroma.BUGS{}.Lexer()
l := lexer.BUGS{}.Lexer()

assert.Equal(t, float32(0.7), l.AnalyseText(string(data)))
}
2 changes: 1 addition & 1 deletion pkg/language/chroma/c_test.go → pkg/lexer/c_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma_test
package lexer_test

import (
"os"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"regexp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package chroma_test
package lexer_test

import (
"os"
"testing"

"github.com/wakatime/wakatime-cli/pkg/language/chroma"
"github.com/wakatime/wakatime-cli/pkg/lexer"

"github.com/stretchr/testify/assert"
)
Expand All @@ -13,7 +13,7 @@ func TestCa65Assembler_AnalyseText(t *testing.T) {
data, err := os.ReadFile("testdata/ca65assembler_comment.s")
assert.NoError(t, err)

l := chroma.Ca65Assembler{}.Lexer()
l := lexer.Ca65Assembler{}.Lexer()

assert.Equal(t, float32(0.9), l.AnalyseText(string(data)))
}
2 changes: 1 addition & 1 deletion pkg/language/chroma/cadl.go → pkg/lexer/cadl.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chroma
package lexer

import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
Expand Down
Loading

0 comments on commit d7422d6

Please sign in to comment.