Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-hykin committed May 24, 2019
2 parents bf2cbe8 + ef2b059 commit 9cafdb6
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 31 deletions.
18 changes: 12 additions & 6 deletions cpp/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,16 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
:probably_a_parameter,
:attributes_context,
:comments_context,
:string_context,
:string_context_c,
:storage_types,
:operators,
:vararg_ellipses,
:function_pointer,
:comma,
:string
# the following are a temp workaround for defaulted arguments
# e.g. aFunc(int a = 10 + 10)
:language_constants,
:number_literal,
:string_context,
:operators,
]
# eventually this context will be more exclusive (can't have class definitons inside of an evaluation)
# but for now it just includes everything
Expand Down Expand Up @@ -823,7 +825,10 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
tag_as: "punctuation.section.parameters.end.bracket.round"
),
includes: [
:function_parameter_context
:function_parameter_context,
# TODO: the function_call_context is included here as workaround for function-initializations like issue #198
# e.g. std::string ("hello");
:function_call_context,
]
)
],
Expand Down Expand Up @@ -1004,7 +1009,7 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
tag_as: "punctuation.section.parameters.end.bracket.round.function.pointer"
).then(after_declaration),
includes: [
:function_parameter_context
:function_parameter_context,
]
)
#
Expand Down Expand Up @@ -3236,6 +3241,7 @@ def generateBlockFinder( name:"", tag_as:"", start_pattern:nil, needs_semicolon:
:attributes_context,
:comments_context,
:operators,
:string_context,
:storage_types,
:method_access,
:member_access,
Expand Down
22 changes: 14 additions & 8 deletions syntaxes/cpp.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,28 +336,28 @@
"include": "#comments_context"
},
{
"include": "#string_context"
"include": "#storage_types"
},
{
"include": "#string_context_c"
"include": "#vararg_ellipses"
},
{
"include": "#storage_types"
"include": "#function_pointer"
},
{
"include": "#operators"
"include": "#comma"
},
{
"include": "#vararg_ellipses"
"include": "#language_constants"
},
{
"include": "#function_pointer"
"include": "#number_literal"
},
{
"include": "#comma"
"include": "#string_context"
},
{
"include": "#string"
"include": "#operators"
}
]
},
Expand Down Expand Up @@ -2078,6 +2078,9 @@
"patterns": [
{
"include": "#function_parameter_context"
},
{
"include": "#function_call_context"
}
]
}
Expand Down Expand Up @@ -5651,6 +5654,9 @@
{
"include": "#operators"
},
{
"include": "#string_context"
},
{
"include": "#storage_types"
},
Expand Down
10 changes: 6 additions & 4 deletions syntaxes/cpp.tmLanguage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@
- include: "#probably_a_parameter"
- include: "#attributes_context"
- include: "#comments_context"
- include: "#string_context"
- include: "#string_context_c"
- include: "#storage_types"
- include: "#operators"
- include: "#vararg_ellipses"
- include: "#function_pointer"
- include: "#comma"
- include: "#string"
- include: "#language_constants"
- include: "#number_literal"
- include: "#string_context"
- include: "#operators"
evaluation_context:
patterns:
- include: "$base"
Expand Down Expand Up @@ -1096,6 +1096,7 @@
name: punctuation.section.parameters.end.bracket.round.cpp
patterns:
- include: "#function_parameter_context"
- include: "#function_call_context"
- name: meta.body.function.definition.cpp
begin: "(?<=\\{)"
end: "(\\})"
Expand Down Expand Up @@ -3055,6 +3056,7 @@
- include: "#attributes_context"
- include: "#comments_context"
- include: "#operators"
- include: "#string_context"
- include: "#storage_types"
- include: "#method_access"
- include: "#member_access"
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/issues/198.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <string>

std::string s = "correct";
std::string s("incorrect");
std::string s("?"); // incorrect
3 changes: 1 addition & 2 deletions test/specs/issues/002.cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
- source: '::'
scopes:
- punctuation.separator.namespace.access
- >-
punctuation.separator.scope-resolution.function.definition.operator-overload
- punctuation.separator.scope-resolution.function.definition.operator-overload
- source: string &
scopesEnd:
- entity.name.operator.overloadee
Expand Down
25 changes: 16 additions & 9 deletions test/specs/issues/055.cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,27 @@
- source: (
scopes:
- punctuation.section.parameters.begin.bracket.round
- source: 'enum foo::bar::baz '
- source: 'enum'
scopesBegin:
- meta.function.definition.parameters
- source: quix
- meta.block.enum
- meta.head.enum
scopes:
- variable.parameter
scopesEnd:
- meta.function.definition.parameters
- source: )
- storage.type.enum
- source: foo
scopes:
- entity.name.type.enum
- source: '::'
- source: bar
scopes:
- punctuation.section.parameters.end.bracket.round
- entity.name.scope-resolution
- source: '::'
scopes:
- punctuation.separator.namespace.access
- punctuation.separator.scope-resolution
- source: 'baz quix)'
scopesEnd:
- meta.function.definition
- meta.head.function.definition
- meta.head.enum
- source: ;
scopes:
- punctuation.terminator.statement
4 changes: 3 additions & 1 deletion test/specs/issues/158.cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
- source: =
scopes:
- keyword.operator.assignment
- source: ' false'
- source: 'false'
scopes:
- constant.language.false
scopesEnd:
- meta.function.definition.parameters
- source: )
Expand Down
142 changes: 142 additions & 0 deletions test/specs/issues/198.cpp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
- source: '#'
scopesBegin:
- meta.preprocessor.include
- keyword.control.directive.include
scopes:
- punctuation.definition.directive
- source: include
scopesEnd:
- keyword.control.directive.include
- source: <
scopesBegin:
- string.quoted.other.lt-gt.include
scopes:
- punctuation.definition.string.begin
- source: string
- source: '>'
scopes:
- punctuation.definition.string.end
scopesEnd:
- meta.preprocessor.include
- string.quoted.other.lt-gt.include
- source: std
scopes:
- entity.name.scope-resolution
- source: '::'
scopes:
- punctuation.separator.namespace.access
- punctuation.separator.scope-resolution
- source: 'string s '
- source: =
scopes:
- keyword.operator.assignment
- source: '"'
scopesBegin:
- string.quoted.double
scopes:
- punctuation.definition.string.begin
- source: correct
- source: '"'
scopes:
- punctuation.definition.string.end
scopesEnd:
- string.quoted.double
- source: ;
scopes:
- punctuation.terminator.statement
- source: std
scopesBegin:
- meta.function.definition
- meta.qualified_type
scopes:
- entity.name.scope-resolution
- source: '::'
scopes:
- punctuation.separator.namespace.access
- punctuation.separator.scope-resolution
- source: string
scopes:
- entity.name.type
scopesEnd:
- meta.qualified_type
- source: s
scopesBegin:
- meta.head.function.definition
scopes:
- entity.name.function.definition
- source: (
scopes:
- punctuation.section.parameters.begin.bracket.round
- source: '"'
scopesBegin:
- meta.function.definition.parameters
- string.quoted.double
scopes:
- punctuation.definition.string.begin
- source: incorrect
- source: '"'
scopes:
- punctuation.definition.string.end
scopesEnd:
- meta.function.definition.parameters
- string.quoted.double
- source: )
scopes:
- punctuation.section.parameters.end.bracket.round
scopesEnd:
- meta.function.definition
- meta.head.function.definition
- source: ;
scopes:
- punctuation.terminator.statement
- source: std
scopesBegin:
- meta.function.definition
- meta.qualified_type
scopes:
- entity.name.scope-resolution
- source: '::'
scopes:
- punctuation.separator.namespace.access
- punctuation.separator.scope-resolution
- source: string
scopes:
- entity.name.type
scopesEnd:
- meta.qualified_type
- source: s
scopesBegin:
- meta.head.function.definition
scopes:
- entity.name.function.definition
- source: (
scopes:
- punctuation.section.parameters.begin.bracket.round
- source: '"'
scopesBegin:
- meta.function.definition.parameters
- string.quoted.double
scopes:
- punctuation.definition.string.begin
- source: '?'
- source: '"'
scopes:
- punctuation.definition.string.end
scopesEnd:
- meta.function.definition.parameters
- string.quoted.double
- source: )
scopes:
- punctuation.section.parameters.end.bracket.round
scopesEnd:
- meta.function.definition
- meta.head.function.definition
- source: ;
scopes:
- punctuation.terminator.statement
- source: //
scopesBegin:
- comment.line.double-slash
scopes:
- punctuation.definition.comment
- source: ' incorrect'
4 changes: 3 additions & 1 deletion test/specs/test.cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
- source: ' a comment /* no nest */'
scopesEnd:
- comment.line.double-slash
- source: /*
- source: '/*'
scopesBegin:
- comment.block
scopes:
Expand All @@ -54,3 +54,5 @@
- source: '*/'
scopes:
- punctuation.definition.comment.end
scopesEnd:
- comment.block

0 comments on commit 9cafdb6

Please sign in to comment.