Skip to content

Commit 893e741

Browse files
String annotations (#12)
* example * formatter * makefile * tests
1 parent 05e5d78 commit 893e741

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ install:
77
rerun-install:
88
rerun -watch . -ignore out -run sh -c 'go install .'
99

10-
rerun:
10+
rerun-1:
1111
rerun -watch . -ignore out -run sh -c 'go run . -s _examples/e1.ridl'
1212

13+
rerun-2:
14+
rerun -watch . -ignore out -run sh -c 'go run . -s _examples/e2.ridl'
15+
1316
test:
1417
go test -v -coverprofile=coverage.txt -covermode=atomic ./...

_examples/e1.ridl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ service ExampleService # oof
7171
@ auth : ApiKeyAuth @ who dsa : J W T ## dadsadadsa
7272
- Ping()
7373
- Status() => (status: bool)
74-
@ internal @ public ## dsada s dsa
74+
@ internal @ public @ stringo : " string with spaces" ## dsada s dsa
7575
- Version() => (version: Version)
7676
@public
7777
- GetUser ( header : map < string , string > , userID : uint64 ) => ( code : uint32 , user : User )

formatter/processor.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,12 @@ func (f *form) formatLine(line string) (string, error) {
263263
case 1:
264264
as = fmt.Sprintf("%s@%s", as, removeSpaces(ap[0]))
265265
case 2:
266-
as = fmt.Sprintf("%s@%s:%s", as, removeSpaces(ap[0]), removeSpaces(ap[1]))
266+
v := strings.TrimSpace(ap[1])
267+
if !strings.HasPrefix(v, `"`) && !strings.HasSuffix(v, `"`) {
268+
v = removeSpaces(v)
269+
}
270+
271+
as = fmt.Sprintf("%s@%s:%s", as, removeSpaces(ap[0]), v)
267272
default:
268273
return "", fmt.Errorf("unexpected amount of parts for one anotation parts=(%d) %s", len(ap), line)
269274
}

main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ service ExampleService # oof
156156
@ auth : ApiKeyAuth @ who dsa : J W T ## dadsadadsa
157157
- Ping()
158158
- Status() => (status: bool)
159-
@ internal @ public ## dsada s dsa
159+
@ internal @ public @ stringo : " string with spaces " ## dsada s dsa
160160
- Version() => (version: Version)
161161
@public
162162
- GetUser ( header : map < string , string > , userID : uint64 ) => ( code : uint32 , user : User )
@@ -248,7 +248,7 @@ service ExampleService # oof
248248
@auth:ApiKeyAuth @whodsa:JWT ## dadsadadsa
249249
- Ping()
250250
- Status() => (status: bool)
251-
@internal @public ## dsada s dsa
251+
@internal @public @stringo:" string with spaces " ## dsada s dsa
252252
- Version() => (version: Version)
253253
@public
254254
- GetUser(header: map<string,string>, userID: uint64) => (code: uint32, user: User)

0 commit comments

Comments
 (0)