This repository was archived by the owner on Feb 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
fix(StaticMetadataExtractor): Map members annotations to all annotations #907
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,8 @@ class ContainsSelector { | |
} | ||
} | ||
|
||
RegExp _SELECTOR_REGEXP = new RegExp(r'^(?:([\w\-]+)|(?:\.([\w\-]+))|(?:\[([\w\-\*]+)(?:=([^\]]*))?\]))'); | ||
RegExp _COMMENT_COMPONENT_REGEXP = new RegExp(r'^\[([\w\-]+)(?:\=(.*))?\]$'); | ||
RegExp _SELECTOR_REGEXP = new RegExp(r'^(?:([-\w]+)|(?:\.([-\w]+))|(?:\[([-\w*]+)(?:=([^\]]*))?\]))'); | ||
RegExp _COMMENT_COMPONENT_REGEXP = new RegExp(r'^\[([-\w]+)(?:\=(.*))?\]$'); | ||
RegExp _CONTAINS_REGEXP = new RegExp(r'^:contains\(\/(.+)\/\)$'); // | ||
RegExp _ATTR_CONTAINS_REGEXP = new RegExp(r'^\[\*=\/(.+)\/\]$'); // | ||
|
||
|
@@ -22,17 +22,17 @@ class _SelectorPart { | |
final String attrName; | ||
final String attrValue; | ||
|
||
const _SelectorPart.fromElement(String this.element) | ||
const _SelectorPart.fromElement(this.element) | ||
: className = null, attrName = null, attrValue = null; | ||
|
||
const _SelectorPart.fromClass(String this.className) | ||
const _SelectorPart.fromClass(this.className) | ||
: element = null, attrName = null, attrValue = null; | ||
|
||
|
||
const _SelectorPart.fromAttribute(String this.attrName, String this.attrValue) | ||
const _SelectorPart.fromAttribute(this.attrName, this.attrValue) | ||
: element = null, className = null; | ||
|
||
toString() => | ||
String toString() => | ||
element == null | ||
? (className == null | ||
? (attrValue == '' ? '[$attrName]' : '[$attrName=$attrValue]') | ||
|
@@ -68,19 +68,13 @@ List<_SelectorPart> _splitCss(String selector) { | |
bool matchesNode(Node node, String selector) { | ||
var match, selectorParts; | ||
if ((match = _CONTAINS_REGEXP.firstMatch(selector)) != null) { | ||
if (node is! Text) { | ||
return false; | ||
} | ||
if (node is! Text) return false; | ||
return new RegExp(match.group(1)).hasMatch((node as Text).text); | ||
} else if ((match = _ATTR_CONTAINS_REGEXP.firstMatch(selector)) != null) { | ||
if (node is! Element) { | ||
return false; | ||
} | ||
if (node is! Element) return false; | ||
var regexp = new RegExp(match.group(1)); | ||
for (String attrName in node.attributes.keys) { | ||
if (regexp.hasMatch(node.attributes[attrName])) { | ||
return true; | ||
} | ||
if (regexp.hasMatch(node.attributes[attrName])) return true; | ||
} | ||
return false; | ||
} else if ((selectorParts = _splitCss(selector)) != null) { | ||
|
@@ -90,9 +84,7 @@ bool matchesNode(Node node, String selector) { | |
bool stillGood = true; | ||
selectorParts.forEach((_SelectorPart part) { | ||
if (part.element != null) { | ||
if (nodeName != part.element) { | ||
stillGood = false; | ||
} | ||
if (nodeName != part.element) stillGood = false; | ||
} else if (part.className != null) { | ||
if (node.attributes['class'] == null || | ||
!node.attributes['class'].split(' ').contains(part.className)) { | ||
|
@@ -116,5 +108,5 @@ bool matchesNode(Node node, String selector) { | |
|
||
String _matchingKey(Iterable keys, String attrName) => | ||
keys.firstWhere( | ||
(key) => new RegExp('^${attrName.replaceAll('*', r'[\w\-]+')}\$').hasMatch(key.toString()), | ||
(key) => new RegExp('^${attrName.replaceAll('*', r'[-\w]+')}\$').hasMatch(key.toString()), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
orElse: () => null); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these regexp changes be split into a separate PR?