Skip to content

Commit 1d4538f

Browse files
Merge pull request #19 from dart-native/feature/annotation_fix
Fix protocol macro
2 parents 64f58c7 + a018ccb commit 1d4538f

File tree

5 files changed

+2175
-2139
lines changed

5 files changed

+2175
-2139
lines changed

lib/objc/DNObjectiveCContext.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,17 @@ class DNPropertyContext extends DNContext {
380380
class DNProtocolContext extends DNContext {
381381
constructor(internal) {
382382
super(internal)
383-
this.name = internal.children[1].start.text
383+
this.name = internal.name.start.text
384384
this.properties = []
385385
this.methods = []
386386
this.protocols = []
387+
this.macros = []
388+
this.availability = []
387389
}
388390

389391
parse() {
390-
var result = 'abstract class ' + this.name
392+
var result = this.availability.map((a) => a.parse()).join(' ') + '\n'
393+
result += 'abstract class ' + this.name
391394
if (typeof this.protocols !== 'undefined' && this.protocols.length > 0) {
392395
result += ' implements ' + this.protocols.join(',')
393396
}

lib/objc/DNObjectiveCParserListener.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,8 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
834834
this.currentContext instanceof DNClassContext ||
835835
this.currentContext instanceof DNPropertyContext ||
836836
this.currentContext instanceof DNEnumDefContext ||
837-
this.currentContext instanceof DNEnumItemContext) {
837+
this.currentContext instanceof DNEnumItemContext ||
838+
this.currentContext instanceof DNProtocolContext) {
838839
var name = ctx.start.text
839840
this.currentContext.macros.push(name)
840841

parser/objc/ObjectiveCParser.g4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,9 @@ genericTypeSpecifier
9090
;
9191

9292
protocolDeclaration
93-
: '@protocol'
94-
protocolName (LT protocolList GT)? protocolDeclarationSection*
93+
: macro*
94+
'@protocol'
95+
name = protocolName (LT protocolList GT)? protocolDeclarationSection*
9596
'@end'
9697
;
9798

0 commit comments

Comments
 (0)