Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle syntax_test headers which use "partial-symbols" mode #355

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package/Sublime Text Snippet/syntax_test_snippet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ It is possible to include a literal newline in the replacement: ${1/test/_


${TM_CURRENT_LINE/^\\s*((?:\\/\\/[\\/!]?|#|%|--|::|(?i:rem)|'|;)\\s*).*/$1/}
# ^ meta.group.regexp meta.group.regexp meta.literal.regexp
# ^ meta.group.regexp meta.group.regexp
# ^ keyword.other.regex.mid.snippet

]]>snippet<</content>
Expand Down
18 changes: 12 additions & 6 deletions plugins/syntaxtest_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@
'AssertionLineDetails', ['comment_marker_match', 'assertion_colrange', 'line_region']
)
SyntaxTestHeader = namedtuple(
'SyntaxTestHeader', ['comment_start', 'comment_end', 'syntax_file', 'reindent']
'SyntaxTestHeader', ['comment_start', 'comment_end', 'syntax_file', 'test_mode']
)


syntax_test_header_regex = re.compile(
r'^(?P<comment_start>\s*.+?)'
r'\s+SYNTAX TEST\s+'
r'(?P<test_mode>(?:partial-symbols|(?:reindent(?:-un(?:indented|changed))?)\s+)*)'
r'"(?P<syntax_file>[^"]+)"'
r'\s*(?P<comment_end>\S+)?$'
)


Expand All @@ -37,11 +46,8 @@ def get_syntax_test_tokens(view):
match = None
if line.size() < 1000: # no point checking longer lines as they are unlikely to match
first_line = view.substr(line)
match = re.match(r'^(?P<comment_start>\s*.+?)'
r'\s+SYNTAX TEST\s+'
r'(?P<reindent>(?:reindent(?:-un(?:indented|changed))?\s+)*)'
r'"(?P<syntax_file>[^"]+)"'
r'\s*(?P<comment_end>\S+)?$', first_line)
match = syntax_test_header_regex.match(first_line)

if not match:
return None
else:
Expand Down