Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ rerun-install:

rerun:
rerun -watch . -ignore out -run sh -c 'go run . -s _examples/e1.ridl'

test:
go test -v -coverprofile=coverage.txt -covermode=atomic ./...
7 changes: 7 additions & 0 deletions _examples/e1.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ service ExampleService # oof
@public
- GetUser ( header : map < string , string > , userID : uint64 ) => ( code : uint32 , user : User )
- FindUser(s :SearchFilter) => (name: string, user: User) ###! last

- stream Re cv (req : string )

- stream Sen d() => (resp: string)

-stream Se ndAndRecv(req: string) => stream (resp: string)
-streamSe ndAndRecv(req: string) => stream (resp: string)
10 changes: 9 additions & 1 deletion formatter/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@ func (f *form) formatLine(line string) (string, error) {
s, c := parseAndDivideInlineComment(line)
parts := strings.Split(s, "=>")
p1 := strings.TrimSpace(parts[0])
methodName := strings.TrimPrefix(strings.TrimSpace(strings.ReplaceAll(strings.Split(p1, "(")[0], " ", "")), "-")

methodName := strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(strings.Split(p1, "(")[0]), "-"))
methodName, isStreamInput := strings.CutPrefix(methodName, "stream ")
methodName = removeSpaces(methodName)

if isStreamInput {
methodName = "stream " + methodName
}

inArgs, err := formatMethodArguments(p1)
if err != nil {
return line, err
Expand Down
14 changes: 14 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ service ExampleService # oof
- GetUser ( header : map < string , string > , userID : uint64 ) => ( code : uint32 , user : User )
- FindUser(s :SearchFilter) => (name: string, user: User) ###! last

- stream Re cv (req : string )


- stream Sen d() => (resp: string)

-stream Se ndAndRecv(req: string) => stream (resp: string)
-streamSe ndAndRecv(req: string) => stream (resp: string)



Expand Down Expand Up @@ -246,4 +253,11 @@ service ExampleService # oof
@public
- GetUser(header: map<string,string>, userID: uint64) => (code: uint32, user: User)
- FindUser(s: SearchFilter) => (name: string, user: User) ###! last

- stream Recv(req: string)

- stream Send() => (resp: string)

- stream SendAndRecv(req: string) => stream (resp: string)
- streamSendAndRecv(req: string) => stream (resp: string)
`
Loading