Alternate fix for import highlighting with instantiations
This commit is contained in:
committed by
Philip Ginsbach
parent
353e22d6e8
commit
c78f01758a
@@ -661,29 +661,38 @@ repository:
|
|||||||
- include: '#non-context-sensitive'
|
- include: '#non-context-sensitive'
|
||||||
- include: '#annotation'
|
- include: '#annotation'
|
||||||
|
|
||||||
instantiation-arguments:
|
# The argument list of an instantiation, enclosed in angle brackets.
|
||||||
|
instantiation-args:
|
||||||
beginPattern: '#open-angle'
|
beginPattern: '#open-angle'
|
||||||
end: '#close-angle'
|
endPattern: '#close-angle'
|
||||||
|
name: meta.type.parameters.ql
|
||||||
patterns:
|
patterns:
|
||||||
- include: '#potential-instantiation'
|
# Include `#instantiation-args` first so that `#open-angle` and `#close-angle` take precedence
|
||||||
|
# over `#relational-operator`.
|
||||||
potential-instantiation:
|
- include: '#instantiation-args'
|
||||||
matches: '(?#simple-id) (?#instantiation-arguments)?'
|
- include: '#non-context-sensitive'
|
||||||
|
- match: '(?#simple-id)'
|
||||||
|
name: entity.name.type.namespace.ql
|
||||||
|
|
||||||
# An `import` directive. Note that we parse the optional `as` clause as a separate top-level
|
# An `import` directive. Note that we parse the optional `as` clause as a separate top-level
|
||||||
# directive, because otherwise it's too hard to figure out where the `import` directive ends.
|
# directive, because otherwise it's too hard to figure out where the `import` directive ends.
|
||||||
import-directive:
|
import-directive:
|
||||||
beginPattern: '#import'
|
beginPattern: '#import'
|
||||||
# Ends with a simple-id that is not followed by a `.` or a `::`. This does not handle comments or
|
# TextMate makes it tricky to tell whether an identifier that we encounter is part of the
|
||||||
# line breaks between the simple-id and the `.` or `::`.
|
# `import` directive or whether it's the first token of the next module-level declaration.
|
||||||
end: '(?#simple-id) (?!\s*(\.|\:\:))'
|
# To find the end of the import directive, we'll look for a zero-width match where the previous
|
||||||
endCaptures:
|
# token is either an identifier (other than `import`) or a `>`, and the next token is not a `.`,
|
||||||
'0':
|
# `<`, `,`, or `::`. This works for nearly all real-world `import` directives, but it will end the
|
||||||
name: entity.name.type.namespace.ql
|
# `import` directive too early if there is a comment or line break between two components of the
|
||||||
|
# module expression.
|
||||||
|
end: '(?<!\bimport)(?<=(?:\>)|[A-Za-z0-9_]) (?!\s*(\.|\:\:|\,|(?#open-angle)))'
|
||||||
name: meta.block.import-directive.ql
|
name: meta.block.import-directive.ql
|
||||||
patterns:
|
patterns:
|
||||||
|
# Include `#instantiation-args` first so that `#open-angle` and `#close-angle` take precedence
|
||||||
|
# over `#relational-operator`.
|
||||||
|
- include: '#instantiation-args'
|
||||||
- include: '#non-context-sensitive'
|
- include: '#non-context-sensitive'
|
||||||
- match: '(?#potential-instantiation)'
|
- match: '(?#simple-id)'
|
||||||
name: entity.name.type.namespace.ql
|
name: entity.name.type.namespace.ql
|
||||||
|
|
||||||
# The end pattern for an `as` clause, whether on an `import` directive, in an aggregate, or on a
|
# The end pattern for an `as` clause, whether on an `import` directive, in an aggregate, or on a
|
||||||
|
|||||||
Reference in New Issue
Block a user