diff --git a/grammars/csharp.tmLanguage b/grammars/csharp.tmLanguage index 39475fd..25fb7b4 100644 --- a/grammars/csharp.tmLanguage +++ b/grammars/csharp.tmLanguage @@ -227,6 +227,10 @@ include #comment + + include + #storage-modifier + include #property-declaration @@ -243,6 +247,10 @@ include #method-declaration + + include + #operator-declaration + include #attribute-section diff --git a/grammars/csharp.tmLanguage.cson b/grammars/csharp.tmLanguage.cson index 653818f..e61aaf8 100644 --- a/grammars/csharp.tmLanguage.cson +++ b/grammars/csharp.tmLanguage.cson @@ -156,6 +156,9 @@ repository: { include: "#comment" } + { + include: "#storage-modifier" + } { include: "#property-declaration" } @@ -168,6 +171,9 @@ repository: { include: "#method-declaration" } + { + include: "#operator-declaration" + } { include: "#attribute-section" } diff --git a/src/csharp.tmLanguage.yml b/src/csharp.tmLanguage.yml index 194bbd8..fe43f6b 100644 --- a/src/csharp.tmLanguage.yml +++ b/src/csharp.tmLanguage.yml @@ -69,10 +69,12 @@ repository: patterns: - include: '#preprocessor' - include: '#comment' + - include: '#storage-modifier' - include: '#property-declaration' - include: '#event-declaration' - include: '#indexer-declaration' - include: '#method-declaration' + - include: '#operator-declaration' - include: '#attribute-section' - include: '#punctuation-semicolon' diff --git a/test/interface.tests.ts b/test/interface.tests.ts index 26a2f95..afdbdd5 100644 --- a/test/interface.tests.ts +++ b/test/interface.tests.ts @@ -100,5 +100,79 @@ interface IBar : IFoo { } Token.Punctuation.OpenBrace, Token.Punctuation.CloseBrace]); }); + + it("generic interface with abstract methods (issue #307)", async () => { + + const input = ` +public interface IAdditionSubtraction where T : IAdditionSubtraction +{ + public abstract static T operator -(T left, T right); + abstract static T operator +(T left, T right); + public abstract void M(); + void N(); +}`; + const tokens = await tokenize(input); + + tokens.should.deep.equal([ + Token.Keyword.Modifier.Public, + Token.Keyword.Definition.Interface, + Token.Identifier.InterfaceName("IAdditionSubtraction"), + Token.Punctuation.TypeParameter.Begin, + Token.Identifier.TypeParameterName("T"), + Token.Punctuation.TypeParameter.End, + Token.Keyword.Modifier.Where, + Token.Identifier.TypeParameterName("T"), + Token.Punctuation.Colon, + Token.Type("IAdditionSubtraction"), + Token.Punctuation.TypeParameter.Begin, + Token.Type("T"), + Token.Punctuation.TypeParameter.End, + Token.Punctuation.OpenBrace, + + Token.Keyword.Modifier.Public, + Token.Keyword.Modifier.Abstract, + Token.Keyword.Modifier.Static, + Token.Type("T"), + Token.Keyword.Definition.Operator, + Token.Identifier.MethodName("-"), + Token.Punctuation.OpenParen, + Token.Type("T"), + Token.Identifier.ParameterName("left"), + Token.Punctuation.Comma, + Token.Type("T"), + Token.Identifier.ParameterName("right"), + Token.Punctuation.CloseParen, + Token.Punctuation.Semicolon, + + Token.Keyword.Modifier.Abstract, + Token.Keyword.Modifier.Static, + Token.Type("T"), + Token.Keyword.Definition.Operator, + Token.Identifier.MethodName("+"), + Token.Punctuation.OpenParen, + Token.Type("T"), + Token.Identifier.ParameterName("left"), + Token.Punctuation.Comma, + Token.Type("T"), + Token.Identifier.ParameterName("right"), + Token.Punctuation.CloseParen, + Token.Punctuation.Semicolon, + + Token.Keyword.Modifier.Public, + Token.Keyword.Modifier.Abstract, + Token.PrimitiveType.Void, + Token.Identifier.MethodName("M"), + Token.Punctuation.OpenParen, + Token.Punctuation.CloseParen, + Token.Punctuation.Semicolon, + + Token.PrimitiveType.Void, + Token.Identifier.MethodName("N"), + Token.Punctuation.OpenParen, + Token.Punctuation.CloseParen, + Token.Punctuation.Semicolon, + + Token.Punctuation.CloseBrace]); + }); }); });