This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 5.2] SCIP ctags: improve kind output (#58051)
* SCIP syntax: add more kinds for go ctags (#57806) This change adds fine-grained kinds to the Go ctags output. Specific changes: * Split `type` into `interface`, `struct`, and `typealias` * Map struct members to `field` instead of `variable` Universal ctags does not have a clear spec, and some languages use different names for the same kind. So my strategy is not to match universal ctags exactly, but just to capture the correct SCIP kinds. Clients need to handle the fact that the kind names can be different. * SCIP ctags: add kinds for C#, Python, Ruby (#57879) Added more fine-grained kinds for C#, Python, and Ruby to better match the universal-ctags output. Addresses https://github.com/sourcegraph/sourcegraph/issues/57659 * Add scip-ctags kinds for js, ts, and rust (#57899) * SCIP ctags: use MethodSpec kind for Go (#57929) Now that MethodSpec is available in SCIP, we can use it in the Go SCIP ctags output. * SCIP ctags: add kinds for Kotlin (#57998) Improved ctags kind output for Kotlin: * Split type into class, interface, object, and enum * Split variable into enumMember, constant, and property * Add type alias * Fix snapshot tests by adding back trailing whitespace Our precommit hook removes trailing whitespace, but the generated snapshots include it. --------- Co-authored-by: Auguste Rame <[email protected]>
- Loading branch information
1 parent
9de3bed
commit c071963
Showing
41 changed files
with
748 additions
and
365 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 13 additions & 15 deletions
28
docker-images/syntax-highlighter/crates/scip-syntax/queries/c_sharp/scip-tags.scm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
(using_directive (qualified_name) @descriptor.type) | ||
|
||
(class_declaration name: (_) @descriptor.type) @scope | ||
(interface_declaration name: (_) @descriptor.type) @scope | ||
(enum_declaration name: (_) @descriptor.type) @scope | ||
(struct_declaration name: (_) @descriptor.type) @scope | ||
(namespace_declaration name: (_) @descriptor.namespace) @scope | ||
(class_declaration name: (_) @descriptor.type @kind.class) @scope | ||
(interface_declaration name: (_) @descriptor.type @kind.interface) @scope | ||
(enum_declaration name: (_) @descriptor.type @kind.enum) @scope | ||
(struct_declaration name: (_) @descriptor.type @kind.struct) @scope | ||
(namespace_declaration name: (_) @descriptor.namespace @kind.namespace) @scope | ||
|
||
; Counter-intuitive name; it can actually be global | ||
(local_function_statement name: (_) @descriptor.method) | ||
(method_declaration name: (_) @descriptor.method) | ||
(constructor_declaration name: (_) @descriptor.method) | ||
(local_function_statement name: (_) @descriptor.method @kind.function) | ||
(method_declaration name: (_) @descriptor.method @kind.method) | ||
(constructor_declaration name: (_) @descriptor.method @kind.constructor) | ||
|
||
(block) @local | ||
|
||
(field_declaration (variable_declaration (variable_declarator (identifier) @descriptor.term))) | ||
(event_field_declaration (variable_declaration (variable_declarator (identifier) @descriptor.term))) | ||
(property_declaration name: (identifier) @descriptor.term) | ||
(enum_member_declaration name: (_) @descriptor.term) | ||
(delegate_declaration name: (identifier) @descriptor.method) | ||
(field_declaration (variable_declaration (variable_declarator (identifier) @descriptor.term @kind.field))) | ||
(event_field_declaration (variable_declaration (variable_declarator (identifier) @kind.event @descriptor.term))) | ||
(property_declaration name: (identifier) @descriptor.term @kind.property) | ||
(enum_member_declaration name: (_) @descriptor.term @kind.enummember) | ||
(delegate_declaration name: (identifier) @descriptor.method @kind.delegate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 34 additions & 10 deletions
44
docker-images/syntax-highlighter/crates/scip-syntax/queries/kotlin/scip-tags.scm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
(source_file | ||
(package_header | ||
(identifier) | ||
@descriptor.namespace)) @scope | ||
@descriptor.namespace @kind.package)) @scope | ||
|
||
(function_declaration | ||
(simple_identifier) @descriptor.method | ||
(function_body) @local) | ||
(simple_identifier) @descriptor.method @kind.method | ||
(function_body)? @local) | ||
|
||
(anonymous_function (_ (type_identifier) @descriptor.type . (type_identifier) @descriptor.method)) @local | ||
(class_declaration (type_identifier) @descriptor.type) @scope | ||
(object_declaration (type_identifier) @descriptor.type) @scope | ||
(class_parameter (simple_identifier) @descriptor.term) | ||
(enum_entry (simple_identifier) @descriptor.term) | ||
(property_declaration (variable_declaration (simple_identifier) @descriptor.term)) | ||
(anonymous_function) @local | ||
|
||
(multi_variable_declaration (variable_declaration (simple_identifier) @descriptor.term)) | ||
(class_declaration "interface" (type_identifier) @descriptor.type @kind.interface) @scope | ||
(class_declaration "enum" "class" (type_identifier) @descriptor.type @kind.enum) @scope | ||
|
||
;; Exclude enums from the 'class' kind | ||
((class_declaration | ||
("enum")? @_enum "class" | ||
(type_identifier) @descriptor.type @kind.class) | ||
(#filter! @_enum "enum")) @scope | ||
|
||
(object_declaration (type_identifier) @descriptor.type @kind.object) @scope | ||
(companion_object (type_identifier) @descriptor.type @kind.object) @scope | ||
|
||
(type_alias (type_identifier) @descriptor.type @kind.typealias) | ||
|
||
(class_parameter (simple_identifier) @descriptor.term @kind.property) | ||
(enum_entry (simple_identifier) @descriptor.term @kind.enummember) | ||
|
||
;; In the grammar, property_modifier always represents 'const' | ||
(property_declaration | ||
(modifiers (property_modifier)) | ||
(variable_declaration (simple_identifier) @descriptor.term @kind.constant)) | ||
|
||
;; Exclude constants from the 'property' kind | ||
((property_declaration | ||
(modifiers (property_modifier) @_const)? | ||
(variable_declaration (simple_identifier) @descriptor.term @kind.property)) | ||
(#filter! @_const "property_modifier")) | ||
|
||
(property_declaration | ||
(multi_variable_declaration (variable_declaration (simple_identifier) @descriptor.term @kind.property))) | ||
|
||
;; Future TODOs: | ||
;; - Should probably unescape `Escaped` simple identifiers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.