Skip to content

Conversation

@frodella-daitan
Copy link

The class detection mechanism would fail in cases where an access modifier was used before the class definition.

I debated using "\w*" instead of naming each possible modifier, but I feel that the latter approach is safer.

@samdods
Copy link
Owner

samdods commented May 12, 2015

Good call, but I think you should use ? instead of * because correct me if i'm wrong but you can only use one of the modifiers at a time?

@frodella-daitan
Copy link
Author

You're right, I was trying to account for both the @objc and an access modifier being present at the same time, but I forgot to:

  • handle the whitespace between @objc and the access modifier
  • handle the exposed name for the @objc directive

My latest commit fixes that. The resulting regex turned out quite complex, so I moved the prefix handling to separate strings and then composed the complete regex using stringWithFormat. Here are some cases the regex should now handle correctly:

  • public class MyClass
  • @objc public class MyClass
  • @objc(ObjCName) public class MyClass
  • @objc (ObjCName) public class MyClass
  • @objc ( ObjCName ) public class MyClass

Let me know your thoughts :)

@samdods
Copy link
Owner

samdods commented May 13, 2015

I think there's probably a way we could remove some of the repetition and simplify this more... but perhaps it would lead to less readable regex expressions - and they're already getting quite unreadable!! happy to merge, but i'll wait till i get to my main machine to run and test before merging

thanks for your input :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants