Skip to content

Commit

Permalink
Merge pull request #19 from dart-native/feature/annotation_fix
Browse files Browse the repository at this point in the history
Fix protocol macro
  • Loading branch information
yulingtianxia authored Jun 1, 2020
2 parents 64f58c7 + a018ccb commit 1d4538f
Show file tree
Hide file tree
Showing 5 changed files with 2,175 additions and 2,139 deletions.
7 changes: 5 additions & 2 deletions lib/objc/DNObjectiveCContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,17 @@ class DNPropertyContext extends DNContext {
class DNProtocolContext extends DNContext {
constructor(internal) {
super(internal)
this.name = internal.children[1].start.text
this.name = internal.name.start.text
this.properties = []
this.methods = []
this.protocols = []
this.macros = []
this.availability = []
}

parse() {
var result = 'abstract class ' + this.name
var result = this.availability.map((a) => a.parse()).join(' ') + '\n'
result += 'abstract class ' + this.name
if (typeof this.protocols !== 'undefined' && this.protocols.length > 0) {
result += ' implements ' + this.protocols.join(',')
}
Expand Down
3 changes: 2 additions & 1 deletion lib/objc/DNObjectiveCParserListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,8 @@ class DNObjectiveCParserListener extends ObjectiveCParserListener {
this.currentContext instanceof DNClassContext ||
this.currentContext instanceof DNPropertyContext ||
this.currentContext instanceof DNEnumDefContext ||
this.currentContext instanceof DNEnumItemContext) {
this.currentContext instanceof DNEnumItemContext ||
this.currentContext instanceof DNProtocolContext) {
var name = ctx.start.text
this.currentContext.macros.push(name)

Expand Down
5 changes: 3 additions & 2 deletions parser/objc/ObjectiveCParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ genericTypeSpecifier
;

protocolDeclaration
: '@protocol'
protocolName (LT protocolList GT)? protocolDeclarationSection*
: macro*
'@protocol'
name = protocolName (LT protocolList GT)? protocolDeclarationSection*
'@end'
;

Expand Down
Loading

0 comments on commit 1d4538f

Please sign in to comment.