Skip to content
This repository was archived by the owner on Feb 6, 2018. It is now read-only.

Commit c214824

Browse files
committed
fix for type-parameter-constraints-clauses (C# scanner)
1 parent 7ec0a53 commit c214824

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/coderay/scanners/csharp.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def scan_tokens encoder, options
6464
case_expected = false
6565
label_expected_before_preproc_line = nil
6666
in_preproc_line = false
67+
in_type_parameter_constraints_clauses = false
6768

6869
until eos?
6970

@@ -91,6 +92,9 @@ def scan_tokens encoder, options
9192
label_expected = true if match == ':'
9293
case_expected = false
9394
end
95+
if match !~ /^[(),.:?\[\]<>]+$/
96+
in_type_parameter_constraints_clauses = false
97+
end
9498
encoder.text_token match, :operator
9599

96100
elsif match = scan(/ @?[A-Za-z_][A-Za-z_0-9]* /x)
@@ -102,8 +106,12 @@ def scan_tokens encoder, options
102106
label_expected = false
103107
if kind == :keyword
104108
case match
109+
when 'where'
110+
in_type_parameter_constraints_clauses = true
105111
when 'class', 'interface', 'struct'
106-
state = :class_name_expected
112+
if !in_type_parameter_constraints_clauses
113+
state = :class_name_expected
114+
end
107115
when 'case', 'default'
108116
case_expected = true
109117
end

0 commit comments

Comments
 (0)